linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/5] scsi: bfa: bfa_fcs_lport.c:  Cleaning up missing null-terminate by switching from strncpy to strzcpy
@ 2014-10-18 22:13 Rickard Strandqvist
  2014-10-20 15:37 ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Rickard Strandqvist @ 2014-10-18 22:13 UTC (permalink / raw)
  To: Anil Gurumurthy, Sudarsana Kalluru
  Cc: Rickard Strandqvist, James E.J. Bottomley, Andi Kleen,
	Andrew Morton, Dan Carpenter, Grant Likely, linux-kernel,
	linux-scsi

Ensures that the string is null-terminate in connection with the
use of strncpy, by switching from strncpy to strzcpy.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
 drivers/scsi/bfa/bfa_fcs_lport.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/bfa/bfa_fcs_lport.c b/drivers/scsi/bfa/bfa_fcs_lport.c
index ff75ef8..78af89e 100644
--- a/drivers/scsi/bfa/bfa_fcs_lport.c
+++ b/drivers/scsi/bfa/bfa_fcs_lport.c
@@ -2633,7 +2633,7 @@ bfa_fcs_fdmi_get_hbaattr(struct bfa_fcs_lport_fdmi_s *fdmi,
 	strncpy(hba_attr->driver_version, (char *)driver_info->version,
 		sizeof(hba_attr->driver_version));
 
-	strncpy(hba_attr->os_name, driver_info->host_os_name,
+	strzcpy(hba_attr->os_name, driver_info->host_os_name,
 		sizeof(hba_attr->os_name));
 
 	/*
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/5] scsi: bfa: bfa_fcs_lport.c:  Cleaning up missing null-terminate by switching from strncpy to strzcpy
  2014-10-18 22:13 [PATCH 2/5] scsi: bfa: bfa_fcs_lport.c: Cleaning up missing null-terminate by switching from strncpy to strzcpy Rickard Strandqvist
@ 2014-10-20 15:37 ` Dan Carpenter
  2014-10-20 21:10   ` Rickard Strandqvist
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2014-10-20 15:37 UTC (permalink / raw)
  To: Rickard Strandqvist
  Cc: Anil Gurumurthy, Sudarsana Kalluru, James E.J. Bottomley,
	Andi Kleen, Andrew Morton, Grant Likely, linux-kernel,
	linux-scsi

On Sun, Oct 19, 2014 at 12:13:10AM +0200, Rickard Strandqvist wrote:
> Ensures that the string is null-terminate in connection with the
> use of strncpy, by switching from strncpy to strzcpy.
> 

I wish the changelogs were more clear that we have no reason to think
this is a real issue.

> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> ---
>  drivers/scsi/bfa/bfa_fcs_lport.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/bfa/bfa_fcs_lport.c b/drivers/scsi/bfa/bfa_fcs_lport.c
> index ff75ef8..78af89e 100644
> --- a/drivers/scsi/bfa/bfa_fcs_lport.c
> +++ b/drivers/scsi/bfa/bfa_fcs_lport.c
> @@ -2633,7 +2633,7 @@ bfa_fcs_fdmi_get_hbaattr(struct bfa_fcs_lport_fdmi_s *fdmi,
>  	strncpy(hba_attr->driver_version, (char *)driver_info->version,
>  		sizeof(hba_attr->driver_version));

Why do we not change this one?

>  
> -	strncpy(hba_attr->os_name, driver_info->host_os_name,
> +	strzcpy(hba_attr->os_name, driver_info->host_os_name,
>  		sizeof(hba_attr->os_name));

strlcpy() would also be totally safe here.  It's also safe for patch
patch 3 and patch 4.  Patch 5 is trickier to audit so I don't know if
strlcpy() is safe.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/5] scsi: bfa: bfa_fcs_lport.c: Cleaning up missing null-terminate by switching from strncpy to strzcpy
  2014-10-20 15:37 ` Dan Carpenter
@ 2014-10-20 21:10   ` Rickard Strandqvist
  0 siblings, 0 replies; 3+ messages in thread
From: Rickard Strandqvist @ 2014-10-20 21:10 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Anil Gurumurthy, Sudarsana Kalluru, James E.J. Bottomley,
	Andi Kleen, Andrew Morton, Grant Likely, linux-kernel,
	linux-scsi

2014-10-20 17:37 GMT+02:00 Dan Carpenter <dan.carpenter@oracle.com>:
> On Sun, Oct 19, 2014 at 12:13:10AM +0200, Rickard Strandqvist wrote:
>> Ensures that the string is null-terminate in connection with the
>> use of strncpy, by switching from strncpy to strzcpy.
>>
>
> I wish the changelogs were more clear that we have no reason to think
> this is a real issue.
>
>> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
>> ---
>>  drivers/scsi/bfa/bfa_fcs_lport.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/scsi/bfa/bfa_fcs_lport.c b/drivers/scsi/bfa/bfa_fcs_lport.c
>> index ff75ef8..78af89e 100644
>> --- a/drivers/scsi/bfa/bfa_fcs_lport.c
>> +++ b/drivers/scsi/bfa/bfa_fcs_lport.c
>> @@ -2633,7 +2633,7 @@ bfa_fcs_fdmi_get_hbaattr(struct bfa_fcs_lport_fdmi_s *fdmi,
>>       strncpy(hba_attr->driver_version, (char *)driver_info->version,
>>               sizeof(hba_attr->driver_version));
>
> Why do we not change this one?
>
>>
>> -     strncpy(hba_attr->os_name, driver_info->host_os_name,
>> +     strzcpy(hba_attr->os_name, driver_info->host_os_name,
>>               sizeof(hba_attr->os_name));
>
> strlcpy() would also be totally safe here.  It's also safe for patch
> patch 3 and patch 4.  Patch 5 is trickier to audit so I don't know if
> strlcpy() is safe.


Hi Dan

It was a miss, should have done this on both strncpy.

After becoming quite attacked for having changed to strlcpy I am very
careful with it now.
But ok, then I submit 2 3 4 with strlcpy instead.

But this is a little bad example for strzcpy though :-(

Kind regards
Rickard Strandqvist

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-10-20 21:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-18 22:13 [PATCH 2/5] scsi: bfa: bfa_fcs_lport.c: Cleaning up missing null-terminate by switching from strncpy to strzcpy Rickard Strandqvist
2014-10-20 15:37 ` Dan Carpenter
2014-10-20 21:10   ` Rickard Strandqvist

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).