0055-ping6-Fix-interval-to-be-in-seconds-not-milliseconds.patch 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. From 22d00a28c9470bd7132860930a00e1d0ee7f9df0 Mon Sep 17 00:00:00 2001
  2. From: Guillem Jover <guillem@hadrons.org>
  3. Date: Sat, 13 Jul 2019 22:38:53 +0200
  4. Subject: [PATCH 55/60] ping6: Fix --interval to be in seconds not milliseconds
  5. This was allowing unprivileged users to use ping floods by setting very
  6. low values.
  7. Closes: #926750
  8. ---
  9. ping/ping6.c | 6 +++++-
  10. 1 file changed, 5 insertions(+), 1 deletion(-)
  11. diff --git a/ping/ping6.c b/ping/ping6.c
  12. index 114b9c0c..299cd56c 100644
  13. --- a/ping/ping6.c
  14. +++ b/ping/ping6.c
  15. @@ -75,6 +75,8 @@ int tclass = -1; /* Kernel sets default: -1, RFC 3542. */
  16. int flowinfo;
  17. #endif
  18. +#define MIN_USER_INTERVAL (200000/PING_PRECISION)
  19. +
  20. static int ping_echo (char *hostname);
  21. static void ping_reset (PING * p);
  22. static int send_echo (PING * ping);
  23. @@ -159,7 +161,9 @@ parse_opt (int key, char *arg, struct argp_state *state)
  24. case 'i':
  25. options |= OPT_INTERVAL;
  26. - interval = ping_cvt_number (arg, 0, 0);
  27. + interval = ping_cvt_number (arg, 0, 0) * PING_PRECISION;
  28. + if (!is_root && interval < MIN_USER_INTERVAL)
  29. + error (EXIT_FAILURE, 0, "option value too small: %s", arg);
  30. break;
  31. case 'l':
  32. --
  33. 2.26.0.292.g33ef6b2f38