commit 3390afd2245d5100c80ec5afc4d8233413edffbd
parent 07730d30f9524e8177cfda34aba354af3eeb9120
Author: Andrej Kacian <ticho@claws-mail.org>
Date: Fri, 4 Jan 2019 19:43:31 +0100
Fix an impossible to trigger buffer overflow
Gets rid of CID 1442278.
Diffstat:
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/gtk/sslcertwindow.c b/src/gtk/sslcertwindow.c
@@ -27,6 +27,7 @@
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
+#include <gnutls/crypto.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
@@ -151,9 +152,12 @@ static GtkWidget *cert_presenter(SSLCertificate *cert)
ret = gnutls_x509_crt_get_fingerprint(cert->x509_cert, GNUTLS_DIG_SHA1, md, &n);
}
- if (ret != 0)
+ if (ret != 0) {
g_warning("failed to obtain SHA1 fingerprint: %d", ret);
- sha1_fingerprint = readable_fingerprint(md, (int)n); /* all zeroes */
+ sha1_fingerprint = g_strdup("-");
+ } else {
+ sha1_fingerprint = readable_fingerprint(md, (int)n);
+ }
n = 0;
memset(md, 0, sizeof(md));
@@ -162,9 +166,12 @@ static GtkWidget *cert_presenter(SSLCertificate *cert)
ret = gnutls_x509_crt_get_fingerprint(cert->x509_cert, GNUTLS_DIG_SHA256, md, &n);
}
- if (ret != 0)
+ if (ret != 0) {
g_warning("failed to obtain SHA256 fingerprint: %d", ret);
- sha256_fingerprint = readable_fingerprint(md, (int)n); /* all zeroes */
+ sha256_fingerprint = g_strdup("-");
+ } else {
+ sha256_fingerprint = readable_fingerprint(md, (int)n);
+ }
/* signature */