Skip to content

Commit d6c62cc

Browse files
In SSL sniffer, ensure the ClientHello extension length is sufficient to read the length before attempting the actual read.
Thanks to Zou Dikai for the report.
1 parent 78abd54 commit d6c62cc

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/sniffer.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4195,6 +4195,9 @@ static int ProcessClientHello(const byte* input, int* sslBytes,
41954195
{
41964196
word16 listLen = 0, offset = 0;
41974197

4198+
if (extLen < OPAQUE16_LEN)
4199+
return BUFFER_ERROR;
4200+
41984201
ato16(input + offset, &listLen);
41994202
offset += OPAQUE16_LEN;
42004203

@@ -4228,6 +4231,9 @@ static int ProcessClientHello(const byte* input, int* sslBytes,
42284231
#ifdef WOLFSSL_TLS13
42294232
case EXT_KEY_SHARE:
42304233
{
4234+
if (extLen < OPAQUE16_LEN)
4235+
return BUFFER_ERROR;
4236+
42314237
word16 ksLen = (word16)((input[0] << 8) | input[1]);
42324238
if (ksLen + OPAQUE16_LEN > extLen) {
42334239
SetError(CLIENT_HELLO_INPUT_STR, error, session, FATAL_ERROR_STATE);
@@ -4252,6 +4258,9 @@ static int ProcessClientHello(const byte* input, int* sslBytes,
42524258
word32 ticketAge;
42534259
const byte *identity, *binders;
42544260

4261+
if (extLen < OPAQUE16_LEN)
4262+
return BUFFER_ERROR;
4263+
42554264
idsLen = (word16)((input[idx] << 8) | input[idx+1]);
42564265
if ((word32)idsLen + OPAQUE16_LEN + idx > (word32)extLen) {
42574266
SetError(CLIENT_HELLO_INPUT_STR, error, session, FATAL_ERROR_STATE);

0 commit comments

Comments
 (0)