Core: Avoid passing uninitialised data down the hotplug pipe.
authorToby Gray <toby.gray@realvnc.com>
Wed, 26 Jun 2013 15:26:39 +0000 (16:26 +0100)
committerHans de Goede <hdegoede@redhat.com>
Wed, 26 Jun 2013 15:29:36 +0000 (17:29 +0200)
Due to alignment requirements, libusb_hotplug_message might have
some padding bytes.

This change makes sure that these padding bytes are
initialised. Valgrind no longer complains about passing uninitialised
data to the write system call.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
libusb/core.c
libusb/version_nano.h

index 900ac02d27c9f031b6e9fe7c5a2ce4128de391cf..7fa3b6336c829f094e86940c3d241244ff9d13a2 100644 (file)
@@ -531,6 +531,7 @@ void usbi_connect_device(struct libusb_device *dev)
        libusb_hotplug_message message;
        ssize_t ret;
 
+       memset(&message, 0, sizeof(message));
        message.event = LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED;
        message.device = dev;
        dev->attached = 1;
@@ -556,6 +557,7 @@ void usbi_disconnect_device(struct libusb_device *dev)
        struct libusb_context *ctx = dev->ctx;
        ssize_t ret;
 
+       memset(&message, 0, sizeof(message));
        message.event = LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT;
        message.device = dev;
        usbi_mutex_lock(&dev->lock);
index 59c6ba391196eb4880f3df87684a1daf061bae2f..a43bb743b064cbafedca350c3502069fc03b4fd6 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 10761
+#define LIBUSB_NANO 10762