]> granicus.if.org Git - mutt/commitdiff
Revert db13010a2e8d but add a comment. (see #3870)
authorKevin McCarthy <kevin@8t8.us>
Tue, 22 Nov 2016 02:03:20 +0000 (18:03 -0800)
committerKevin McCarthy <kevin@8t8.us>
Tue, 22 Nov 2016 02:03:20 +0000 (18:03 -0800)
X509_NAME_oneline() always NULL-terminates the string, even when it
has to truncate the data to fit in buf.

mutt_ssl.c

index 0bca243f9f3da2ab998536ca99247bdd73960f83..d4efdaf10ef29353d942f3ec00f90d8b545045bd 100644 (file)
@@ -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 */