mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 18:04:25 +09:00
knownhosts: resolve leaks found by coverity
This commit is contained in:
@@ -390,8 +390,10 @@ static char *ssh_client_select_hostkeys(ssh_session session){
|
|||||||
int needcoma=0;
|
int needcoma=0;
|
||||||
|
|
||||||
methods = ssh_knownhosts_algorithms(session);
|
methods = ssh_knownhosts_algorithms(session);
|
||||||
if (methods == NULL || methods[0] == NULL)
|
if (methods == NULL || methods[0] == NULL){
|
||||||
|
SAFE_FREE(methods);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
for (i=0;preferred_hostkeys[i] != NULL; ++i){
|
for (i=0;preferred_hostkeys[i] != NULL; ++i){
|
||||||
for (j=0; methods[j] != NULL; ++j){
|
for (j=0; methods[j] != NULL; ++j){
|
||||||
|
|||||||
@@ -678,24 +678,21 @@ char **ssh_knownhosts_algorithms(ssh_session session) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (session->opts.host == NULL) {
|
if (session->opts.host == NULL) {
|
||||||
return 0;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
host = ssh_lowercase(session->opts.host);
|
host = ssh_lowercase(session->opts.host);
|
||||||
hostport = ssh_hostport(host, session->opts.port);
|
hostport = ssh_hostport(host, session->opts.port);
|
||||||
if (host == NULL || hostport == NULL) {
|
array = malloc(sizeof(char *) * KNOWNHOSTS_MAXTYPES);
|
||||||
|
|
||||||
|
if (host == NULL || hostport == NULL || array == NULL) {
|
||||||
ssh_set_error_oom(session);
|
ssh_set_error_oom(session);
|
||||||
SAFE_FREE(host);
|
SAFE_FREE(host);
|
||||||
SAFE_FREE(hostport);
|
SAFE_FREE(hostport);
|
||||||
|
SAFE_FREE(array);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
array = malloc(sizeof(char *) * KNOWNHOSTS_MAXTYPES);
|
|
||||||
if (array==NULL){
|
|
||||||
ssh_set_error_oom(session);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
tokens = ssh_get_knownhost_line(&file,
|
tokens = ssh_get_knownhost_line(&file,
|
||||||
session->opts.knownhosts, &type);
|
session->opts.knownhosts, &type);
|
||||||
|
|||||||
Reference in New Issue
Block a user