bfa: use strncpy() instead of memcpy()
Subsystems (3)
PATCH 1/1 bfa: use strncpy() instead of memcpy()
BFA_MFG_NAME is "QLogic" which is only 7 bytes, but we are copying 8 bytes. It's harmless because the badding byte is likely zero but it makes static checkers complain.
---
Technically the memset() is not needed because strncpy() will pad the rest of the buffer with zeros but I was worried that people would be paranoid.
drivers/scsi/bfa/bfa_ioc.c +1 -1
@@ -2803,7 +2803,7 @@ void bfa_ioc_get_adapter_manufacturer(struct bfa_ioc_s *ioc, char *manufacturer) { memset((void *)manufacturer, 0, BFA_ADAPTER_MFG_NAME_LEN); -memcpy (manufacturer,BFA_MFG_NAME ,BFA_ADAPTER_MFG_NAME_LEN ); +strncpy (manufacturer,BFA_MFG_NAME ,BFA_ADAPTER_MFG_NAME_LEN ); }void
-----Original Message-----
From: Dan Carpenter [mailto:[email protected]]
Sent: 30 January 2016 20:06
To: Anil Gurumurthy <[email protected]>
Cc: Sudarsana Kalluru <[email protected]>; James E.J. Bottomley <[email protected]>; Martin K. Petersen <[email protected]>; linux-scsi <[email protected]>; linux-kernel <[email protected]>; [email protected]
Subject: [patch] bfa: use strncpy() instead of memcpy()
BFA_MFG_NAME is "QLogic" which is only 7 bytes, but we are copying 8 bytes. It's harmless because the badding byte is likely zero but it makes static checkers complain.
---
Technically the memset() is not needed because strncpy() will pad the rest of the buffer with zeros but I was worried that people would be paranoid.
drivers/scsi/bfa/bfa_ioc.c +1 -1
@@ -2803,7 +2803,7 @@ void bfa_ioc_get_adapter_manufacturer(struct bfa_ioc_s *ioc, char *manufacturer) { memset((void *)manufacturer, 0, BFA_ADAPTER_MFG_NAME_LEN); -memcpy (manufacturer,BFA_MFG_NAME ,BFA_ADAPTER_MFG_NAME_LEN ); +strncpy (manufacturer,BFA_MFG_NAME ,BFA_ADAPTER_MFG_NAME_LEN ); }void
Martin K. Petersen
AppliedQuoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Dan" = Dan Carpenter <[email protected]> writes:
Dan> BFA_MFG_NAME is "QLogic" which is only 7 bytes, but we are copying Dan> 8 bytes. It's harmless because the badding byte is likely zero but Dan> it makes static checkers complain.
Applied to 4.6/scsi-queue.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering