ref: 75e8a1a9cabe7567f6019b1226783b61ba1ac42f
parent: 28671e76b736aeb860b1f725898c45fe70ae6212
author: Ben Harris <bjh21@bjh21.me.uk>
date: Sat Jan 28 18:12:52 EST 2023
Limit number of mines in Mines game description Without this, it's possible to specify a description that has more mines than there are places on the board to place them, which eventually leads to a division by zero. This can be demonstrated by entering a game description of "3:r8,u," and then clicking anywhere on the board.
--- a/mines.c
+++ b/mines.c
@@ -2006,6 +2006,8 @@
desc++;
if (!*desc || !isdigit((unsigned char)*desc))
return "No initial mine count in game description";
+ if (atoi(desc) > wh - 9)
+ return "Too many mines for grid size";
while (*desc && isdigit((unsigned char)*desc))
desc++; /* skip over mine count */
if (*desc != ',')