From ceeab9965aa9ad4ca79f5c7fa694b4e9e8fbf9c8 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Tue, 17 Feb 2015 21:44:16 +0100 Subject: [PATCH] Print null terminated bindata strings as strings --- src/dict.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/dict.c b/src/dict.c index 49c8679f..65864b3a 100644 --- a/src/dict.c +++ b/src/dict.c @@ -536,7 +536,7 @@ getdns_pp_bindata(ldns_buffer *buf, size_t indent, while (i < bindata->size && isprint(bindata->data[i])) i++; - if (bindata->size > 0 && i >= bindata->size) { /* all printable? */ + if (bindata->size > 0 && i == bindata->size) { /* all printable? */ (void) snprintf(truncfmt, 100, "of \"%%.%ds\"%%s>", (int)(i > 32 ? 32 : i)); @@ -544,6 +544,12 @@ getdns_pp_bindata(ldns_buffer *buf, size_t indent, i > 32 ? "... " : "") < 0) return -1; + } else if (bindata->size > 1 && /* null terminated printable */ + i == bindata->size - 1 && bindata->data[i] == 0) { + + if (ldns_buffer_printf(buf, "of \"%s\">", bindata->data) < 0) + return -1; + } else if (bindata->size == 1 && *bindata->data == 0) { if (ldns_buffer_printf(buf, "for .>") < 0) return -1;