aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/openssl/ssl/s2_lib.c
diff options
context:
space:
mode:
authorJacques Vidrine <nectar@FreeBSD.org>2002-08-10 01:46:10 +0000
committerJacques Vidrine <nectar@FreeBSD.org>2002-08-10 01:46:10 +0000
commit484549566e495cb042684cec327d66f24e6fec1d (patch)
tree3c9559c80a7fe01c85e2dfbadcb9f84770a7e8e6 /crypto/openssl/ssl/s2_lib.c
parent9e6c5d1742cb27b1af95f09cda6cf8b330590e03 (diff)
downloadsrc-484549566e495cb042684cec327d66f24e6fec1d.tar.gz
src-484549566e495cb042684cec327d66f24e6fec1d.zip
Import of OpenSSL 0.9.6f.
Notes
Notes: svn path=/vendor-crypto/openssl/dist/; revision=101615
Diffstat (limited to 'crypto/openssl/ssl/s2_lib.c')
-rw-r--r--crypto/openssl/ssl/s2_lib.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/crypto/openssl/ssl/s2_lib.c b/crypto/openssl/ssl/s2_lib.c
index 26a85c2f17a9..01d1e97d6008 100644
--- a/crypto/openssl/ssl/s2_lib.c
+++ b/crypto/openssl/ssl/s2_lib.c
@@ -415,7 +415,7 @@ int ssl2_put_cipher_by_char(const SSL_CIPHER *c, unsigned char *p)
return(3);
}
-void ssl2_generate_key_material(SSL *s)
+int ssl2_generate_key_material(SSL *s)
{
unsigned int i;
MD5_CTX ctx;
@@ -428,14 +428,24 @@ void ssl2_generate_key_material(SSL *s)
#endif
km=s->s2->key_material;
- die(s->s2->key_material_length <= sizeof s->s2->key_material);
+
+ if (s->session->master_key_length < 0 || s->session->master_key_length > sizeof s->session->master_key)
+ {
+ SSLerr(SSL_F_SSL2_GENERATE_KEY_MATERIAL, SSL_R_INTERNAL_ERROR);
+ return 0;
+ }
+
for (i=0; i<s->s2->key_material_length; i+=MD5_DIGEST_LENGTH)
{
+ if (((km - s->s2->key_material) + MD5_DIGEST_LENGTH) > sizeof s->s2->key_material)
+ {
+ /* MD5_Final() below would write beyond buffer */
+ SSLerr(SSL_F_SSL2_GENERATE_KEY_MATERIAL, SSL_R_INTERNAL_ERROR);
+ return 0;
+ }
+
MD5_Init(&ctx);
- die(s->session->master_key_length >= 0
- && s->session->master_key_length
- < sizeof s->session->master_key);
MD5_Update(&ctx,s->session->master_key,s->session->master_key_length);
MD5_Update(&ctx,&c,1);
c++;
@@ -444,6 +454,8 @@ void ssl2_generate_key_material(SSL *s)
MD5_Final(km,&ctx);
km+=MD5_DIGEST_LENGTH;
}
+
+ return 1;
}
void ssl2_return_error(SSL *s, int err)
@@ -468,18 +480,20 @@ void ssl2_write_error(SSL *s)
buf[2]=(s->error_code)&0xff;
/* state=s->rwstate;*/
- error=s->error;
+
+ error=s->error; /* number of bytes left to write */
s->error=0;
- die(error >= 0 && error <= 3);
+ if (error < 0 || error > sizeof buf) /* can't happen */
+ return;
+
i=ssl2_write(s,&(buf[3-error]),error);
+
/* if (i == error) s->rwstate=state; */
if (i < 0)
s->error=error;
else if (i != s->error)
s->error=error-i;
- /* else
- s->error=0; */
}
int ssl2_shutdown(SSL *s)