Message ID | 1406384676-2606-1-git-send-email-rickard_strandqvist@spectrumdigital.se |
---|---|
State | Awaiting Upstream, archived |
Delegated to: | David Miller |
Headers | show |
On Sat, 26 Jul 2014 16:24:36 +0200 Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se> wrote: > Replacing strncpy with strlcpy to avoid strings that lacks null terminate. > > Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se> > --- hw->mac.type, hw->phy.type, hw->phy.sfp_type, This patch doesn't change anything. Netdev is already zeroed when allocated therefore doing strncpy() guarantees it will be null terminated. -- 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 Tue, 2014-07-29 at 14:15 +0200, Rickard Strandqvist wrote: > Den 29 jul 2014 04:40 skrev "Stephen Hemminger" <stephen@networkplumber.org > >: > > > > On Sat, 26 Jul 2014 16:24:36 +0200 > > Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se> wrote: > > > > > Replacing strncpy with strlcpy to avoid strings that lacks null > terminate. > > > > > > Signed-off-by: Rickard Strandqvist < > rickard_strandqvist@spectrumdigital.se> > > > --- > > hw->mac.type, hw->phy.type, hw->phy.sfp_type, > > > > This patch doesn't change anything. > > Netdev is already zeroed when allocated therefore doing strncpy() > guarantees > > it will be null terminated. > > Hi Stephen > > It's not clear that alloc_etherdev_mq() will zero the memory area: > <snip> Thanks Rickard, given strncpy to strlcpy gets suggested by static code generators this will probably come up again even if it results in no real change. I (covering for Jeff Kirsher) went ahead and added it to our internal tree.
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index f5aa331..ccf6a81 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -8161,7 +8161,7 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent) netdev->netdev_ops = &ixgbe_netdev_ops; ixgbe_set_ethtool_ops(netdev); netdev->watchdog_timeo = 5 * HZ; - strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1); + strlcpy(netdev->name, pci_name(pdev), sizeof(netdev->name)); adapter->bd_number = cards_found; @@ -8388,7 +8388,7 @@ skip_sriov: err = ixgbe_read_pba_string_generic(hw, part_str, IXGBE_PBANUM_LENGTH); if (err) - strncpy(part_str, "Unknown", IXGBE_PBANUM_LENGTH); + strlcpy(part_str, "Unknown", IXGBE_PBANUM_LENGTH); 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,
Replacing strncpy with strlcpy to avoid strings that lacks null terminate. Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se> --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)