diff options
author | Kasper K <kasperkantz@outlook.com> | 2021-05-31 09:13:44 +0000 |
---|---|---|
committer | Leo <thinkabit.ukim@gmail.com> | 2021-05-31 07:39:41 -0300 |
commit | 34cd8c45397c63c041cf3cbe1ba5232fd9331196 (patch) | |
tree | 35121432fdd443e442a03019b96a0673a0a522c6 | |
parent | cabf1437a704ede5f32344ebb672ed6bc0289dc4 (diff) |
main/libusb: fix parsing of descriptors
-rw-r--r-- | main/libusb/APKBUILD | 7 | ||||
-rw-r--r-- | main/libusb/f6d2cb561402c3b6d3627c0eb89e009b503d9067.patch | 58 |
2 files changed, 62 insertions, 3 deletions
diff --git a/main/libusb/APKBUILD b/main/libusb/APKBUILD index 9489a735059..00ff081fe2a 100644 --- a/main/libusb/APKBUILD +++ b/main/libusb/APKBUILD @@ -1,8 +1,7 @@ # Maintainer: Natanael Copa <ncopa@alpinelinux.org> pkgname=libusb pkgver=1.0.24 -_ver=${pkgver/_/-} -pkgrel=1 +pkgrel=2 pkgdesc="Library that enables userspace access to USB devices" url="https://libusb.info/" arch="all" @@ -12,6 +11,7 @@ replaces="libusbx" makedepends="linux-headers" source="https://github.com/libusb/libusb/releases/download/v$pkgver/libusb-$pkgver.tar.bz2 f38f09da98acc63966b65b72029b1f7f81166bef.patch + f6d2cb561402c3b6d3627c0eb89e009b503d9067.patch " build() { @@ -33,4 +33,5 @@ package() { } sha512sums="5aea36a530aaa15c6dd656d0ed3ce204522c9946d8d39ffbb290dab4a98cda388a2598da4995123d1032324056090bd429e702459626d3e8d7daeebc4e7ff3dc libusb-1.0.24.tar.bz2 -fdfc2b02eb996661c75ce01652b623afa4339612c2fc84331187ad55ac93d94abe20f48bf3ec891138ebdb8703a29e8b45643518e896f298562f93a5749e014c f38f09da98acc63966b65b72029b1f7f81166bef.patch" +fdfc2b02eb996661c75ce01652b623afa4339612c2fc84331187ad55ac93d94abe20f48bf3ec891138ebdb8703a29e8b45643518e896f298562f93a5749e014c f38f09da98acc63966b65b72029b1f7f81166bef.patch +bdd8fde8302e4cf54e517d61261d3ed2e61959bf825d6eb0c063f108e772715e0e8e14672b4db93dfe981e94514ade1ac181bb29173983849b0086bfc71fa0bf f6d2cb561402c3b6d3627c0eb89e009b503d9067.patch" diff --git a/main/libusb/f6d2cb561402c3b6d3627c0eb89e009b503d9067.patch b/main/libusb/f6d2cb561402c3b6d3627c0eb89e009b503d9067.patch new file mode 100644 index 00000000000..a38aec15be2 --- /dev/null +++ b/main/libusb/f6d2cb561402c3b6d3627c0eb89e009b503d9067.patch @@ -0,0 +1,58 @@ +From f6d2cb561402c3b6d3627c0eb89e009b503d9067 Mon Sep 17 00:00:00 2001 +From: Chris Dickens <christopher.a.dickens@gmail.com> +Date: Sun, 13 Dec 2020 15:49:19 -0800 +Subject: [PATCH] linux_usbfs: Fix parsing of descriptors for + multi-configuration devices + +Commit e2be556bd2 ("linux_usbfs: Parse config descriptors during device +initialization") introduced a regression for devices with multiple +configurations. The logic that verifies the reported length of the +configuration descriptors failed to count the length of the +configuration descriptor itself and would truncate the actual length by +9 bytes, leading to a parsing error for subsequent descriptors. + +Closes #825 + +Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com> +--- + libusb/os/linux_usbfs.c | 12 ++++++++---- + libusb/version_nano.h | 2 +- + 2 files changed, 9 insertions(+), 5 deletions(-) + +diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c +index fb2ed53a..4d2dc8d6 100644 +--- a/libusb/os/linux_usbfs.c ++++ b/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; |