Re: [patch 1/2] target: usb-gadget: silently truncating the last character

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2012-04-17 at 09:31 +0300, Dan Carpenter wrote:
> 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@xxxxxxxxxx>
> 
> 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;
> --

Applied to lio-core.  Thanks!

--nab

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux