scsi: scsi_ioctl: use strnlen() in scsi_ioctl_get_pci
PATCH 1/1 scsi: scsi_ioctl: use strnlen() in scsi_ioctl_get_pci
Use strnlen() to limit 'name' string scanning to 20 characters.
Reformat the code and use tabs instead of spaces while at it.
Signed-off-by Thorsten Blum <[email protected]>
--- drivers/scsi/scsi_ioctl.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/scsi/scsi_ioctl.c +5 -4
@@ -176,10 +176,11 @@ 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)