diff options
author | thompsa <thompsa@FreeBSD.org> | 2009-11-08 20:03:52 +0000 |
---|---|---|
committer | thompsa <thompsa@FreeBSD.org> | 2009-11-08 20:03:52 +0000 |
commit | aded7665d83d8027dd037eca5ab97e468e90f785 (patch) | |
tree | 977c6deb1e9004ec847ecd42fbc6b89e7dc790cc /lib/libusb/libusb20.c | |
parent | ff8940c7c7df8ff8fda10c9b907363bb10fc1fcf (diff) | |
download | FreeBSD-src-aded7665d83d8027dd037eca5ab97e468e90f785.zip FreeBSD-src-aded7665d83d8027dd037eca5ab97e468e90f785.tar.gz |
- fix refcounting error during data transfer
- fix a memory leak on the USB backend
- fix invalid pointer computations (in one case memory outside the allocated
area was written in LibUSB v1.0)
- make sure memory is always initialised, also in failing cases
- add missing functions from v1.0.4
PR: usb/140325
Reported by: Robert Jenssen
Submitted by: Hans Petter Selasky
MFC After: 3 days
Diffstat (limited to 'lib/libusb/libusb20.c')
-rw-r--r-- | lib/libusb/libusb20.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libusb/libusb20.c b/lib/libusb/libusb20.c index 6e0ec47..1a33805 100644 --- a/lib/libusb/libusb20.c +++ b/lib/libusb/libusb20.c @@ -630,6 +630,9 @@ libusb20_dev_req_string_sync(struct libusb20_device *pdev, struct LIBUSB20_CONTROL_SETUP_DECODED req; int error; + /* make sure memory is initialised */ + memset(ptr, 0, len); + if (len < 4) { /* invalid length */ return (LIBUSB20_ERROR_INVALID_PARAM); @@ -1093,7 +1096,8 @@ libusb20_be_free(struct libusb20_backend *pbe) if (pbe->methods->exit_backend) { pbe->methods->exit_backend(pbe); } - return; + /* free backend */ + free(pbe); } void @@ -1101,7 +1105,6 @@ libusb20_be_enqueue_device(struct libusb20_backend *pbe, struct libusb20_device { pdev->beMethods = pbe->methods; /* copy backend methods */ TAILQ_INSERT_TAIL(&(pbe->usb_devs), pdev, dev_entry); - return; } void @@ -1109,5 +1112,4 @@ libusb20_be_dequeue_device(struct libusb20_backend *pbe, struct libusb20_device *pdev) { TAILQ_REMOVE(&(pbe->usb_devs), pdev, dev_entry); - return; } |