aboutsummaryrefslogtreecommitdiffstats
path: root/FICS
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2025-04-05 14:55:57 +0200
committerMarkus Uhlin <markus@nifty-networks.net>2025-04-05 14:55:57 +0200
commitffb7e0cc243fa5cf7db1e188353364f9d2fd22a1 (patch)
tree41625dbe701287cf513e9141a509e910df61649d /FICS
parenteaf33e4caf3dbd77e89ff7cbbc1afe35c529fe84 (diff)
alg_parse_move: return ambiguous move on out-of-bounds array read/write
Diffstat (limited to 'FICS')
-rw-r--r--FICS/algcheck.c10
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 {