Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.10.0: build fails with -Werror=format-security #72

Open
kloczek opened this issue Jun 19, 2023 · 4 comments
Open

1.10.0: build fails with -Werror=format-security #72

kloczek opened this issue Jun 19, 2023 · 4 comments

Comments

@kloczek
Copy link

kloczek commented Jun 19, 2023

[tkloczko@pers-jacek liboping-1.10.0]$ make
Making all in src
make[1]: Entering directory '/home/tkloczko/rpmbuild/BUILD/liboping-1.10.0/src'
make  all-recursive
make[2]: Entering directory '/home/tkloczko/rpmbuild/BUILD/liboping-1.10.0/src'
Making all in mans
make[3]: Entering directory '/home/tkloczko/rpmbuild/BUILD/liboping-1.10.0/src/mans'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/liboping-1.10.0/src/mans'
make[3]: Entering directory '/home/tkloczko/rpmbuild/BUILD/liboping-1.10.0/src'
/bin/sh ../libtool  --tag=CC   --mode=link /usr/bin/gcc -Wall -O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none  -version-info 3:0:3 -Wl,--gc-sections -Wl,--as-needed -flto=auto -flto-partition=none -fuse-linker-plugin -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,--build-id=sha1 -o liboping.la -rpath /usr/lib64 liboping_la-liboping.lo
libtool: link: /usr/bin/gcc -shared  -fPIC -DPIC  .libs/liboping_la-liboping.o   -O2 -g -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -mno-omit-leaf-frame-pointer -m64 -mtune=generic -flto=auto -flto-partition=none -Wl,--gc-sections -Wl,--as-needed -flto=auto -flto-partition=none -fuse-linker-plugin -Wl,-z -Wl,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,--build-id=sha1   -Wl,-soname -Wl,liboping.so.0 -o .libs/liboping.so.0.3.0
libtool: link: (cd ".libs" && rm -f "liboping.so.0" && ln -s "liboping.so.0.3.0" "liboping.so.0")
libtool: link: (cd ".libs" && rm -f "liboping.so" && ln -s "liboping.so.0.3.0" "liboping.so")
libtool: link: ( cd ".libs" && rm -f "liboping.la" && ln -s "../liboping.la" "liboping.la" )
/bin/sh ../libtool  --tag=CC   --mode=link /usr/bin/gcc -Wall -O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none  -Wl,--gc-sections -Wl,--as-needed -flto=auto -flto-partition=none -fuse-linker-plugin -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,--build-id=sha1 -o oping oping.o liboping.la -lm
libtool: link: /usr/bin/gcc -Wall -O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -Wl,--gc-sections -Wl,--as-needed -flto=auto -flto-partition=none -fuse-linker-plugin -Wl,-z -Wl,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,--build-id=sha1 -o .libs/oping oping.o  ./.libs/liboping.so -lm
/usr/bin/gcc -DHAVE_CONFIG_H -I.   -DUSE_NCURSES=1 -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600  -Wall -O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -c -o noping-oping.o `test -f 'oping.c' || echo './'`oping.c
oping.c: In function ‘update_graph_prettyping’:
oping.c:1136:25: error: format not a string literal and no format arguments [-Werror=format-security]
 1136 |                         mvwprintw (ctx->window, /* y = */ y_max, /* x = */ x + 2, symbol);
      |                         ^~~~~~~~~
oping.c: In function ‘update_graph_histogram’:
oping.c:1239:41: error: format not a string literal and no format arguments [-Werror=format-security]
 1239 |                                         hist_symbols_utf8[index]);
      |                                         ^~~~~~~~~~~~~~~~~
oping.c: In function ‘update_host_hook’:
oping.c:1583:38: warning: too many arguments for format [-Wformat-extra-args]
 1583 |                         HOST_PRINTF ("%zu bytes from %s (%s): icmp_seq=%u ttl=%i ",
      |                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
oping.c:1560:45: note: in definition of macro ‘HOST_PRINTF’
 1560 | # define HOST_PRINTF(...) wprintw(main_win, __VA_ARGS__)
      |                                             ^~~~~~~~~~~
cc1: some warnings being treated as errors
@barak
Copy link

barak commented Jun 27, 2023

I think it's fixed in a Debian patch which basically uses "%s" foo instead of just foo as a format string.

@kloczek
Copy link
Author

kloczek commented Jun 27, 2023

Yep looks like below patch from Debian should fix the issue

Index: liboping/src/oping.c
===================================================================
--- liboping.orig/src/oping.c
+++ liboping/src/oping.c
@@ -1156,7 +1156,7 @@ static int update_graph_prettyping (ping
                        wattron (ctx->window, COLOR_PAIR(color));

                if (has_utf8())
-                       mvwprintw (ctx->window, /* y = */ y_max, /* x = */ x + 2, symbol);
+                       mvwprintw (ctx->window, /* y = */ y_max, /* x = */ x + 2, "%s", symbol);
                else
                        mvwaddch (ctx->window, /* y = */ y_max, /* x = */ x + 2, symbolc);

@@ -1262,7 +1262,7 @@ static int update_graph_histogram (ping_
                        mvwaddch (ctx->window, /* y = */ y_max, /* x = */ x + 2, ' ');
                else if (has_utf8 ())
                        mvwprintw (ctx->window, /* y = */ y_max, /* x = */ x + 2,
-                                       hist_symbols_utf8[index]);
+                                       "%s", hist_symbols_utf8[index]);
                else
                        mvwaddch (ctx->window, /* y = */ y_max, /* x = */ x + 2,
                                        hist_symbols_acs[index] | A_ALTCHARSET);
@@ -1639,8 +1639,7 @@ static void update_host_hook (pingobj_it

                        HOST_PRINTF ("%zu bytes from %s (%s): icmp_seq=%u ttl=%i ",
                                        data_len, context->host, context->addr,
-                                       sequence, recv_ttl,
-                                       format_qos (recv_qos, recv_qos_str, sizeof (recv_qos_str)));
+                                       sequence, recv_ttl);
                        if ((recv_qos != 0) || (opt_send_qos != 0))
                        {
                                HOST_PRINTF ("qos=%s ",

@barak
Copy link

barak commented Jun 28, 2023

:)

@barracuda156
Copy link

The patch fixes the build on macOS too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants