From: Bei Zhang Date: Fri, 23 Aug 2013 08:10:35 +0000 (-0700) Subject: Darwin: Fix a SIGFPE X-Git-Tag: upstream/1.0.21~296 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=314f4ff998f6ba63607ce3be6cd7193a39cd1f78;p=platform%2Fupstream%2Flibusb.git Darwin: Fix a SIGFPE * GetPipeProperties() may fail when the device is unplugged if DeviceVersion is not greater than 320. * In this case maxPacketSize will be zero and the integer division will throw a EXC_ARITHMETIC signal. * Closes #136 --- diff --git a/libusb/os/darwin_usb.c b/libusb/os/darwin_usb.c index 0105e3c..146218b 100644 --- a/libusb/os/darwin_usb.c +++ b/libusb/os/darwin_usb.c @@ -1445,8 +1445,14 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer) { cInterface = &priv->interfaces[iface]; - (*(cInterface->interface))->GetPipeProperties (cInterface->interface, pipeRef, &direction, &number, - &transferType, &maxPacketSize, &interval); + ret = (*(cInterface->interface))->GetPipeProperties (cInterface->interface, pipeRef, &direction, &number, + &transferType, &maxPacketSize, &interval); + + if (ret) { + usbi_err (TRANSFER_CTX (transfer), "bulk transfer failed (dir = %s): %s (code = 0x%08x)", IS_XFERIN(transfer) ? "In" : "Out", + darwin_error_str(ret), ret); + return darwin_to_libusb (ret); + } if (0 != (transfer->length % maxPacketSize)) { /* do not need a zero packet */ diff --git a/libusb/version_nano.h b/libusb/version_nano.h index d576271..6d6aaaa 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 10858 +#define LIBUSB_NANO 10859