* [patch 2/2] target: strlen() doesn't count the terminator
@ 2012-10-02 8:27 Dan Carpenter
2012-10-02 20:24 ` Nicholas A. Bellinger
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2012-10-02 8:27 UTC (permalink / raw)
To: kernel-janitors
We need to take the terminator into consideration here or the last
character gets silently truncated away later.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/usb/gadget/tcm_usb_gadget.c b/drivers/usb/gadget/tcm_usb_gadget.c
index 1ad4a69..97e68b3 100644
--- a/drivers/usb/gadget/tcm_usb_gadget.c
+++ b/drivers/usb/gadget/tcm_usb_gadget.c
@@ -1812,7 +1812,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* Re: [patch 2/2] target: strlen() doesn't count the terminator
2012-10-02 8:27 [patch 2/2] target: strlen() doesn't count the terminator Dan Carpenter
@ 2012-10-02 20:24 ` Nicholas A. Bellinger
0 siblings, 0 replies; 2+ messages in thread
From: Nicholas A. Bellinger @ 2012-10-02 20:24 UTC (permalink / raw)
To: kernel-janitors
On Tue, 2012-10-02 at 11:27 +0300, Dan Carpenter wrote:
> We need to take the terminator into consideration here or the last
> character gets silently truncated away later.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/usb/gadget/tcm_usb_gadget.c b/drivers/usb/gadget/tcm_usb_gadget.c
> index 1ad4a69..97e68b3 100644
> --- a/drivers/usb/gadget/tcm_usb_gadget.c
> +++ b/drivers/usb/gadget/tcm_usb_gadget.c
> @@ -1812,7 +1812,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;
> --
Also applied to for-next.
Thanks Dan !
--nab
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-10-02 20:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-02 8:27 [patch 2/2] target: strlen() doesn't count the terminator Dan Carpenter
2012-10-02 20:24 ` 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