mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 18:50:28 +09:00
Check any input username for validity
Check possible inputs of username for malicious code. Signed-off-by: Norbert Pocs <norbertpocs0@gmail.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
committed by
Jakub Jelen
parent
ebcd6eee3c
commit
d97a5930c9
@@ -194,6 +194,10 @@ int ssh_config_parse_uri(const char *tok,
|
|||||||
if (*username == NULL) {
|
if (*username == NULL) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
rc = ssh_check_username_syntax(*username);
|
||||||
|
if (rc != SSH_OK) {
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
tok = endp + 1;
|
tok = endp + 1;
|
||||||
/* If there is second @ character, this does not look like our URI */
|
/* If there is second @ character, this does not look like our URI */
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ char *ssh_get_local_username(void)
|
|||||||
{
|
{
|
||||||
DWORD size = 0;
|
DWORD size = 0;
|
||||||
char *user;
|
char *user;
|
||||||
|
int rc;
|
||||||
|
|
||||||
/* get the size */
|
/* get the size */
|
||||||
GetUserName(NULL, &size);
|
GetUserName(NULL, &size);
|
||||||
@@ -192,8 +193,11 @@ char *ssh_get_local_username(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (GetUserName(user, &size)) {
|
if (GetUserName(user, &size)) {
|
||||||
|
rc = ssh_check_username_syntax(user);
|
||||||
|
if (rc == SSH_OK) {
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -336,8 +340,10 @@ char *ssh_get_local_username(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
name = strdup(pwd.pw_name);
|
name = strdup(pwd.pw_name);
|
||||||
|
rc = ssh_check_username_syntax(name);
|
||||||
|
|
||||||
if (name == NULL) {
|
if (rc != SSH_OK) {
|
||||||
|
free(name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -738,6 +738,11 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type,
|
|||||||
ssh_set_error_oom(session);
|
ssh_set_error_oom(session);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
rc = ssh_check_username_syntax(session->opts.username);
|
||||||
|
if (rc != SSH_OK) {
|
||||||
|
ssh_set_error_invalid(session);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SSH_OPTIONS_SSH_DIR:
|
case SSH_OPTIONS_SSH_DIR:
|
||||||
|
|||||||
Reference in New Issue
Block a user