aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremanuele-f <faranda@ntop.org>2020-02-13 10:14:57 +0100
committeremanuele-f <faranda@ntop.org>2020-02-13 10:14:57 +0100
commit7234f369499e02f44efcbbf0efe43bae596ddc53 (patch)
treeff3b83ccbe98d5d433e4bab7a50fa922ea12ce67
parent2efc09a20e6503d99fe3d76fcc16b1892fb7c7ff (diff)
Fix possible leak
-rw-r--r--src/lib/protocols/tls.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lib/protocols/tls.c b/src/lib/protocols/tls.c
index b70538949..1b120dc7b 100644
--- a/src/lib/protocols/tls.c
+++ b/src/lib/protocols/tls.c
@@ -392,8 +392,10 @@ int processCertificate(struct ndpi_detection_module_struct *ndpi_struct,
if((packet->payload[4] != 0x0) || ((certificates_length+3) != length))
return(-2); /* Invalid length */
- if((flow->l4.tcp.tls.srv_cert_fingerprint_ctx = (void*)ndpi_malloc(sizeof(SHA1_CTX))) == NULL)
- return(-3); /* Not enough memory */
+ if(!flow->l4.tcp.tls.srv_cert_fingerprint_ctx) {
+ if((flow->l4.tcp.tls.srv_cert_fingerprint_ctx = (void*)ndpi_malloc(sizeof(SHA1_CTX))) == NULL)
+ return(-3); /* Not enough memory */
+ }
/* Now let's process each individual certificates */
while(certificates_offset < certificates_length) {