mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Last-ditch maximum size limit for Signpost
This makes sure that width * height <= INT_MAX, which it rather needs to be.
This commit is contained in:
@ -7,6 +7,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "puzzles.h"
|
#include "puzzles.h"
|
||||||
@ -421,6 +422,8 @@ static const char *validate_params(const game_params *params, bool full)
|
|||||||
{
|
{
|
||||||
if (params->w < 1) return "Width must be at least one";
|
if (params->w < 1) return "Width must be at least one";
|
||||||
if (params->h < 1) return "Height must be at least one";
|
if (params->h < 1) return "Height must be at least one";
|
||||||
|
if (params->w > INT_MAX / params->h)
|
||||||
|
return "Width times height must not be unreasonably large";
|
||||||
if (full && params->w == 1 && params->h == 1)
|
if (full && params->w == 1 && params->h == 1)
|
||||||
/* The UI doesn't let us move these from unsolved to solved,
|
/* The UI doesn't let us move these from unsolved to solved,
|
||||||
* so we disallow generating (but not playing) them. */
|
* so we disallow generating (but not playing) them. */
|
||||||
|
Reference in New Issue
Block a user