From 82a628f887409f8a863482627c6d6ea6f208d3b2 Mon Sep 17 00:00:00 2001 From: Sebastian Mitterle Date: Tue, 11 Oct 2022 17:12:16 +0200 Subject: [PATCH] qemu-edid: Restrict input parameter -d to avoid division by zero 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 Signed-off-by: Sebastian Mitterle Message-Id: <20221011151216.64897-1-smitterl@redhat.com> Signed-off-by: Gerd Hoffmann --- qemu-edid.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qemu-edid.c b/qemu-edid.c index 20c958d9c7..92e1a660a7 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;