From: chaoskagami Date: Tue, 10 Jan 2017 07:52:46 +0000 (-0500) Subject: Potential edge case; when the first byte of the NAND CID is 0x00 - 0x0F, the config... X-Git-Tag: v0.3.1~36 X-Git-Url: https://chaos.moe/g/?a=commitdiff_plain;h=919d0437b0b534531e8baeb37947eb2fe1d7ef62;p=corbenik%2Fcorbenik.git 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 --- 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; }