mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shuah Khan <shuah@kernel.org>
To: Juan Zea <juan.zea@qindel.com>, linux-usb@vger.kernel.org
Cc: Valentina Manea <valentina.manea.m@gmail.com>,
	linux-kernel@vger.kernel.org,
	Shuah Khan <shuahkh@osg.samsung.com>,
	Shuah Khan <shuah@kernel.org>
Subject: Re: [PATCH] usbip: fix usbip bind writing random string after command in match_busid
Date: Wed, 13 Dec 2017 10:42:44 -0700	[thread overview]
Message-ID: <7eb8f072-c4fe-92c9-a7ad-dda390b5f9db@kernel.org> (raw)
In-Reply-To: <473236275.1374013.1513163260837.JavaMail.zimbra@qindel.com>

On 12/13/2017 04:07 AM, Juan Zea wrote:
> usbip bind writes commands followed by random string when writing to
> match_busid attribute in sysfs, caused by using full variable size
> instead of string length.
> 
> Signed-off-by: Juan Zea <juan.zea@qindel.com>
> ---
>  tools/usb/usbip/src/utils.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/usb/usbip/src/utils.c b/tools/usb/usbip/src/utils.c
> index 2b3d6d2..ea1a1af 100644
> --- a/tools/usb/usbip/src/utils.c
> +++ b/tools/usb/usbip/src/utils.c
> @@ -42,7 +42,7 @@ int modify_match_busid(char *busid, int add)
>                 snprintf(command, SYSFS_BUS_ID_SIZE + 4, "del %s", busid);
>  
>         rc = write_sysfs_attribute(match_busid_attr_path, command,
> -                                  sizeof(command));
> +                                  strlen(command));
>         if (rc < 0) {
>                 dbg("failed to write match_busid: %s", strerror(errno));
>                 return -1;
> 

Why not use the return value from snprintf() for length, instead of calling
strlen(command)?

thanks,
-- Shuah

  reply	other threads:[~2017-12-13 17:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <204103862.1370220.1513160163538.JavaMail.zimbra@qindel.com>
2017-12-13 11:07 ` Juan Zea
2017-12-13 17:42   ` Shuah Khan [this message]
2017-12-14 10:23     ` Juan Zea
2017-12-14 20:14       ` Shuah Khan
2017-12-15  9:21         ` Juan Zea
2017-12-15 17:39           ` Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7eb8f072-c4fe-92c9-a7ad-dda390b5f9db@kernel.org \
    --to=shuah@kernel.org \
    --cc=juan.zea@qindel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=shuahkh@osg.samsung.com \
    --cc=valentina.manea.m@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome