diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2024-11-23 18:48:11 +0100 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2024-11-23 18:48:11 +0100 |
commit | c5a9716e18dbfdab7a21f12ca6a608ac71927b7b (patch) | |
tree | 98e48158dfa151bb4f6d9cdd03acd4c40c9ad76c /FICS | |
parent | b3b3277ceb473b59748a7353d26ec867a7868df7 (diff) |
pgames: fscanf: added width spec (found by PVS-Studio)
Diffstat (limited to 'FICS')
-rw-r--r-- | FICS/gamedb.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/FICS/gamedb.c b/FICS/gamedb.c index 0d65328..9514c91 100644 --- a/FICS/gamedb.c +++ b/FICS/gamedb.c @@ -2047,7 +2047,7 @@ pgames(int p, int p1, char *fname) char OppName[MAX_LOGIN_NAME + 1] = { '\0' }; char eco[100] = { '\0' }; char ending[100] = { '\0' }; - char result[2] = { 0,0 }; + char result[2] = { 0,0 }; // XXX: right size? char type[100] = { '\0' }; int MyRating, OppRating; int count; @@ -2063,8 +2063,16 @@ pgames(int p, int p1, char *fname) pprintf(p, " Opponent Type " "ECO End Date\n"); + _Static_assert(ARRAY_SIZE(result) > 1, "'result' too small"); + _Static_assert(ARRAY_SIZE(MyColor) > 1, "'MyColor' too small"); + _Static_assert(ARRAY_SIZE(OppName) > 19, "'OppName' too small"); + _Static_assert(ARRAY_SIZE(type) > 99, "'type' too small"); + _Static_assert(ARRAY_SIZE(eco) > 99, "'eco' too small"); + _Static_assert(ARRAY_SIZE(ending) > 99, "'ending' too small"); + while (!feof(fp)) { - if (fscanf(fp, "%d %s %d %s %d %s %s %d %d %d %d %s %s %ld\n", + if (fscanf(fp, "%d %1s %d %1s %d %19s %99s %d %d %d %d %99s " + "%99s %ld\n", &count, result, &MyRating, MyColor, &OppRating, OppName, type, |