Change magic port number for generic knownhost check.

libssh2_knownhost_checkp took 0 as a magic port number that indicated
a 'generic' check should be performed.  However, 0 is a valid port
number in its own right so this commit changes the magic value to any
negative int.
This commit is contained in:
Alexander Lamaison 2010-05-21 00:01:57 +01:00
parent c8df661129
commit 798a808a2b
2 changed files with 9 additions and 9 deletions

View File

@ -19,10 +19,10 @@ and returns info back about the (partially) matched entry.
\fIhost\fP is a pointer the host name in plain text. The host name can be the
IP numerical address of the host or the full name.
\fIport\fP is the port number used by the host (or 0 to check the generic
host). If the port number is given, libssh2 will check the key for the
specific host + port number combination in addition to the plain host name
only check.
\fIport\fP is the port number used by the host (or a negative number
to check the generic host). If the port number is given, libssh2 will
check the key for the specific host + port number combination in
addition to the plain host name only check.
\fIkey\fP is a pointer to the key for the given host.

View File

@ -366,7 +366,7 @@ knownhost_check(LIBSSH2_KNOWNHOSTS *hosts,
/* if a port number is given, check for a '[host]:port' first before the
plain 'host' */
if(port) {
if(port >= 0) {
snprintf(hostbuff, sizeof(hostbuff), "[%s]:%d", hostp, port);
host = hostbuff;
numcheck = 2; /* check both combos, start with this */
@ -475,7 +475,7 @@ libssh2_knownhost_check(LIBSSH2_KNOWNHOSTS *hosts,
int typemask,
struct libssh2_knownhost **ext)
{
return knownhost_check(hosts, hostp, 0, key, keylen,
return knownhost_check(hosts, hostp, -1, key, keylen,
typemask, ext);
}
@ -485,9 +485,9 @@ libssh2_knownhost_check(LIBSSH2_KNOWNHOSTS *hosts,
* Check a host+port and its associated key against the collection of known
* hosts.
*
* Note that if 'port' is specified as non-zero, the check function will be
* able to check for a dedicated key for this particular host+port combo, and
* if 'port' is set to zero it only checks for the generic host key.
* Note that if 'port' is specified as greater than zero, the check function
* will be able to check for a dedicated key for this particular host+port
* combo, and if 'port' is negative it only checks for the generic host key.
*
* The typemask is the type/format of the given host name and key
*