]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
3785. [bug] Debugging code dumphex didn't accept arbitarily long
authorMark Andrews <marka@isc.org>
Thu, 13 Mar 2014 01:37:07 +0000 (12:37 +1100)
committerMark Andrews <marka@isc.org>
Thu, 13 Mar 2014 01:37:07 +0000 (12:37 +1100)
                        input (only compiled with -DDEBUG). [RT #35544]

CHANGES
lib/dns/rbt.c
lib/dns/rbtdb.c

diff --git a/CHANGES b/CHANGES
index b14faa51d386ab18aed8b4ff57b1f5a093c57782..ca3e7ebe5aec1918a0c6d887ac42fa45315c41cc 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+3785.  [bug]           Debugging code dumphex didn't accept arbitarily long
+                       input (only compiled with -DDEBUG). [RT #35544]
+
 3784.  [bug]           Using "rrset-order fixed" when it had not been
                        enabled at compile time caused inconsistent
                        results. It now works as documented, defaulting
index e2f82d83ef82baf293eab97cacdf40c40f6e4803..e1421f826d1e91ecc65779940fa1eef3ded3ecc8 100644 (file)
@@ -306,16 +306,25 @@ static void printnodename(dns_rbtnode_t *node);
 
 static void
 hexdump(const char *desc, unsigned char *data, size_t size) {
-       char hexdump[BUFSIZ];
+       char hexdump[BUFSIZ * 2 + 1];
        isc_buffer_t b;
        isc_region_t r;
+       isc_result_t result;
+       size_t bytes;
 
-       isc_buffer_init(&b, hexdump, sizeof(hexdump));
-       r.base = data;
-       r.length = size;
-       isc_hex_totext(&r, 0, "", &b);
-       isc_buffer_putuint8(&b, 0);
-       fprintf(stderr, "%s: %s\n", desc, hexdump);
+       fprintf(stderr, "%s: ", desc);
+       do {
+               isc_buffer_init(&b, hexdump, sizeof(hexdump));
+               r.base = data;
+               r.length = bytes = (size > BUFSIZ) ? BUFSIZ : size;
+               result = isc_hex_totext(&r, 0, "", &b);
+               RUNTIME_CHECK(result == ISC_R_SUCCESS);
+               isc_buffer_putuint8(&b, 0);
+               fprintf(stderr, "%s", hexdump);
+               data += bytes;
+               size -= bytes;
+       } while (size > 0);
+       fprintf(stderr, "\n");
 }
 #endif
 
@@ -644,7 +653,7 @@ dns_rbt_serialize_tree(FILE *file, dns_rbt_t *rbt,
 
        isc_crc64_final(&crc);
 #ifdef DEBUG
-       hexdump("serializing CRC", &crc, sizeof(crc));
+       hexdump("serializing CRC", (unsigned char *)&crc, sizeof(crc));
 #endif
 
        /* Serialize header */
@@ -839,7 +848,7 @@ dns_rbt_deserialize_tree(void *base_address, size_t filesize,
 
        isc_crc64_final(&crc);
 #ifdef DEBUG
-       hexdump("deserializing CRC", &crc, sizeof(crc));
+       hexdump("deserializing CRC", (unsigned char *)&crc, sizeof(crc));
 #endif
 
        /* Check file hash */
index 0e705fad14d7e07ed28b026aa42d3218f0eec725..481c7117cdd6b4337b30016d11c066743c9b4e06 100644 (file)
@@ -748,16 +748,25 @@ static unsigned int init_count;
 #ifdef DEBUG
 static void
 hexdump(const char *desc, unsigned char *data, size_t size) {
-       char hexdump[BUFSIZ];
+       char hexdump[BUFSIZ * 2 + 1];
        isc_buffer_t b;
        isc_region_t r;
+       isc_result_t result;
+       size_t bytes;
 
-       isc_buffer_init(&b, hexdump, sizeof(hexdump));
-       r.base = data;
-       r.length = size;
-       isc_hex_totext(&r, 0, "", &b);
-       isc_buffer_putuint8(&b, 0);
-       fprintf(stderr, "%s: %s\n", desc, hexdump);
+       fprintf(stderr, "%s: ", desc);
+       do {
+               isc_buffer_init(&b, hexdump, sizeof(hexdump));
+               r.base = data;
+               r.length = bytes = (size > BUFSIZ) ? BUFSIZ : size;
+               result = isc_hex_totext(&r, 0, "", &b);
+               RUNTIME_CHECK(result == ISC_R_SUCCESS);
+               isc_buffer_putuint8(&b, 0);
+               fprintf(stderr, "%s", hexdump);
+               data += bytes;
+               size -= bytes;
+       } while (size > 0);
+       fprintf(stderr, "\n");
 }
 #endif