aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDon Skidmore <donald.c.skidmore@intel.com>2010-08-19 09:33:16 -0400
committerDavid S. Miller <davem@davemloft.net>2010-08-19 19:36:44 -0400
commit083fc582b8752c64b0ae73935ddb45a1dd794b4c (patch)
treeb77af1a514e8f2e585c0f442175929cbcae3150d /drivers
parent357e8b5f723ba9e1d0a0f8ffb1361d607e43e19a (diff)
ixgbe: cleanup ixgbe_get_drvinfo to be extra careful with buffer boundaries
Make the code in ixgbe_get_drvinfo more protected against buffer overflow boundaries by using snprintf and sizeof with snprintf. Signed-off-by: Don Skidmore <donald.c.skidmore@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ixgbe/ixgbe_ethtool.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/drivers/net/ixgbe/ixgbe_ethtool.c b/drivers/net/ixgbe/ixgbe_ethtool.c
index dcebc82c6f4d..fb6d8e88eb05 100644
--- a/drivers/net/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ixgbe/ixgbe_ethtool.c
@@ -820,16 +820,19 @@ static void ixgbe_get_drvinfo(struct net_device *netdev,
820 struct ixgbe_adapter *adapter = netdev_priv(netdev); 820 struct ixgbe_adapter *adapter = netdev_priv(netdev);
821 char firmware_version[32]; 821 char firmware_version[32];
822 822
823 strncpy(drvinfo->driver, ixgbe_driver_name, 32); 823 strncpy(drvinfo->driver, ixgbe_driver_name, sizeof(drvinfo->driver));
824 strncpy(drvinfo->version, ixgbe_driver_version, 32); 824 strncpy(drvinfo->version, ixgbe_driver_version,
825 825 sizeof(drvinfo->version));
826 sprintf(firmware_version, "%d.%d-%d", 826
827 (adapter->eeprom_version & 0xF000) >> 12, 827 snprintf(firmware_version, sizeof(firmware_version), "%d.%d-%d",
828 (adapter->eeprom_version & 0x0FF0) >> 4, 828 (adapter->eeprom_version & 0xF000) >> 12,
829 adapter->eeprom_version & 0x000F); 829 (adapter->eeprom_version & 0x0FF0) >> 4,
830 830 adapter->eeprom_version & 0x000F);
831 strncpy(drvinfo->fw_version, firmware_version, 32); 831
832 strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); 832 strncpy(drvinfo->fw_version, firmware_version,
833 sizeof(drvinfo->fw_version));
834 strncpy(drvinfo->bus_info, pci_name(adapter->pdev),
835 sizeof(drvinfo->bus_info));
833 drvinfo->n_stats = IXGBE_STATS_LEN; 836 drvinfo->n_stats = IXGBE_STATS_LEN;
834 drvinfo->testinfo_len = IXGBE_TEST_LEN; 837 drvinfo->testinfo_len = IXGBE_TEST_LEN;
835 drvinfo->regdump_len = ixgbe_get_regs_len(netdev); 838 drvinfo->regdump_len = ixgbe_get_regs_len(netdev);