mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 16:05:44 -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) {
|
while (*string) {
|
||||||
if (*string == 'r') {
|
if (*string == 'r') {
|
||||||
ret->rowsonly = true;
|
ret->rowsonly = true;
|
||||||
|
string++;
|
||||||
} else if (*string == 'o') {
|
} else if (*string == 'o') {
|
||||||
ret->orientable = true;
|
ret->orientable = true;
|
||||||
|
string++;
|
||||||
} else if (*string == 'm') {
|
} else if (*string == 'm') {
|
||||||
string++;
|
string++;
|
||||||
ret->movetarget = atoi(string);
|
ret->movetarget = atoi(string);
|
||||||
while (string[1] && isdigit((unsigned char)string[1])) string++;
|
while (*string && isdigit((unsigned char)*string)) string++;
|
||||||
}
|
} else
|
||||||
string++;
|
string++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user