diff options
| author | Ben Harris <bjh21@bjh21.me.uk> | 2023-01-07 23:24:39 +0000 |
|---|---|---|
| committer | Ben Harris <bjh21@bjh21.me.uk> | 2023-01-15 16:24:27 +0000 |
| commit | 8c5279cf75e41f1ae75b2daf0d06c883a5ae0bca (patch) | |
| tree | dd1895d76f6f6b7da25c0c5dcff93e77c5c9d380 /samegame.c | |
| parent | 0dbbd52935b8b17b3b3ab3d9ae6271cde891f70b (diff) | |
| download | puzzles-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.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -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); |