diff --git a/src/ChangeLog b/src/ChangeLog index ced611bf..6b6d6355 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2005-05-14 Hrvoje Niksic + + * 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 * http.c (gethttp): Would forget to close the connection when diff --git a/src/host.c b/src/host.c index 14a7a29d..f1fb64e7 100644 --- a/src/host.c +++ b/src/host.c @@ -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); } } diff --git a/src/openssl.c b/src/openssl.c index d459dd65..e72ea28a 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -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) diff --git a/src/wget.h b/src/wget.h index ec8e0534..38c8fbde 100644 --- a/src/wget.h +++ b/src/wget.h @@ -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; /* Document type ("dt") flags */ diff --git a/src/xmalloc.c b/src/xmalloc.c index 75112c6b..cf3ad267 100644 --- a/src/xmalloc.c +++ b/src/xmalloc.c @@ -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;