lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAFo99gZXrgn7SZsS+GYXrf65JcfwuCP-qej08yQCs5Z0g3e2rA@mail.gmail.com>
Date:	Sat, 16 Aug 2014 23:18:54 +0200
From:	Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>
To:	Jiri Pirko <jiri@...nulli.us>
Cc:	Hyong-Youb Kim <hykim@...i.com>,
	Network Development <netdev@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH V2] net: ethernet: myricom: myri10ge: myri10ge.c: Cleaning
 up missing null-terminate after strncpy call

2014-08-13 19:06 GMT+02:00 Jiri Pirko <jiri@...nulli.us>:
> Mon, Aug 11, 2014 at 09:18:16PM CEST, rickard_strandqvist@...ctrumdigital.se wrote:
>>Added a guaranteed null-terminate after call to strncpy.
>>
>>Signed-off-by: Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.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..69c26f0 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[sizeof(mgp->fw_version) - 1] = '\0';
>
>         Why not to use strlcpy?
>
>>
>>       sscanf(mgp->fw_version, "%d.%d.%d", &mgp->fw_ver_major,
>>              &mgp->fw_ver_minor, &mgp->fw_ver_tiny);
>>--
>>1.7.10.4


Hi

Sure, strlcpy is preferable in many ways if we only can guarantee that
it is safe.
I have seldom received so much criticism when I start switching to
strlcpy, although much of it was justified :)
Even Linus was getting into the debate.  See more:

https://plus.google.com/111049168280159033135/posts/1amLbuhWbh5


I change to strlcpy only when I'm sure it will not cause any other problems.
But if you or anyone else can guarantee that in this case, so I'd make
a new patch with strlcpy.


Kind regards

Rickard Strandqvist
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ