Fix publickey authentication regression

Commit 70b199f47659a74b8778c528beccf893843e5ecb introduced a parsing
bug in file_read_publickey() which made the algorithm name contain an
extra trailing space character, breaking all publickey authentication.
This commit is contained in:
Peter Stuge 2009-12-24 01:24:57 +01:00
parent bd0505d6b9
commit 87e32272f9

View File

@ -545,7 +545,7 @@ file_read_publickey(LIBSSH2_SESSION * session, unsigned char **method,
sp1++;
if ((sp2 = memchr(sp1, ' ', pubkey_len - *method_len)) == NULL) {
if ((sp2 = memchr(sp1, ' ', pubkey_len - (sp1 - pubkey - 1))) == NULL) {
/* Assume that the id string is missing, but that it's okay */
sp2 = pubkey + pubkey_len;
}
@ -562,7 +562,7 @@ file_read_publickey(LIBSSH2_SESSION * session, unsigned char **method,
* to be freed soon anyway, we'll just avoid the extra free/alloc and call
* it a wash */
*method = pubkey;
*method_len = sp1 - pubkey;
*method_len = sp1 - pubkey - 1;
*pubkeydata = tmp;
*pubkeydata_len = tmp_len;