@@ -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,7 +4231,13 @@ static int ProcessClientHello(const byte* input, int* sslBytes,
42284231 #ifdef WOLFSSL_TLS13
42294232 case EXT_KEY_SHARE :
42304233 {
4231- word16 ksLen = (word16 )((input [0 ] << 8 ) | input [1 ]);
4234+ word16 ksLen = 0 ;
4235+ if (extLen < OPAQUE16_LEN ) {
4236+ SetError (BUFFER_ERROR_STR , error , session , FATAL_ERROR_STATE );
4237+ return BUFFER_ERROR ;
4238+ }
4239+
4240+ ksLen = (word16 )((input [0 ] << 8 ) | input [1 ]);
42324241 if (ksLen + OPAQUE16_LEN > extLen ) {
42334242 SetError (CLIENT_HELLO_INPUT_STR , error , session , FATAL_ERROR_STATE );
42344243 return WOLFSSL_FATAL_ERROR ;
@@ -4252,6 +4261,11 @@ static int ProcessClientHello(const byte* input, int* sslBytes,
42524261 word32 ticketAge ;
42534262 const byte * identity , * binders ;
42544263
4264+ if (extLen < OPAQUE16_LEN ) {
4265+ SetError (BUFFER_ERROR_STR , error , session , FATAL_ERROR_STATE );
4266+ return BUFFER_ERROR ;
4267+ }
4268+
42554269 idsLen = (word16 )((input [idx ] << 8 ) | input [idx + 1 ]);
42564270 if ((word32 )idsLen + OPAQUE16_LEN + idx > (word32 )extLen ) {
42574271 SetError (CLIENT_HELLO_INPUT_STR , error , session , FATAL_ERROR_STATE );
0 commit comments