linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] lightnvm: convert sprintf into snprintf
@ 2017-04-10 18:51 Javier González
  2017-04-10 18:51 ` [PATCH 2/3] lightnvm: make nvm_free static Javier González
  2017-04-10 18:56 ` [PATCH 1/3] lightnvm: convert sprintf into snprintf Bart Van Assche
  0 siblings, 2 replies; 5+ messages in thread
From: Javier González @ 2017-04-10 18:51 UTC (permalink / raw)
  To: mb; +Cc: linux-block, linux-kernel, Javier González

Convert sprintf calls to snprintf in order to make possible buffer
overflow more obvious.

Signed-off-by: Javier González <javier@cnexlabs.com>
---
 drivers/lightnvm/core.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index c3340ef..bdbb333 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -272,7 +272,8 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create)
 		goto err_disk;
 	blk_queue_make_request(tqueue, tt->make_rq);
 
-	sprintf(tdisk->disk_name, "%s", create->tgtname);
+	snprintf(tdisk->disk_name, sizeof(tdisk->disk_name), "%s",
+							create->tgtname);
 	tdisk->flags = GENHD_FL_EXT_DEVT;
 	tdisk->major = 0;
 	tdisk->first_minor = 0;
@@ -1195,13 +1196,13 @@ static long nvm_ioctl_get_devices(struct file *file, void __user *arg)
 	list_for_each_entry(dev, &nvm_devices, devices) {
 		struct nvm_ioctl_device_info *info = &devices->info[i];
 
-		sprintf(info->devname, "%s", dev->name);
+		snprintf(info->devname, sizeof(info->devname), "%s", dev->name);
 
 		/* kept for compatibility */
 		info->bmversion[0] = 1;
 		info->bmversion[1] = 0;
 		info->bmversion[2] = 0;
-		sprintf(info->bmname, "%s", "gennvm");
+		snprintf(info->bmname, sizeof(info->bmname), "%s", "gennvm");
 		i++;
 
 		if (i > 31) {
-- 
2.7.4

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

end of thread, other threads:[~2017-04-11 10:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-10 18:51 [PATCH 1/3] lightnvm: convert sprintf into snprintf Javier González
2017-04-10 18:51 ` [PATCH 2/3] lightnvm: make nvm_free static Javier González
2017-04-11 10:51   ` Matias Bjørling
2017-04-10 18:56 ` [PATCH 1/3] lightnvm: convert sprintf into snprintf Bart Van Assche
2017-04-11  6:31   ` Javier González

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).