gnutls-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU gnutls branch, master, updated. gnutls_2_9_10-328-ga0c6e34


From: Simon Josefsson
Subject: [SCM] GNU gnutls branch, master, updated. gnutls_2_9_10-328-ga0c6e34
Date: Sun, 25 Jul 2010 16:27:09 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU gnutls".

http://git.savannah.gnu.org/cgit/gnutls.git/commit/?id=a0c6e34c983423d41c80652402fc2cd17ef27a5c

The branch, master has been updated
       via  a0c6e34c983423d41c80652402fc2cd17ef27a5c (commit)
      from  a1474d558e182b1c23320f8e865249fd27d810e7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit a0c6e34c983423d41c80652402fc2cd17ef27a5c
Author: Simon Josefsson <address@hidden>
Date:   Sun Jul 25 18:27:04 2010 +0200

    Avoid fixed size buffers (now handles the big >100 SAN cert).

-----------------------------------------------------------------------

Summary of changes:
 src/common.c |   49 +++++++++++++++++++++++++++++++++++++------------
 1 files changed, 37 insertions(+), 12 deletions(-)

diff --git a/src/common.c b/src/common.c
index 1371ded..7590482 100644
--- a/src/common.c
+++ b/src/common.c
@@ -44,8 +44,6 @@
 int print_cert;
 extern int verbose;
 
-static char buffer[5 * 1024];
-
 const char str_unknown[] = "(unknown)";
 
 /* Hex encodes the given data.
@@ -115,12 +113,23 @@ print_x509_info (gnutls_session_t session, const char 
*hostname, int insecure)
 
       if (print_cert)
        {
-         size_t size;
-
-         size = sizeof (buffer);
+         size_t size = 0;
+         char *p = NULL;
 
          ret = gnutls_x509_crt_export (crt, GNUTLS_X509_FMT_PEM,
-                                       buffer, &size);
+                                       p, &size);
+         if (ret == GNUTLS_E_SHORT_MEMORY_BUFFER)
+           {
+             p = malloc (size);
+             if (!p)
+               {
+                 fprintf (stderr, "gnutls_malloc\n");
+                 exit (1);
+               }
+
+             ret = gnutls_x509_crt_export (crt, GNUTLS_X509_FMT_PEM,
+                                           p, &size);
+           }
          if (ret < 0)
            {
              fprintf (stderr, "Encoding error: %s\n", gnutls_strerror (ret));
@@ -128,8 +137,10 @@ print_x509_info (gnutls_session_t session, const char 
*hostname, int insecure)
            }
 
          fputs ("\n", stdout);
-         fputs (buffer, stdout);
+         fputs (p, stdout);
          fputs ("\n", stdout);
+
+         gnutls_free (p);
        }
 
       if (j == 0 && hostname != NULL)
@@ -200,19 +211,33 @@ print_openpgp_info (gnutls_session_t session, const char 
*hostname,
 
       if (print_cert)
        {
-         size_t size;
-
-         size = sizeof (buffer);
+         size_t size = 0;
+         char *p = NULL;
 
          ret = gnutls_openpgp_crt_export (crt, GNUTLS_OPENPGP_FMT_BASE64,
-                                          buffer, &size);
+                                          p, &size);
+         if (ret == GNUTLS_E_SHORT_MEMORY_BUFFER)
+           {
+             p = malloc (size);
+             if (!p)
+               {
+                 fprintf (stderr, "gnutls_malloc\n");
+                 exit (1);
+               }
+
+             ret = gnutls_openpgp_crt_export (crt, GNUTLS_OPENPGP_FMT_BASE64,
+                                              p, &size);
+           }
          if (ret < 0)
            {
              fprintf (stderr, "Encoding error: %s\n", gnutls_strerror (ret));
              return;
            }
-         fputs (buffer, stdout);
+
+         fputs (p, stdout);
          fputs ("\n", stdout);
+
+         gnutls_free (p);
        }
 
       if (hostname != NULL)


hooks/post-receive
-- 
GNU gnutls



reply via email to

[Prev in Thread] Current Thread [Next in Thread]