From ca0fc3738525520bb41c49534bf802eb17977707 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 20 Jul 2005 01:50:47 +0000 Subject: [PATCH] 1904. [bug] A escaped character is, potentially, converted to the output character set too early. [RT #14666] --- CHANGES | 3 +++ lib/dns/name.c | 13 +++++++------ lib/dns/rdata.c | 9 ++++++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CHANGES b/CHANGES index 0e2f29ad7b..eac293a630 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +1904. [bug] A escaped character is, potentially, converted to + the output character set too early. [RT #14666] + 1902. [port] Use uintptr_t if available. [RT #14606] 1898. [port] sunos: non blocking i/o support. [RT #14951] diff --git a/lib/dns/name.c b/lib/dns/name.c index 37a5f4e812..ecf1ca06bd 100644 --- a/lib/dns/name.c +++ b/lib/dns/name.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: name.c,v 1.127.2.7.2.11 2004/09/01 05:19:59 marka Exp $ */ +/* $Id: name.c,v 1.127.2.7.2.12 2005/07/20 01:50:46 marka Exp $ */ #include @@ -1305,13 +1305,14 @@ dns_name_totext(dns_name_t *name, isc_boolean_t omit_final_dot, trem--; nlen--; } else { - char buf[5]; if (trem < 4) return (ISC_R_NOSPACE); - snprintf(buf, sizeof(buf), - "\\%03u", c); - memcpy(tdata, buf, 4); - tdata += 4; + *tdata++ = 0x5c; + *tdata++ = 0x30 + + ((c / 100) % 10); + *tdata++ = 0x30 + + ((c / 10) % 10); + *tdata++ = 0x30 + (c % 10); trem -= 4; ndata++; nlen--; diff --git a/lib/dns/rdata.c b/lib/dns/rdata.c index 86b8e8d942..d7512f27be 100644 --- a/lib/dns/rdata.c +++ b/lib/dns/rdata.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rdata.c,v 1.147.2.11.2.18 2005/03/20 22:34:00 marka Exp $ */ +/* $Id: rdata.c,v 1.147.2.11.2.19 2005/07/20 01:50:47 marka Exp $ */ #include #include @@ -986,11 +986,14 @@ txt_totext(isc_region_t *source, isc_buffer_t *target) { if (*sp < 0x20 || *sp >= 0x7f) { if (tl < 4) return (ISC_R_NOSPACE); - snprintf(tp, 5, "\\%03u", *sp++); - tp += 4; + *tp++ = 0x5c; + *tp++ = 0x30 + ((*sp / 100) % 10); + *tp++ = 0x30 + ((*sp / 10) % 10); + *tp++ = 0x30 + (*sp % 10); tl -= 4; continue; } + /* double quote, semi-colon, backslash */ if (*sp == 0x22 || *sp == 0x3b || *sp == 0x5c) { if (tl < 2) return (ISC_R_NOSPACE);