Search Linux Wireless

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

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

 



Dmitry Antipov <dmantipov@xxxxxxxxx> wrote:

> 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>

I tried to fix this a bit differently:

https://patchwork.kernel.org/project/linux-wireless/patch/20231012135854.3473332-2-kvalo@xxxxxxxxxx/

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20231017165215.143992-1-dmantipov@xxxxxxxxx/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches




[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