From 51a1f3666e827f4934ea158850b33c88efacbc2c Mon Sep 17 00:00:00 2001 From: Shachar Sharon Date: Mon, 8 Sep 2025 08:19:23 +0300 Subject: [PATCH] tdbtorture: Fix CID 1034815,1034816: protect from out-of-bounds access A user may provide a non-valid input value for 'num_procs' (negative). Avoid potential out-of-bound access by forcing 'unsigned int' value (Coverity: OVERRUN). Signed-off-by: Shachar Sharon Reviewed-by: Volker Lendecke Reviewed-by: Anoop C S Autobuild-User(master): Anoop C S Autobuild-Date(master): Thu Sep 11 19:06:16 UTC 2025 on atb-devel-224 --- lib/tdb/tools/tdbtorture.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/tdb/tools/tdbtorture.c b/lib/tdb/tools/tdbtorture.c index 14dc5e7a8d1..cf9fdfbbe10 100644 --- a/lib/tdb/tools/tdbtorture.c +++ b/lib/tdb/tools/tdbtorture.c @@ -314,7 +314,7 @@ int main(int argc, char * const *argv) { int i, seed = -1; int num_loops = 5000; - int num_procs = 3; + unsigned num_procs = 3; int c, pfds[2]; extern char *optarg; pid_t *pids; @@ -327,7 +327,7 @@ int main(int argc, char * const *argv) while ((c = getopt(argc, argv, "n:l:s:H:thkm")) != -1) { switch (c) { case 'n': - num_procs = strtol(optarg, NULL, 0); + num_procs = strtoul(optarg, NULL, 0); break; case 'l': num_loops = strtol(optarg, NULL, 0); @@ -364,7 +364,7 @@ int main(int argc, char * const *argv) seed = (getpid() + time(NULL)) & 0x7FFFFFFF; } - printf("Testing with %d processes, %d loops, %d hash_size, seed=%d%s\n", + printf("Testing with %u processes, %d loops, %d hash_size, seed=%d%s\n", num_procs, num_loops, hash_size, seed, (always_transaction ? " (all within transactions)" : "")); -- 2.47.3