Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752653AbdLMLNj (ORCPT ); Wed, 13 Dec 2017 06:13:39 -0500 Received: from smtp.qindel.com ([89.140.90.34]:58211 "EHLO thor.qindel.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751933AbdLMLNf (ORCPT ); Wed, 13 Dec 2017 06:13:35 -0500 X-Greylist: delayed 347 seconds by postgrey-1.27 at vger.kernel.org; Wed, 13 Dec 2017 06:13:35 EST Date: Wed, 13 Dec 2017 12:07:40 +0100 (CET) From: Juan Zea To: linux-usb@vger.kernel.org Cc: Valentina Manea , Shuah Khan , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Message-ID: <473236275.1374013.1513163260837.JavaMail.zimbra@qindel.com> In-Reply-To: <204103862.1370220.1513160163538.JavaMail.zimbra@qindel.com> References: <204103862.1370220.1513160163538.JavaMail.zimbra@qindel.com> Subject: [PATCH] usbip: fix usbip bind writing random string after command in match_busid MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [172.26.0.51] X-Mailer: Zimbra 8.0.6_GA_5922 (ZimbraWebClient - FF57 (Linux)/8.0.6_GA_5922) Thread-Topic: usbip: fix usbip bind writing random string after command in match_busid Thread-Index: ZW5tdz3iKWNpvRqTJz2nlbqubEK2wLAurhT/ Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 911 Lines: 24 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 | 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; -- 2.7.4