ethtool: Null-terminate filename passed to ethtool_ops::flash_device
Subsystems (3)
PATCH 1/1 ethtool: Null-terminate filename passed to ethtool_ops::flash_device
The parameters for ETHTOOL_FLASHDEV include a filename, which ought to be null-terminated. Currently the only driver that implements ethtool_ops::flash_device attempts to add a null terminator if necessary, but does it wrongly. Do it in the ethtool core instead.
Signed-off-by Ben Hutchings <[email protected]>
---
Compile-tested only.
Ben.
drivers/net/ethernet/emulex/benet/be_ethtool.c | 6 +----- net/core/ethtool.c | 2 ++ 2 files changed, 3 insertions(+), 5 deletions(-)
drivers/net/ethernet/emulex/benet/be_ethtool.c +1 -5
@@ -716,12 +716,8 @@ static int be_do_flash(struct net_device *netdev, struct ethtool_flash *efl) { struct be_adapter *adapter = netdev_priv(netdev); -char file_name[ETHTOOL_FLASH_MAX_FILENAME ]; - file_name[ETHTOOL_FLASH_MAX_FILENAME -1 ] =0 ; -strcpy (file_name, efl->data); - -return be_load_fw (adapter, file_name); +return be_load_fw (adapter, efl->data); } static int
net/core/ethtool.c +2 -0
@@ -1190,6 +1190,8 @@ static noinline_for_stack int ethtool_flash_device(struct net_device *dev,if (!dev->ethtool_ops->flash_device)return -EOPNOTSUPP ; + efl.data[ETHTOOL_FLASH_MAX_FILENAME -1 ] =0 ; +return dev->ethtool_ops->flash_device (dev, &efl); }
Signature · 7 lines
1.7.7.5 -- Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
From: Ben Hutchings <[email protected]>
Date: Wed, 1 Feb 2012 19:32:25 +0000
Quoted 6 lines
The parameters for
ETHTOOL_FLASHDEVinclude a filename, which ought to be null-terminated. Currently the only driver that implementsethtool_ops::flash_deviceattempts to add a null terminator if necessary, but does it wrongly. Do it in the ethtool core instead.Signed-off-by Ben Hutchings <[email protected]>
Applied, thanks Ben.