summaryrefslogtreecommitdiffstats
path: root/ssl/s3_both.c
diff options
context:
space:
mode:
authorBodo Möller <bodo@openssl.org>2001-10-15 19:49:25 +0000
committerBodo Möller <bodo@openssl.org>2001-10-15 19:49:25 +0000
commit48948d53b6f61aa14bc5eab33f67f124c43175ff (patch)
tree9b766b938ef6e59fb5f37210b25fd78370fa5bb6 /ssl/s3_both.c
parentdbec19622e2cc6ae50b303ece36d15810192d022 (diff)
Change ssl3_get_message and the functions using it so that complete
'Handshake' protocol structures are kept in memory, including 'msg_type' and 'length'. (This is in preparation of future support for callbacks that get to peek at handshake messages and the like.)
Diffstat (limited to 'ssl/s3_both.c')
-rw-r--r--ssl/s3_both.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/ssl/s3_both.c b/ssl/s3_both.c
index cd97280374..409120bade 100644
--- a/ssl/s3_both.c
+++ b/ssl/s3_both.c
@@ -109,6 +109,7 @@
*
*/
+#include <limits.h>
#include <string.h>
#include <stdio.h>
#include <openssl/buffer.h>
@@ -205,7 +206,7 @@ int ssl3_get_finished(SSL *s, int a, int b)
}
s->s3->change_cipher_spec=0;
- p = (unsigned char *)s->init_buf->data;
+ p = (unsigned char *)s->init_msg;
i = s->s3->tmp.peer_finish_md_len;
if (i != n)
@@ -355,6 +356,7 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
goto f_err;
}
*ok=1;
+ s->init_msg = s->init_buf->data + 4;
return((int)s->s3->tmp.message_size);
}
@@ -415,8 +417,6 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
ssl3_init_finished_mac(s);
}
- ssl3_finish_mac(s, (unsigned char *)s->init_buf->data, 4);
-
s->s3->tmp.message_type= *(p++);
n2l3(p,l);
@@ -426,7 +426,13 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
SSLerr(SSL_F_SSL3_GET_MESSAGE,SSL_R_EXCESSIVE_MESSAGE_SIZE);
goto f_err;
}
- if (l && !BUF_MEM_grow(s->init_buf,(int)l))
+ if (l > (INT_MAX-4)) /* BUF_MEM_grow takes an 'int' parameter */
+ {
+ al=SSL_AD_ILLEGAL_PARAMETER;
+ SSLerr(SSL_F_SSL3_GET_MESSAGE,SSL_R_EXCESSIVE_MESSAGE_SIZE);
+ goto f_err;
+ }
+ if (l && !BUF_MEM_grow(s->init_buf,(int)l+4))
{
SSLerr(SSL_F_SSL3_GET_MESSAGE,ERR_R_BUF_LIB);
goto err;
@@ -434,13 +440,13 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
s->s3->tmp.message_size=l;
s->state=stn;
- s->init_num=0;
+ s->init_msg = s->init_buf->data + 4;
+ s->init_num = 0;
}
/* next state (stn) */
- p=(unsigned char *)s->init_buf->data;
- n=s->s3->tmp.message_size;
- n -= s->init_num;
+ p = s->init_msg;
+ n = s->s3->tmp.message_size - s->init_num;
while (n > 0)
{
i=ssl3_read_bytes(s,SSL3_RT_HANDSHAKE,&p[s->init_num],n,0);
@@ -453,7 +459,7 @@ long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
s->init_num += i;
n -= i;
}
- ssl3_finish_mac(s, (unsigned char *)s->init_buf->data, s->init_num);
+ ssl3_finish_mac(s, (unsigned char *)s->init_buf->data, s->init_num + 4);
*ok=1;
return s->init_num;
f_err: