* [patch] bfa: use strncpy() instead of memcpy()
@ 2016-01-30 14:36 ` Dan Carpenter
0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2016-01-30 14:36 UTC (permalink / raw)
To: Anil Gurumurthy
Cc: Sudarsana Kalluru, James E.J. Bottomley, Martin K. Petersen,
linux-scsi, linux-kernel, kernel-janitors
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.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
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.
diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c
index 251e2ff..a1ada4a 100644
--- a/drivers/scsi/bfa/bfa_ioc.c
+++ b/drivers/scsi/bfa/bfa_ioc.c
@@ -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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [patch] bfa: use strncpy() instead of memcpy()
@ 2016-01-30 14:36 ` Dan Carpenter
0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2016-01-30 14:36 UTC (permalink / raw)
To: Anil Gurumurthy
Cc: Sudarsana Kalluru, James E.J. Bottomley, Martin K. Petersen,
linux-scsi, linux-kernel, kernel-janitors
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.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
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.
diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c
index 251e2ff..a1ada4a 100644
--- a/drivers/scsi/bfa/bfa_ioc.c
+++ b/drivers/scsi/bfa/bfa_ioc.c
@@ -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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* RE: [patch] bfa: use strncpy() instead of memcpy()
2016-01-30 14:36 ` Dan Carpenter
@ 2016-02-03 6:50 ` Anil Gurumurthy
-1 siblings, 0 replies; 6+ messages in thread
From: Anil Gurumurthy @ 2016-02-03 6:50 UTC (permalink / raw)
To: Dan Carpenter
Cc: Sudarsana Kalluru, James E.J. Bottomley, Martin K. Petersen,
linux-scsi, linux-kernel, kernel-janitors
Acked-by: Anil Gurumurthy <anil.gurumurthy@qlogic.com>
-----Original Message-----
From: Dan Carpenter [mailto:dan.carpenter@oracle.com]
Sent: 30 January 2016 20:06
To: Anil Gurumurthy <Anil.Gurumurthy@qlogic.com>
Cc: Sudarsana Kalluru <Sudarsana.Kalluru@qlogic.com>; James E.J. Bottomley <JBottomley@odin.com>; Martin K. Petersen <martin.petersen@oracle.com>; linux-scsi <linux-scsi@vger.kernel.org>; linux-kernel <linux-kernel@vger.kernel.org>; kernel-janitors@vger.kernel.org
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.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
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.
diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c index 251e2ff..a1ada4a 100644
--- a/drivers/scsi/bfa/bfa_ioc.c
+++ b/drivers/scsi/bfa/bfa_ioc.c
@@ -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
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [patch] bfa: use strncpy() instead of memcpy()
@ 2016-02-03 6:50 ` Anil Gurumurthy
0 siblings, 0 replies; 6+ messages in thread
From: Anil Gurumurthy @ 2016-02-03 6:50 UTC (permalink / raw)
To: Dan Carpenter
Cc: Sudarsana Kalluru, James E.J. Bottomley, Martin K. Petersen,
linux-scsi, linux-kernel, kernel-janitors
Acked-by: Anil Gurumurthy <anil.gurumurthy@qlogic.com>
-----Original Message-----
From: Dan Carpenter [mailto:dan.carpenter@oracle.com]
Sent: 30 January 2016 20:06
To: Anil Gurumurthy <Anil.Gurumurthy@qlogic.com>
Cc: Sudarsana Kalluru <Sudarsana.Kalluru@qlogic.com>; James E.J. Bottomley <JBottomley@odin.com>; Martin K. Petersen <martin.petersen@oracle.com>; linux-scsi <linux-scsi@vger.kernel.org>; linux-kernel <linux-kernel@vger.kernel.org>; kernel-janitors@vger.kernel.org
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.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
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.
diff --git a/drivers/scsi/bfa/bfa_ioc.c b/drivers/scsi/bfa/bfa_ioc.c index 251e2ff..a1ada4a 100644
--- a/drivers/scsi/bfa/bfa_ioc.c
+++ b/drivers/scsi/bfa/bfa_ioc.c
@@ -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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] bfa: use strncpy() instead of memcpy()
2016-01-30 14:36 ` Dan Carpenter
@ 2016-02-04 2:54 ` Martin K. Petersen
-1 siblings, 0 replies; 6+ messages in thread
From: Martin K. Petersen @ 2016-02-04 2:54 UTC (permalink / raw)
To: Dan Carpenter
Cc: Anil Gurumurthy, Sudarsana Kalluru, James E.J. Bottomley,
Martin K. Petersen, linux-scsi, linux-kernel, kernel-janitors
>>>>> "Dan" == Dan Carpenter <dan.carpenter@oracle.com> 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.
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] bfa: use strncpy() instead of memcpy()
@ 2016-02-04 2:54 ` Martin K. Petersen
0 siblings, 0 replies; 6+ messages in thread
From: Martin K. Petersen @ 2016-02-04 2:54 UTC (permalink / raw)
To: Dan Carpenter
Cc: Anil Gurumurthy, Sudarsana Kalluru, James E.J. Bottomley,
Martin K. Petersen, linux-scsi, linux-kernel, kernel-janitors
>>>>> "Dan" = Dan Carpenter <dan.carpenter@oracle.com> 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.
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-02-04 2:54 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-30 14:36 [patch] bfa: use strncpy() instead of memcpy() Dan Carpenter
2016-01-30 14:36 ` Dan Carpenter
2016-02-03 6:50 ` Anil Gurumurthy
2016-02-03 6:50 ` Anil Gurumurthy
2016-02-04 2:54 ` Martin K. Petersen
2016-02-04 2:54 ` Martin K. Petersen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.