mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
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:
+1
-2
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user