mirror of https://github.com/wolfSSL/wolfssh.git
Make HandlePort use GetConfigInt and add 0 port test.
parent
90769af1f8
commit
f0caefcc33
|
@ -329,16 +329,16 @@ static int HandlePwAuth(WOLFSSHD_CONFIG* conf, const char* value)
|
||||||
static int HandlePort(WOLFSSHD_CONFIG* conf, const char* value)
|
static int HandlePort(WOLFSSHD_CONFIG* conf, const char* value)
|
||||||
{
|
{
|
||||||
int ret = WS_SUCCESS;
|
int ret = WS_SUCCESS;
|
||||||
int portInt;
|
long portInt;
|
||||||
|
|
||||||
if (conf == NULL || value == NULL) {
|
if (conf == NULL || value == NULL) {
|
||||||
ret = WS_BAD_ARGUMENT;
|
ret = WS_BAD_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == WS_SUCCESS) {
|
if (ret == WS_SUCCESS) {
|
||||||
portInt = XATOI(value);
|
portInt = GetConfigInt(value, WSTRLEN(value), 0, conf->heap);
|
||||||
if (portInt <= 0) {
|
if (portInt <= 0) {
|
||||||
wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Unable to parse port number: %s.",
|
wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Invalid port number: %s.",
|
||||||
value);
|
value);
|
||||||
ret = WS_BAD_ARGUMENT;
|
ret = WS_BAD_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
@ -347,7 +347,7 @@ static int HandlePort(WOLFSSHD_CONFIG* conf, const char* value)
|
||||||
conf->port = (word16)portInt;
|
conf->port = (word16)portInt;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Port number %d too big.",
|
wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Port number %ld too big.",
|
||||||
portInt);
|
portInt);
|
||||||
ret = WS_BAD_ARGUMENT;
|
ret = WS_BAD_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,7 @@ static int test_ParseConfigLine(void)
|
||||||
{"Valid port", "Port 22", 0},
|
{"Valid port", "Port 22", 0},
|
||||||
{"Port too big", "Port 65536", 1},
|
{"Port too big", "Port 65536", 1},
|
||||||
{"Negative port", "Port -99", 1},
|
{"Negative port", "Port -99", 1},
|
||||||
|
{"Port 0", "Port 0", 1},
|
||||||
{"Port NaN", "Port wolfsshd", 1},
|
{"Port NaN", "Port wolfsshd", 1},
|
||||||
{"Port no value", "Port \n", 1},
|
{"Port no value", "Port \n", 1},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue