As pointed out, feof() will always fail after a rewind
This commit is contained in:
parent
bebd14a011
commit
1e889ca947
@ -254,11 +254,11 @@ static int libssh2_file_read_publickey(LIBSSH2_SESSION *session, unsigned char *
|
||||
return -1;
|
||||
}
|
||||
while (!feof(fd) && (c = fgetc(fd)) != '\r' && c != '\n') pubkey_len++;
|
||||
rewind(fd);
|
||||
if (feof(fd)) {
|
||||
/* the last character was EOF */
|
||||
pubkey_len--;
|
||||
}
|
||||
rewind(fd);
|
||||
|
||||
if (pubkey_len <= 1) {
|
||||
libssh2_error(session, LIBSSH2_ERROR_FILE, "Invalid data in public key file", 0);
|
||||
|
Loading…
Reference in New Issue
Block a user