]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
(print_certificate_info): Don't crash on large X.509 extensions
authorSimon Josefsson <simon@josefsson.org>
Sun, 22 Aug 2004 13:54:09 +0000 (13:54 +0000)
committerSimon Josefsson <simon@josefsson.org>
Sun, 22 Aug 2004 13:54:09 +0000 (13:54 +0000)
(thanks to PKITS test suite).  Also output ASCII representation of
printable extension data (some extension contain humanly readable
strings).

src/certtool.c

index 8d312af799b1fd12ec1c440c7353c63865a6df79..d95f425df5c952e827aada4e4a80df74d7ecc4c7 100644 (file)
@@ -28,6 +28,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <ctype.h>
 #include <gnutls/x509.h>
 #include <time.h>
 #include "certtool-gaa.h"
@@ -1229,13 +1230,19 @@ static void print_certificate_info(gnutls_x509_crt crt, FILE * out,
                else
                    fprintf(out, "\n");
 
-               print = printable;
+               fprintf(out, "\t\tDER Data: ");
                for (j = 0; j < size; j++) {
-                   sprintf(print, "%.2x", (unsigned char) buffer[j]);
-                   print += 2;
+                 fprintf(out, "%.2x", (unsigned char) buffer[j]);
                }
-               fprintf(out, "\t\tDER Data: %s\n", printable);
-
+               fprintf(out, "\n");
+               fprintf(out, "\t\tASCII: ");
+               for (j = 0; j < size; j++) {
+                 if (isprint (buffer[j]))
+                   fprintf(out, "%c", (unsigned char) buffer[j]);
+                 else
+                   fprintf(out, ".");
+               }
+               fprintf(out, "\n");
            }
 
            ret = 0;