]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
curses: validate packet size input 628/head
authoryvs <VSYakovetsky@gmail.com>
Fri, 8 May 2026 13:28:05 +0000 (17:28 +0400)
committerDarafei Praliaskouski <me@komzpa.net>
Fri, 8 May 2026 13:28:05 +0000 (17:28 +0400)
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 <VSYakovetsky@gmail.com>

ui/curses.c

index 5c776e9770781312531d66ff1b641a874ede29c1..aa9a57c4cb8cbb673dc83bdf52deac9c569bbd19 100644 (file)
@@ -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':