aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Harris <bjh21@bjh21.me.uk>2023-01-10 20:41:24 +0000
committerBen Harris <bjh21@bjh21.me.uk>2023-01-15 16:24:27 +0000
commit5c36e1536a05abf514b09476813cf71bc9dc1e31 (patch)
tree43f1312db3cc8dd36350792b473811ee8e8481a7
parentd5ec2758ee3b7a8934475a1122813ad2312dc850 (diff)
downloadpuzzles-5c36e1536a05abf514b09476813cf71bc9dc1e31.zip
puzzles-5c36e1536a05abf514b09476813cf71bc9dc1e31.tar.gz
puzzles-5c36e1536a05abf514b09476813cf71bc9dc1e31.tar.bz2
puzzles-5c36e1536a05abf514b09476813cf71bc9dc1e31.tar.xz
Last-ditch maximum size limit for Signpost
This makes sure that width * height <= INT_MAX, which it rather needs to be.
-rw-r--r--signpost.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/signpost.c b/signpost.c
index 1c8cfee..daf5509 100644
--- a/signpost.c
+++ b/signpost.c
@@ -7,6 +7,7 @@
#include <string.h>
#include <assert.h>
#include <ctype.h>
+#include <limits.h>
#include <math.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->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)
/* The UI doesn't let us move these from unsolved to solved,
* so we disallow generating (but not playing) them. */