All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: ethernet: myricom: myri10ge: myri10ge.c:  Cleaning up missing null-terminate after strncpy call
@ 2014-08-09 23:40 Rickard Strandqvist
  2014-08-11  0:58 ` Mark D Rustad
  0 siblings, 1 reply; 2+ messages in thread
From: Rickard Strandqvist @ 2014-08-09 23:40 UTC (permalink / raw)
  To: Hyong-Youb Kim, netdev; +Cc: Rickard Strandqvist, linux-kernel

Added a guaranteed null-terminate after call to strncpy.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
 drivers/net/ethernet/myricom/myri10ge/myri10ge.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
index f3d5d79..de327b6 100644
--- a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
+++ b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
@@ -574,6 +574,7 @@ myri10ge_validate_firmware(struct myri10ge_priv *mgp,
 
 	/* save firmware version for ethtool */
 	strncpy(mgp->fw_version, hdr->version, sizeof(mgp->fw_version));
+	mgp->fw_version[sizeif(mgp->fw_version) - 1] = '\0';
 
 	sscanf(mgp->fw_version, "%d.%d.%d", &mgp->fw_ver_major,
 	       &mgp->fw_ver_minor, &mgp->fw_ver_tiny);
-- 
1.7.10.4


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

* Re: [PATCH] net: ethernet: myricom: myri10ge: myri10ge.c:  Cleaning up missing null-terminate after strncpy call
  2014-08-09 23:40 [PATCH] net: ethernet: myricom: myri10ge: myri10ge.c: Cleaning up missing null-terminate after strncpy call Rickard Strandqvist
@ 2014-08-11  0:58 ` Mark D Rustad
  0 siblings, 0 replies; 2+ messages in thread
From: Mark D Rustad @ 2014-08-11  0:58 UTC (permalink / raw)
  To: Rickard Strandqvist; +Cc: Hyong-Youb Kim, netdev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1091 bytes --]

On Aug 9, 2014, at 4:40 PM, Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se> wrote:

> Added a guaranteed null-terminate after call to strncpy.
> 
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> ---
> drivers/net/ethernet/myricom/myri10ge/myri10ge.c |    1 +
> 1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
> index f3d5d79..de327b6 100644
> --- a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
> +++ b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
> @@ -574,6 +574,7 @@ myri10ge_validate_firmware(struct myri10ge_priv *mgp,
> 
> 	/* save firmware version for ethtool */
> 	strncpy(mgp->fw_version, hdr->version, sizeof(mgp->fw_version));
> +	mgp->fw_version[sizeif(mgp->fw_version) - 1] = '\0';

Surely you meant sizeof above. Did you really not even compile this?

> 	sscanf(mgp->fw_version, "%d.%d.%d", &mgp->fw_ver_major,
> 	       &mgp->fw_ver_minor, &mgp->fw_ver_tiny);

-- 
Mark Rustad, MRustad@gmail.com


[-- Attachment #2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 841 bytes --]

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

end of thread, other threads:[~2014-08-11  0:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-09 23:40 [PATCH] net: ethernet: myricom: myri10ge: myri10ge.c: Cleaning up missing null-terminate after strncpy call Rickard Strandqvist
2014-08-11  0:58 ` Mark D Rustad

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.