commit b5145c1c4e138e6ae0a4731b0192f1c52cac6166
parent 99f869f79c9ab8f93d40d34598311ae5ab83cb05
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
@@ -25,6 +25,7 @@
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
+#include <gnutls/crypto.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
@@ -149,9 +150,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));
@@ -160,9 +164,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 */