Bug 96 - nsd-xfer cannot handle 8bit domainname correctly
nsd-xfer cannot handle 8bit domainname correctly
Status: RESOLVED FIXED
Product: NSD
Classification: Unclassified
Component: Documentation
2.2.x
All All
: P2 normal
Assigned To: NSD team
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2005-05-02 07:20 CEST by Kazunori Fujiwara
Modified: 2005-05-02 13:36 CEST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kazunori Fujiwara 2005-05-02 07:20:45 CEST
When dumping axfr data to zonefile, nsd-xfer uses dname.c:dname_to_string().
In this function, each character is treated as signed character at line 394.

	char ch = (char) *src++;

At line 401, signed character value ch is sign extended and then,
casted to unsigned. As a result, (unsigned)ch becomes 2^32-1 to -128
(4294967295 to 4294967168).

	snprintf(dst, 5, "\\%03u", (unsigned) ch);

All 8bit (MSB=1) labels are printerd as \429 in generated zone file.

To fix this problem, change ch type to uint8_t.

--- nsd-2.2.1/dname.c	Wed Jan 12 18:28:41 2005
+++ nsd-2.2.1+/dname.c	Mon May  2 12:15:33 2005
@@ -391,14 +391,14 @@
 		size_t j;
 		++src;
 		for (j = 0; j < len; ++j) {
-			char ch = (char) *src++;
+			uint8_t ch = *src++;
 			if (isalnum(ch) || ch == '-' || ch == '_') {
 				*dst++ = ch;
 			} else if (ch == '.' || ch == '\\') {
 				*dst++ = '\\';
 				*dst++ = ch;
 			} else {
-				snprintf(dst, 5, "\\%03u", (unsigned) ch);
+				snprintf(dst, 5, "\\%03u", ch);
 				dst += 4;
 			}
 		}
Comment 1 Erik Rozendaal 2005-05-02 13:36:55 CEST
Patch applied in CVS. This will be part of the 2.3.0 release later this week.