target: usb-gadget: silently truncating the last character
Subsystems (2)
PATCH 1/2 target: usb-gadget: silently truncating the last character
strlen() doesn't count the NULL character, so this test is off by one. The result is that sometimes it can silently chop off the last character of the name.
Signed-off-by Dan Carpenter <[email protected]>
drivers/target/usb-gadget/usb_gadget.c +1 -1
@@ -1830,7 +1830,7 @@ static ssize_t tcm_usbg_tpg_store_nexus( ret =tcm_usbg_drop_nexus (tpg);return (!ret) ? count : ret; } -if (strlen (page) >USBG_NAMELEN ) { +if (strlen (page) >=USBG_NAMELEN ) {pr_err ("Emulated NAA Sas Address: %s, exceeds" " max: %d\n" , page,USBG_NAMELEN );return -EINVAL ;
Nicholas A. Bellinger
AppliedQuoted 11 lines · Dan Carpenter
strlen()doesn't count the NULL character, so this test is off by one. The result is that sometimes it can silently chop off the last character of the name.Signed-off-by Dan Carpenter <[email protected]>drivers/target/usb-gadget/usb_gadget.c +0
-0
drivers/target/usb-gadget/usb_gadget.c static ssize_t tcm_usbg_tpg_store_nexus(
Quoted 9 lines
drivers/target/usb-gadget/usb_gadget.c +1
-2@@ -1830,7 +1830,7 @@ static ssize_t tcm_usbg_tpg_store_nexus( ret =tcm_usbg_drop_nexus (tpg);return (!ret) ? count : ret; } -if (strlen (page) >USBG_NAMELEN ) { +if (strlen (page) >=USBG_NAMELEN ) {pr_err ("Emulated NAA Sas Address: %s, exceeds" " max: %d\n" , page,USBG_NAMELEN );return -EINVAL ; --
Applied to lio-core. Thanks!
--nab