liboping icon indicating copy to clipboard operation
liboping copied to clipboard

Failed to build liboping

Open cc-michaelu opened this issue 1 year ago • 3 comments

I've been searching for a ping library solution and came across this project. We are trying to cross-compile for our target device and encounter a build failure, the output is included below.

michael_uman@cana-thinkpad ~/gitroot/liboping/build (master)$ make -j 4 
Making all in src
make[1]: Entering directory '/home/michael_uman/gitroot/liboping/build/src'
make  all-recursive
make[2]: Entering directory '/home/michael_uman/gitroot/liboping/build/src'
Making all in mans
make[3]: Entering directory '/home/michael_uman/gitroot/liboping/build/src/mans'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/michael_uman/gitroot/liboping/build/src/mans'
make[3]: Entering directory '/home/michael_uman/gitroot/liboping/build/src'
../aarch64-fslc-linux-gcc-libtool  --tag=CC   --mode=compile aarch64-fslc-linux-gcc  -mcpu=cortex-a53+crc+crypto -fstack-protector-strong  -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/fslc-xwayland/3.1/sysroots/aarch64-fslc-linux -DHAVE_CONFIG_H -I. -I../../src    -Wall -Werror -O2 -pipe -g -feliminate-unused-debug-types  -c -o liboping_la-liboping.lo `test -f 'liboping.c' || echo '../../src/'`liboping.c
aarch64-fslc-linux-gcc-libtool: compile:  aarch64-fslc-linux-gcc -mcpu=cortex-a53+crc+crypto -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/fslc-xwayland/3.1/sysroots/aarch64-fslc-linux -DHAVE_CONFIG_H -I. -I../../src -Wall -Werror -O2 -pipe -g -feliminate-unused-debug-types -c ../../src/liboping.c  -fPIC -DPIC -o .libs/liboping_la-liboping.o
../../src/liboping.c: In function ‘ping_host_add’:
../../src/liboping.c:207:9: error: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 243 [-Werror=format-truncation=]
  207 |    "%s: %s", function, message);
      |         ^~
......
 1650 |    ping_set_error (obj, "getaddrinfo", errmsg);
      |                                        ~~~~~~
In file included from /opt/fslc-xwayland/3.1/sysroots/aarch64-fslc-linux/usr/include/stdio.h:867,
                 from ../../src/liboping.c:30:
/opt/fslc-xwayland/3.1/sysroots/aarch64-fslc-linux/usr/include/bits/stdio2.h:67:10: note: ‘__builtin___snprintf_chk’ output between 14 and 269 bytes into a destination of size 256
   67 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   68 |        __bos (__s), __fmt, __va_arg_pack ());
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[3]: *** [Makefile:593: liboping_la-liboping.lo] Error 1
make[3]: Leaving directory '/home/michael_uman/gitroot/liboping/build/src'
make[2]: *** [Makefile:656: all-recursive] Error 1
make[2]: Leaving directory '/home/michael_uman/gitroot/liboping/build/src'
make[1]: *** [Makefile:431: all] Error 2
make[1]: Leaving directory '/home/michael_uman/gitroot/liboping/build/src'
make: *** [Makefile:393: all-recursive] Error 1

Our device uses a Yocto build SDK. I sourced the SDK environment and configured the project with the autoupdate and ./autogen.sh steps... When I tried to make the resulting project I got the error. I am using the following version of GCC:

michael_uman@cana-thinkpad ~/gitroot/liboping/build (master)$ aarch64-fslc-linux-gcc --version
aarch64-fslc-linux-gcc (GCC) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

It seems I may try turning off the -Werror=format-security flag in the $CXX environment which is used in the compile stage.

michael_uman@cana-thinkpad ~/gitroot/liboping/build (master)$ echo $CXX
aarch64-fslc-linux-g++ -mcpu=cortex-a53+crc+crypto -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/fslc-xwayland/3.1/sysroots/aarch64-fslc-linux

Please advise me if there is an active maintainer of this project. And if I can provide a patch which fixes this I will push a PR.

cc-michaelu avatar Apr 27 '23 21:04 cc-michaelu

I'm the Debian maintainer. Upstream isn't too active, but there are some Debian patches which might help with your problem. It is certainly my intent to keep this compiling correctly, even if upstream isn't reliably responding to pings...

barak avatar Apr 28 '23 15:04 barak

Upstream has not been very responsive in the last few years, alas. Great tool, but needs a bit of love and tending.

If someone wants to fork and take over maintenance, I'd be willing to help with FreeBSD porting.

cron2 avatar May 02 '23 14:05 cron2

I managed to build it on arch linux by replacing snprintf with snprintf_nowarn macro from https://stackoverflow.com/questions/51534284/how-to-circumvent-format-truncation-warning-in-gcc and replacing line at 1601 in oping.c with the following line.

HOST_PRINTF ("%zu bytes from %s (%s): icmp_seq=%u ttl=%i ", data_len, context->host, context->addr, sequence, recv_ttl);

It works. but I have to run it with root privilege, otherwise "operation not permitted" error issued. have no idea why.

image

bach001 avatar Oct 26 '23 04:10 bach001