shithub: puzzles

Download patch

ref: e2d390aae872cee4cb16d746af3b2eeb7713cbf5
parent: 93be3f7ccaa63b0fd953bcfd88d685b47b76605e
author: Ben Harris <bjh21@bjh21.me.uk>
date: Sun Feb 26 09:51:09 EST 2023

Map: reduce maximum size

validate_desc relies on being able to calculate 2*wh in an int, so the
maximum grid size is at most INT_MAX/2.

--- a/map.c
+++ b/map.c
@@ -255,7 +255,7 @@
 {
     if (params->w < 2 || params->h < 2)
 	return "Width and height must be at least two";
-    if (params->w > INT_MAX / params->h)
+    if (params->w > INT_MAX / 2 / params->h)
         return "Width times height must not be unreasonably large";
     if (params->n < 5)
 	return "Must have at least five regions";