As pointed out, feof() will always fail after a rewind

This commit is contained in:
James Housley 2006-11-13 15:10:38 +00:00
parent bebd14a011
commit 1e889ca947

View File

@ -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);