aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2025-04-02 21:37:13 +0200
committerMarkus Uhlin <markus@nifty-networks.net>2025-04-02 21:37:13 +0200
commitf5a824143109e30f2cc1599a19e1de14cc86a517 (patch)
tree02a71aa2431e0cc7e2bb5f2ec292fb3e21b7ecb0
parent98103851c44e810d7af3ead17dc927f5f644a3fc (diff)
Bounds checking
-rw-r--r--FICS/playerdb.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/FICS/playerdb.c b/FICS/playerdb.c
index 411bbd5..06694ab 100644
--- a/FICS/playerdb.c
+++ b/FICS/playerdb.c
@@ -584,6 +584,23 @@ ReadV1PlayerFmt(int p, player *pp, FILE *fp, char *file, int version)
pp->timeOfReg = array[0];
pp->totalTime = array[1];
+ if (pp->num_plan > MAX_PLAN) {
+ warnx("Player %s is corrupt\nToo many plans (%d)",
+ parray[p].name,
+ pp->num_plan);
+ return;
+ } else if (pp->num_formula > MAX_FORMULA) {
+ warnx("Player %s is corrupt\nToo many formulas (%d)",
+ parray[p].name,
+ pp->num_formula);
+ return;
+ } else if (pp->numAlias > MAX_ALIASES) {
+ warnx("Player %s is corrupt\nToo many aliases (%d)",
+ parray[p].name,
+ pp->numAlias);
+ return;
+ }
+
if (pp->num_plan > 0) {
for (i = 0; i < pp->num_plan; i++) {
if (fgets(tmp2, sizeof tmp2, fp) == NULL) {