ssl: improve 'first cert' check to avoid leaks

In some error conditions, or potentially in case of multiple 'certificate'
records, the extracted subject, issuerdn and serial could be overwritten
without freeing the original memory.
pull/4922/head
Victor Julien 6 years ago
parent fa2a1385ea
commit 9a97821c43

@ -498,7 +498,11 @@ static int TlsDecodeHSCertificate(SSLState *ssl_state,
int rc = 0;
/* only store fields from the first certificate in the chain */
if (processed_len == 0) {
if (processed_len == 0 &&
ssl_state->server_connp.cert0_subject == NULL &&
ssl_state->server_connp.cert0_issuerdn == NULL &&
ssl_state->server_connp.cert0_serial == NULL)
{
char * str;
int64_t not_before, not_after;

Loading…
Cancel
Save