aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2025-04-02 19:16:20 +0200
committerMarkus Uhlin <markus@nifty-networks.net>2025-04-02 19:16:20 +0200
commitdfb2c68944a7bc5bf786e3d8883a57dcffcf2a76 (patch)
treeb1563458e01a807b9ef07f5e64780d88c4ffb24c
parenta5bf336e3842608db8912508907b8fe9479f3ad8 (diff)
add_to_list: added an upper limit for the list size
-rw-r--r--FICS/playerdb.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/FICS/playerdb.c b/FICS/playerdb.c
index 309a8fc..d1a08e5 100644
--- a/FICS/playerdb.c
+++ b/FICS/playerdb.c
@@ -409,10 +409,14 @@ add_to_list(FILE *fp, enum ListWhich lw, int *size, int p)
#define SCAN_STR "%1023s"
- if (*size <= 0)
- return -2;
+ if (*size <= 0 || *size > MAX_GLOBAL_LIST_SIZE) {
+ warnx("%s: illegal list size (%d)", __func__, *size);
+ return -1;
+ }
+
while ((*size)-- > 0 && fscanf(fp, SCAN_STR, buf) == 1)
list_add(p, lw, buf);
+
return (*size <= 0 ? 0 : -1);
}