Skip to content

Commit

Permalink
#492 avoid undefined behavior if user input contains more pieces that…
Browse files Browse the repository at this point in the history
… we can handle
  • Loading branch information
Thomas Maeder committed May 20, 2024
1 parent 5ffb472 commit ad7fe77
Show file tree
Hide file tree
Showing 14 changed files with 299 additions and 171 deletions.
17 changes: 12 additions & 5 deletions input/plaintext/condition.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,25 +527,30 @@ static char *ParseCirceVariants(char *tok, circe_variant_type *variant)
return tok;
}

static void HandleImitatorPosition(square pos, void *param)
static boolean HandleImitatorPosition(square pos, void *param)
{
unsigned int * const number_of_imitators = param;

being_solved.isquare[(*number_of_imitators)++] = pos;

return true;
}

static void HandleGridCell(square cell, void *param)
static boolean HandleGridCell(square cell, void *param)
{
unsigned int * const currentgridnum = param;

ClearGridNum(cell);
sq_spec(cell) += *currentgridnum << Grid;

return true;
}

static void HandleSquaresWithFlag(square sq, void *param)
static boolean HandleSquaresWithFlag(square sq, void *param)
{
SquareFlags * const flag = param;
SETFLAG(sq_spec(sq),*flag);
return true;
}

static char *ParseSquaresWithFlag(char *tok, SquareFlags flag)
Expand All @@ -570,19 +575,21 @@ static char *ParseSquaresWithFlag(char *tok, SquareFlags flag)
return tok;
}

static void HandleHole(square sq, void *dummy)
static boolean HandleHole(square sq, void *dummy)
{
block_square(sq);
return true;
}

static void HandleDisterReferenceSquare(square sq, void *v)
static boolean HandleDisterReferenceSquare(square sq, void *v)
{
unsigned int *nr_reference_squares_read = (unsigned int *)v;

if (*nr_reference_squares_read<2)
dister_reference_square[*nr_reference_squares_read] = sq;

++*nr_reference_squares_read;
return true;
}

static char *ParseRoyalSquare(char *tok, Side side)
Expand Down
Loading

0 comments on commit ad7fe77

Please sign in to comment.