Boundary check on QUIC

This commit is contained in:
Luca Deri
2020-07-27 07:40:50 +02:00
parent 4b1cae2c2b
commit 69f140878c
+6 -3
View File
@@ -124,14 +124,16 @@ void ndpi_search_quic(struct ndpi_detection_module_struct *ndpi_struct,
&& (packet->payload[i+3] == 0)) { && (packet->payload[i+3] == 0)) {
u_int32_t offset = (*((u_int32_t*)&packet->payload[i+4])); u_int32_t offset = (*((u_int32_t*)&packet->payload[i+4]));
u_int32_t prev_offset = (*((u_int32_t*)&packet->payload[i-4])); u_int32_t prev_offset = (*((u_int32_t*)&packet->payload[i-4]));
int len = offset-prev_offset;
int sni_offset = i+prev_offset+1; if(offset > prev_offset) {
u_int32_t len = offset-prev_offset;
u_int32_t sni_offset = i+prev_offset+1;
while((sni_offset < udp_len) && (packet->payload[sni_offset] == '-')) while((sni_offset < udp_len) && (packet->payload[sni_offset] == '-'))
sni_offset++; sni_offset++;
if(len > 0 && (sni_offset+len) < udp_len) { if(len > 0 && (sni_offset+len) < udp_len) {
int max_len = sizeof(flow->host_server_name)-1, j = 0; u_int32_t max_len = sizeof(flow->host_server_name)-1, j = 0;
ndpi_protocol_match_result ret_match; ndpi_protocol_match_result ret_match;
if(len > max_len) len = max_len; if(len > max_len) len = max_len;
@@ -153,6 +155,7 @@ void ndpi_search_quic(struct ndpi_detection_module_struct *ndpi_struct,
} }
} }
} }
}
return; return;
} }