summaryrefslogtreecommitdiff
path: root/authfile.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2004-05-13 16:39:33 +1000
committerDarren Tucker <dtucker@zip.com.au>2004-05-13 16:39:33 +1000
commit1f8311c836a20ce4923e2142d206f8d8073d0ca4 (patch)
tree93c92ccf9709d18faa075fb2b3c5fda4d969b28a /authfile.c
parentb42714e28bcb22c5b52b0266813165cf5e7e9ccb (diff)
- deraadt@cvs.openbsd.org 2004/05/11 19:01:43
[auth.c auth2-none.c authfile.c channels.c monitor.c monitor_mm.c packet.c packet.h progressmeter.c session.c openbsd-compat/xmmap.c] improve some code lint did not like; djm millert ok
Diffstat (limited to 'authfile.c')
-rw-r--r--authfile.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/authfile.c b/authfile.c
index 83ddd635f..305e9473b 100644
--- a/authfile.c
+++ b/authfile.c
@@ -36,7 +36,7 @@
36 */ 36 */
37 37
38#include "includes.h" 38#include "includes.h"
39RCSID("$OpenBSD: authfile.c,v 1.55 2003/09/18 07:56:05 markus Exp $"); 39RCSID("$OpenBSD: authfile.c,v 1.56 2004/05/11 19:01:43 deraadt Exp $");
40 40
41#include <openssl/err.h> 41#include <openssl/err.h>
42#include <openssl/evp.h> 42#include <openssl/evp.h>
@@ -236,14 +236,16 @@ key_load_public_rsa1(int fd, const char *filename, char **commentp)
236 struct stat st; 236 struct stat st;
237 char *cp; 237 char *cp;
238 int i; 238 int i;
239 off_t len; 239 size_t len;
240 240
241 if (fstat(fd, &st) < 0) { 241 if (fstat(fd, &st) < 0) {
242 error("fstat for key file %.200s failed: %.100s", 242 error("fstat for key file %.200s failed: %.100s",
243 filename, strerror(errno)); 243 filename, strerror(errno));
244 return NULL; 244 return NULL;
245 } 245 }
246 len = st.st_size; 246 if (st.st_size > 1*1024*1024)
247 close(fd);
248 len = (size_t)st.st_size; /* truncated */
247 249
248 buffer_init(&buffer); 250 buffer_init(&buffer);
249 cp = buffer_append_space(&buffer, len); 251 cp = buffer_append_space(&buffer, len);
@@ -318,7 +320,7 @@ key_load_private_rsa1(int fd, const char *filename, const char *passphrase,
318 char **commentp) 320 char **commentp)
319{ 321{
320 int i, check1, check2, cipher_type; 322 int i, check1, check2, cipher_type;
321 off_t len; 323 size_t len;
322 Buffer buffer, decrypted; 324 Buffer buffer, decrypted;
323 u_char *cp; 325 u_char *cp;
324 CipherContext ciphercontext; 326 CipherContext ciphercontext;
@@ -332,7 +334,11 @@ key_load_private_rsa1(int fd, const char *filename, const char *passphrase,
332 close(fd); 334 close(fd);
333 return NULL; 335 return NULL;
334 } 336 }
335 len = st.st_size; 337 if (st.st_size > 1*1024*1024) {
338 close(fd);
339 return (NULL);
340 }
341 len = (size_t)st.st_size; /* truncated */
336 342
337 buffer_init(&buffer); 343 buffer_init(&buffer);
338 cp = buffer_append_space(&buffer, len); 344 cp = buffer_append_space(&buffer, len);