shithub: puzzles

Download patch

ref: c53e0d386793840ad84b8bbcb4760cfb2b6897d4
parent: 07999443c24414602cf046fefc84d1d17b5afd69
author: Ben Harris <bjh21@bjh21.me.uk>
date: Tue Jan 10 15:39:06 EST 2023

Last-ditch maximum size limit for Tracks

This makes sure that width * height <= INT_MAX, which it rather needs
to be.

--- a/tracks.c
+++ b/tracks.c
@@ -20,6 +20,7 @@
 #include <string.h>
 #include <assert.h>
 #include <ctype.h>
+#include <limits.h>
 #include <math.h>
 
 #include "puzzles.h"
@@ -196,6 +197,8 @@
      */
     if (params->w < 4 || params->h < 4)
         return "Width and height must both be at least four";
+    if (params->w > INT_MAX / params->h)
+        return "Width times height must not be unreasonably large";
     return NULL;
 }