提交 8253e019 编写于 作者: S Shengliang Guan

fix: invalid port described in TD-15165

上级 91780376
......@@ -62,7 +62,7 @@ typedef struct {
bool is_check;
bool is_startup;
bool is_help;
uint16_t port;
int32_t port;
int32_t pktLen;
int32_t pktNum;
int32_t displayWidth;
......
......@@ -99,6 +99,7 @@ static int32_t shellParseSingleOpt(int32_t key, char *arg) {
break;
case 'P':
pArgs->port = atoi(arg);
if (pArgs->port == 0) pArgs->port = -1;
break;
case 'u':
pArgs->user = arg;
......@@ -304,6 +305,11 @@ static int32_t shellCheckArgs() {
return -1;
}
if (pArgs->port < 0 || pArgs->port > 65535) {
printf("Invalid port\n");
return -1;
}
if (pArgs->pktLen < SHELL_MIN_PKG_LEN || pArgs->pktLen > SHELL_MAX_PKG_LEN) {
printf("Invalid pktLen:%d, range:[%d, %d]\n", pArgs->pktLen, SHELL_MIN_PKG_LEN, SHELL_MAX_PKG_LEN);
return -1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册