mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-06 10:27:22 +09:00
Added an option to set the port as string.
This commit is contained in:
@@ -621,10 +621,8 @@ static int ssh_bind_options_set_algo(ssh_bind sshbind, int algo,
|
||||
|
||||
int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type,
|
||||
const void *value) {
|
||||
#if 0
|
||||
char *p, *q;
|
||||
int i;
|
||||
#endif
|
||||
|
||||
if (sshbind == NULL) {
|
||||
return -1;
|
||||
@@ -661,6 +659,24 @@ int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type,
|
||||
sshbind->bindport = *x & 0xffff;
|
||||
}
|
||||
break;
|
||||
case SSH_BIND_OPTIONS_BINDPORT_STR:
|
||||
if (value == NULL) {
|
||||
sshbind->bindport = 22 & 0xffff;
|
||||
} else {
|
||||
q = strdup(value);
|
||||
if (q == NULL) {
|
||||
ssh_set_error_oom(sshbind);
|
||||
return -1;
|
||||
}
|
||||
i = strtol(q, &p, 10);
|
||||
if (q == p) {
|
||||
SAFE_FREE(q);
|
||||
}
|
||||
SAFE_FREE(q);
|
||||
|
||||
sshbind->bindport = i & 0xffff;
|
||||
}
|
||||
break;
|
||||
case SSH_BIND_OPTIONS_DSAKEY:
|
||||
if (value == NULL) {
|
||||
ssh_set_error_invalid(sshbind, __FUNCTION__);
|
||||
|
||||
Reference in New Issue
Block a user