]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
user interface: do not allow out of range --ipinfo arguments 159/head
authorSami Kerola <kerolasa@iki.fi>
Tue, 11 Oct 2016 20:20:50 +0000 (21:20 +0100)
committerSami Kerola <kerolasa@iki.fi>
Tue, 11 Oct 2016 20:25:17 +0000 (21:25 +0100)
Likewise --displaymode and --port.

mtr.c

diff --git a/mtr.c b/mtr.c
index a68fe14c558a328a4be122c7116a6416c4156a43..4ff0258dba0e6a64338c7b1c6a7e99936e7a1dc2 100644 (file)
--- a/mtr.c
+++ b/mtr.c
@@ -549,8 +549,9 @@ static void parse_arg (struct mtr_ctl *ctl, names_t **names, int argc, char **ar
 #ifdef HAVE_IPINFO
     case 'y':
       ctl->ipinfo_no = strtonum_or_err(optarg, "invalid argument", STRTO_INT);
-      if (ctl->ipinfo_no < 0)
-        ctl->ipinfo_no = 0;
+      if (ctl->ipinfo_no < 0 || 4 < ctl->ipinfo_no) {
+        error(EXIT_FAILURE, 0, "value %d out of range (0 - 4)", ctl->ipinfo_no);
+      }
       break;
     case 'z':
       ctl->ipinfo_no = 0;