knownhost_check(): Don't dereference ext if NULL is passed
Documentation for libssh2_knownhost_checkp() and related functions states that the last argument is filled with data if non-NULL. "knownhost if set to non-NULL, it must be a pointer to a 'struct libssh2_knownhost' pointer that gets filled in to point to info about a known host that matches or partially matches." In this function ext is dereferenced even if set to NULL, causing segfault in applications not needing the extra data.
This commit is contained in:
parent
378311fe5b
commit
fed94fa85d
@ -417,6 +417,7 @@ knownhost_check(LIBSSH2_KNOWNHOSTS *hosts,
|
||||
/* host name match, now compare the keys */
|
||||
if(!strcmp(key, node->key)) {
|
||||
/* they match! */
|
||||
if (ext)
|
||||
*ext = knownhost_to_external(node);
|
||||
badkey = NULL;
|
||||
rc = LIBSSH2_KNOWNHOST_CHECK_MATCH;
|
||||
@ -438,6 +439,7 @@ knownhost_check(LIBSSH2_KNOWNHOSTS *hosts,
|
||||
|
||||
if(badkey) {
|
||||
/* key mismatch */
|
||||
if (ext)
|
||||
*ext = knownhost_to_external(badkey);
|
||||
rc = LIBSSH2_KNOWNHOST_CHECK_MISMATCH;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user