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.
---
src/knownhost.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/knownhost.c b/src/knownhost.c
index d90f1d4..193bda3 100644
--- a/src/knownhost.c
+++ b/src/knownhost.c
@@ -417,7 +417,8 @@ knownhost_check(LIBSSH2_KNOWNHOSTS *hosts,
/* host name match, now compare the keys */
if(!strcmp(key, node->key)) {
/* they match! */
- *ext = knownhost_to_external(node);
+ if (ext)
+ *ext = knownhost_to_external(node);
badkey = NULL;
rc = LIBSSH2_KNOWNHOST_CHECK_MATCH;
break;
@@ -438,7 +439,8 @@ knownhost_check(LIBSSH2_KNOWNHOSTS *hosts,
if(badkey) {
/* key mismatch */
- *ext = knownhost_to_external(badkey);
+ if (ext)
+ *ext = knownhost_to_external(badkey);
rc = LIBSSH2_KNOWNHOST_CHECK_MISMATCH;
}
--
1.7.3.4
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2011-11-15