0005-src-oping.c-always-use-s-style-format-for-printf-sty.patch 2.2 KB

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