[glibc/release/2.43/master] resolv: Improve formatting of unknown records in ns_sprintrrf

Aurelien Jarno via Glibc-cvs <[email protected]> Wed, 1 Jul 2026 21:37:35 +0000 (GMT)
Newsgroups gmane.comp.lib.glibc.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c46f7b2fd6cdbecaa821f35f7e2f9c989e7a3767

commit c46f7b2fd6cdbecaa821f35f7e2f9c989e7a3767
Author: Florian Weimer <[email protected]>
Date:   Fri Jun 19 18:22:20 2026 +0200

    resolv: Improve formatting of unknown records in ns_sprintrrf
    
    Do not add the "unknown RR type" comment.  After adding the TYPE
    prefix, the number is largely redundant.
    
    Reviewed-by: Carlos O'Donell <[email protected]>
    Reviewed-by: Adhemerval Zanella <[email protected]>
    (cherry picked from commit d58415eb17d457a160af99f9e8ab164404ca151b)

Diff:
---
 resolv/ns_print.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/resolv/ns_print.c b/resolv/ns_print.c
index e75c39eaa8..3d38876483 100644
--- a/resolv/ns_print.c
+++ b/resolv/ns_print.c
@@ -115,7 +115,6 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
 
 	const char *comment;
 	char tmp[100];
-	char errbuf[40];
 	int len, x;
 
 	/*
@@ -590,20 +589,18 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
 		T(addstr(tmp, len, &buf, &buflen));
 		break;
 	    }
-
 	default:
-		snprintf (errbuf, sizeof (errbuf), "unknown RR type %d", type);
-		comment = errbuf;
+		comment = "";
 		goto hexify;
 	}
 	return (buf - obuf);
  formerr:
-	comment = "RR format error";
+	comment = " ; RR format error";
  hexify: {
 	int n, m;
 	char *p;
 
-	len = SPRINTF((tmp, "\\# %u%s\t; %s", (unsigned)(edata - rdata),
+	len = SPRINTF((tmp, "\\# %u%s%s", (unsigned)(edata - rdata),
 		       rdlen != 0U ? " (" : "", comment));
 	T(addstr(tmp, len, &buf, &buflen));
 	while (rdata < edata) {