diff options
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | authfile.c | 21 |
2 files changed, 26 insertions, 6 deletions
@@ -1,3 +1,12 @@ | |||
1 | 20021222 | ||
2 | - (bal) OpenBSD CVS Sync | ||
3 | - fgsch@cvs.openbsd.org 2002/11/15 10:03:09 | ||
4 | [authfile.c] | ||
5 | lseek(2) may return -1 when getting the public/private key lenght. | ||
6 | Simplify the code and check for errors using fstat(2). | ||
7 | |||
8 | Problem reported by Mauricio Sanchez, markus@ ok. | ||
9 | |||
1 | 20021205 | 10 | 20021205 |
2 | - (djm) PERL-free fixpaths from stuge-openssh-unix-dev@cdy.org | 11 | - (djm) PERL-free fixpaths from stuge-openssh-unix-dev@cdy.org |
3 | 12 | ||
@@ -832,4 +841,4 @@ | |||
832 | save auth method before monitor_reset_key_state(); bugzilla bug #284; | 841 | save auth method before monitor_reset_key_state(); bugzilla bug #284; |
833 | ok provos@ | 842 | ok provos@ |
834 | 843 | ||
835 | $Id: ChangeLog,v 1.2515 2002/12/05 09:59:33 djm Exp $ | 844 | $Id: ChangeLog,v 1.2516 2002/12/23 02:00:23 mouring Exp $ |
diff --git a/authfile.c b/authfile.c index 1fa5d811a..24ae6abd3 100644 --- a/authfile.c +++ b/authfile.c | |||
@@ -36,7 +36,7 @@ | |||
36 | */ | 36 | */ |
37 | 37 | ||
38 | #include "includes.h" | 38 | #include "includes.h" |
39 | RCSID("$OpenBSD: authfile.c,v 1.50 2002/06/24 14:55:38 markus Exp $"); | 39 | RCSID("$OpenBSD: authfile.c,v 1.51 2002/11/15 10:03:09 fgsch Exp $"); |
40 | 40 | ||
41 | #include <openssl/err.h> | 41 | #include <openssl/err.h> |
42 | #include <openssl/evp.h> | 42 | #include <openssl/evp.h> |
@@ -232,12 +232,17 @@ key_load_public_rsa1(int fd, const char *filename, char **commentp) | |||
232 | { | 232 | { |
233 | Buffer buffer; | 233 | Buffer buffer; |
234 | Key *pub; | 234 | Key *pub; |
235 | struct stat st; | ||
235 | char *cp; | 236 | char *cp; |
236 | int i; | 237 | int i; |
237 | off_t len; | 238 | off_t len; |
238 | 239 | ||
239 | len = lseek(fd, (off_t) 0, SEEK_END); | 240 | if (fstat(fd, &st) < 0) { |
240 | lseek(fd, (off_t) 0, SEEK_SET); | 241 | error("fstat for key file %.200s failed: %.100s", |
242 | filename, strerror(errno)); | ||
243 | return NULL; | ||
244 | } | ||
245 | len = st.st_size; | ||
241 | 246 | ||
242 | buffer_init(&buffer); | 247 | buffer_init(&buffer); |
243 | cp = buffer_append_space(&buffer, len); | 248 | cp = buffer_append_space(&buffer, len); |
@@ -318,9 +323,15 @@ key_load_private_rsa1(int fd, const char *filename, const char *passphrase, | |||
318 | CipherContext ciphercontext; | 323 | CipherContext ciphercontext; |
319 | Cipher *cipher; | 324 | Cipher *cipher; |
320 | Key *prv = NULL; | 325 | Key *prv = NULL; |
326 | struct stat st; | ||
321 | 327 | ||
322 | len = lseek(fd, (off_t) 0, SEEK_END); | 328 | if (fstat(fd, &st) < 0) { |
323 | lseek(fd, (off_t) 0, SEEK_SET); | 329 | error("fstat for key file %.200s failed: %.100s", |
330 | filename, strerror(errno)); | ||
331 | close(fd); | ||
332 | return NULL; | ||
333 | } | ||
334 | len = st.st_size; | ||
324 | 335 | ||
325 | buffer_init(&buffer); | 336 | buffer_init(&buffer); |
326 | cp = buffer_append_space(&buffer, len); | 337 | cp = buffer_append_space(&buffer, len); |