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:
Simon Tatham
2005-10-10 16:29:58 +00:00
parent 8a8474a311
commit 813cd5e3bf

3
solo.c
View File

@ -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++;