From: John de la Garza <john@jjdev.com>
To: linux-kernel@vger.kernel.org
Cc: gregkh@linuxfoundation.org, shuah.kh@samsung.com
Subject: [PATCH] usbip:vhci_sysfs.c: check return value of sscanf
Date: Thu, 6 Mar 2014 10:36:34 -0800 [thread overview]
Message-ID: <20140306183631.GA31595@vega.jjdev.com> (raw)
Added code to check return value of sscanf.
Signed-off-by: John de la Garza <john@jjdev.com>
---
drivers/staging/usbip/vhci_sysfs.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/usbip/vhci_sysfs.c b/drivers/staging/usbip/vhci_sysfs.c
index 03e6edf..82dd49f 100644
--- a/drivers/staging/usbip/vhci_sysfs.c
+++ b/drivers/staging/usbip/vhci_sysfs.c
@@ -114,7 +114,8 @@ static ssize_t store_detach(struct device *dev, struct device_attribute *attr,
int err;
__u32 rhport = 0;
- sscanf(buf, "%u", &rhport);
+ if (sscanf(buf, "%u", &rhport) != 1)
+ return -EINVAL;
/* check rhport */
if (rhport >= VHCI_NPORTS) {
@@ -182,7 +183,8 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
* @devid: unique device identifier in a remote host
* @speed: usb device speed in a remote host
*/
- sscanf(buf, "%u %u %u %u", &rhport, &sockfd, &devid, &speed);
+ if (sscanf(buf, "%u %u %u %u", &rhport, &sockfd, &devid, &speed) != 1)
+ return -EINVAL;
usbip_dbg_vhci_sysfs("rhport(%u) sockfd(%u) devid(%u) speed(%u)\n",
rhport, sockfd, devid, speed);
--
1.7.10.4
next reply other threads:[~2014-03-06 18:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-06 18:36 John de la Garza [this message]
2014-03-06 20:23 ` 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=20140306183631.GA31595@vega.jjdev.com \
--to=john@jjdev.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=shuah.kh@samsung.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
all inboxes | Powered by JetHome®