platform: avoid wrong coverity warning in nmp_utils_sysctl_open_netdir()

The warning is wrong, because we already assert for the string length a few
lines earlier.

  Error: STRING_OVERFLOW (CWE-120): [#def595]
  NetworkManager-1.31.90/src/libnm-platform/nm-platform-utils.c:1896: fixed_size_dest: You might overrun the 16-character fixed-size string "ifname_buf_last_try" by copying "ifname" without checking the length.
  # 1894|           if (nm_streq(ifname, ifname_buf_last_try))
  # 1895|               return -1;
  # 1896|->         strcpy(ifname_buf_last_try, ifname);
  # 1897|
  # 1898|           fd_dir = open(sysdir, O_DIRECTORY | O_CLOEXEC);
This commit is contained in:
Thomas Haller 2021-06-08 13:26:19 +02:00
parent b57167fe74
commit c87433ebd2
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -1893,7 +1893,9 @@ nmp_utils_sysctl_open_netdir(int ifindex, const char *ifname_guess, char *out_if
* end of the @try_count. */
if (nm_streq(ifname, ifname_buf_last_try))
return -1;
strcpy(ifname_buf_last_try, ifname);
if (g_strlcpy(ifname_buf_last_try, ifname, IFNAMSIZ) >= IFNAMSIZ)
nm_assert_not_reached();
fd_dir = open(sysdir, O_DIRECTORY | O_CLOEXEC);
if (fd_dir < 0)