mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Patches from Ben Hutchings to fix failures of sscanf error checking.
[originally from svn r6147]
This commit is contained in:
2
mines.c
2
mines.c
@ -2370,7 +2370,7 @@ static char *encode_ui(game_ui *ui)
|
|||||||
|
|
||||||
static void decode_ui(game_ui *ui, char *encoding)
|
static void decode_ui(game_ui *ui, char *encoding)
|
||||||
{
|
{
|
||||||
int p;
|
int p= 0;
|
||||||
sscanf(encoding, "D%d%n", &ui->deaths, &p);
|
sscanf(encoding, "D%d%n", &ui->deaths, &p);
|
||||||
if (encoding[p] == 'C')
|
if (encoding[p] == 'C')
|
||||||
ui->completed = TRUE;
|
ui->completed = TRUE;
|
||||||
|
2
pegs.c
2
pegs.c
@ -869,7 +869,7 @@ static game_state *execute_move(game_state *state, char *move)
|
|||||||
int sx, sy, tx, ty;
|
int sx, sy, tx, ty;
|
||||||
game_state *ret;
|
game_state *ret;
|
||||||
|
|
||||||
if (sscanf(move, "%d,%d-%d,%d", &sx, &sy, &tx, &ty)) {
|
if (sscanf(move, "%d,%d-%d,%d", &sx, &sy, &tx, &ty) == 4) {
|
||||||
int mx, my, dx, dy;
|
int mx, my, dx, dy;
|
||||||
|
|
||||||
if (sx < 0 || sx >= w || sy < 0 || sy >= h)
|
if (sx < 0 || sx >= w || sy < 0 || sy >= h)
|
||||||
|
Reference in New Issue
Block a user