From 4e84ee69e7af21fe4cf357677739a32744f07e49 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Tue, 11 Oct 2016 21:20:50 +0100 Subject: [PATCH] user interface: do not allow out of range --ipinfo arguments Likewise --displaymode and --port. --- mtr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mtr.c b/mtr.c index a68fe14..4ff0258 100644 --- 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; -- 2.47.2