mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 15:41:30 -07:00
Don't allow zero clues in Pattern
Some nonogram implementations allow zero clues so that a row or column with a single zero clue is equivalent to one with no clues, that is it has no black squares in it. Pattern, however, doesn't interpret them like this and treats a puzzle with a zero clue as insoluble, so it's not helpful to permit them. Permitting zero clues also confuses Pattern's memory allocation so that it can suffer a buffer overrun. As an example, before this commit a build with AddressSanitizer would report a buffer overrun with the description "1:0/0.0" because it tries to put two clues in a row that can have a maximum of one.
This commit is contained in:
@ -917,8 +917,8 @@ static const char *validate_desc(const game_params *params, const char *desc)
|
|||||||
p = desc;
|
p = desc;
|
||||||
while (*desc && isdigit((unsigned char)*desc)) desc++;
|
while (*desc && isdigit((unsigned char)*desc)) desc++;
|
||||||
n = atoi(p);
|
n = atoi(p);
|
||||||
if (n < 0)
|
if (n <= 0)
|
||||||
return "at least one clue is negative";
|
return "all clues must be positive";
|
||||||
if (n > INT_MAX - 1)
|
if (n > INT_MAX - 1)
|
||||||
return "at least one clue is grossly excessive";
|
return "at least one clue is grossly excessive";
|
||||||
rowspace -= n+1;
|
rowspace -= n+1;
|
||||||
|
Reference in New Issue
Block a user