diff options
Diffstat (limited to 'FICS/algcheck.c')
-rw-r--r-- | FICS/algcheck.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/FICS/algcheck.c b/FICS/algcheck.c index 250c129..0564786 100644 --- a/FICS/algcheck.c +++ b/FICS/algcheck.c @@ -26,6 +26,8 @@ #include "stdinclude.h" #include "common.h" +#include <err.h> + #include "algcheck.h" #include "board.h" #include "maxxes-utils.h" @@ -250,8 +252,16 @@ alg_parse_move(char *mstr, game_state_t *gs, move_t *mt) NextPieceLoop(gs->board, &f, &r, gs->onMove);) { if ((ff != ALG_UNKNOWN) && (ff != f)) continue; + + if (f < 0 || f >= 8 || + r < 0 || r >= 8) { + warnx("%s: out-of-bounds array read/write: " + "f:%d r:%d", __func__, f, r); + return MOVE_AMBIGUOUS; + } if (piecetype(gs->board[f][r]) != piece) continue; + if (gs->onMove == WHITE) { tmpr = r + 1; } else { |