Package: sgt-puzzles / 20191231.79a5378-3+deb11u1

0326-Last-ditch-maximum-size-limit-for-Net.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
From: Ben Harris <bjh21@bjh21.me.uk>
Date: Tue, 10 Jan 2023 20:24:49 +0000
Subject: [PATCH 326/389] Last-ditch maximum size limit for Net
Origin: https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=051357bb24c0f05c291d6f9e6b460839847923b4
Bug-Debian: https://bugs.debian.org/1028986

This makes sure that width * height <= INT_MAX, which it rather needs
to be.
---
 net.c | 3 +++
 1 file changed, 3 insertions(+)

--- a/net.c
+++ b/net.c
@@ -7,6 +7,7 @@
 #include <string.h>
 #include <assert.h>
 #include <ctype.h>
+#include <limits.h>
 #include <math.h>
 
 #include "puzzles.h"
@@ -313,6 +314,8 @@ static const char *validate_params(const
 	return "Width and height must both be greater than zero";
     if (params->width <= 1 && params->height <= 1)
 	return "At least one of width and height must be greater than one";
+    if (params->width > INT_MAX / params->height)
+        return "Width times height must not be unreasonably large";
     if (params->barrier_probability < 0)
 	return "Barrier probability may not be negative";
     if (params->barrier_probability > 1)