Skip to content

Commit d9f5917

Browse files
committed
s390/vmur: Use scnprintf() instead of sprintf()
Use scnprintf() instead of sprintf() for those cases where the destination is an array and the size of the array is known at compile time. This prevents theoretical buffer overflows, but also avoids that people again and again spend time to figure out if the code is actually safe. Reviewed-by: Jan Polensky <japo@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
1 parent 51d90a1 commit d9f5917

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/s390/char/vmur.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ static struct urdev *urdev_get_from_devno(u16 devno)
154154
struct ccw_device *cdev;
155155
struct urdev *urd;
156156

157-
sprintf(bus_id, "0.0.%04x", devno);
157+
scnprintf(bus_id, sizeof(bus_id), "0.0.%04x", devno);
158158
cdev = get_ccwdev_by_busid(&ur_driver, bus_id);
159159
if (!cdev)
160160
return NULL;
@@ -904,11 +904,11 @@ static int ur_set_online(struct ccw_device *cdev)
904904
goto fail_free_cdev;
905905
if (urd->cdev->id.cu_type == READER_PUNCH_DEVTYPE) {
906906
if (urd->class == DEV_CLASS_UR_I)
907-
sprintf(node_id, "vmrdr-%s", dev_name(&cdev->dev));
907+
scnprintf(node_id, sizeof(node_id), "vmrdr-%s", dev_name(&cdev->dev));
908908
if (urd->class == DEV_CLASS_UR_O)
909-
sprintf(node_id, "vmpun-%s", dev_name(&cdev->dev));
909+
scnprintf(node_id, sizeof(node_id), "vmpun-%s", dev_name(&cdev->dev));
910910
} else if (urd->cdev->id.cu_type == PRINTER_DEVTYPE) {
911-
sprintf(node_id, "vmprt-%s", dev_name(&cdev->dev));
911+
scnprintf(node_id, sizeof(node_id), "vmprt-%s", dev_name(&cdev->dev));
912912
} else {
913913
rc = -EOPNOTSUPP;
914914
goto fail_free_cdev;

0 commit comments

Comments
 (0)