Re: [PATCH] scsi: lpfc: Terminate string in lpfc_debugfs_nvmeio_trc_write()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2021-12-14 at 10:05 +0300, Dan Carpenter wrote:
> The "mybuf" string comes from the user, so we need to ensure that it
> is NUL terminated.
> 
> Fixes: bd2cdd5e400f ("scsi: lpfc: NVME Initiator: Add debugfs
> support")
> Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> ---
>  drivers/scsi/lpfc/lpfc_debugfs.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c
> b/drivers/scsi/lpfc/lpfc_debugfs.c
> index 21152c9a96ef..30fac2f6fb06 100644
> --- a/drivers/scsi/lpfc/lpfc_debugfs.c
> +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
> @@ -2954,8 +2954,8 @@ lpfc_debugfs_nvmeio_trc_write(struct file
> *file, const char __user *buf,
>  	char mybuf[64];
>  	char *pbuf;
>  
> -	if (nbytes > 64)
> -		nbytes = 64;
> +	if (nbytes > 63)
> +		nbytes = 63;

Just for future reference, next time could we do

if (nbytes > sizeof(mybuf) - 1)
        nbytes = sizeof(mybuf) - 1;

just so we minimize the possibility of screw ups in the unlikely event
that someone reduces the size of the mybuf array?

James





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux