userauth: Fix off by one error when reading public key file
After reading the public key from file the size was incorrectly decremented by one. This was usually a harmless error as the last character on the public key file is an unimportant EOL. But if due to some error the public key file is empty, the public key size becomes (uint)(0 - 1), resulting in an unrecoverable out of memory error later. Signed-off-by: Salvador Fandi??o <sfandino-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
This commit is contained in:
parent
fb432f3f78
commit
4d97ed92b2
@ -546,10 +546,6 @@ file_read_publickey(LIBSSH2_SESSION * session, unsigned char **method,
|
||||
while (!feof(fd) && 1 == fread(&c, 1, 1, fd) && c != '\r' && c != '\n') {
|
||||
pubkey_len++;
|
||||
}
|
||||
if (feof(fd)) {
|
||||
/* the last character was EOF */
|
||||
pubkey_len--;
|
||||
}
|
||||
rewind(fd);
|
||||
|
||||
if (pubkey_len <= 1) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user