mirror of
https://github.com/torvalds/linux.git
synced 2024-11-01 17:51:43 +00:00
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>
This commit is contained in:
parent
357e8b5f72
commit
083fc582b8
@ -820,16 +820,19 @@ static void ixgbe_get_drvinfo(struct net_device *netdev,
|
||||
struct ixgbe_adapter *adapter = netdev_priv(netdev);
|
||||
char firmware_version[32];
|
||||
|
||||
strncpy(drvinfo->driver, ixgbe_driver_name, 32);
|
||||
strncpy(drvinfo->version, ixgbe_driver_version, 32);
|
||||
strncpy(drvinfo->driver, ixgbe_driver_name, sizeof(drvinfo->driver));
|
||||
strncpy(drvinfo->version, ixgbe_driver_version,
|
||||
sizeof(drvinfo->version));
|
||||
|
||||
sprintf(firmware_version, "%d.%d-%d",
|
||||
(adapter->eeprom_version & 0xF000) >> 12,
|
||||
(adapter->eeprom_version & 0x0FF0) >> 4,
|
||||
adapter->eeprom_version & 0x000F);
|
||||
snprintf(firmware_version, sizeof(firmware_version), "%d.%d-%d",
|
||||
(adapter->eeprom_version & 0xF000) >> 12,
|
||||
(adapter->eeprom_version & 0x0FF0) >> 4,
|
||||
adapter->eeprom_version & 0x000F);
|
||||
|
||||
strncpy(drvinfo->fw_version, firmware_version, 32);
|
||||
strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32);
|
||||
strncpy(drvinfo->fw_version, firmware_version,
|
||||
sizeof(drvinfo->fw_version));
|
||||
strncpy(drvinfo->bus_info, pci_name(adapter->pdev),
|
||||
sizeof(drvinfo->bus_info));
|
||||
drvinfo->n_stats = IXGBE_STATS_LEN;
|
||||
drvinfo->testinfo_len = IXGBE_TEST_LEN;
|
||||
drvinfo->regdump_len = ixgbe_get_regs_len(netdev);
|
||||
|
Loading…
Reference in New Issue
Block a user