Compare commits
10 Commits
6dd40036f0
...
1a12cc5a64
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a12cc5a64 | ||
|
|
fdad35ccf0 | ||
|
|
7f1bf4471e | ||
|
|
6c7009a91b | ||
|
|
bc94c78856 | ||
|
|
da41b71499 | ||
|
|
e90dc55f2e | ||
|
|
f890c091d8 | ||
|
|
90a6e00bda | ||
|
|
26824f51c6 |
@ -0,0 +1,30 @@
|
||||
From 96d775860fb7e404d6acaf7e8dfbd171cfbcee15 Mon Sep 17 00:00:00 2001
|
||||
From: Han Han <hhan@redhat.com>
|
||||
Date: Mon, 20 Jun 2022 16:45:19 +0800
|
||||
Subject: [PATCH] Fix an runtime error reported by undefind sanitizer
|
||||
|
||||
Fix the following error when compiling with undefined sanitizer:
|
||||
|
||||
./lsusb
|
||||
names.c:36:29: runtime error: left shift of 16 by 27 places cannot be represented in type 'int'
|
||||
|
||||
Signed-off-by: Han Han <hhan@redhat.com>
|
||||
---
|
||||
names.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/names.c b/names.c
|
||||
index c8cdd02..beae8f8 100644
|
||||
--- a/names.c
|
||||
+++ b/names.c
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
static unsigned int hashnum(unsigned int num)
|
||||
{
|
||||
- unsigned int mask1 = HASH1 << 27, mask2 = HASH2 << 27;
|
||||
+ unsigned int mask1 = (unsigned int)HASH1 << 27, mask2 = (unsigned int)HASH2 << 27;
|
||||
|
||||
for (; mask1 >= HASH1; mask1 >>= 1, mask2 >>= 1)
|
||||
if (num & mask1)
|
||||
--
|
||||
2.37.0.windows.1
|
||||
@ -1,37 +0,0 @@
|
||||
From e3a98cd4870e46cefbfaa1c6f3142c70351aba02 Mon Sep 17 00:00:00 2001
|
||||
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
Date: Thu, 22 Oct 2020 12:01:44 +0200
|
||||
Subject: [PATCH 11/15] usbmisc: initialize string buffer before reading from
|
||||
device.
|
||||
|
||||
Cliff Biffle points out that some devices lie about the length of their
|
||||
string, so we end up with stack data in the string buffer, which is then
|
||||
displayed by userspace. Fix this up by initializing the data to 0 first
|
||||
before reading from the device.
|
||||
|
||||
Reported-by: Cliff L. Biffle <code@cliffle.com>
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
usbmisc.c | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
diff --git a/usbmisc.c b/usbmisc.c
|
||||
index 9a329f2..ba0591f 100644
|
||||
--- a/usbmisc.c
|
||||
+++ b/usbmisc.c
|
||||
@@ -210,6 +210,12 @@ char *get_dev_string(libusb_device_handle *dev, uint8_t id)
|
||||
langid = get_any_langid(dev);
|
||||
if (!langid) return strdup("(error)");
|
||||
|
||||
+ /*
|
||||
+ * Some devices lie about their string size, so initialize
|
||||
+ * the buffer with all 0 to account for that.
|
||||
+ */
|
||||
+ memset(unicode_buf, 0x00, sizeof(unicode_buf));
|
||||
+
|
||||
ret = libusb_get_string_descriptor(dev, id, langid,
|
||||
(unsigned char *) unicode_buf,
|
||||
sizeof unicode_buf);
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
29
0002-lsusb-h-returns-an-error.patch
Normal file
29
0002-lsusb-h-returns-an-error.patch
Normal file
@ -0,0 +1,29 @@
|
||||
From 882a852d06321968a420fda46aef0c52b8220eae Mon Sep 17 00:00:00 2001
|
||||
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
Date: Sun, 25 Jun 2023 09:04:23 +0200
|
||||
Subject: [PATCH 1/2] lsusb -h returns an error
|
||||
|
||||
Fix up the issue where 'lsusb -h' will return an error to the shell, it
|
||||
succeeded, so return 0 instead.
|
||||
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
lsusb.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/lsusb.c b/lsusb.c
|
||||
index 90825c5..1d4c5fd 100644
|
||||
--- a/lsusb.c
|
||||
+++ b/lsusb.c
|
||||
@@ -3797,7 +3797,7 @@ int main(int argc, char *argv[])
|
||||
" -h, --help\n"
|
||||
" Show usage and help\n"
|
||||
);
|
||||
- return EXIT_FAILURE;
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
|
||||
--
|
||||
2.23.0
|
||||
|
||||
32
0003-lsusb-h-fixups.patch
Normal file
32
0003-lsusb-h-fixups.patch
Normal file
@ -0,0 +1,32 @@
|
||||
From 09af21c154cf7b239f39644d1245d2191abf2c76 Mon Sep 17 00:00:00 2001
|
||||
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
Date: Sun, 25 Jun 2023 09:47:50 +0200
|
||||
Subject: [PATCH 2/2] lsusb -h fixups
|
||||
|
||||
Previous change to make `lsusb -h` not return an error forgot to account
|
||||
that the help is also printed when an invalid option is used.
|
||||
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
lsusb.c | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/lsusb.c b/lsusb.c
|
||||
index 3cb61b7..7fa1555 100644
|
||||
--- a/lsusb.c
|
||||
+++ b/lsusb.c
|
||||
@@ -3799,7 +3799,10 @@ int main(int argc, char *argv[])
|
||||
" -h, --help\n"
|
||||
" Show usage and help\n"
|
||||
);
|
||||
- return 0;
|
||||
+ if (help && !err)
|
||||
+ return 0;
|
||||
+ else
|
||||
+ return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
--
|
||||
2.23.0
|
||||
|
||||
61
0004-fix-incorrect-value.patch
Normal file
61
0004-fix-incorrect-value.patch
Normal file
@ -0,0 +1,61 @@
|
||||
From 5d7d3d14b660ef453e657dc661a380649e6f0f7d Mon Sep 17 00:00:00 2001
|
||||
From: Dingyan Li <18500469033@163.com>
|
||||
Date: Sat, 11 Mar 2023 21:48:59 +0800
|
||||
Subject: [PATCH] Fix an incorrect length value in hid descriptor.
|
||||
|
||||
While dumping descriptors of a USB hid device, I saw a weird line:
|
||||
'Report Descriptor: (length is -1)'
|
||||
|
||||
This is because variable 'n' is used to hold a potential negative
|
||||
integer value even though it's an unsigned int type in function
|
||||
dump_hid_device. When usb_control_msg() fails, overflow happens.
|
||||
It will always pass the 'if' statement below and call dump_report_desc(),
|
||||
where this weird line finally shows up.
|
||||
|
||||
To fix it, an int type should be used to avoid overflow.
|
||||
|
||||
Signed-off-by: Dingyan Li <18500469033@163.com>
|
||||
---
|
||||
lsusb.c | 10 ++++++----
|
||||
1 file changed, 6 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/lsusb.c b/lsusb.c
|
||||
index 90825c5..46c9b49 100644
|
||||
--- a/lsusb.c
|
||||
+++ b/lsusb.c
|
||||
@@ -2438,8 +2438,7 @@ static void dump_hid_device(libusb_device_handle *dev,
|
||||
const struct libusb_interface_descriptor *interface,
|
||||
const unsigned char *buf)
|
||||
{
|
||||
- unsigned int i, len;
|
||||
- unsigned int n;
|
||||
+ int i, len;
|
||||
unsigned char dbuf[8192];
|
||||
|
||||
if (buf[1] != LIBUSB_DT_HID)
|
||||
@@ -2474,13 +2473,13 @@ static void dump_hid_device(libusb_device_handle *dev,
|
||||
if (buf[6+3*i] != LIBUSB_DT_REPORT)
|
||||
continue;
|
||||
len = buf[7+3*i] | (buf[8+3*i] << 8);
|
||||
- if (len > (unsigned int)sizeof(dbuf)) {
|
||||
+ if (len > (int)sizeof(dbuf)) {
|
||||
printf("report descriptor too long\n");
|
||||
continue;
|
||||
}
|
||||
if (libusb_claim_interface(dev, interface->bInterfaceNumber) == 0) {
|
||||
int retries = 4;
|
||||
- n = 0;
|
||||
+ int n = 0;
|
||||
while (n < len && retries--)
|
||||
n = usb_control_msg(dev,
|
||||
LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_STANDARD
|
||||
@@ -2495,6 +2494,9 @@ static void dump_hid_device(libusb_device_handle *dev,
|
||||
if (n < len)
|
||||
printf(" Warning: incomplete report descriptor\n");
|
||||
dump_report_desc(dbuf, n);
|
||||
+ } else {
|
||||
+ printf(" Warning: can't get report descriptor, %s\n",
|
||||
+ libusb_error_name(n));
|
||||
}
|
||||
libusb_release_interface(dev, interface->bInterfaceNumber);
|
||||
} else {
|
||||
40
0005-fix-misalignments-device-descripptor.patch
Normal file
40
0005-fix-misalignments-device-descripptor.patch
Normal file
@ -0,0 +1,40 @@
|
||||
From 4a677f085bb7b594287f9b7d598bba6c6c341fab Mon Sep 17 00:00:00 2001
|
||||
From: Dingyan Li <18500469033@163.com>
|
||||
Date: Sat, 11 Mar 2023 22:02:06 +0800
|
||||
Subject: [PATCH] Fix misalignments in hid device descripptor.
|
||||
|
||||
Extra spaces should be added when printing below lines:
|
||||
'Report Descriptors:
|
||||
** UNAVAILABLE **'
|
||||
|
||||
Signed-off-by: Dingyan Li <18500469033@163.com>
|
||||
---
|
||||
lsusb.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/lsusb.c b/lsusb.c
|
||||
index 46c9b49..4aba88c 100644
|
||||
--- a/lsusb.c
|
||||
+++ b/lsusb.c
|
||||
@@ -2463,8 +2463,8 @@ static void dump_hid_device(libusb_device_handle *dev,
|
||||
return;
|
||||
|
||||
if (!dev) {
|
||||
- printf(" Report Descriptors: \n"
|
||||
- " ** UNAVAILABLE **\n");
|
||||
+ printf(" Report Descriptors: \n"
|
||||
+ " ** UNAVAILABLE **\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2503,8 +2503,8 @@ static void dump_hid_device(libusb_device_handle *dev,
|
||||
/* recent Linuxes require claim() for RECIP_INTERFACE,
|
||||
* so "rmmod hid" will often make these available.
|
||||
*/
|
||||
- printf(" Report Descriptors: \n"
|
||||
- " ** UNAVAILABLE **\n");
|
||||
+ printf(" Report Descriptors: \n"
|
||||
+ " ** UNAVAILABLE **\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
BIN
usbutils-014.tar.xz
Normal file
BIN
usbutils-014.tar.xz
Normal file
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
Name: usbutils
|
||||
Version: 012
|
||||
Release: 3
|
||||
Version: 014
|
||||
Release: 4
|
||||
Summary: Linux utilities for USB device
|
||||
License: GPLv2+
|
||||
URL: http://www.linux-usb.org/
|
||||
@ -9,7 +9,11 @@ Source0: https://www.kernel.org/pub/linux/utils/usb/usbutils/%{name}-%{version}.
|
||||
Source1: GPL-2.0.txt
|
||||
Source2: GPL-3.0.txt
|
||||
|
||||
Patch1: 0001-usbmisc-initialize-string-buffer-before-reading-from.patch
|
||||
Patch1: 0001-Fix-an-runtime-error-reported-by-undefind-sanitizer.patch
|
||||
Patch2: 0002-lsusb-h-returns-an-error.patch
|
||||
patch3: 0003-lsusb-h-fixups.patch
|
||||
Patch4: 0004-fix-incorrect-value.patch
|
||||
Patch5: 0005-fix-misalignments-device-descripptor.patch
|
||||
|
||||
BuildRequires: libusbx-devel systemd-devel gcc autoconf automake libtool
|
||||
Requires: hwdata
|
||||
@ -46,13 +50,25 @@ install -D -m 644 %{SOURCE2} %{buildroot}%{_defaultlicensedir}/%{name}/GPL-3.0.t
|
||||
%{_mandir}/*/*
|
||||
|
||||
%changelog
|
||||
* Wed Sep 18 2024 Wangmian <wangmian19@h-partners.com> - 014-4
|
||||
- Fix incorrect value type and device descripptor misalignments
|
||||
|
||||
* Sun Jun 25 2023 zhanghongtao <zhanghongtao22@hiuawei.com> - 014-3
|
||||
- Fix 'lsusb -h' returns an error
|
||||
|
||||
* Tue Nov 1 2022 lihaoxiang <lihaoxiang9@huawei.com> - 014-2
|
||||
- fix an runtime error reported by undefined sanitizer
|
||||
|
||||
* Tue Nov 23 2021 yanglongkang <yanglongkang@hiuawei.com> - 014-1
|
||||
- update package to 014
|
||||
|
||||
* Fri Jul 30 2021 chenyanpanHW <chenyanpan@huawei.com> - 012-3
|
||||
- DESC: delete -S git from %autosetup, and delete BuildRequires git
|
||||
|
||||
* Thu Oct 29 2020 Zhiqiang Liu <liuzhiqiang26@huawei.com> -012-2
|
||||
- backport one patch to init string buffer before reading from it
|
||||
|
||||
* Thu July 16 2020 liubo <liubo254@huawei.com> -012-1
|
||||
* Thu Jul 16 2020 liubo <liubo254@huawei.com> -012-1
|
||||
- upgrade package to 012
|
||||
|
||||
* Wed Aug 21 2019 zhanghaibo <ted.zhang@huawei.com> - 010-4
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user