From ab12a88beeceb7f025658e7a8857a9f2545a16ba Mon Sep 17 00:00:00 2001 From: noarchwastaken Date: Sun, 9 May 2021 00:25:44 -0400 Subject: [PATCH] libusb: fix descriptor parsing backported upstream commit which fixes a regression for multi-configuration devices, e.g. iPhone. --- .../patches/fix-descriptor-parsing.patch | 35 +++++++++++++++++++ srcpkgs/libusb/template | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 srcpkgs/libusb/patches/fix-descriptor-parsing.patch diff --git a/srcpkgs/libusb/patches/fix-descriptor-parsing.patch b/srcpkgs/libusb/patches/fix-descriptor-parsing.patch new file mode 100644 index 000000000000..41b78b7348b3 --- /dev/null +++ b/srcpkgs/libusb/patches/fix-descriptor-parsing.patch @@ -0,0 +1,35 @@ +--- libusb/os/linux_usbfs.c ++++ libusb/os/linux_usbfs.c +@@ -641,7 +641,12 @@ static int seek_to_next_config(struct libusb_context *ctx, + uint8_t *buffer, size_t len) + { + struct usbi_descriptor_header *header; +- int offset = 0; ++ int offset; ++ ++ /* Start seeking past the config descriptor */ ++ offset = LIBUSB_DT_CONFIG_SIZE; ++ buffer += LIBUSB_DT_CONFIG_SIZE; ++ len -= LIBUSB_DT_CONFIG_SIZE; + + while (len > 0) { + if (len < 2) { +@@ -718,7 +723,7 @@ static int parse_config_descriptors(struct libusb_device *dev) + } + + if (priv->sysfs_dir) { +- /* ++ /* + * In sysfs wTotalLength is ignored, instead the kernel returns a + * config descriptor with verified bLength fields, with descriptors + * with an invalid bLength removed. +@@ -727,8 +732,7 @@ static int parse_config_descriptors(struct libusb_device *dev) + int offset; + + if (num_configs > 1 && idx < num_configs - 1) { +- offset = seek_to_next_config(ctx, buffer + LIBUSB_DT_CONFIG_SIZE, +- remaining - LIBUSB_DT_CONFIG_SIZE); ++ offset = seek_to_next_config(ctx, buffer, remaining); + if (offset < 0) + return offset; + sysfs_config_len = (uint16_t)offset; diff --git a/srcpkgs/libusb/template b/srcpkgs/libusb/template index 1f2036d0ecad..8c5ff6054eed 100644 --- a/srcpkgs/libusb/template +++ b/srcpkgs/libusb/template @@ -1,7 +1,7 @@ # Template file for 'libusb' pkgname=libusb version=1.0.24 -revision=1 +revision=2 build_style=gnu-configure hostmakedepends="pkg-config" makedepends="eudev-libudev-devel"