• Jacob Keller's avatar
    i40e: prevent snprintf format specifier truncation · b5d5504a
    Jacob Keller authored
    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: default avatarJacob Keller <jacob.e.keller@intel.com>
    Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
    Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
    b5d5504a
i40e_common.c 42.3 KB