Print null terminated bindata strings as strings

This commit is contained in:
Willem Toorop 2015-02-17 21:44:16 +01:00
parent 7fecb7d922
commit ceeab9965a
1 changed files with 7 additions and 1 deletions

View File

@ -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;