summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJiri Pirko <jiri@resnulli.us>2013-01-05 19:44:26 -0500
committerDavid S. Miller <davem@davemloft.net>2013-01-07 00:06:31 -0500
commit7826d43f2db45c9305a6e0ba165650e1a203f517 (patch)
treea8659c995a37f58db809da9537aafac178431f31 /net
parent2afb9b533423a9b97f84181e773cf9361d98fed6 (diff)
ethtool: fix drvinfo strings set in drivers
Use strlcpy where possible to ensure the string is \0 terminated. Use always sizeof(string) instead of 32, ETHTOOL_BUSINFO_LEN and custom defines. Use snprintf instead of sprint. Remove unnecessary inits of ->fw_version Remove unnecessary inits of drvinfo struct. Signed-off-by: Jiri Pirko <jiri@resnulli.us> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/8021q/vlan_dev.c6
-rw-r--r--net/batman-adv/soft-interface.c8
-rw-r--r--net/bridge/br_device.c8
-rw-r--r--net/dsa/slave.c8
-rw-r--r--net/openvswitch/vport-internal_dev.c2
-rw-r--r--net/wireless/ethtool.c4
6 files changed, 18 insertions, 18 deletions
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 4a6d31a082b9..09f9108d4688 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -640,9 +640,9 @@ static int vlan_ethtool_get_settings(struct net_device *dev,
640static void vlan_ethtool_get_drvinfo(struct net_device *dev, 640static void vlan_ethtool_get_drvinfo(struct net_device *dev,
641 struct ethtool_drvinfo *info) 641 struct ethtool_drvinfo *info)
642{ 642{
643 strcpy(info->driver, vlan_fullname); 643 strlcpy(info->driver, vlan_fullname, sizeof(info->driver));
644 strcpy(info->version, vlan_version); 644 strlcpy(info->version, vlan_version, sizeof(info->version));
645 strcpy(info->fw_version, "N/A"); 645 strlcpy(info->fw_version, "N/A", sizeof(info->fw_version));
646} 646}
647 647
648static struct rtnl_link_stats64 *vlan_dev_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) 648static struct rtnl_link_stats64 *vlan_dev_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index fa388b2c60d7..90f4049a90dd 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -580,10 +580,10 @@ static int batadv_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
580static void batadv_get_drvinfo(struct net_device *dev, 580static void batadv_get_drvinfo(struct net_device *dev,
581 struct ethtool_drvinfo *info) 581 struct ethtool_drvinfo *info)
582{ 582{
583 strcpy(info->driver, "B.A.T.M.A.N. advanced"); 583 strlcpy(info->driver, "B.A.T.M.A.N. advanced", sizeof(info->driver));
584 strcpy(info->version, BATADV_SOURCE_VERSION); 584 strlcpy(info->version, BATADV_SOURCE_VERSION, sizeof(info->version));
585 strcpy(info->fw_version, "N/A"); 585 strlcpy(info->fw_version, "N/A", sizeof(info->fw_version));
586 strcpy(info->bus_info, "batman"); 586 strlcpy(info->bus_info, "batman", sizeof(info->bus_info));
587} 587}
588 588
589static u32 batadv_get_msglevel(struct net_device *dev) 589static u32 batadv_get_msglevel(struct net_device *dev)
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index 38974f70ec7b..e1bc090bc00a 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -184,10 +184,10 @@ static int br_set_mac_address(struct net_device *dev, void *p)
184 184
185static void br_getinfo(struct net_device *dev, struct ethtool_drvinfo *info) 185static void br_getinfo(struct net_device *dev, struct ethtool_drvinfo *info)
186{ 186{
187 strcpy(info->driver, "bridge"); 187 strlcpy(info->driver, "bridge", sizeof(info->driver));
188 strcpy(info->version, BR_VERSION); 188 strlcpy(info->version, BR_VERSION, sizeof(info->version));
189 strcpy(info->fw_version, "N/A"); 189 strlcpy(info->fw_version, "N/A", sizeof(info->fw_version));
190 strcpy(info->bus_info, "N/A"); 190 strlcpy(info->bus_info, "N/A", sizeof(info->bus_info));
191} 191}
192 192
193static netdev_features_t br_fix_features(struct net_device *dev, 193static netdev_features_t br_fix_features(struct net_device *dev,
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index e32083d5d8f8..f795b0ca7ee6 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -203,10 +203,10 @@ dsa_slave_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
203static void dsa_slave_get_drvinfo(struct net_device *dev, 203static void dsa_slave_get_drvinfo(struct net_device *dev,
204 struct ethtool_drvinfo *drvinfo) 204 struct ethtool_drvinfo *drvinfo)
205{ 205{
206 strncpy(drvinfo->driver, "dsa", 32); 206 strlcpy(drvinfo->driver, "dsa", sizeof(drvinfo->driver));
207 strncpy(drvinfo->version, dsa_driver_version, 32); 207 strlcpy(drvinfo->version, dsa_driver_version, sizeof(drvinfo->version));
208 strncpy(drvinfo->fw_version, "N/A", 32); 208 strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version));
209 strncpy(drvinfo->bus_info, "platform", 32); 209 strlcpy(drvinfo->bus_info, "platform", sizeof(drvinfo->bus_info));
210} 210}
211 211
212static int dsa_slave_nway_reset(struct net_device *dev) 212static int dsa_slave_nway_reset(struct net_device *dev)
diff --git a/net/openvswitch/vport-internal_dev.c b/net/openvswitch/vport-internal_dev.c
index 44cd5c3a4c22..0531de6c7a4a 100644
--- a/net/openvswitch/vport-internal_dev.c
+++ b/net/openvswitch/vport-internal_dev.c
@@ -97,7 +97,7 @@ static int internal_dev_stop(struct net_device *netdev)
97static void internal_dev_getinfo(struct net_device *netdev, 97static void internal_dev_getinfo(struct net_device *netdev,
98 struct ethtool_drvinfo *info) 98 struct ethtool_drvinfo *info)
99{ 99{
100 strcpy(info->driver, "openvswitch"); 100 strlcpy(info->driver, "openvswitch", sizeof(info->driver));
101} 101}
102 102
103static const struct ethtool_ops internal_dev_ethtool_ops = { 103static const struct ethtool_ops internal_dev_ethtool_ops = {
diff --git a/net/wireless/ethtool.c b/net/wireless/ethtool.c
index 48c48ffafa1d..e37862f1b127 100644
--- a/net/wireless/ethtool.c
+++ b/net/wireless/ethtool.c
@@ -15,10 +15,10 @@ static void cfg80211_get_drvinfo(struct net_device *dev,
15 strlcpy(info->version, init_utsname()->release, sizeof(info->version)); 15 strlcpy(info->version, init_utsname()->release, sizeof(info->version));
16 16
17 if (wdev->wiphy->fw_version[0]) 17 if (wdev->wiphy->fw_version[0])
18 strncpy(info->fw_version, wdev->wiphy->fw_version, 18 strlcpy(info->fw_version, wdev->wiphy->fw_version,
19 sizeof(info->fw_version)); 19 sizeof(info->fw_version));
20 else 20 else
21 strncpy(info->fw_version, "N/A", sizeof(info->fw_version)); 21 strlcpy(info->fw_version, "N/A", sizeof(info->fw_version));
22 22
23 strlcpy(info->bus_info, dev_name(wiphy_dev(wdev->wiphy)), 23 strlcpy(info->bus_info, dev_name(wiphy_dev(wdev->wiphy)),
24 sizeof(info->bus_info)); 24 sizeof(info->bus_info));