aboutsummaryrefslogtreecommitdiff
path: root/samegame.c
diff options
context:
space:
mode:
authorBen Harris <bjh21@bjh21.me.uk>2023-01-07 23:24:39 +0000
committerBen Harris <bjh21@bjh21.me.uk>2023-01-15 16:24:27 +0000
commit8c5279cf75e41f1ae75b2daf0d06c883a5ae0bca (patch)
treedd1895d76f6f6b7da25c0c5dcff93e77c5c9d380 /samegame.c
parent0dbbd52935b8b17b3b3ab3d9ae6271cde891f70b (diff)
downloadpuzzles-8c5279cf75e41f1ae75b2daf0d06c883a5ae0bca.zip
puzzles-8c5279cf75e41f1ae75b2daf0d06c883a5ae0bca.tar.gz
puzzles-8c5279cf75e41f1ae75b2daf0d06c883a5ae0bca.tar.bz2
puzzles-8c5279cf75e41f1ae75b2daf0d06c883a5ae0bca.tar.xz
Same Game: reject moves with unexpected characters in
Previously if a move string starting with "M" contained anything else other than a digit or a comma, execute_move() would spin trying to parse it. Now it returns NULL.
Diffstat (limited to '')
-rw-r--r--samegame.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/samegame.c b/samegame.c
index 3abd042..c161234 100644
--- a/samegame.c
+++ b/samegame.c
@@ -1346,6 +1346,10 @@ static game_state *execute_move(const game_state *from, const char *move)
move++;
while (*move) {
+ if (!isdigit((unsigned char)*move)) {
+ free_game(ret);
+ return NULL;
+ }
i = atoi(move);
if (i < 0 || i >= ret->n) {
free_game(ret);