1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-29 01:03:57 +03:00

options: Check for null

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Jakub Jelen
2018-12-10 10:52:14 +01:00
committed by Andreas Schneider
parent fe309ba43f
commit 48aede2a31

View File

@@ -74,7 +74,7 @@ int ssh_options_copy(ssh_session src, ssh_session *dest) {
return -1; return -1;
} }
if (src->opts.username) { if (src->opts.username != NULL) {
new->opts.username = strdup(src->opts.username); new->opts.username = strdup(src->opts.username);
if (new->opts.username == NULL) { if (new->opts.username == NULL) {
ssh_free(new); ssh_free(new);
@@ -82,7 +82,7 @@ int ssh_options_copy(ssh_session src, ssh_session *dest) {
} }
} }
if (src->opts.host) { if (src->opts.host != NULL) {
new->opts.host = strdup(src->opts.host); new->opts.host = strdup(src->opts.host);
if (new->opts.host == NULL) { if (new->opts.host == NULL) {
ssh_free(new); ssh_free(new);
@@ -90,9 +90,7 @@ int ssh_options_copy(ssh_session src, ssh_session *dest) {
} }
} }
if (src->opts.identity) { if (src->opts.identity != NULL) {
struct ssh_iterator *it;
it = ssh_list_get_iterator(src->opts.identity); it = ssh_list_get_iterator(src->opts.identity);
while (it) { while (it) {
char *id; char *id;
@@ -114,7 +112,7 @@ int ssh_options_copy(ssh_session src, ssh_session *dest) {
} }
} }
if (src->opts.sshdir) { if (src->opts.sshdir != NULL) {
new->opts.sshdir = strdup(src->opts.sshdir); new->opts.sshdir = strdup(src->opts.sshdir);
if (new->opts.sshdir == NULL) { if (new->opts.sshdir == NULL) {
ssh_free(new); ssh_free(new);
@@ -122,7 +120,7 @@ int ssh_options_copy(ssh_session src, ssh_session *dest) {
} }
} }
if (src->opts.knownhosts) { if (src->opts.knownhosts != NULL) {
new->opts.knownhosts = strdup(src->opts.knownhosts); new->opts.knownhosts = strdup(src->opts.knownhosts);
if (new->opts.knownhosts == NULL) { if (new->opts.knownhosts == NULL) {
ssh_free(new); ssh_free(new);
@@ -131,7 +129,7 @@ int ssh_options_copy(ssh_session src, ssh_session *dest) {
} }
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
if (src->opts.wanted_methods[i]) { if (src->opts.wanted_methods[i] != NULL) {
new->opts.wanted_methods[i] = strdup(src->opts.wanted_methods[i]); new->opts.wanted_methods[i] = strdup(src->opts.wanted_methods[i]);
if (new->opts.wanted_methods[i] == NULL) { if (new->opts.wanted_methods[i] == NULL) {
ssh_free(new); ssh_free(new);
@@ -140,7 +138,7 @@ int ssh_options_copy(ssh_session src, ssh_session *dest) {
} }
} }
if (src->opts.ProxyCommand) { if (src->opts.ProxyCommand != NULL) {
new->opts.ProxyCommand = strdup(src->opts.ProxyCommand); new->opts.ProxyCommand = strdup(src->opts.ProxyCommand);
if (new->opts.ProxyCommand == NULL) { if (new->opts.ProxyCommand == NULL) {
ssh_free(new); ssh_free(new);