]> www.infradead.org Git - users/jedix/linux-maple.git/commit
i40e: prevent snprintf format specifier truncation
authorJacob Keller <jacob.e.keller@intel.com>
Wed, 12 Jul 2017 09:46:09 +0000 (05:46 -0400)
committerJack Vogel <jack.vogel@oracle.com>
Tue, 10 Oct 2017 21:15:25 +0000 (14:15 -0700)
commit46694d324a628c39f2af2dc17d782c4fd582d872
treea4ad23a4dc5d58ee24e3eb3f04a60ec68fd4d658
parent688e968a2da0557bc23815534650df856c8f463e
i40e: prevent snprintf format specifier truncation

Increase the size of the prefix buffer so that it can hold enough
characters for every possible input. Although 20 is enough for all
expected inputs, it is possible for the values to be larger than
expected, resulting in a possibly truncated string. Additionally, lets
use sizeof(prefix) in order to ensure we use the correct size if we need
to change the array length in the future.

New versions of GCC starting at 7 now include warnings to prevent
truncation unless you handle the return code. At most 27 bytes can be
written here, so lets just increase the buffer size even if for all
expected hw->bus.* values we only needed 20.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Orabug: 26785018
(cherry picked from commit b5d5504aa1e961fc1f87ee7b092bf5ce1a7bf0de)
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Kyle Fortin <kyle.fortin@oracle.com>
drivers/net/ethernet/intel/i40e/i40e_common.c
drivers/net/ethernet/intel/i40evf/i40e_common.c