patch "usbip: tools: fix GCC8 warning for strncpy" added to usb-next
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Greg,
Do we have plan to merge this patch into 5.3 Release?
I hit the build problem(warning turns to be error under -Werror) when building 5.3 version.
B.R.
Changcheng
Quoted 82 lines · On 09:02 Fri 26 Jul, [email protected] wrote:
This is a note to let you know that I've just added the patch titled
usbip: tools: fix GCC8 warning for strncpy
to my usb git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
in the usb-next branch.The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will also be merged in the next major kernel release during the merge window.
If you have any questions about this process, please let me know.
From
6389a62ff798e781567645c0b0ca3dd7b8a4289dMon Sep 17 00:00:00 2001
From: "Liu, Changcheng" <[email protected]>
Date: Thu, 25 Jul 2019 21:22:09 +0800
Subject: usbip: tools: fix GCC8 warning for strncpyGCC8 started emitting warning about using strncpy with number of bytes exactly equal destination size which could lead to non-zero terminated string being copied. Use "
SYSFS_PATH_MAX- 1" & "SYSFS_BUS_ID_SIZE- 1" as number of bytes to ensure name is always zero-terminated.Signed-off-by Changcheng Liu <[email protected]>Acked-by Shuah Khan <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- tools/usb/usbip/libsrc/usbip_common.c | 6 ++++-- tools/usb/usbip/libsrc/usbip_device_driver.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-)tools/usb/usbip/libsrc/usbip_common.c +4
-2@@ -226,8 +226,10 @@ int read_usb_device(struct udev_device *sdev, struct usbip_usb_device *udev) 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 ); +strncpy (udev->path, path,SYSFS_PATH_MAX -1 ); + udev->path[SYSFS_PATH_MAX -1 ] ='\0' ; +strncpy (udev->busid, name,SYSFS_BUS_ID_SIZE -1 ); + udev->busid[SYSFS_BUS_ID_SIZE -1 ] ='\0' ;sscanf (name,"%u-%u" , &busnum, &devnum); udev->busnum = busnum;tools/usb/usbip/libsrc/usbip_device_driver.c +4
-2@@ -91,7 +91,8 @@ int read_usb_vudc_device(struct udev_device *sdev, struct usbip_usb_device *dev)copy_descr_attr16 (dev, &descr, idProduct);copy_descr_attr16 (dev, &descr, bcdDevice); -strncpy (dev->path, path,SYSFS_PATH_MAX ); +strncpy (dev->path, path,SYSFS_PATH_MAX -1 ); + dev->path[SYSFS_PATH_MAX -1 ] ='\0' ; dev->speed =USB_SPEED_UNKNOWN ; speed =udev_device_get_sysattr_value (sdev,"current_speed" );@@ -110,7 +111,8 @@ int read_usb_vudc_device(struct udev_device *sdev, struct usbip_usb_device *dev) dev->busnum =0 ; name =udev_device_get_sysname (plat); -strncpy (dev->busid, name,SYSFS_BUS_ID_SIZE ); +strncpy (dev->busid, name,SYSFS_BUS_ID_SIZE -1 ); + dev->busid[SYSFS_BUS_ID_SIZE -1 ] ='\0' ;return 0 ; err:fclose (fd);Signature · 1 line
2.22.0
Greg KH
maintainerA: http://en.wikipedia.org/wiki/Top_post
Q: Were do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?
A: No.
Q: Should I include quotations after my reply?
http://daringfireball.net/2007/07/on_top
Quoted 4 lines · Changcheng
Hi Greg,
Do we have plan to merge this patch into 5.3 Release?
I hit the build problem(warning turns to be error under -Werror) when building 5.3 version.
This will be submitted for 5.4-rc1. If this is needed in 5.3, please ask [email protected] to backport it once it is in Linus's tree.
But we do not build the kernel with -Werror, so this should not be a "real" problem for you.
thanks,
greg k-h