shithub: puzzles

Download patch

ref: 48e34522640e25a8186a1e133ac2c74041de3387
parent: 9e2e0692ed087dbe0d5f4abbddf3aebd6a11b30e
author: Ben Harris <bjh21@bjh21.me.uk>
date: Tue Jan 10 16:12:46 EST 2023

Avoid integer overflow in Mosaic maximum-size check

--- a/mosaic.c
+++ b/mosaic.c
@@ -241,7 +241,7 @@
     if (params->height < 3 || params->width < 3) {
         return "Minimal size is 3x3";
     }
-    if (params->height * params->width > MAX_TILES) {
+    if (params->height > MAX_TILES / params->width) {
         return MAX_TILES_ERROR;
     }
     return NULL;