* [PATCH] net: ethernet: intel: ixgbe: ixgbe_main.c: Cleaning up missing null-terminate in conjunction with strncpy
@ 2014-07-26 14:24 Rickard Strandqvist
2014-07-28 15:39 ` Stephen Hemminger
0 siblings, 1 reply; 4+ messages in thread
From: Rickard Strandqvist @ 2014-07-26 14:24 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
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(-)
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,
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] net: ethernet: intel: ixgbe: ixgbe_main.c: Cleaning up missing null-terminate in conjunction with strncpy
2014-07-26 14:24 [PATCH] net: ethernet: intel: ixgbe: ixgbe_main.c: Cleaning up missing null-terminate in conjunction with strncpy Rickard Strandqvist
@ 2014-07-28 15:39 ` Stephen Hemminger
2014-07-29 12:15 ` Rickard Strandqvist
0 siblings, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2014-07-28 15:39 UTC (permalink / raw)
To: Rickard Strandqvist
Cc: Jeff Kirsher, Jesse Brandeburg, Bruce Allan, Carolyn Wyborny,
Don Skidmore, Greg Rose, Alex Duyck, John Ronciak, Mitch Williams,
Linux NICS, e1000-devel, netdev, linux-kernel
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: ethernet: intel: ixgbe: ixgbe_main.c: Cleaning up missing null-terminate in conjunction with strncpy
2014-07-28 15:39 ` Stephen Hemminger
@ 2014-07-29 12:15 ` Rickard Strandqvist
2014-07-29 20:20 ` Brown, Aaron F
0 siblings, 1 reply; 4+ messages in thread
From: Rickard Strandqvist @ 2014-07-29 12:15 UTC (permalink / raw)
To: Stephen Hemminger
Cc: Linux NICS, e1000-devel, netdev, Bruce Allan, Jesse Brandeburg,
linux-kernel, John Ronciak
[-- Attachment #1.1: Type: text/plain, Size: 1121 bytes --]
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:
http://www.filewatcher.com/p/kernel-doc-2.6.32-71.14.1.el6.centos.plus.noarch.rpm.8821380/usr/share/man/man9/alloc_etherdev_mq.9.gz.html
If we are convinced that this is done, it works whith strncpy and sizeof()
- 1
But on the next with "part_str" I can not see that it can not be created
without a trailing zero. Except of course "Unknown" is less than 11
characters, but if we think that way, you can go back to using strcpy.
BR
Rickard Strandqvist
[-- Attachment #2: Type: text/plain, Size: 332 bytes --]
------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls.
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
[-- 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
* Re: [PATCH] net: ethernet: intel: ixgbe: ixgbe_main.c: Cleaning up missing null-terminate in conjunction with strncpy
2014-07-29 12:15 ` Rickard Strandqvist
@ 2014-07-29 20:20 ` Brown, Aaron F
0 siblings, 0 replies; 4+ messages in thread
From: Brown, Aaron F @ 2014-07-29 20:20 UTC (permalink / raw)
To: rickard_strandqvist@spectrumdigital.se
Cc: e1000-devel@lists.sourceforge.net, netdev@vger.kernel.org,
Allan, Bruce W, Brandeburg, Jesse, Linux NICS, Ronciak, John,
linux-kernel@vger.kernel.org
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.
------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls.
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
_______________________________________________
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-07-29 20:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-26 14:24 [PATCH] net: ethernet: intel: ixgbe: ixgbe_main.c: Cleaning up missing null-terminate in conjunction with strncpy Rickard Strandqvist
2014-07-28 15:39 ` Stephen Hemminger
2014-07-29 12:15 ` Rickard Strandqvist
2014-07-29 20:20 ` Brown, Aaron F
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox