[Patch 2.6] Stop using ETHTOOL_BUSINFO_LEN as size of driver and version members of ethtoo_drvinfo struct.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

a few drivers used ETHTOOL_BUSINFO_LEN as size of driver and version of 
ethtoo_drvinfo struct. But these are not defined as this.

So define it (for others) and remove usage of those I found.

Also uses strlcpy() instead of strncpy() which could be wrong by 1, I 
believe.

Patch is against today's BK.

 Michal
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2005/01/18 00:24:07+01:00 michal@xxxxxxxxxx 
#   [NetDrivers] Stop using ETHTOOL_BUSINFO_LEN as size of driver and version members of ethtoo_drvinfo struct.
#   natsemi, sk98lin, catc, rtl8150: Remove silent usage ETHTOOL_BUSINFO_LEN as size of driver and version members of ethtool_drvinfo.
#   natsemi, catc, rtl8150: use strlcpy() instead of strncpy() for copiing members above.
#   
#   Signed-off-by: Michal Rokos <michal@xxxxxxxxxx>
# 
# include/linux/ethtool.h
#   2005/01/18 00:23:28+01:00 michal@xxxxxxxxxx +3 -3
#   Quarantee that size of driver, version, and fw_version of struct ethtool_drvinfo() is the same as ETHTOOL_BUSINFO_LEN.
# 
# drivers/usb/net/rtl8150.c
#   2005/01/18 00:23:28+01:00 michal@xxxxxxxxxx +3 -3
#   Remove usage of ETHTOOL_BUSINFO_LEN for size of driver and version members of struct ethtool_drvinfo since it's not guaranteed by <linux/ethtool.h>.
#   Use strlcpy() instead of strncpy() to make it safe.
# 
# drivers/usb/net/catc.c
#   2005/01/18 00:23:28+01:00 michal@xxxxxxxxxx +3 -3
#   Remove usage of ETHTOOL_BUSINFO_LEN for size of driver and version members of struct ethtool_drvinfo since it's not guaranteed by <linux/ethtool.h>.
#   Use strlcpy() instead of strncpy() to make it safe.
# 
# drivers/net/sk98lin/skethtool.c
#   2005/01/18 00:23:28+01:00 michal@xxxxxxxxxx +1 -1
#   Remove usage of ETHTOOL_BUSINFO_LEN for size of driver and version members of struct ethtool_drvinfo since it's not guaranteed by <linux/ethtool.h>.
# 
# drivers/net/natsemi.c
#   2005/01/18 00:23:27+01:00 michal@xxxxxxxxxx +3 -3
#   Remove usage of ETHTOOL_BUSINFO_LEN for size of driver and version members of struct ethtool_drvinfo since it's not guaranteed by <linux/ethtool.h>.
#   Use strlcpy() instead of strncpy() to make it safe.
# 
diff -Nru a/drivers/net/natsemi.c b/drivers/net/natsemi.c
--- a/drivers/net/natsemi.c	2005-01-18 23:37:33 +01:00
+++ b/drivers/net/natsemi.c	2005-01-18 23:37:33 +01:00
@@ -2487,9 +2487,9 @@
 static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	strncpy(info->driver, DRV_NAME, ETHTOOL_BUSINFO_LEN);
-	strncpy(info->version, DRV_VERSION, ETHTOOL_BUSINFO_LEN);
-	strncpy(info->bus_info, pci_name(np->pci_dev), ETHTOOL_BUSINFO_LEN);
+	strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
+	strlcpy(info->version, DRV_VERSION, sizeof(info->version));
+	strlcpy(info->bus_info, pci_name(np->pci_dev), sizeof(info->bus_info));
 }
 
 static int get_regs_len(struct net_device *dev)
diff -Nru a/drivers/net/sk98lin/skethtool.c b/drivers/net/sk98lin/skethtool.c
--- a/drivers/net/sk98lin/skethtool.c	2005-01-18 23:37:33 +01:00
+++ b/drivers/net/sk98lin/skethtool.c	2005-01-18 23:37:33 +01:00
@@ -257,7 +257,7 @@
 	strlcpy(info->driver, DRIVER_FILE_NAME, sizeof(info->driver));
 	strcpy(info->version, vers);
 	strcpy(info->fw_version, "N/A");
-	strlcpy(info->bus_info, pAC->PciDev->slot_name, ETHTOOL_BUSINFO_LEN);
+	strlcpy(info->bus_info, pAC->PciDev->slot_name, sizeof(info->bus_info));
 }
 
 /*
diff -Nru a/drivers/usb/net/catc.c b/drivers/usb/net/catc.c
--- a/drivers/usb/net/catc.c	2005-01-18 23:37:33 +01:00
+++ b/drivers/usb/net/catc.c	2005-01-18 23:37:33 +01:00
@@ -667,9 +667,9 @@
 void catc_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 {
 	struct catc *catc = netdev_priv(dev);
-	strncpy(info->driver, driver_name, ETHTOOL_BUSINFO_LEN);
-	strncpy(info->version, DRIVER_VERSION, ETHTOOL_BUSINFO_LEN);
-	usb_make_path (catc->usbdev, info->bus_info, sizeof info->bus_info);
+	strlcpy(info->driver, driver_name, sizeof(info->driver));
+	strlcpy(info->version, DRIVER_VERSION, sizeof(info->version));
+	usb_make_path(catc->usbdev, info->bus_info, sizeof(info->bus_info));
 }
 
 static int catc_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
diff -Nru a/drivers/usb/net/rtl8150.c b/drivers/usb/net/rtl8150.c
--- a/drivers/usb/net/rtl8150.c	2005-01-18 23:37:33 +01:00
+++ b/drivers/usb/net/rtl8150.c	2005-01-18 23:37:33 +01:00
@@ -762,9 +762,9 @@
 {
 	rtl8150_t *dev = netdev_priv(netdev);
 
-	strncpy(info->driver, driver_name, ETHTOOL_BUSINFO_LEN);
-	strncpy(info->version, DRIVER_VERSION, ETHTOOL_BUSINFO_LEN);
-	usb_make_path(dev->udev, info->bus_info, sizeof info->bus_info);
+	strlcpy(info->driver, driver_name, sizeof(info->driver));
+	strlcpy(info->version, DRIVER_VERSION, sizeof(info->version));
+	usb_make_path(dev->udev, info->bus_info, sizeof(info->bus_info));
 }
 
 static int rtl8150_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
diff -Nru a/include/linux/ethtool.h b/include/linux/ethtool.h
--- a/include/linux/ethtool.h	2005-01-18 23:37:33 +01:00
+++ b/include/linux/ethtool.h	2005-01-18 23:37:33 +01:00
@@ -33,9 +33,9 @@
 /* these strings are set to whatever the driver author decides... */
 struct ethtool_drvinfo {
 	u32	cmd;
-	char	driver[32];	/* driver short name, "tulip", "eepro100" */
-	char	version[32];	/* driver version string */
-	char	fw_version[32];	/* firmware version string, if applicable */
+	char	driver[ETHTOOL_BUSINFO_LEN];	/* driver short name, "tulip", "eepro100" */
+	char	version[ETHTOOL_BUSINFO_LEN];	/* driver version string */
+	char	fw_version[ETHTOOL_BUSINFO_LEN];/* firmware version string, if applicable */
 	char	bus_info[ETHTOOL_BUSINFO_LEN];	/* Bus info for this IF. */
 				/* For PCI devices, use pci_name(pci_dev). */
 	char	reserved1[32];

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux