shithub: puzzles

Download patch

ref: d5b8a20def7634d4df79800fe54d8e34c6353974
parent: 85ccdf2f75e3ea55d5e92d9790e50394e1bec089
author: Ben Harris <bjh21@bjh21.me.uk>
date: Tue Jan 10 15:46:24 EST 2023

Last-ditch point-count limit for Untangle

Anything over INT_MAX/3 will cause an integer overflow, so put the
limit there for now.

--- a/untangle.c
+++ b/untangle.c
@@ -31,6 +31,7 @@
 #include <string.h>
 #include <assert.h>
 #include <ctype.h>
+#include <limits.h>
 #include <math.h>
 
 #include "puzzles.h"
@@ -206,6 +207,8 @@
 {
     if (params->n < 4)
         return "Number of points must be at least four";
+    if (params->n > INT_MAX / 3)
+        return "Number of points must not be unreasonably large";
     return NULL;
 }