From 22d00a28c9470bd7132860930a00e1d0ee7f9df0 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@hadrons.org>
Date: Sat, 13 Jul 2019 22:38:53 +0200
Subject: [PATCH 55/60] ping6: Fix --interval to be in seconds not milliseconds

This was allowing unprivileged users to use ping floods by setting very
low values.

Closes: #926750
---
 ping/ping6.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/ping/ping6.c b/ping/ping6.c
index 114b9c0c..299cd56c 100644
--- a/ping/ping6.c
+++ b/ping/ping6.c
@@ -75,6 +75,8 @@ int tclass = -1;	/* Kernel sets default: -1, RFC 3542.  */
 int flowinfo;
 #endif
 
+#define MIN_USER_INTERVAL (200000/PING_PRECISION)
+
 static int ping_echo (char *hostname);
 static void ping_reset (PING * p);
 static int send_echo (PING * ping);
@@ -159,7 +161,9 @@ parse_opt (int key, char *arg, struct argp_state *state)
 
     case 'i':
       options |= OPT_INTERVAL;
-      interval = ping_cvt_number (arg, 0, 0);
+      interval = ping_cvt_number (arg, 0, 0) * PING_PRECISION;
+      if (!is_root && interval < MIN_USER_INTERVAL)
+        error (EXIT_FAILURE, 0, "option value too small: %s", arg);
       break;
 
     case 'l':
-- 
2.26.0.292.g33ef6b2f38

