aboutsummaryrefslogtreecommitdiff
path: root/lightup.c
diff options
context:
space:
mode:
authorBen Harris <bjh21@bjh21.me.uk>2023-01-10 20:31:10 +0000
committerBen Harris <bjh21@bjh21.me.uk>2023-01-15 16:24:27 +0000
commitfcda12f4b73e69841fd8957b8e33930c584093e5 (patch)
tree10ebe32d866bdf2d7d0609a5415f49ea50215f52 /lightup.c
parent98724b90936c46e457234a0189bb09242fc727d1 (diff)
downloadpuzzles-fcda12f4b73e69841fd8957b8e33930c584093e5.zip
puzzles-fcda12f4b73e69841fd8957b8e33930c584093e5.tar.gz
puzzles-fcda12f4b73e69841fd8957b8e33930c584093e5.tar.bz2
puzzles-fcda12f4b73e69841fd8957b8e33930c584093e5.tar.xz
Last-ditch maximum size limit for Light Up
This makes sure that width * height <= INT_MAX, which it rather needs to be.
Diffstat (limited to 'lightup.c')
-rw-r--r--lightup.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lightup.c b/lightup.c
index 3f0237a..c37be86 100644
--- a/lightup.c
+++ b/lightup.c
@@ -47,6 +47,7 @@
#include <string.h>
#include <assert.h>
#include <ctype.h>
+#include <limits.h>
#include <math.h>
#include "puzzles.h"
@@ -346,6 +347,8 @@ static const char *validate_params(const game_params *params, bool full)
{
if (params->w < 2 || params->h < 2)
return "Width and height must be at least 2";
+ if (params->w > INT_MAX / params->h)
+ return "Width times height must not be unreasonably large";
if (full) {
if (params->blackpc < 5 || params->blackpc > 100)
return "Percentage of black squares must be between 5% and 100%";