summaryrefslogtreecommitdiffstats
path: root/crypto/openssh/authfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/openssh/authfile.c')
-rw-r--r--crypto/openssh/authfile.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/crypto/openssh/authfile.c b/crypto/openssh/authfile.c
index 83ddd63..76a60d0 100644
--- a/crypto/openssh/authfile.c
+++ b/crypto/openssh/authfile.c
@@ -36,7 +36,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: authfile.c,v 1.55 2003/09/18 07:56:05 markus Exp $");
+RCSID("$OpenBSD: authfile.c,v 1.57 2004/06/21 17:36:31 avsm Exp $");
#include <openssl/err.h>
#include <openssl/evp.h>
@@ -72,7 +72,7 @@ key_save_private_rsa1(Key *key, const char *filename, const char *passphrase,
int fd, i, cipher_num;
CipherContext ciphercontext;
Cipher *cipher;
- u_int32_t rand;
+ u_int32_t rnd;
/*
* If the passphrase is empty, use SSH_CIPHER_NONE to ease converting
@@ -87,9 +87,9 @@ key_save_private_rsa1(Key *key, const char *filename, const char *passphrase,
buffer_init(&buffer);
/* Put checkbytes for checking passphrase validity. */
- rand = arc4random();
- buf[0] = rand & 0xff;
- buf[1] = (rand >> 8) & 0xff;
+ rnd = arc4random();
+ buf[0] = rnd & 0xff;
+ buf[1] = (rnd >> 8) & 0xff;
buf[2] = buf[0];
buf[3] = buf[1];
buffer_append(&buffer, buf, 4);
@@ -236,14 +236,16 @@ key_load_public_rsa1(int fd, const char *filename, char **commentp)
struct stat st;
char *cp;
int i;
- off_t len;
+ size_t len;
if (fstat(fd, &st) < 0) {
error("fstat for key file %.200s failed: %.100s",
filename, strerror(errno));
return NULL;
}
- len = st.st_size;
+ if (st.st_size > 1*1024*1024)
+ close(fd);
+ len = (size_t)st.st_size; /* truncated */
buffer_init(&buffer);
cp = buffer_append_space(&buffer, len);
@@ -318,7 +320,7 @@ key_load_private_rsa1(int fd, const char *filename, const char *passphrase,
char **commentp)
{
int i, check1, check2, cipher_type;
- off_t len;
+ size_t len;
Buffer buffer, decrypted;
u_char *cp;
CipherContext ciphercontext;
@@ -332,7 +334,11 @@ key_load_private_rsa1(int fd, const char *filename, const char *passphrase,
close(fd);
return NULL;
}
- len = st.st_size;
+ if (st.st_size > 1*1024*1024) {
+ close(fd);
+ return (NULL);
+ }
+ len = (size_t)st.st_size; /* truncated */
buffer_init(&buffer);
cp = buffer_append_space(&buffer, len);
OpenPOWER on IntegriCloud