Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932131AbdLORjv (ORCPT ); Fri, 15 Dec 2017 12:39:51 -0500 Received: from osg.samsung.com ([64.30.133.232]:49195 "EHLO osg.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932098AbdLORjt (ORCPT ); Fri, 15 Dec 2017 12:39:49 -0500 Subject: Re: [PATCH] usbip: fix usbip bind writing random string after command in match_busid To: Juan Zea , linux-usb@vger.kernel.org, Greg Kroah-Hartman Cc: shuah@kernel.org, Valentina Manea , linux-kernel@vger.kernel.org References: <204103862.1370220.1513160163538.JavaMail.zimbra@qindel.com> <473236275.1374013.1513163260837.JavaMail.zimbra@qindel.com> <7eb8f072-c4fe-92c9-a7ad-dda390b5f9db@kernel.org> <1372575371.1424549.1513247019662.JavaMail.zimbra@qindel.com> <3e547346-a2ec-b8b2-2d4a-25a75b068e08@osg.samsung.com> <1908899250.1619879.1513329680276.JavaMail.zimbra@qindel.com> From: Shuah Khan Message-ID: <69d48140-9559-fba7-511f-604fc2cdcf98@osg.samsung.com> Date: Fri, 15 Dec 2017 10:39:37 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <1908899250.1619879.1513329680276.JavaMail.zimbra@qindel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1600 Lines: 49 On 12/15/2017 02:21 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 > --- > tools/usb/usbip/src/utils.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/tools/usb/usbip/src/utils.c b/tools/usb/usbip/src/utils.c > index 2b3d6d2..3d7b42e 100644 > --- a/tools/usb/usbip/src/utils.c > +++ b/tools/usb/usbip/src/utils.c > @@ -30,6 +30,7 @@ int modify_match_busid(char *busid, int add) > char command[SYSFS_BUS_ID_SIZE + 4]; > char match_busid_attr_path[SYSFS_PATH_MAX]; > int rc; > + int cmd_size; > > snprintf(match_busid_attr_path, sizeof(match_busid_attr_path), > "%s/%s/%s/%s/%s/%s", SYSFS_MNT_PATH, SYSFS_BUS_NAME, > @@ -37,12 +38,14 @@ int modify_match_busid(char *busid, int add) > attr_name); > > if (add) > - snprintf(command, SYSFS_BUS_ID_SIZE + 4, "add %s", busid); > + cmd_size = snprintf(command, SYSFS_BUS_ID_SIZE + 4, "add %s", > + busid); > else > - snprintf(command, SYSFS_BUS_ID_SIZE + 4, "del %s", busid); > + cmd_size = snprintf(command, SYSFS_BUS_ID_SIZE + 4, "del %s", > + busid); > > rc = write_sysfs_attribute(match_busid_attr_path, command, > - sizeof(command)); > + cmd_size); > if (rc < 0) { > dbg("failed to write match_busid: %s", strerror(errno)); > return -1; > Thanks for the patch. Greg, could you please pick this up. Acked-by: Shuah Khan -- Shuah