public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [patch 1/2] target: usb-gadget: silently truncating the last character
@ 2012-04-17  6:31 Dan Carpenter
  2012-04-18  7:12 ` Nicholas A. Bellinger
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2012-04-17  6:31 UTC (permalink / raw)
  To: kernel-janitors

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 <dan.carpenter@oracle.com>

diff --git a/drivers/target/usb-gadget/usb_gadget.c b/drivers/target/usb-gadget/usb_gadget.c
index f5e7531..ba62bef 100644
--- a/drivers/target/usb-gadget/usb_gadget.c
+++ b/drivers/target/usb-gadget/usb_gadget.c
@@ -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;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-04-18  7:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-17  6:31 [patch 1/2] target: usb-gadget: silently truncating the last character Dan Carpenter
2012-04-18  7:12 ` Nicholas A. Bellinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox