Check to avoid allocating twice the esni memory
This commit is contained in:
+14
-12
@@ -1288,19 +1288,21 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
printf("Client SSL [Encrypted Server Name len: %u]\n", e_sni_len);
|
||||
#endif
|
||||
|
||||
flow->protos.stun_ssl.ssl.encrypted_sni.esni = (char*)ndpi_malloc(e_sni_len*2+1);
|
||||
|
||||
if(flow->protos.stun_ssl.ssl.encrypted_sni.esni) {
|
||||
u_int16_t i, off;
|
||||
if(flow->protos.stun_ssl.ssl.encrypted_sni.esni == NULL) {
|
||||
flow->protos.stun_ssl.ssl.encrypted_sni.esni = (char*)ndpi_malloc(e_sni_len*2+1);
|
||||
|
||||
for(i=e_offset, off=0; i<(e_offset+e_sni_len); i++) {
|
||||
int rc = sprintf(&flow->protos.stun_ssl.ssl.encrypted_sni.esni[off], "%02X", packet->payload[i] & 0XFF);
|
||||
|
||||
if(rc <= 0) {
|
||||
flow->protos.stun_ssl.ssl.encrypted_sni.esni[off] = '\0';
|
||||
break;
|
||||
} else
|
||||
off += rc;
|
||||
if(flow->protos.stun_ssl.ssl.encrypted_sni.esni) {
|
||||
u_int16_t i, off;
|
||||
|
||||
for(i=e_offset, off=0; i<(e_offset+e_sni_len); i++) {
|
||||
int rc = sprintf(&flow->protos.stun_ssl.ssl.encrypted_sni.esni[off], "%02X", packet->payload[i] & 0XFF);
|
||||
|
||||
if(rc <= 0) {
|
||||
flow->protos.stun_ssl.ssl.encrypted_sni.esni[off] = '\0';
|
||||
break;
|
||||
} else
|
||||
off += rc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user