Re: [PATCH v2] mpi3mr: Fix W=1 compilation warnings

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

 



On Wed, Jun 30, 2021 at 2:06 AM Martin K. Petersen
<martin.petersen@xxxxxxxxxx> wrote:
>
>
> Sreekanth,
>
> > -     strncpy(drv_info->os_name, utsname()->sysname, sizeof(drv_info->os_name));
> > +     strscpy(drv_info->os_name, utsname()->sysname, sizeof(drv_info->os_name));
> >       drv_info->os_name[sizeof(drv_info->os_name) - 1] = 0;
>
> strscpy() terminates the string.

I verified strscpy() is not adding any null terminator when source
string length is greater than destination buffer size. And we need the
string to be null terminated. or Can I replace it as
strscpy(drv_info->os_name, utsname()->sysname, sizeof(drv_info->os_name) -1);

>
> > -     strncpy(drv_info->os_version, utsname()->release, sizeof(drv_info->os_version));
> > +     strscpy(drv_info->os_version, utsname()->release, sizeof(drv_info->os_version));
> >       drv_info->os_version[sizeof(drv_info->os_version) - 1] = 0;
>
> Same here.
>
> >       strncpy(drv_info->driver_name, MPI3MR_DRIVER_NAME, sizeof(drv_info->driver_name));
> >       strncpy(drv_info->driver_version, MPI3MR_DRIVER_VERSION, sizeof(drv_info->driver_version));
>
> Please convert the remaining strncpy() calls as well.

Sure. I will replace strncpy() with strscpy() in the next update patch.

Thanks,
Sreekanth

>
> Thanks!
>
> --
> Martin K. Petersen      Oracle Linux Engineering

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


[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