[Spice-devel] [PATCH spice-gtk 1/2] usb-device-manager: Fix number truncation by spice_usb_device_get_busnum

Frediano Ziglio fziglio at redhat.com
Thu Aug 1 09:52:21 UTC 2019


"bus" field is 16 bit so returning using a guint8 type potentially
truncate the value.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 src/usb-device-manager-priv.h | 2 +-
 src/usb-device-manager.c      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/usb-device-manager-priv.h b/src/usb-device-manager-priv.h
index 66acf6d5..2530d294 100644
--- a/src/usb-device-manager-priv.h
+++ b/src/usb-device-manager-priv.h
@@ -29,7 +29,7 @@ G_BEGIN_DECLS
 void spice_usb_device_manager_device_error(
     SpiceUsbDeviceManager *manager, SpiceUsbDevice *device, GError *err);
 
-guint8 spice_usb_device_get_busnum(const SpiceUsbDevice *device);
+guint16 spice_usb_device_get_busnum(const SpiceUsbDevice *device);
 guint8 spice_usb_device_get_devaddr(const SpiceUsbDevice *device);
 guint16 spice_usb_device_get_vid(const SpiceUsbDevice *device);
 guint16 spice_usb_device_get_pid(const SpiceUsbDevice *device);
diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
index 544e5687..a035683d 100644
--- a/src/usb-device-manager.c
+++ b/src/usb-device-manager.c
@@ -1490,7 +1490,7 @@ static SpiceUsbDevice *spice_usb_device_new(SpiceUsbBackendDevice *bdev)
     return info;
 }
 
-guint8 spice_usb_device_get_busnum(const SpiceUsbDevice *info)
+guint16 spice_usb_device_get_busnum(const SpiceUsbDevice *info)
 {
     const UsbDeviceInformation *b_info;
 
-- 
2.20.1



More information about the Spice-devel mailing list