mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 16:05:44 -07:00
Richard Earnshaw points out that if you enter an out-of-range number
in the game description, the solver will fail to notice it and overrun an array leading to assertion failure, silent wrong answers or (in extreme cases) segfaults. Hence, validate_desc() now spots them and kicks them out. [originally from svn r6383]
This commit is contained in:
3
solo.c
3
solo.c
@ -2293,6 +2293,9 @@ static char *validate_desc(game_params *params, char *desc)
|
|||||||
} else if (n == '_') {
|
} else if (n == '_') {
|
||||||
/* do nothing */;
|
/* do nothing */;
|
||||||
} else if (n > '0' && n <= '9') {
|
} else if (n > '0' && n <= '9') {
|
||||||
|
int val = atoi(desc-1);
|
||||||
|
if (val < 1 || val > params->c * params->r)
|
||||||
|
return "Out-of-range number in game description";
|
||||||
squares++;
|
squares++;
|
||||||
while (*desc >= '0' && *desc <= '9')
|
while (*desc >= '0' && *desc <= '9')
|
||||||
desc++;
|
desc++;
|
||||||
|
Reference in New Issue
Block a user