diff --git a/debian/changelog b/debian/changelog index 07046856c..5a4c0114f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 diff --git a/debian/patches/bugfix/all/tools-lib-api-fs-fs.c-fix-misuse-of-strncpy.patch b/debian/patches/bugfix/all/tools-lib-api-fs-fs.c-fix-misuse-of-strncpy.patch new file mode 100644 index 000000000..33405fac7 --- /dev/null +++ b/debian/patches/bugfix/all/tools-lib-api-fs-fs.c-fix-misuse-of-strncpy.patch @@ -0,0 +1,38 @@ +From: Ben Hutchings +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 +--- +--- a/tools/lib/api/fs/fs.c ++++ b/tools/lib/api/fs/fs.c +@@ -12,6 +12,7 @@ + #include + #include + #include ++#include + + #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; + } + diff --git a/debian/patches/bugfix/all/usbip-fix-misuse-of-strncpy.patch b/debian/patches/bugfix/all/usbip-fix-misuse-of-strncpy.patch new file mode 100644 index 000000000..9f0d3f815 --- /dev/null +++ b/debian/patches/bugfix/all/usbip-fix-misuse-of-strncpy.patch @@ -0,0 +1,56 @@ +From: Ben Hutchings +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 +--- +--- 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); diff --git a/debian/patches/series b/debian/patches/series index d72af9ee6..1bc88e01a 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -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