summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDenis Rastyogin <gerben@altlinux.org>2025-03-27 19:24:23 +0300
committerKevin Wolf <kwolf@redhat.com>2025-04-25 18:09:04 +0200
commit2b689db0bedd24eda8b491cb1fcfb015dfec5a31 (patch)
tree6abee86816ffd4df41e99af57df18c5930173e19
parented1aef171671ef49761017cb1d8d10bf67d05c57 (diff)
downloadfocaccia-qemu-2b689db0bedd24eda8b491cb1fcfb015dfec5a31.tar.gz
focaccia-qemu-2b689db0bedd24eda8b491cb1fcfb015dfec5a31.zip
qemu-img: improve queue depth validation in img_bench
This error was discovered by fuzzing qemu-img.

Currently, running `qemu-img bench -d 0` in img_bench is allowed,
which is a pointless operation and causes qemu-img to hang.

Signed-off-by: Denis Rastyogin <gerben@altlinux.org>
Message-ID: <20250327162423.25154-5-gerben@altlinux.org>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r--qemu-img.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/qemu-img.c b/qemu-img.c
index 2044c22a4c..76ac5d3028 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -4571,7 +4571,7 @@ static int img_bench(int argc, char **argv)
         {
             unsigned long res;
 
-            if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > INT_MAX) {
+            if (qemu_strtoul(optarg, NULL, 0, &res) <= 0 || res > INT_MAX) {
                 error_report("Invalid queue depth specified");
                 return 1;
             }