Commit 6eb08245 authored by Javier González's avatar Javier González Committed by Jens Axboe

lightnvm: convert sprintf into strlcpy

Convert sprintf calls to strlcpy in order to make possible buffer
overflow more obvious.
Signed-off-by: default avatarJavier González <javier@cnexlabs.com>
Signed-off-by: default avatarMatias Bjørling <matias@cnexlabs.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent d788c59b
...@@ -273,7 +273,7 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create) ...@@ -273,7 +273,7 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create)
goto err_disk; goto err_disk;
blk_queue_make_request(tqueue, tt->make_rq); blk_queue_make_request(tqueue, tt->make_rq);
sprintf(tdisk->disk_name, "%s", create->tgtname); strlcpy(tdisk->disk_name, create->tgtname, sizeof(tdisk->disk_name));
tdisk->flags = GENHD_FL_EXT_DEVT; tdisk->flags = GENHD_FL_EXT_DEVT;
tdisk->major = 0; tdisk->major = 0;
tdisk->first_minor = 0; tdisk->first_minor = 0;
...@@ -1198,13 +1198,13 @@ static long nvm_ioctl_get_devices(struct file *file, void __user *arg) ...@@ -1198,13 +1198,13 @@ static long nvm_ioctl_get_devices(struct file *file, void __user *arg)
list_for_each_entry(dev, &nvm_devices, devices) { list_for_each_entry(dev, &nvm_devices, devices) {
struct nvm_ioctl_device_info *info = &devices->info[i]; struct nvm_ioctl_device_info *info = &devices->info[i];
sprintf(info->devname, "%s", dev->name); strlcpy(info->devname, dev->name, sizeof(info->devname));
/* kept for compatibility */ /* kept for compatibility */
info->bmversion[0] = 1; info->bmversion[0] = 1;
info->bmversion[1] = 0; info->bmversion[1] = 0;
info->bmversion[2] = 0; info->bmversion[2] = 0;
sprintf(info->bmname, "%s", "gennvm"); strlcpy(info->bmname, "gennvm", sizeof(info->bmname));
i++; i++;
if (i > 31) { if (i > 31) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment