From 1098e733374f6a7c6c909f0a9c900156f01b68e2 Mon Sep 17 00:00:00 2001 From: d00f Date: Sat, 8 Aug 2026 17:38:10 +0200 Subject: [PATCH] cmd: stop "mtu" from acting on a value it failed to parse The handler threw away atoi_short()'s return and leant on the range test alone. The range test cannot tell a failed parse from a small number, so "mtu 1 99999" stopped at the partial 9999 and went through as a number nobody typed. With the parse result checked, a failure is rejected with the same message as an out-of-range value. --- cmd_parser.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd_parser.c b/cmd_parser.c index dbc7848..e10d8c7 100644 --- a/cmd_parser.c +++ b/cmd_parser.c @@ -736,8 +736,7 @@ void parse_mtu(void) print_string("mtu [port] [size]\n"); return; } - atoi_short(&mtu, cmd_words_b[2]); - if (mtu < 64 || mtu > 0x3fff) { + if (atoi_short(&mtu, cmd_words_b[2]) || mtu < 64 || mtu > 0x3fff) { print_string("MTU must be 64..16383\n"); return; }