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.
This commit is contained in:
d00f
2026-08-08 17:38:10 +02:00
parent 99b0fc4b32
commit 1098e73337
+1 -2
View File
@@ -736,8 +736,7 @@ void parse_mtu(void)
print_string("mtu [port] [size]\n"); print_string("mtu [port] [size]\n");
return; return;
} }
atoi_short(&mtu, cmd_words_b[2]); if (atoi_short(&mtu, cmd_words_b[2]) || mtu < 64 || mtu > 0x3fff) {
if (mtu < 64 || mtu > 0x3fff) {
print_string("MTU must be 64..16383\n"); print_string("MTU must be 64..16383\n");
return; return;
} }