mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [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: Rickard Strandqvist, Bruce Allan, Carolyn Wyborny, Don Skidmore,
	Greg Rose, Alex Duyck, John Ronciak, Mitch Williams, Linux NICS,
	e1000-devel, netdev, linux-kernel

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


^ 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   ` [E1000-devel] " 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

all inboxes | Powered by JetHome®