From: Kevin McCarthy Date: Tue, 22 Nov 2016 02:03:20 +0000 (-0800) Subject: Revert db13010a2e8d but add a comment. (see #3870) X-Git-Tag: neomutt-20170225~32^2~48 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=85cca740e385578b9a89cfc471e736a8f708ddcc;p=neomutt Revert db13010a2e8d but add a comment. (see #3870) X509_NAME_oneline() always NULL-terminates the string, even when it has to truncate the data to fit in buf. --- diff --git a/mutt_ssl.c b/mutt_ssl.c index 0bca243f9..d4efdaf10 100644 --- a/mutt_ssl.c +++ b/mutt_ssl.c @@ -969,10 +969,11 @@ static int ssl_check_certificate (CONNECTION *conn, sslsockdata *data) #ifdef DEBUG char buf[STRING]; - buf[STRING - 1] = '\0'; + /* Note that X509_NAME_online will NULL-terminate buf, even when it + * has to truncate the data. */ dprint (1, (debugfile, "ssl_check_certificate: checking cert %s\n", X509_NAME_oneline (X509_get_subject_name (data->cert), - buf, sizeof (buf) - 1))); + buf, sizeof (buf)))); #endif if ((preauthrc = ssl_check_preauth (data->cert, conn->account.host)) > 0) @@ -992,7 +993,7 @@ static int ssl_check_certificate (CONNECTION *conn, sslsockdata *data) dprint (1, (debugfile, "ssl_check_certificate: checking cert chain entry %s\n", X509_NAME_oneline (X509_get_subject_name (cert), - buf, sizeof (buf) - 1))); + buf, sizeof (buf)))); /* if the certificate validates or is manually accepted, then add it to * the trusted set and recheck the peer certificate */