aboutsummaryrefslogtreecommitdiffstats
path: root/FICS/algcheck.c
diff options
context:
space:
mode:
Diffstat (limited to 'FICS/algcheck.c')
-rw-r--r--FICS/algcheck.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/FICS/algcheck.c b/FICS/algcheck.c
index 250c129..15642fd 100644
--- a/FICS/algcheck.c
+++ b/FICS/algcheck.c
@@ -21,11 +21,16 @@
name email yy/mm/dd Change
Richard Nash 93/10/22 Created
Markus Uhlin 24/05/05 Revised
+ Markus Uhlin 25/04/05 alg_parse_move:
+ return ambiguous move on
+ out-of-bounds array read/write.
*/
#include "stdinclude.h"
#include "common.h"
+#include <err.h>
+
#include "algcheck.h"
#include "board.h"
#include "maxxes-utils.h"
@@ -250,6 +255,11 @@ 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 (r < 0 || r >= 8) {
+ warnx("%s: out-of-bounds array read/write: "
+ "r=%d", __func__, r);
+ return MOVE_AMBIGUOUS;
+ }
if (piecetype(gs->board[f][r]) != piece)
continue;
if (gs->onMove == WHITE) {
@@ -257,6 +267,11 @@ alg_parse_move(char *mstr, game_state_t *gs, move_t *mt)
} else {
tmpr = r - 1;
}
+ if (tmpr < 0 || tmpr >= 8) {
+ warnx("%s: out-of-bounds array read/write: "
+ "tmpr=%d", __func__, tmpr);
+ return MOVE_AMBIGUOUS;
+ }
if (gs->board[tf][tmpr] == NOPIECE) {
if ((gs->ep_possible[((gs->onMove == WHITE) ?