usbreset: replace some unbounded strcpy() calls

We "know" the sysfs attribute is not going to be bigger than the buffer,
but the thousands of "ooh, a strcpy() call is bad for you!" scanning
tools do not.  So to shut them up, use strncpy() just to make things
quiet and for us to stop getting foolish reports.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Greg Kroah-Hartman 2024-10-22 11:06:18 +02:00
parent a73e7ce5b8
commit bb1e4b7dce

View File

@ -86,11 +86,11 @@ static struct usbentry *parse_devlist(DIR *d)
attr = sysfs_attr(e->d_name, "manufacturer");
if (attr)
strcpy(dev.vendor_name, attr);
strncpy(dev.vendor_name, attr, sizeof(dev.vendor_name) - 1);
attr = sysfs_attr(e->d_name, "product");
if (attr)
strcpy(dev.product_name, attr);
strncpy(dev.product_name, attr, sizeof(dev.product_name) - 1);
if (dev.bus_num && dev.dev_num && dev.vendor_id >= 0 && dev.product_id >= 0)
return &dev;