aboutsummaryrefslogtreecommitdiff
path: root/src/lib/protocols/tls.c
diff options
context:
space:
mode:
authorLuca Deri <deri@ntop.org>2020-06-01 16:34:24 +0200
committerLuca Deri <deri@ntop.org>2020-06-01 16:34:24 +0200
commit16dc0ec29e0a6b0e12bcebdc2f5619d5d88da697 (patch)
tree1d4b1b94fe30b4fe684a1a1f2b88caa4d775f6e2 /src/lib/protocols/tls.c
parent29d9c2d2c80289f31278f8717959a5718a2e6ce1 (diff)
Check to avoid allocating twice the esni memory
Diffstat (limited to 'src/lib/protocols/tls.c')
-rw-r--r--src/lib/protocols/tls.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/lib/protocols/tls.c b/src/lib/protocols/tls.c
index e2d1a572e..222fa480d 100644
--- a/src/lib/protocols/tls.c
+++ b/src/lib/protocols/tls.c
@@ -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;
+ }
}
}
}