1From 670834fd8fbd2533ea25ca83065800e924116579 Mon Sep 17 00:00:00 2001 2From: Sergei Trofimovich <slyich@gmail.com> 3Date: Mon, 15 Nov 2021 08:05:43 +0000 4Subject: [PATCH] src/oping.c: always use "%s"-style format for 5 printf()-style functions 6 7`ncuses-6.3` added printf-style function attributes and now makes 8it easier to catch cases when user input is used in palce of format 9string when built with CFLAGS=-Werror=format-security: 10 11 oping.c:1265:41: error: format not a string literal and no format arguments [-Werror=format-security] 12 1265 | hist_symbols_utf8[index]); 13 | ^~~~~~~~~~~~~~~~~ 14 15Let's wrap all the missing places with "%s" format. 16 17Downloaded from upstream PR https://github.com/octo/liboping/pull/61 18 19Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de> 20[Bernd: rebased for liboping version 1.10.0] 21--- 22 src/oping.c | 7 +++---- 23 1 file changed, 3 insertions(+), 4 deletions(-) 24 25diff --git a/src/oping.c b/src/oping.c 26index c087c80..af4a0cb 100644 27--- a/src/oping.c 28+++ b/src/oping.c 29@@ -1156,7 +1156,7 @@ static int update_graph_prettyping (ping_context_t *ctx, /* {{{ */ 30 wattron (ctx->window, COLOR_PAIR(color)); 31 32 if (has_utf8()) 33- mvwprintw (ctx->window, /* y = */ 3, /* x = */ x + 2, symbol); 34+ mvwprintw (ctx->window, /* y = */ 3, /* x = */ x + 2, "%s", symbol); 35 else 36 mvwaddch (ctx->window, /* y = */ 3, /* x = */ x + 2, symbolc); 37 38@@ -1262,7 +1262,7 @@ static int update_graph_histogram (ping_context_t *ctx) /* {{{ */ 39 mvwaddch (ctx->window, /* y = */ 3, /* x = */ x + 2, ' '); 40 else if (has_utf8 ()) 41 mvwprintw (ctx->window, /* y = */ 3, /* x = */ x + 2, 42- hist_symbols_utf8[index]); 43+ "%s", hist_symbols_utf8[index]); 44 else 45 mvwaddch (ctx->window, /* y = */ 3, /* x = */ x + 2, 46 hist_symbols_acs[index] | A_ALTCHARSET); 47@@ -1639,8 +1639,7 @@ static void update_host_hook (pingobj_iter_t *iter, /* {{{ */ 48 49 HOST_PRINTF ("%zu bytes from %s (%s): icmp_seq=%u ttl=%i ", 50 data_len, context->host, context->addr, 51- sequence, recv_ttl, 52- format_qos (recv_qos, recv_qos_str, sizeof (recv_qos_str))); 53+ sequence, recv_ttl); 54 if ((recv_qos != 0) || (opt_send_qos != 0)) 55 { 56 HOST_PRINTF ("qos=%s ", 57-- 582.34.1 59 60