* [PATCH] net: ethernet: intel: ixgbe: ixgbe_main.c: Cleaning up missing null-terminate after strncpy call
@ 2014-06-04 21:29 Rickard Strandqvist
2014-06-04 21:55 ` Joe Perches
2014-06-04 23:45 ` [linux-nics] " Jeff Kirsher
0 siblings, 2 replies; 4+ messages in thread
From: Rickard Strandqvist @ 2014-06-04 21:29 UTC (permalink / raw)
To: Jeff Kirsher, Jesse Brandeburg
Cc: Linux NICS, Rickard Strandqvist, e1000-devel, Bruce Allan,
linux-kernel, John Ronciak, netdev
Added a guaranteed null-terminate after call to strncpy.
This was partly found using a static code analysis program called cppcheck.
Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index d62e7a2..58322e4 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -8237,8 +8237,10 @@ skip_sriov:
ixgbe_check_minimum_link(adapter, expected_gts);
err = ixgbe_read_pba_string_generic(hw, part_str, IXGBE_PBANUM_LENGTH);
- if (err)
+ if (err) {
strncpy(part_str, "Unknown", IXGBE_PBANUM_LENGTH);
+ part_str[sizeof(part_str) - 1] = '\0';
+ }
if (ixgbe_is_sfp(hw) && hw->phy.sfp_type != ixgbe_sfp_type_not_present)
e_dev_info("MAC: %d, PHY: %d, SFP+: %d, PBA No: %s\n",
hw->mac.type, hw->phy.type, hw->phy.sfp_type,
--
1.7.10.4
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] net: ethernet: intel: ixgbe: ixgbe_main.c: Cleaning up missing null-terminate after strncpy call
2014-06-04 21:29 [PATCH] net: ethernet: intel: ixgbe: ixgbe_main.c: Cleaning up missing null-terminate after strncpy call Rickard Strandqvist
@ 2014-06-04 21:55 ` Joe Perches
2014-06-04 22:14 ` Rustad, Mark D
2014-06-04 23:45 ` [linux-nics] " Jeff Kirsher
1 sibling, 1 reply; 4+ messages in thread
From: Joe Perches @ 2014-06-04 21:55 UTC (permalink / raw)
To: Rickard Strandqvist
Cc: Alex, e1000-devel, Bruce Allan, Jesse Brandeburg, linux-kernel,
John Ronciak, netdev, Linux NICS
On Wed, 2014-06-04 at 23:29 +0200, Rickard Strandqvist wrote:
> Added a guaranteed null-terminate after call to strncpy.
Perhaps all of these should be strlcpy
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: ethernet: intel: ixgbe: ixgbe_main.c: Cleaning up missing null-terminate after strncpy call
2014-06-04 21:55 ` Joe Perches
@ 2014-06-04 22:14 ` Rustad, Mark D
0 siblings, 0 replies; 4+ messages in thread
From: Rustad, Mark D @ 2014-06-04 22:14 UTC (permalink / raw)
To: Joe Perches
Cc: Rickard Strandqvist, e1000-devel, Netdev, Allan, Bruce W,
<linux-kernel@vger.kernel.org>,
Brandeburg, Jesse, Ronciak, John, Linux NICS
On Jun 4, 2014, at 2:55 PM, Joe Perches <joe@perches.com> wrote:
> On Wed, 2014-06-04 at 23:29 +0200, Rickard Strandqvist wrote:
>> Added a guaranteed null-terminate after call to strncpy.
>
> Perhaps all of these should be strlcpy
The code that is there seems fine. The length of the array exceeds the length of the literal, and the strncpy ensures that the entire buffer is initialized so no information can possibly leak from the kernel.
I think this is fine as it is without any patch.
--
Mark Rustad, Networking Division, Intel Corporation
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [linux-nics] [PATCH] net: ethernet: intel: ixgbe: ixgbe_main.c: Cleaning up missing null-terminate after strncpy call
2014-06-04 21:29 [PATCH] net: ethernet: intel: ixgbe: ixgbe_main.c: Cleaning up missing null-terminate after strncpy call Rickard Strandqvist
2014-06-04 21:55 ` Joe Perches
@ 2014-06-04 23:45 ` Jeff Kirsher
1 sibling, 0 replies; 4+ messages in thread
From: Jeff Kirsher @ 2014-06-04 23:45 UTC (permalink / raw)
To: Rickard Strandqvist
Cc: Don, NICS, Linux, e1000-devel, netdev, Jesse Brandeburg, linux-kernel
[-- Attachment #1.1: Type: text/plain, Size: 493 bytes --]
On Wed, 2014-06-04 at 23:29 +0200, Rickard Strandqvist wrote:
> Added a guaranteed null-terminate after call to strncpy.
>
> This was partly found using a static code analysis program called
> cppcheck.
>
> Signed-off-by: Rickard Strandqvist
> <rickard_strandqvist@spectrumdigital.se>
> ---
> drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
NAK, I won't be picking this patch up based on Mark's and Joe's
feedback.
[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 366 bytes --]
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
[-- Attachment #3: Type: text/plain, Size: 257 bytes --]
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-06-04 23:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-04 21:29 [PATCH] net: ethernet: intel: ixgbe: ixgbe_main.c: Cleaning up missing null-terminate after strncpy call Rickard Strandqvist
2014-06-04 21:55 ` Joe Perches
2014-06-04 22:14 ` Rustad, Mark D
2014-06-04 23:45 ` [linux-nics] " Jeff Kirsher
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).