summaryrefslogtreecommitdiff
path: root/lib/libssl
diff options
context:
space:
mode:
authorDoug Hogan <doug@cvs.openbsd.org>2015-07-14 05:41:08 +0000
committerDoug Hogan <doug@cvs.openbsd.org>2015-07-14 05:41:08 +0000
commitd66060f90daa3db022fe9be50add34e275f93c46 (patch)
tree7d0ba12430bb3cd5f90fcf72ad7a9301f41f06e2 /lib/libssl
parent4cbfbe2fcd1b463f6c28f7812eddd9adbd68d8bb (diff)
Partially convert ssl3_get_message to CBS.
Unlike the other conversions, this only partially converts the function for now. This is the second to last function which still uses the n2l3 macro. That macro is deprecated since we're using CBS. ok miod@ jsing@
Diffstat (limited to 'lib/libssl')
-rw-r--r--lib/libssl/s3_both.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/libssl/s3_both.c b/lib/libssl/s3_both.c
index 63fea5217d5..5db0a116187 100644
--- a/lib/libssl/s3_both.c
+++ b/lib/libssl/s3_both.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: s3_both.c,v 1.40 2015/07/14 03:47:38 doug Exp $ */
+/* $OpenBSD: s3_both.c,v 1.41 2015/07/14 05:41:07 doug Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -391,9 +391,11 @@ long
ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
{
unsigned char *p;
- unsigned long l;
+ uint32_t l;
long n;
int i, al;
+ CBS cbs;
+ uint8_t u8;
if (s->s3->tmp.reuse_message) {
s->s3->tmp.reuse_message = 0;
@@ -443,8 +445,8 @@ ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, p, 4, s, s->msg_callback_arg);
}
}
- }
- while (skip_message);
+
+ } while (skip_message);
/* s->init_num == 4 */
@@ -453,9 +455,16 @@ ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
SSLerr(SSL_F_SSL3_GET_MESSAGE, SSL_R_UNEXPECTED_MESSAGE);
goto f_err;
}
- s->s3->tmp.message_type= *(p++);
- n2l3(p, l);
+ /* XXX remove call to n2l3 */
+ CBS_init(&cbs, p, 4);
+ if (!CBS_get_u8(&cbs, &u8) ||
+ !CBS_get_u24(&cbs, &l)) {
+ SSLerr(SSL_F_SSL3_GET_MESSAGE, ERR_R_BUF_LIB);
+ goto err;
+ }
+ s->s3->tmp.message_type = u8;
+
if (l > (unsigned long)max) {
al = SSL_AD_ILLEGAL_PARAMETER;
SSLerr(SSL_F_SSL3_GET_MESSAGE, SSL_R_EXCESSIVE_MESSAGE_SIZE);