]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: chardev: avoid impossible overflow
authorJán Tomko <jtomko@redhat.com>
Wed, 6 Nov 2024 12:15:26 +0000 (13:15 +0100)
committerJán Tomko <jtomko@redhat.com>
Wed, 6 Nov 2024 16:12:32 +0000 (17:12 +0100)
In the rare case where int and long long are not the same size,
the multiplication of an int variable and an int constant might
overflow. Cast the constant to long long to avoid this.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: baa4edfb79d5ee861a08b5ec11416c5c156d8cd2
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_chardev.c

index b6828b67521bea1ac4bfd2f99d622e368fb6d6c2..6b29744975befb2d0f8244e197e7b9c2f99ba41f 100644 (file)
@@ -247,7 +247,7 @@ qemuChardevGetBackendProps(const virDomainChrSourceDef *chr,
 
         if (reconnect != -1 &&
             virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_RECONNECT_MILISECONDS)) {
-            reconnect_ms = reconnect * 1000;
+            reconnect_ms = reconnect * (long long) 1000;
             reconnect = -1;
         }