From: Guus Sliepen Date: Sun, 26 Dec 2010 13:45:33 +0000 (+0100) Subject: Use field width limits with fscanf(). X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=c1b7512a607d2002f7228dcd6b810648c23cdd53;p=quix0rs-blobwars.git Use field width limits with fscanf(). Cppcheck warns that unlimited field withs can lead to crashes with huge files. --- 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);