From 91d96fa0bc133c8d967f3c4b01804e7773de8504 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Tue, 10 Jan 2023 20:24:59 +0000 Subject: [PATCH] Last-ditch maximum size limit for Sixteen This makes sure that width * height <= INT_MAX, which it rather needs to be. --- sixteen.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sixteen.c b/sixteen.c index aa10f4a..7c9e7aa 100644 --- a/sixteen.c +++ b/sixteen.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "puzzles.h" @@ -173,6 +174,8 @@ static const char *validate_params(const game_params *params, bool full) { if (params->w < 2 || params->h < 2) return "Width and height must both be at least two"; + if (params->w > INT_MAX / params->h) + return "Width times height must not be unreasonably large"; return NULL; }