aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranklin Wei <franklin@rockbox.org>2024-07-21 18:54:43 -0400
committerSimon Tatham <anakin@pobox.com>2024-07-31 23:29:00 +0100
commitaf3ab1cc5dae69917f921c959e1105491fecdab7 (patch)
treeaf6cf8f09d5c443772534a6b2c369fb378c3c2ef
parenta2f7f962ced158dbceebbfc0c3dfbbc58b119e55 (diff)
downloadpuzzles-af3ab1cc5dae69917f921c959e1105491fecdab7.zip
puzzles-af3ab1cc5dae69917f921c959e1105491fecdab7.tar.gz
puzzles-af3ab1cc5dae69917f921c959e1105491fecdab7.tar.bz2
puzzles-af3ab1cc5dae69917f921c959e1105491fecdab7.tar.xz
Add more configuration parameter lower-bound checks.
-rw-r--r--blackbox.c2
-rw-r--r--flood.c2
-rw-r--r--mines.c2
-rw-r--r--netslide.c2
-rw-r--r--pattern.c2
-rw-r--r--sixteen.c3
-rw-r--r--twiddle.c2
7 files changed, 13 insertions, 2 deletions
diff --git a/blackbox.c b/blackbox.c
index 43323f9..ab8e382 100644
--- a/blackbox.c
+++ b/blackbox.c
@@ -198,6 +198,8 @@ static const char *validate_params(const game_params *params, bool full)
return "Widths and heights greater than 255 are not supported";
if (params->minballs < 0)
return "Negative number of balls";
+ if (params->minballs < 1)
+ return "Number of balls must be at least one";
if (params->minballs > params->maxballs)
return "Minimum number of balls may not be greater than maximum";
if (params->minballs >= params->w * params->h)
diff --git a/flood.c b/flood.c
index bef45f3..fe80974 100644
--- a/flood.c
+++ b/flood.c
@@ -212,7 +212,7 @@ static game_params *custom_params(const config_item *cfg)
static const char *validate_params(const game_params *params, bool full)
{
- if (params->w < 2 && params->h < 2)
+ if (params->w * params->h < 2)
return "Grid must contain at least two squares";
if (params->w < 1 || params->h < 1)
return "Width and height must be at least one";
diff --git a/mines.c b/mines.c
index d823341..e1441fa 100644
--- a/mines.c
+++ b/mines.c
@@ -279,6 +279,8 @@ static const char *validate_params(const game_params *params, bool full)
return "Width times height must not be unreasonably large";
if (params->n < 0)
return "Mine count may not be negative";
+ if (params->n < 1)
+ return "Number of mines must be greater than zero";
if (params->n > params->w * params->h - 9)
return "Too many mines for grid size";
diff --git a/netslide.c b/netslide.c
index e3d03c4..4e6e82b 100644
--- a/netslide.c
+++ b/netslide.c
@@ -318,6 +318,8 @@ static const char *validate_params(const game_params *params, bool full)
return "Barrier probability may not be negative";
if (params->barrier_probability > 1)
return "Barrier probability may not be greater than 1";
+ if (params->movetarget < 0)
+ return "Number of shuffling moves may not be negative";
return NULL;
}
diff --git a/pattern.c b/pattern.c
index d38cada..b370a3d 100644
--- a/pattern.c
+++ b/pattern.c
@@ -185,6 +185,8 @@ static const char *validate_params(const game_params *params, bool full)
if (params->w > INT_MAX - 1 || params->h > INT_MAX - 1 ||
params->w > INT_MAX / params->h)
return "Puzzle must not be unreasonably large";
+ if (params->w * params->h < 2)
+ return "Grid must contain at least two squares";
return NULL;
}
diff --git a/sixteen.c b/sixteen.c
index fef2e5f..38f6711 100644
--- a/sixteen.c
+++ b/sixteen.c
@@ -180,7 +180,8 @@ static const char *validate_params(const game_params *params, bool full)
return "Width and height must both be at least two";
if (params->w > INT_MAX / params->h)
return "Width times height must not be unreasonably large";
-
+ if (params->movetarget < 0)
+ return "Number of shuffling moves may not be negative";
return NULL;
}
diff --git a/twiddle.c b/twiddle.c
index 9aea4e4..b3aa06f 100644
--- a/twiddle.c
+++ b/twiddle.c
@@ -219,6 +219,8 @@ static const char *validate_params(const game_params *params, bool full)
return "Height must be at least the rotating block size";
if (params->w > INT_MAX / params->h)
return "Width times height must not be unreasonably large";
+ if (params->movetarget < 0)
+ return "Number of shuffling moves may not be negative";
return NULL;
}