talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit e33f7bd8955517e9bc74951df3fc7ba26a579eb0
parent 5b4c3de1dc3440e03272fa8b89f7f4e633821895
Author: Paul <paul@claws-mail.org>
Date:   Fri,  4 Jan 2019 13:10:36 +0000

fix bug 4143, 'fingerprint in SSL/TLS certificates for ... (regress error)'

patch by Andrej

Diffstat:
Msrc/gtk/sslcertwindow.c | 31++++++++++++++++++++++++-------
1 file changed, 24 insertions(+), 7 deletions(-)

diff --git a/src/gtk/sslcertwindow.c b/src/gtk/sslcertwindow.c @@ -1,6 +1,6 @@ /* * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2018 Colin Leroy and the Claws Mail team + * Copyright (C) 1999-2019 Colin Leroy and the Claws Mail team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -68,6 +68,7 @@ static GtkWidget *cert_presenter(SSLCertificate *cert) char *tmp; time_t exp_time_t; struct tm lt; + guint ret; /* issuer */ issuer_commonname = g_malloc(BUFFSIZE); @@ -140,12 +141,28 @@ static GtkWidget *cert_presenter(SSLCertificate *cert) } else exp_date = g_strdup(""); - /* fingerprint */ - n = 128; - gnutls_x509_crt_get_fingerprint(cert->x509_cert, GNUTLS_DIG_SHA1, md, &n); - sha1_fingerprint = readable_fingerprint(md, (int)n); - gnutls_x509_crt_get_fingerprint(cert->x509_cert, GNUTLS_DIG_SHA256, md, &n); - sha256_fingerprint = readable_fingerprint(md, (int)n); + /* fingerprints */ + n = 0; + memset(md, 0, sizeof(md)); + if ((ret = gnutls_x509_crt_get_fingerprint(cert->x509_cert, GNUTLS_DIG_SHA1, md, &n)) == GNUTLS_E_SHORT_MEMORY_BUFFER) { + if (n <= sizeof(md)) + ret = gnutls_x509_crt_get_fingerprint(cert->x509_cert, GNUTLS_DIG_SHA1, md, &n); + } + + if (ret != 0) + g_warning("failed to obtain SHA1 fingerprint: %d", ret); + sha1_fingerprint = readable_fingerprint(md, (int)n); /* all zeroes */ + + n = 0; + memset(md, 0, sizeof(md)); + if ((ret = gnutls_x509_crt_get_fingerprint(cert->x509_cert, GNUTLS_DIG_SHA256, md, &n)) == GNUTLS_E_SHORT_MEMORY_BUFFER) { + if (n <= sizeof(md)) + ret = gnutls_x509_crt_get_fingerprint(cert->x509_cert, GNUTLS_DIG_SHA256, md, &n); + } + + if (ret != 0) + g_warning("failed to obtain SHA256 fingerprint: %d", ret); + sha256_fingerprint = readable_fingerprint(md, (int)n); /* all zeroes */ /* signature */