ofalk / libdnet

libdnet provides a simplified, portable interface to several low-level networking routines.
Other
153 stars 60 forks source link

Use of libbsds strlcpy #57

Closed ofalk closed 4 years ago

ofalk commented 4 years ago
fw.c: In function ‘arg_to_fr’:
fw.c:102:3: warning: implicit declaration of function ‘strlcpy’; did you mean ‘strncpy’? [-Wimplicit-function-declaration]
  102 |   strlcpy(fr->fw_device, argv[2], sizeof(fr->fw_device));
      |   ^~~~~~~
      |   strncpy

This is a non-standard glibc function and only available in libbsd.

ofalk commented 4 years ago

Fixing with simply replacing with strncpy leads to:

fw.c: In function ‘arg_to_fr’:
fw.c:103:3: warning: ‘strncpy’ specified bound 16 equals destination size [-Wstringop-truncation]
  103 |   strncpy(fr->fw_device, argv[2], sizeof(fr->fw_device));
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Yeah, null termination byte of course.