lkml.org 
[lkml]   [2014]   [Mar]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] usbip:usbip_common.c: check return value of sscanf
From
Date
On Thu, 2014-03-06 at 15:51 -0800, John de la Garza wrote:
> Added code to check return value of sscanf.
[]
> diff --git a/drivers/staging/usbip/usbip_common.c b/drivers/staging/usbip/usbip_common.c
[]
> @@ -55,7 +55,8 @@ static ssize_t usbip_debug_store(struct device *dev,
> struct device_attribute *attr, const char *buf,
> size_t count)
> {
> - sscanf(buf, "%lx", &usbip_debug_flag);
> + if (sscanf(buf, "%lx", &usbip_debug_flag) != 1)
> + return -EINVAL;

Generally, it's probably better to convert these
sscanf uses to kstrto<foo>, kstrtoul in this case.




\
 
 \ /
  Last update: 2014-03-07 02:01    [W:0.044 / U:0.592 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site