BIO_debug_callback: Fix output on 64-bit machines
authorRichard Godbee <richard@godbee.net>
Sun, 21 Sep 2014 06:14:11 +0000 (02:14 -0400)
committerRichard Levitte <levitte@openssl.org>
Tue, 10 Mar 2015 11:34:21 +0000 (12:34 +0100)
BIO_debug_callback() no longer assumes the hexadecimal representation of
a pointer fits in 8 characters.

Signed-off-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 460e920d8a274e27aab36346eeda6685a42c3314)

crypto/bio/bio_cb.c

index 8715f5cbcbaaffc11f271640e66aa4e2cad401a2..d3e860686c3c5821c27e40af5db95760d398039a 100644 (file)
@@ -70,14 +70,17 @@ long MS_CALLBACK BIO_debug_callback(BIO *bio, int cmd, const char *argp,
     MS_STATIC char buf[256];
     char *p;
     long r = 1;
+    int len;
     size_t p_maxlen;
 
     if (BIO_CB_RETURN & cmd)
         r = ret;
 
-    BIO_snprintf(buf, sizeof buf, "BIO[%08lX]:", (unsigned long)bio);
-    p = &(buf[14]);
-    p_maxlen = sizeof buf - 14;
+    len = BIO_snprintf(buf,sizeof buf,"BIO[%p]: ",(void *)bio);
+
+    p = buf + len;
+    p_maxlen = sizeof(buf) - len;
+
     switch (cmd) {
     case BIO_CB_FREE:
         BIO_snprintf(p, p_maxlen, "Free - %s\n", bio->method->name);