Fix issue in handling legacy_compression_methods in ssl_tls13_parse_client_hello()

Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
diff --git a/library/ssl_tls13_server.c b/library/ssl_tls13_server.c
index f5ef920..ca3ea53 100644
--- a/library/ssl_tls13_server.c
+++ b/library/ssl_tls13_server.c
@@ -1265,6 +1265,8 @@
     mbedtls_ssl_handshake_params *handshake = ssl->handshake;
     int hrr_required = 0;
     int no_usable_share_for_key_agreement = 0;
+    unsigned char legacy_compression_methods_len;
+    unsigned char legacy_compression_methods;
 
 #if defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_SOME_PSK_ENABLED)
     int got_psk = 0;
@@ -1362,6 +1364,13 @@
     p += cipher_suites_len;
     cipher_suites_end = p;
 
+    legacy_compression_methods_len = *p;
+    legacy_compression_methods = *(p+1);
+
+    if (legacy_compression_methods_len != 1 || legacy_compression_methods != 0) {
+        return SSL_CLIENT_HELLO_TLS1_2;
+    }
+
     /*
      * Search for the supported versions extension and parse it to determine
      * if the client supports TLS 1.3.