Skip to content

Commit

Permalink
Fix possible leak
Browse files Browse the repository at this point in the history
  • Loading branch information
emanuele-f committed Feb 13, 2020
1 parent 2efc09a commit 7234f36
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib/protocols/tls.c
Expand Up @@ -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) {
Expand Down

0 comments on commit 7234f36

Please sign in to comment.