diff mbox series

[PULL,23/26] qemu-edid: Restrict input parameter -d to avoid division by zero

Message ID 20221013065224.1864145-24-kraxel@redhat.com (mailing list archive)
State New, archived
Headers show
Series [PULL,01/26] audio: refactor code in audio_run_out() | expand

Commit Message

Gerd Hoffmann Oct. 13, 2022, 6:52 a.m. UTC
From: Sebastian Mitterle <smitterl@redhat.com>

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 | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/qemu-edid.c b/qemu-edid.c
index 20c958d9c7eb..92e1a660a76b 100644
--- a/qemu-edid.c
+++ b/qemu-edid.c
@@ -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;