fix possible overflow, improve tests

This commit is contained in:
Sergio R. Caprile committed 2025-07-31 13:43:18 -03:00
1 parent 77e369bc79
commit e670ea3d61
6 files changed
+45 -16

No files matched your search

+1
View File
@@ -597,6 +597,7 @@ static int mg_tls_server_recv_hello(struct mg_connection *c) {
uint16_t key_exchange_len;
uint8_t *key_exchange;
uint16_t n = MG_LOAD_BE16(ext + j + 2);
if (((uint32_t) n + j + 4) > ext_len) goto fail;
if (MG_LOAD_BE16(ext + j) != 0x0033) { // not a key share extension, ignore
j += (uint16_t) (n + 4);
continue;