Skip to content

Commit

Permalink
- [email protected] 2002/11/15 10:03:09
Browse files Browse the repository at this point in the history
     [authfile.c]
     lseek(2) may return -1 when getting the public/private key lenght.
     Simplify the code and check for errors using fstat(2).

     Problem reported by Mauricio Sanchez, markus@ ok.
  • Loading branch information
mouring committed Dec 23, 2002
1 parent ab1c12a commit 44adb8f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
11 changes: 10 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
20021222
- (bal) OpenBSD CVS Sync
- [email protected] 2002/11/15 10:03:09
[authfile.c]
lseek(2) may return -1 when getting the public/private key lenght.
Simplify the code and check for errors using fstat(2).

Problem reported by Mauricio Sanchez, markus@ ok.

20021205
- (djm) PERL-free fixpaths from [email protected]

Expand Down Expand Up @@ -832,4 +841,4 @@
save auth method before monitor_reset_key_state(); bugzilla bug #284;
ok provos@

$Id: ChangeLog,v 1.2515 2002/12/05 09:59:33 djm Exp $
$Id: ChangeLog,v 1.2516 2002/12/23 02:00:23 mouring Exp $
21 changes: 16 additions & 5 deletions authfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*/

#include "includes.h"
RCSID("$OpenBSD: authfile.c,v 1.50 2002/06/24 14:55:38 markus Exp $");
RCSID("$OpenBSD: authfile.c,v 1.51 2002/11/15 10:03:09 fgsch Exp $");

#include <openssl/err.h>
#include <openssl/evp.h>
Expand Down Expand Up @@ -232,12 +232,17 @@ key_load_public_rsa1(int fd, const char *filename, char **commentp)
{
Buffer buffer;
Key *pub;
struct stat st;
char *cp;
int i;
off_t len;

len = lseek(fd, (off_t) 0, SEEK_END);
lseek(fd, (off_t) 0, SEEK_SET);
if (fstat(fd, &st) < 0) {
error("fstat for key file %.200s failed: %.100s",
filename, strerror(errno));
return NULL;
}
len = st.st_size;

buffer_init(&buffer);
cp = buffer_append_space(&buffer, len);
Expand Down Expand Up @@ -318,9 +323,15 @@ key_load_private_rsa1(int fd, const char *filename, const char *passphrase,
CipherContext ciphercontext;
Cipher *cipher;
Key *prv = NULL;
struct stat st;

len = lseek(fd, (off_t) 0, SEEK_END);
lseek(fd, (off_t) 0, SEEK_SET);
if (fstat(fd, &st) < 0) {
error("fstat for key file %.200s failed: %.100s",
filename, strerror(errno));
close(fd);
return NULL;
}
len = st.st_size;

buffer_init(&buffer);
cp = buffer_append_space(&buffer, len);
Expand Down

0 comments on commit 44adb8f

Please sign in to comment.