diff options
| author | Ben Harris <bjh21@bjh21.me.uk> | 2023-01-10 20:31:10 +0000 |
|---|---|---|
| committer | Ben Harris <bjh21@bjh21.me.uk> | 2023-01-15 16:24:27 +0000 |
| commit | fcda12f4b73e69841fd8957b8e33930c584093e5 (patch) | |
| tree | 10ebe32d866bdf2d7d0609a5415f49ea50215f52 | |
| parent | 98724b90936c46e457234a0189bb09242fc727d1 (diff) | |
| download | puzzles-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.
| -rw-r--r-- | lightup.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -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%"; |