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);
|
printf("Client SSL [Encrypted Server Name len: %u]\n", e_sni_len);
|
||||||
#endif
|
#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 == NULL) {
|
||||||
|
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;
|
|
||||||
|
|
||||||
for(i=e_offset, off=0; i<(e_offset+e_sni_len); i++) {
|
if(flow->protos.stun_ssl.ssl.encrypted_sni.esni) {
|
||||||
int rc = sprintf(&flow->protos.stun_ssl.ssl.encrypted_sni.esni[off], "%02X", packet->payload[i] & 0XFF);
|
u_int16_t i, off;
|
||||||
|
|
||||||
if(rc <= 0) {
|
for(i=e_offset, off=0; i<(e_offset+e_sni_len); i++) {
|
||||||
flow->protos.stun_ssl.ssl.encrypted_sni.esni[off] = '\0';
|
int rc = sprintf(&flow->protos.stun_ssl.ssl.encrypted_sni.esni[off], "%02X", packet->payload[i] & 0XFF);
|
||||||
break;
|
|
||||||
} else
|
if(rc <= 0) {
|
||||||
off += rc;
|
flow->protos.stun_ssl.ssl.encrypted_sni.esni[off] = '\0';
|
||||||
|
break;
|
||||||
|
} else
|
||||||
|
off += rc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user