From 919d0437b0b534531e8baeb37947eb2fe1d7ef62 Mon Sep 17 00:00:00 2001 From: chaoskagami Date: Tue, 10 Jan 2017 02:52:46 -0500 Subject: [PATCH] Potential edge case; when the first byte of the NAND CID is 0x00 - 0x0F, the config name is zero terminated early and this may very well break everything --- source/config-backend-file.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/config-backend-file.c b/source/config-backend-file.c index 254aa20..34edaf1 100644 --- a/source/config-backend-file.c +++ b/source/config-backend-file.c @@ -103,13 +103,17 @@ load_config(void) changed_consoles = 1; } - strcpy(config_file_path, SYSCONFDIR "/config-"); + strcpy(config_file_path, SYSCONFDIR "/config-00000000"); - size_t len = strlen(config_file_path) + 7; + static const char hexDigits[] = "0123456789ABCDEF"; + char* cfg = config_file_path; uint32_t cid_cp = cid[0]; + while(cfg[1] != 0) cfg++; + + // Get path of actual config. while (cid_cp) { - static const char hexDigits[] = "0123456789ABCDEF"; - config_file_path[len--] = hexDigits[(uint32_t)(cid_cp & 0xF)]; + cfg[0] = hexDigits[(uint32_t)(cid_cp & 0xF)]; + cfg--; cid_cp >>= 4; } -- 2.39.5