From: Fabian Keil <fk@fabiankeil.de>
Date: Wed, 26 Aug 2020 13:45:47 +0000 (+0200)
Subject: ssl_store_cert(): Handle html_encode() failures
X-Git-Tag: v_3_0_29~202
X-Git-Url: http://www.privoxy.org/gitweb/%22https:/developer-manual/static/faq/static/@default-cgi@?a=commitdiff_plain;h=b987797ccc0276de1f36b8175ce105950d5e97eb;p=privoxy.git

ssl_store_cert(): Handle html_encode() failures

Sponsored by: Robert Klemme
---

diff --git a/openssl.c b/openssl.c
index 6cc2af55..723820bf 100644
--- a/openssl.c
+++ b/openssl.c
@@ -638,6 +638,14 @@ static int ssl_store_cert(struct client_state *csp, X509* crt)
 
    len = BIO_get_mem_data(bio, &bio_mem_data);
    encoded_text = html_encode(bio_mem_data);
+   if (encoded_text == NULL)
+   {
+      log_error(LOG_LEVEL_ERROR,
+         "Failed to HTML-encode the certificate information");
+      ret = -1;
+      goto exit;
+   }
+
    strlcpy(last->info_buf, encoded_text, sizeof(last->info_buf));
    freez(encoded_text);
    ret = 0;