diff options
author | Chris Dickens <christopher.a.dickens@gmail.com> | 2013-08-02 11:33:41 +0200 |
---|---|---|
committer | Ludovic Rousseau <ludovic.rousseau+github@gmail.com> | 2013-08-02 11:37:21 +0200 |
commit | 7dad81fe6167c7dc903f88f3d1878a2f65b91710 (patch) | |
tree | 941c314cfa88072c1d300d8528347e9724c6d60d /libusb/io.c | |
parent | fedc3631f88462d7dfa6af7fc1328b5675eea059 (diff) | |
download | android_external_libusbx-7dad81fe6167c7dc903f88f3d1878a2f65b91710.tar.gz android_external_libusbx-7dad81fe6167c7dc903f88f3d1878a2f65b91710.tar.bz2 android_external_libusbx-7dad81fe6167c7dc903f88f3d1878a2f65b91710.zip |
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.
Diffstat (limited to 'libusb/io.c')
-rw-r--r-- | libusb/io.c | 4 |
1 files changed, 2 insertions, 2 deletions
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; |