Fix remaining build failures with gcc 8 (Closes: #897802)

- tools/lib/api/fs/fs.c: Fix misuse of strncpy()
- usbip: Fix misuse of strncpy()
This commit is contained in:
Ben Hutchings 2018-07-20 02:00:58 +01:00
parent d280893ac4
commit b9984b38e6
4 changed files with 99 additions and 0 deletions

3
debian/changelog vendored
View File

@ -76,6 +76,9 @@ linux (4.17.8-1) UNRELEASED; urgency=medium
[ Ben Hutchings ]
* ext4: fix false negatives *and* false positives in ext4_check_descriptors()
(Closes: #903838)
* Fix remaining build failures with gcc 8 (Closes: #897802):
- tools/lib/api/fs/fs.c: Fix misuse of strncpy()
- usbip: Fix misuse of strncpy()
[ Salvatore Bonaccorso ]
* Ignore ABI changes for acpi_nfit_desc_init and acpi_nfit_init

View File

@ -0,0 +1,38 @@
From: Ben Hutchings <ben@decadent.org.uk>
Date: Thu, 19 Jul 2018 23:36:52 +0100
Subject: tools/lib/api/fs/fs.c: Fix misuse of strncpy()
Bug-Debian: https://bugs.debian.org/897802
gcc 8 reports:
In function 'fs__env_override',
inlined from 'fs__get_mountpoint' at fs/fs.c:228:6:
fs/fs.c:222:2: error: 'strncpy' specified bound 4096 equals destination size [-Werror=stringop-truncation]
strncpy(fs->path, override_path, sizeof(fs->path));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I'm not convinced it makes sense to truncate the copied string here,
but since we're already doing so let's ensure it's still null-
terminated. Use strlcpy() instead.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -12,6 +12,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <sys/mount.h>
+#include <linux/string.h>
#include "fs.h"
#include "debug-internal.h"
@@ -219,7 +220,7 @@ static bool fs__env_override(struct fs *
return false;
fs->found = true;
- strncpy(fs->path, override_path, sizeof(fs->path));
+ strlcpy(fs->path, override_path, sizeof(fs->path));
return true;
}

View File

@ -0,0 +1,56 @@
From: Ben Hutchings <ben@decadent.org.uk>
Date: Fri, 20 Jul 2018 01:30:24 +0100
Subject: usbip: Fix misuse of strncpy()
Bug-Debian: https://bugs.debian.org/897802
gcc 8 reports:
usbip_device_driver.c: In function read_usb_vudc_device:
usbip_device_driver.c:106:2: error: strncpy specified bound 256 equals destination size [-Werror=stringop-truncation]
strncpy(dev->path, path, SYSFS_PATH_MAX);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
usbip_device_driver.c:125:2: error: strncpy specified bound 32 equals destination size [-Werror=stringop-truncation]
strncpy(dev->busid, name, SYSFS_BUS_ID_SIZE);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I'm not convinced it makes sense to truncate the copied strings here,
but since we're already doing so let's ensure they're still null-
terminated. We can't easily use strlcpy() here, so use snprintf().
usbip_common.c has the same problem.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
--- a/tools/usb/usbip/libsrc/usbip_common.c
+++ b/tools/usb/usbip/libsrc/usbip_common.c
@@ -226,8 +226,8 @@ int read_usb_device(struct udev_device *
path = udev_device_get_syspath(sdev);
name = udev_device_get_sysname(sdev);
- strncpy(udev->path, path, SYSFS_PATH_MAX);
- strncpy(udev->busid, name, SYSFS_BUS_ID_SIZE);
+ snprintf(udev->path, SYSFS_PATH_MAX, "%s", path);
+ snprintf(udev->busid, SYSFS_BUS_ID_SIZE, "%s", name);
sscanf(name, "%u-%u", &busnum, &devnum);
udev->busnum = busnum;
--- a/tools/usb/usbip/libsrc/usbip_device_driver.c
+++ b/tools/usb/usbip/libsrc/usbip_device_driver.c
@@ -103,7 +103,7 @@ int read_usb_vudc_device(struct udev_dev
copy_descr_attr16(dev, &descr, idProduct);
copy_descr_attr16(dev, &descr, bcdDevice);
- strncpy(dev->path, path, SYSFS_PATH_MAX);
+ snprintf(dev->path, SYSFS_PATH_MAX, "%s", path);
dev->speed = USB_SPEED_UNKNOWN;
speed = udev_device_get_sysattr_value(sdev, "current_speed");
@@ -122,7 +122,7 @@ int read_usb_vudc_device(struct udev_dev
dev->busnum = 0;
name = udev_device_get_sysname(plat);
- strncpy(dev->busid, name, SYSFS_BUS_ID_SIZE);
+ snprintf(dev->busid, SYSFS_BUS_ID_SIZE, "%s", name);
return 0;
err:
fclose(fd);

View File

@ -154,6 +154,8 @@ bugfix/all/tools-build-remove-bpf-run-time-check-at-build-time.patch
bugfix/all/cpupower-bump-soname-version.patch
bugfix/all/cpupower-fix-checks-for-cpu-existence.patch
bugfix/all/lockdep-stub-nmi-watchdog-reset.patch
bugfix/all/tools-lib-api-fs-fs.c-fix-misuse-of-strncpy.patch
bugfix/all/usbip-fix-misuse-of-strncpy.patch
# wireless: Disable regulatory.db direct loading (until we sort out signing)
debian/wireless-disable-regulatory.db-direct-loading.patch