diff --git a/src/payload.c b/src/payload.c index 457541189..5e39133ba 100644 --- a/src/payload.c +++ b/src/payload.c @@ -116,6 +116,9 @@ smp_client_hello_parse( struct sample *smp, enum client_hello_type type, unsigne data += 5; /* enter TLS handshake */ bleft -= 5; + if (bleft < hs_len) + goto too_short; + /* Check for a complete client hello starting at */ if (bleft < 1) goto too_short; @@ -129,15 +132,18 @@ smp_client_hello_parse( struct sample *smp, enum client_hello_type type, unsigne if (hs_len < 2 + 32 + 1 + 2 + 2 + 1 + 1 + 2 + 2) goto not_ssl_hello; /* too short to have an extension */ + data += 4; + bleft -= 4; + /* We want the full handshake here */ if (bleft < hs_len) goto too_short; - data += 4; /* Start of the ClientHello message */ if (data[0] < 0x03 || data[1] < 0x01) /* TLSv1 minimum */ goto not_ssl_hello; + /* Note: covered by the hs_len test 30 lines above */ ext_len = data[34]; /* session_id_len */ if (ext_len > 32 || ext_len > (hs_len - 35)) /* check for correct session_id len */ goto not_ssl_hello;