From: Chris Dickens Date: Fri, 2 Aug 2013 09:33:41 +0000 (+0200) Subject: Core: correctly check usbi_read() returned value X-Git-Tag: upstream/1.0.21~356 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7dad81fe6167c7dc903f88f3d1878a2f65b91710;p=platform%2Fupstream%2Flibusb.git Core: correctly check usbi_read() returned value For messages received on the hotplug pipe, the message was read via usbi_read() (ssize_t) and compared against the size of the message struct (size_t). usbi_read() returns -1 on an error condition, so some systems can cast the ssize_t to size_t for the comparison, making it equal to SIZE_MAX and causing the error check condition to incorrectly evaluate to false. --- diff --git a/libusb/io.c b/libusb/io.c index 8438e77..64712c2 100644 --- a/libusb/io.c +++ b/libusb/io.c @@ -1999,8 +1999,8 @@ static int handle_events(struct libusb_context *ctx, struct timeval *tv) /* read the message from the hotplug thread */ ret = usbi_read(ctx->hotplug_pipe[0], &message, sizeof (message)); - if (ret < sizeof(message)) { - usbi_err(ctx, "hotplug pipe read error %d < %d", + if (ret != sizeof(message)) { + usbi_err(ctx, "hotplug pipe read error %d != %u", ret, sizeof(message)); r = LIBUSB_ERROR_OTHER; goto handled; diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 13fec84..8e5c2d3 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 10798 +#define LIBUSB_NANO 10799