mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Twiddle: don't read off the end of parameter strings ending 'm'
The overrun could be demonstrated by specifying a parameter string of "3x3m" to a build with AddressSanitizer.
This commit is contained in:
@ -124,13 +124,15 @@ static void decode_params(game_params *ret, char const *string)
|
||||
while (*string) {
|
||||
if (*string == 'r') {
|
||||
ret->rowsonly = true;
|
||||
string++;
|
||||
} else if (*string == 'o') {
|
||||
ret->orientable = true;
|
||||
string++;
|
||||
} else if (*string == 'm') {
|
||||
string++;
|
||||
ret->movetarget = atoi(string);
|
||||
while (string[1] && isdigit((unsigned char)string[1])) string++;
|
||||
}
|
||||
while (*string && isdigit((unsigned char)*string)) string++;
|
||||
} else
|
||||
string++;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user