]> sjero.net Git - wget/commitdiff
[svn] Announce the beginning and the end of the SSL handshake when in debug mode.
authorhniksic <devnull@localhost>
Sat, 14 May 2005 19:36:30 +0000 (12:36 -0700)
committerhniksic <devnull@localhost>
Sat, 14 May 2005 19:36:30 +0000 (12:36 -0700)
Avoid the use of the %p format.

src/ChangeLog
src/host.c
src/openssl.c
src/wget.h
src/xmalloc.c

index ced611bf64cc979c66f2010887736bad46b166c9..6b6d63551800834632f200350d47c3fac8b44d5d 100644 (file)
@@ -1,3 +1,11 @@
+2005-05-14  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * openssl.c (ssl_connect): Announce the beginning and the end of
+       the SSL handshake when in debug mode.
+
+       * wget.h (PTR_FORMAT): New macro for easier printing of pointer
+       values.  Use %0*lx along with PTR_FORMAT instead of %p.
+
 2005-05-14  Hrvoje Niksic  <hniksic@xemacs.org>
 
        * http.c (gethttp): Would forget to close the connection when
index 14a7a29d11d6ee8af62fa6b79090b9d7fc0257e8..f1fb64e7d3f7d040371711f15ca2f0942d9be873 100644 (file)
@@ -311,10 +311,11 @@ void
 address_list_release (struct address_list *al)
 {
   --al->refcount;
-  DEBUGP (("Releasing %p (new refcount %d).\n", al, al->refcount));
+  DEBUGP (("Releasing 0x%0*lx (new refcount %d).\n", PTR_FORMAT (al),
+          al->refcount));
   if (al->refcount <= 0)
     {
-      DEBUGP (("Deleting unused %p.\n", al));
+      DEBUGP (("Deleting unused 0x%0*lx.\n", PTR_FORMAT (al)));
       address_list_delete (al);
     }
 }
index d459dd653a7ff15683111b395fddc9665d0e28a8..e72ea28af0e94d8fbb200b1e0b4dc30db98e478e 100644 (file)
@@ -321,6 +321,8 @@ ssl_connect (int fd)
 {
   SSL *ssl;
 
+  DEBUGP (("Initiating SSL handshake.\n"));
+
   assert (ssl_ctx != NULL);
   ssl = SSL_new (ssl_ctx);
   if (!ssl)
@@ -335,11 +337,12 @@ ssl_connect (int fd)
      functions are used for reading, writing, and polling.  */
   fd_register_transport (fd, openssl_read, openssl_write, openssl_poll,
                         openssl_peek, openssl_close, ssl);
-  DEBUGP (("Connected %d to SSL 0x%0*lx\n", fd, 2 * sizeof (void *),
-          (unsigned long) ssl));
+  DEBUGP (("Handshake successful; connected socket %d to SSL handle 0x%0*lx\n",
+          fd, PTR_FORMAT (ssl)));
   return 1;
 
  error:
+  DEBUGP (("SSL handshake failed.\n"));
   print_errors ();
   if (ssl)
     SSL_free (ssl);
@@ -478,6 +481,8 @@ ssl_check_certificate (int fd, const char *host)
 
   /* The certificate was found, verified, and matched HOST. */
   success = 1;
+  DEBUGP (("X509 certificate successfully verified and matches host %s\n",
+          escnonprint (host)));
 
  out:
   if (cert)
index ec8e0534b76b3957a8922e7f58870f31af726559..38c8fbdeba8afde932f3ca2431cd178a9864c2a4 100644 (file)
@@ -224,6 +224,12 @@ typedef off_t wgint;
     basevar = (type *)xrealloc (basevar, DR_newsize * sizeof (type));  \
 } while (0)
 
+/* Used to print pointers (usually for debugging).  Print pointers
+   using printf ("%0*lx", PTR_FORMAT (p)).  (%p is too unpredictable;
+   some implementations prepend 0x, while some don't, and most don't
+   0-pad the address.)  */
+#define PTR_FORMAT(p) 2 * sizeof (void *), (unsigned long) (p)
+
 extern const char *exec_name;
 \f
 /* Document type ("dt") flags */
index 75112c6b2b1aed76f9652076b92124a7b2dc7f2c..cf3ad267dc76eb185d3d2fcf71b7dfe430e2d64a 100644 (file)
@@ -304,8 +304,7 @@ print_malloc_debug_stats (void)
          malloc_count, free_count, malloc_count - free_count);
   for (i = 0; i < SZ; i++)
     if (malloc_table[i].ptr != NULL)
-      printf ("0x%0*lx: %s:%d\n", 2 * sizeof (void *),
-             (long) malloc_table[i].ptr,
+      printf ("0x%0*lx: %s:%d\n", PTR_FORMAT (malloc_table[i].ptr),
              malloc_table[i].file, malloc_table[i].line);
 }
 
@@ -368,8 +367,7 @@ debugging_free (void *ptr, const char *source_file, int source_line)
   if (!unregister_ptr (ptr))
     {
       fprintf (stderr, "%s: bad xfree(%0*lx) at %s:%d\n",
-              exec_name, 2 * sizeof (void *), (long) ptr,
-              source_file, source_line);
+              exec_name, PTR_FORMAT (ptr), source_file, source_line);
       abort ();
     }
   ++free_count;