From c1b7512a607d2002f7228dcd6b810648c23cdd53 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sun, 26 Dec 2010 14:45:33 +0100 Subject: [PATCH] Use field width limits with fscanf(). Cppcheck warns that unlimited field withs can lead to crashes with huge files. --- src/init.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 861af14..90617b0 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -144,7 +144,7 @@ bool loadConfig() return true; } - fscanf(fp, "%f %d", &version, &release); + fscanf(fp, "%10f %10d", &version, &release); debug(("Version = %.2f - Expected %.2f\n", version, VERSION)); debug(("Release = %d - Expected %d\n", release, RELEASE)); @@ -154,7 +154,7 @@ bool loadConfig() rtn = true; } - fscanf(fp, "%d %d %d %d %d %d %d", &engine.fullScreen, &game.musicVol, &game.soundVol, &game.output, &game.brightness, &engine.extremeAvailable, &game.gore); + fscanf(fp, "%10d %10d %10d %10d %10d %10d %10d", &engine.fullScreen, &game.musicVol, &game.soundVol, &game.output, &game.brightness, &engine.extremeAvailable, &game.gore); fclose(fp); @@ -223,7 +223,7 @@ int initMedalService(void *data) return 0; } - fscanf(fp, "%s", privateKey); + fscanf(fp, "%19s", privateKey); fclose(fp); -- 2.39.5