Search Linux Wireless

[PATCH] wifi: ipw2x00: fix -Wformat-truncation warnings

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

 



Fix the following warnings observed with GCC 13.2 and -Wformat-truncation:

drivers/net/wireless/intel/ipw2x00/ipw2100.c: In function ‘ipw_ethtool_get_drvinfo’:
drivers/net/wireless/intel/ipw2x00/ipw2100.c:5905:63: warning: ‘%s’ directive output
may be truncated writing up to 63 bytes into a region of size 32 [-Wformat-truncation=]
 5905 |         snprintf(info->fw_version, sizeof(info->fw_version), "%s:%d:%s",
      |                                                               ^~
 5906 |                  fw_ver, priv->eeprom_version, ucode_ver);
      |                  ~~~~~~
drivers/net/wireless/intel/ipw2x00/ipw2100.c:5905:9: note: ‘snprintf’ output between
4 and 140 bytes into a destination of size 32
 5905 |         snprintf(info->fw_version, sizeof(info->fw_version), "%s:%d:%s",
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 5906 |                  fw_ver, priv->eeprom_version, ucode_ver);
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

For ipw2100, 'ipw2100_get_fwversion()' says that the firmware version
is no longer than 14 bytes, and 'ipw2100_get_ucodeversion()' uses "%08X"
so 10 bytes should be enough.

drivers/net/wireless/intel/ipw2x00/ipw2200.c: In function ‘ipw_ethtool_get_drvinfo’:
drivers/net/wireless/intel/ipw2x00/ipw2200.c:10392:63: warning: ‘%s’ directive output
may be truncated writing up to 63 bytes into a region of size 32 [-Wformat-truncation=]
10392 |         snprintf(info->fw_version, sizeof(info->fw_version), "%s (%s)",
      |                                                               ^~
10393 |                  vers, date);
      |                  ~~~~
drivers/net/wireless/intel/ipw2x00/ipw2200.c:10392:9: note: ‘snprintf’ output between
4 and 98 bytes into a destination of size 32
10392 |         snprintf(info->fw_version, sizeof(info->fw_version), "%s (%s)",
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10393 |                  vers, date);
      |                  ~~~~~~~~~~~

For ipw2200, I assume that the firmware version is no longer than 14
bytes as well, and, according to ipw2100.h, firmware date is in
'mmm dd yyyy' format so 12 bytes should be enough.

Suggested-by: Kalle Valo <kvalo@xxxxxxxxxx>
Signed-off-by: Dmitry Antipov <dmantipov@xxxxxxxxx>
---
 drivers/net/wireless/intel/ipw2x00/ipw2100.c | 2 +-
 drivers/net/wireless/intel/ipw2x00/ipw2200.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2100.c b/drivers/net/wireless/intel/ipw2x00/ipw2100.c
index 0812db8936f1..11b698255fe8 100644
--- a/drivers/net/wireless/intel/ipw2x00/ipw2100.c
+++ b/drivers/net/wireless/intel/ipw2x00/ipw2100.c
@@ -5894,7 +5894,7 @@ static void ipw_ethtool_get_drvinfo(struct net_device *dev,
 				    struct ethtool_drvinfo *info)
 {
 	struct ipw2100_priv *priv = libipw_priv(dev);
-	char fw_ver[64], ucode_ver[64];
+	char fw_ver[16], ucode_ver[10];
 
 	strscpy(info->driver, DRV_NAME, sizeof(info->driver));
 	strscpy(info->version, DRV_VERSION, sizeof(info->version));
diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2200.c b/drivers/net/wireless/intel/ipw2x00/ipw2200.c
index 820100cac491..f9a539d2e93b 100644
--- a/drivers/net/wireless/intel/ipw2x00/ipw2200.c
+++ b/drivers/net/wireless/intel/ipw2x00/ipw2200.c
@@ -10377,8 +10377,8 @@ static void ipw_ethtool_get_drvinfo(struct net_device *dev,
 				    struct ethtool_drvinfo *info)
 {
 	struct ipw_priv *p = libipw_priv(dev);
-	char vers[64];
-	char date[32];
+	char vers[16];
+	char date[12];
 	u32 len;
 
 	strscpy(info->driver, DRV_NAME, sizeof(info->driver));
-- 
2.41.0




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux