[PATCH] qemu-edid: Restrict input parameter -d to avoid division by zero

Sebastian Mitterle posted 1 patch 3 years, 3 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20221011151216.64897-1-smitterl@redhat.com
Maintainers: Gerd Hoffmann <kraxel@redhat.com>
qemu-edid.c | 4 ++++
1 file changed, 4 insertions(+)
[PATCH] qemu-edid: Restrict input parameter -d to avoid division by zero
Posted by Sebastian Mitterle 3 years, 3 months ago
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>
---
 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;
-- 
2.37.3
Re: [PATCH] qemu-edid: Restrict input parameter -d to avoid division by zero
Posted by Gerd Hoffmann 3 years, 3 months ago
On Tue, Oct 11, 2022 at 05:12:16PM +0200, Sebastian Mitterle wrote:
> 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>

Added to queue.

thanks,
  Gerd