From: yvs Date: Fri, 8 May 2026 13:28:05 +0000 (+0400) Subject: curses: validate packet size input X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F628%2Fhead;p=thirdparty%2Fmtr.git curses: validate packet size input Port the interactive packet-size validation from yvs2014/mtr085. The curses s command now validates the newly entered value before assigning it, matching the command-line packet-size range. Ported-from: yvs2014/mtr085@e100fd72be37f0a98d6893db7e0baa8a5b81b72a Original-author: yvs --- diff --git a/ui/curses.c b/ui/curses.c index 5c776e9..aa9a57c 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -217,8 +217,11 @@ int mtr_curses_keyaction( } buf[i] = '\0'; int new_packetsize = atoi(buf); - if (abs(ctl->cpacketsize) >= MINPACKET && abs(ctl->cpacketsize) < MAXPACKET) { + if (abs(new_packetsize) >= MINPACKET + && abs(new_packetsize) <= MAXPACKET) { ctl->cpacketsize = new_packetsize; + } else { + printf("\a"); } return ActionNone; case 'b':