scsi: scsi_ioctl: Use strnlen() in scsi_ioctl_get_pci()

Use strnlen() to limit string scanning to 20 characters.

Reformat the code and use tabs instead of spaces while at it.

[mkp: tweaked comment formatting]

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Link: https://patch.msgid.link/20260517171546.2304-2-thorsten.blum@linux.dev
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
Thorsten Blum
2026-05-17 19:15:47 +02:00
committed by Martin K. Petersen
parent 016d484531
commit 09be9d404f

View File

@@ -176,10 +176,13 @@ static int scsi_ioctl_get_pci(struct scsi_device *sdev, void __user *arg)
name = dev_name(dev);
/* compatibility with old ioctl which only returned
* 20 characters */
return copy_to_user(arg, name, min(strlen(name), (size_t)20))
? -EFAULT: 0;
/*
* Compatibility with old ioctl which only returned 20 characters.
*/
if (copy_to_user(arg, name, strnlen(name, 20)))
return -EFAULT;
return 0;
}
static int sg_get_version(int __user *p)