nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] dax: replace sprintf() by scnprintf()
@ 2021-07-10 16:46 Salah Triki
  2021-07-10 17:04 ` Joe Perches
  0 siblings, 1 reply; 5+ messages in thread
From: Salah Triki @ 2021-07-10 16:46 UTC (permalink / raw)
  To: dan.j.williams, vishal.l.verma, dave.jiang; +Cc: nvdimm, linux-kernel

Replace sprintf() by scnprintf() in order to avoid buffer overflows.

Signed-off-by: Salah Triki <salah.triki@gmail.com>
---
 drivers/dax/bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
index 5aee26e1bbd6..bcae4be6ae76 100644
--- 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;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-07-12 19:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-10 16:46 [PATCH] dax: replace sprintf() by scnprintf() Salah Triki
2021-07-10 17:04 ` Joe Perches
2021-07-12 12:26   ` Salah Triki
2021-07-12 16:14     ` Joe Perches
2021-07-12 16:48       ` Salah Triki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).