libifupdown/interface.c failed to compile becuase of strlcpy
EasyNetDev opened this issue · comments
EasyNet commented
Hi,
I've notice that ifupdown-ng is failing to compile under Debian Trixie:
cc -ggdb3 -Os -Wall -Wextra -Werror -Wmissing-declarations -Wmissing-prototypes -Wcast-align -Wpointer-arith -Wreturn-type -I. -DINTERFACES_FILE=\"/etc/network/interfaces\" -DSTATE_FILE=\"/run/ifstate\" -DCONFIG_FILE=\"/etc/network/ifupdown-ng.conf\" -DPACKAGE_NAME=\"ifupdown-ng\" -DPACKAGE_VERSION=\"0.12.1\" -DPACKAGE_BUGREPORT=\"https://github.com/ifupdown-ng/ifupdown-ng/issues/new\" -DEXECUTOR_PATH=\"/usr/libexec/ifupdown-ng\" -DCONFIG_YAML -c -o libifupdown/interface.o libifupdown/interface.c
libifupdown/interface.c: In function ‘lif_address_parse’:
libifupdown/interface.c:28:9: error: implicit declaration of function ‘strlcpy’; did you mean ‘strncpy’? [-Werror=implicit-function-declaration]
28 | strlcpy(buf, presentation, sizeof buf);
| ^~~~~~~
| strncpy
cc1: all warnings being treated as errors
make: *** [<builtin>: libifupdown/interface.o] Error 1
I found this function under <bsd/string.h>
All files that are using strlcpy are using <string.h> headers. But looks like the automatic compilation on github fails to use the new headers.
There is any particularly reason to use strlcpy instead strncpy?
Should I change the code to strncpy?
EasyNet commented
Notice that I had to use some additional options in my build.
polski-g commented
What options did you use? I ended up having to include the function itself because RHEL9 uses glibc 2.34 and strlcpy was not added until 2.38