config: Avoid NULL dereference if no ssh dir is set

This should never happen while parsing configuration files, but the
configuration strings do not have this safeguard.

Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44619

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
This commit is contained in:
Jakub Jelen
2022-02-15 11:34:55 +01:00
parent f97ff7c2e8
commit 2edb4b50ac

View File

@@ -553,6 +553,10 @@ ssh_config_make_absolute(ssh_session session,
}
/* Parsing user config relative to home directory (generally ~/.ssh) */
if (session->opts.sshdir == NULL) {
ssh_set_error_invalid(session);
return NULL;
}
outlen = strlen(path) + strlen(session->opts.sshdir) + 1 + 1;
out = malloc(outlen);
if (out == NULL) {