diff --git a/configuration.c b/configuration.c index 9349a73a05..94f23b4f0a 100644 --- a/configuration.c +++ b/configuration.c @@ -1365,23 +1365,24 @@ static void load_timezone(char *setting) { char haystack[TIMEZONE_LENGTH+32]; static char *needle = "TIMEZONE="; - size_t needle_len = strlen(needle); - - RFILE *tzfp = filestream_open(LAKKA_TIMEZONE_PATH, + size_t needle_len = strlen(needle); + RFILE *tzfp = filestream_open(LAKKA_TIMEZONE_PATH, RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE); - if (tzfp != NULL) + if (tzfp) { + char *start = NULL; + filestream_gets(tzfp, haystack, sizeof(haystack)-1); filestream_close(tzfp); - char *start = strstr(haystack, needle); + start = strstr(haystack, needle); if (start) - snprintf(setting, TIMEZONE_LENGTH, "%s", start + needle_len); + strlcpy(setting, start + needle_len, TIMEZONE_LENGTH); else - strlcpy(setting, DEFAULT_TIMEZONE, TIMEZONE_LENGTH); + strlcpy(setting, DEFAULT_TIMEZONE, TIMEZONE_LENGTH); } else strlcpy(setting, DEFAULT_TIMEZONE, TIMEZONE_LENGTH); @@ -1399,7 +1400,7 @@ bool config_overlay_enable_default(void) static struct config_array_setting *populate_settings_array(settings_t *settings, int *size) { - unsigned count = 0; + unsigned count = 0; struct config_array_setting *tmp = (struct config_array_setting*)calloc(1, (*size + 1) * sizeof(struct config_array_setting)); if (!tmp)