Skip to content

Commit e41ab00

Browse files
committed
parse_mtu: erase '!' before parse_number call
Do not pass number with trailing '!' to parse_number, which would refuse it. fixed GH-438
1 parent 90ee52d commit e41ab00

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,14 +488,19 @@ static void copy_sv_to_c_buf(char (&dest)[N], std::string_view sv){
488488
}
489489

490490
static int
491-
parse_mtu(const char *optarg)
491+
parse_mtu(char *optarg)
492492
{
493493
enum { IPV4_REQ_MIN_MTU = 576, };
494+
bool enforce = false;
495+
if (optarg[0] != '\0' && optarg[strlen(optarg) - 1] == '!') {
496+
enforce = true;
497+
optarg[strlen(optarg) - 1] = '\0';
498+
}
494499
const int ret = parse_number(optarg, 1, 10);
495500
if (ret == INT_MIN) {
496501
return -1;
497502
}
498-
if (ret < IPV4_REQ_MIN_MTU && optarg[strlen(optarg) - 1] != '!') {
503+
if (ret < IPV4_REQ_MIN_MTU && !enforce) {
499504
MSG(WARNING,
500505
"MTU %s seems to be too low, use \"%d!\" to force.\n",
501506
optarg, ret);

0 commit comments

Comments
 (0)