]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
qemu-img: improve queue depth validation in img_bench
authorDenis Rastyogin <gerben@altlinux.org>
Thu, 27 Mar 2025 16:24:23 +0000 (19:24 +0300)
committerKevin Wolf <kwolf@redhat.com>
Fri, 25 Apr 2025 16:09:04 +0000 (18:09 +0200)
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>
qemu-img.c

index 2044c22a4c7d30b69fcb8e6346c176f8fe787550..76ac5d3028b0ac9ca69cfa3aeb17476fce1f66c3 100644 (file)
@@ -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;
             }