]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Also print out valid printable utf8
authorMark Andrews <marka@isc.org>
Mon, 11 May 2020 06:26:13 +0000 (16:26 +1000)
committerMark Andrews <marka@isc.org>
Wed, 13 May 2020 02:18:55 +0000 (12:18 +1000)
(cherry picked from commit 1c8f9d06e2f5e3d4c9ff9ae71c05da7ac376e52a)
(cherry picked from commit c13fb2c67ff01590dcd8ce7c76a8683ac3491833)

lib/dns/message.c

index 2ec4f96316c3c2bd9bf1f26299765806ef08f5a0..9d2cd2a0e90800c8ac9e3eb5a1ccb6d0e311a2c2 100644 (file)
@@ -3944,7 +3944,7 @@ dns_message_pseudosectiontotext(dns_message_t *msg,
                                        continue;
                                }
                        } else if (optcode == DNS_OPT_EDE) {
-                               ADD_STRING(target, "; EDE:");
+                               ADD_STRING(target, "; EDE");
                                if (optlen >= 2U) {
                                        uint16_t ede;
                                        ede = isc_buffer_getuint16(&optbuf);
@@ -3962,7 +3962,8 @@ dns_message_pseudosectiontotext(dns_message_t *msg,
                                        /* Malformed */
                                        optdata = isc_buffer_current(&optbuf);
                                        snprintf(buf, sizeof(buf),
-                                                " %02x (\"%c\")\n", optdata[0],
+                                                ": %02x (\"%c\")\n",
+                                                optdata[0],
                                                 isprint(optdata[0])
                                                         ? optdata[0]
                                                         : '.');
@@ -4002,10 +4003,15 @@ dns_message_pseudosectiontotext(dns_message_t *msg,
 
                        if (optlen != 0) {
                                int i;
+                               bool utf8ok = false;
                                ADD_STRING(target, ": ");
 
                                optdata = isc_buffer_current(&optbuf);
-                               if (optcode != DNS_OPT_EDE) {
+                               if (optcode == DNS_OPT_EDE) {
+                                       utf8ok = isc_utf8_valid(optdata,
+                                                               optlen);
+                               }
+                               if (!utf8ok) {
                                        for (i = 0; i < optlen; i++) {
                                                const char *sep;
                                                switch (optcode) {
@@ -4064,12 +4070,15 @@ dns_message_pseudosectiontotext(dns_message_t *msg,
                                if (isc_buffer_availablelength(target) < optlen)
                                        return (ISC_R_NOSPACE);
                                for (i = 0; i < optlen; i++) {
-                                       if (isprint(optdata[i]))
-                                               isc_buffer_putmem(target,
-                                                                 &optdata[i],
-                                                                 1);
-                                       else
+                                       if (isprint(optdata[i])) {
+                                               isc_buffer_putmem(
+                                                       target, &optdata[i], 1);
+                                       } else if (utf8ok && optdata[i] > 127) {
+                                               isc_buffer_putmem(
+                                                       target, &optdata[i], 1);
+                                       } else {
                                                isc_buffer_putstr(target, ".");
+                                       }
                                }
                                if (optcode != DNS_OPT_EDE) {
                                        ADD_STRING(target, "\")");