lkml.org 
[lkml]   [2021]   [Jul]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] dax: replace sprintf() by scnprintf()
From
Date
On Sat, 2021-07-10 at 17:46 +0100, Salah Triki wrote:
> Replace sprintf() by scnprintf() in order to avoid buffer overflows.

OK but also not strictly necessary. DAX_NAME_LEN is 30.

Are you finding and changing these manually or with a script?

> diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
[]
> @@ -76,7 +76,7 @@ static ssize_t do_id_store(struct device_driver *drv, const char *buf,
>   fields = sscanf(buf, "dax%d.%d", &region_id, &id);
>   if (fields != 2)
>   return -EINVAL;
> - sprintf(devname, "dax%d.%d", region_id, id);
> + scnprintf(devname, DAX_NAME_LEN, "dax%d.%d", region_id, id);
>   if (!sysfs_streq(buf, devname))
>   return -EINVAL;
>  
>


\
 
 \ /
  Last update: 2021-07-10 19:05    [W:0.050 / U:0.136 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site