Message ID | 1401917380-2772-1-git-send-email-rickard_strandqvist@spectrumdigital.se |
---|---|
State | Awaiting Upstream, archived |
Delegated to: | David Miller |
Headers | show |
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
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
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.
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.
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,
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(-)