diff options
-rw-r--r-- | FICS/gamedb.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/FICS/gamedb.c b/FICS/gamedb.c index 2293ba7..ce0842c 100644 --- a/FICS/gamedb.c +++ b/FICS/gamedb.c @@ -47,6 +47,7 @@ #include <err.h> #include <errno.h> +#include <limits.h> #include "command.h" #include "config.h" @@ -1320,6 +1321,12 @@ ReadV1GameFmt(game *g, FILE *fp, const char *file, int version) if (ret[0] != 4 || ret[1] != 1) { warnx("%s: fscanf error: %s", __func__, file); return -1; + } else if (g->numHalfMoves < 0 || (size_t)g->numHalfMoves > + INT_MAX / sizeof(move_t)) { + warnx("%s: warning: num half moves out-of-bounds (%d)", + __func__, + g->numHalfMoves); + return -1; } if (ReadV1Moves(g, fp) != 0) { |