Be more cautious when probing devices

This commit is contained in:
Linus Walleij 2011-04-01 01:08:56 +02:00
parent 502b98ae71
commit 6326d40cd9
2 changed files with 24 additions and 1 deletions

View File

@ -3,12 +3,13 @@
Name: libmtp
Version: 1.0.6
Release: 1%{?dist}
Release: 2%{?dist}
Summary: A software library for MTP media players
URL: http://libmtp.sourceforge.net/
Group: System Environment/Libraries
Source0: http://download.sourceforge.net/%{name}/%{name}-%{version}.tar.gz
Patch0: probe-3-ep-only.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
License: LGPLv2+
Requires: udev
@ -51,6 +52,7 @@ library for MTP media players.
%prep
%setup -q
%patch0 -p1
%build
%configure --disable-static \
@ -118,6 +120,9 @@ rm -rf $RPM_BUILD_ROOT
%changelog
* Fri Apr 01 2011 Linus Walleij <triad@df.lth.se> 1.0.6-2
- Maybe fixing a probing issue on an input device.
* Sat Feb 12 2011 Linus Walleij <triad@df.lth.se> 1.0.6-1
- New upstream release fixing bugs & more things we patched.

18
probe-3-ep-only.patch Normal file
View File

@ -0,0 +1,18 @@
diff --git a/src/libusb-glue.c b/src/libusb-glue.c
index 5d7889b..3c0a124 100644
--- a/src/libusb-glue.c
+++ b/src/libusb-glue.c
@@ -284,6 +284,13 @@ static int probe_device_descriptor(struct usb_device *dev, FILE *dumpfile)
&dev->config[i].interface[j].altsetting[k];
/*
+ * MTP interfaces have three endpoints, two bulk and one
+ * interrupt. Don't probe anything else.
+ */
+ if (intf->bNumEndpoints != 3)
+ continue;
+
+ /*
* We only want to probe for the OS descriptor if the
* device is USB_CLASS_VENDOR_SPEC or one of the interfaces
* in it is, so flag if we find an interface like this.