From: Sami Kerola Date: Tue, 11 Oct 2016 20:20:50 +0000 (+0100) Subject: user interface: do not allow out of range --ipinfo arguments X-Git-Tag: v0.88~21^2^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F159%2Fhead;p=thirdparty%2Fmtr.git user interface: do not allow out of range --ipinfo arguments Likewise --displaymode and --port. --- 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;