aboutsummaryrefslogtreecommitdiffstats
path: root/FICS
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2025-04-05 19:22:21 +0200
committerMarkus Uhlin <markus@nifty-networks.net>2025-04-05 19:22:21 +0200
commit74430f5522e3449584ec0c140a98ed8a188bbff4 (patch)
treea08df33a1bdfd0386cc9146e83b9eeef7491abf8 /FICS
parentf9f757ec52e4f6540f09986f2717669fc39b73c2 (diff)
alg_parse_move: don't check the bounds of 'f'
Diffstat (limited to 'FICS')
-rw-r--r--FICS/algcheck.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/FICS/algcheck.c b/FICS/algcheck.c
index 4e3d18d..15642fd 100644
--- a/FICS/algcheck.c
+++ b/FICS/algcheck.c
@@ -253,15 +253,13 @@ alg_parse_move(char *mstr, game_state_t *gs, move_t *mt)
*/
for (InitPieceLoop(gs->board, &f, &r, gs->onMove);
NextPieceLoop(gs->board, &f, &r, gs->onMove);) {
- if (f < 0 || f >= 8 ||
- r < 0 || r >= 8) {
+ if ((ff != ALG_UNKNOWN) && (ff != f))
+ continue;
+ if (r < 0 || r >= 8) {
warnx("%s: out-of-bounds array read/write: "
- "f:%d r:%d", __func__, f, r);
+ "r=%d", __func__, r);
return MOVE_AMBIGUOUS;
}
-
- if ((ff != ALG_UNKNOWN) && (ff != f))
- continue;
if (piecetype(gs->board[f][r]) != piece)
continue;
if (gs->onMove == WHITE) {