changeset: 6873:65f180f2904f
user:      Kevin McCarthy <ke...@8t8.us>
date:      Mon Nov 21 18:03:20 2016 -0800
link:      http://dev.mutt.org/hg/mutt/rev/65f180f2904f

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.

diffs (26 lines):

diff -r db13010a2e8d -r 65f180f2904f mutt_ssl.c
--- a/mutt_ssl.c        Mon Nov 21 23:10:47 2016 +0100
+++ b/mutt_ssl.c        Mon Nov 21 18:03:20 2016 -0800
@@ -969,10 +969,11 @@
 #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 @@
 
     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 */

Reply via email to