qemu-edid: Restrict input parameter -d to avoid division by zero
authorSebastian Mitterle <smitterl@redhat.com>
Tue, 11 Oct 2022 15:12:16 +0000 (17:12 +0200)
committerGerd Hoffmann <kraxel@redhat.com>
Wed, 12 Oct 2022 11:38:15 +0000 (13:38 +0200)
A zero value for dpi will lead to a division by zero in qemu_edid_dpi_to_mm().
Tested by runnig qemu-edid -dX, X = 0, 100.

Resolves: qemu-project/qemu#1249

Suggested-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Sebastian Mitterle <smitterl@redhat.com>
Message-Id: <20221011151216.64897-1-smitterl@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
qemu-edid.c

index 20c958d9c7eb627075ebe8982957ce01ce2b7950..92e1a660a76bae7cccb60811bbdd9a1c95918222 100644 (file)
@@ -92,6 +92,10 @@ int main(int argc, char *argv[])
                 fprintf(stderr, "not a number: %s\n", optarg);
                 exit(1);
             }
+            if (dpi == 0) {
+                fprintf(stderr, "cannot be zero: %s\n", optarg);
+                exit(1);
+            }
             break;
         case 'v':
             info.vendor = optarg;