Fix 32-bit build failures

Signed-off-by: Jonathan Dieter <jdieter@lesbg.com>
f38
Jonathan Dieter 8 years ago
parent 25ca1a3f12
commit 91282110dd

@ -1,7 +1,7 @@
From ad4d8dccc457e3b45b47fd5c5fdebfcf0171aa5e Mon Sep 17 00:00:00 2001
From cd2517f4b56e7147d013c7030e09d2c2e3562f2a Mon Sep 17 00:00:00 2001
From: Jonathan Dieter <jdieter@lesbg.com>
Date: Wed, 22 Feb 2017 20:03:06 +0200
Subject: [PATCH] usbip: Fix-format-overflow
Date: Mon, 27 Feb 2017 10:04:29 +0200
Subject: [PATCH v4 1/2] usbip: Fix-format-overflow
The usbip userspace tools call sprintf()/snprintf() and don't check for
the return value which can lead the paths to overflow, truncating the
@ -17,15 +17,16 @@ one place and adding checks for the return value of snprintf().
Reviewed-by: Peter Senna Tschudin <peter.senna@gmail.com>
Signed-off-by: Jonathan Dieter <jdieter@lesbg.com>
---
tools/usb/usbip/libsrc/usbip_common.c | 8 +++++++-
tools/usb/usbip/libsrc/usbip_common.c | 9 ++++++++-
tools/usb/usbip/libsrc/usbip_host_common.c | 28 +++++++++++++++++++++++-----
2 files changed, 30 insertions(+), 6 deletions(-)
2 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/tools/usb/usbip/libsrc/usbip_common.c b/tools/usb/usbip/libsrc/usbip_common.c
index ac73710..66017d7 100644
index ac73710..1517a23 100644
--- a/tools/usb/usbip/libsrc/usbip_common.c
+++ b/tools/usb/usbip/libsrc/usbip_common.c
@@ -215,9 +215,15 @@ int read_usb_interface(struct usbip_usb_device *udev, int i,
@@ -215,9 +215,16 @@ int read_usb_interface(struct usbip_usb_device *udev, int i,
struct usbip_usb_interface *uinf)
{
char busid[SYSFS_BUS_ID_SIZE];
@ -36,14 +37,15 @@ index ac73710..66017d7 100644
+ size = snprintf(busid, sizeof(busid), "%s:%d.%d",
+ udev->busid, udev->bConfigurationValue, i);
+ if (size < 0 || (unsigned int)size >= sizeof(busid)) {
+ err("busid length %i >= %lu or < 0", size, sizeof(busid));
+ err("busid length %i >= %lu or < 0", size,
+ (long unsigned)sizeof(busid));
+ return -1;
+ }
sif = udev_device_new_from_subsystem_sysname(udev_context, "usb", busid);
if (!sif) {
diff --git a/tools/usb/usbip/libsrc/usbip_host_common.c b/tools/usb/usbip/libsrc/usbip_host_common.c
index 9d41522..6fb91d9 100644
index 9d41522..6ff7b60 100644
--- a/tools/usb/usbip/libsrc/usbip_host_common.c
+++ b/tools/usb/usbip/libsrc/usbip_host_common.c
@@ -40,13 +40,20 @@ struct udev *udev_context;
@ -62,7 +64,7 @@ index 9d41522..6fb91d9 100644
+ "%s/usbip_status", udev->path);
+ if (size < 0 || (unsigned int)size >= sizeof(status_attr_path)) {
+ err("usbip_status path length %i >= %lu or < 0", size,
+ sizeof(status_attr_path));
+ (long unsigned)sizeof(status_attr_path));
+ return -1;
+ }
+
@ -87,7 +89,7 @@ index 9d41522..6fb91d9 100644
+ edev->udev.path, attr_name);
+ if (size < 0 || (unsigned int)size >= sizeof(sockfd_attr_path)) {
+ err("exported device path length %i >= %lu or < 0", size,
+ sizeof(sockfd_attr_path));
+ (long unsigned)sizeof(sockfd_attr_path));
+ return -1;
+ }
@ -95,7 +97,7 @@ index 9d41522..6fb91d9 100644
+ size = snprintf(sockfd_buff, sizeof(sockfd_buff), "%d\n", sockfd);
+ if (size < 0 || (unsigned int)size >= sizeof(sockfd_buff)) {
+ err("socket length %i >= %lu or < 0", size,
+ sizeof(sockfd_buff));
+ (long unsigned)sizeof(sockfd_buff));
+ return -1;
+ }

@ -1,7 +1,7 @@
From 1d33ad30f2bad7d2c3f431b676e57f092596840c Mon Sep 17 00:00:00 2001
From b1cabcfde670c82aff0ef07c21095d63c29cbf3e Mon Sep 17 00:00:00 2001
From: Jonathan Dieter <jdieter@lesbg.com>
Date: Tue, 21 Feb 2017 19:41:35 +0200
Subject: [PATCH v2 2/2] usbip: Fix implicit fallthrough warning
Date: Mon, 27 Feb 2017 10:13:01 +0200
Subject: [PATCH v4 2/2] usbip: Fix implicit fallthrough warning
GCC 7 now warns when switch statements fall through implicitly, and with
-Werror enabled in configure.ac, that makes these tools unbuildable.

@ -5,7 +5,7 @@ License: GPLv2+
Summary: USB/IP user-space
Group: System Environment/Daemons
Version: 4.9.9
Release: 2%{?dist}
Release: 3%{?dist}
#Source: https://www.kernel.org/pub/linux/kernel/v3.x/linux-%%{version}.tar.xz
# In the interests of keeping the source rpm from being ridiculously large,
# download the Linux kernel from above and run `extract_usbip.sh <version>`
@ -94,6 +94,9 @@ install -pm 644 %{SOURCE2} %{buildroot}%{_unitdir}
%{_libdir}/*.so
%changelog
* Mon Feb 27 2017 Jonathan Dieter <jdieter@lesbg.com> - 4.9.9-3
- Fix 32-bit build failures
* Mon Feb 20 2017 Jonathan Dieter <jdieter@lesbg.com> - 4.9.9-2
- Add patches to fix continuing build failures with GCC 7

Loading…
Cancel
Save