From d56fa53141ef99613a998796b0858d6840db19f3 Mon Sep 17 00:00:00 2001 From: Brian Wellington Date: Sun, 17 Mar 2002 18:59:43 +0000 Subject: [PATCH] Only allow hex or decimal when parsing key flags, not octal. --- lib/dns/rdata.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/dns/rdata.c b/lib/dns/rdata.c index ce2e8a2e48..edbd7fabb9 100644 --- a/lib/dns/rdata.c +++ b/lib/dns/rdata.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rdata.c,v 1.165 2002/03/17 18:50:21 bwelling Exp $ */ +/* $Id: rdata.c,v 1.166 2002/03/17 18:59:43 bwelling Exp $ */ #include #include @@ -972,7 +972,7 @@ dns_rdatatype_attributes(dns_rdatatype_t type) */ static isc_result_t maybe_numeric(unsigned int *valuep, isc_textregion_t *source, - unsigned int base, unsigned int max) + unsigned int max, isc_boolean_t hex_allowed) { isc_result_t result; isc_uint32_t n; @@ -990,7 +990,9 @@ maybe_numeric(unsigned int *valuep, isc_textregion_t *source, strncpy(buffer, source->base, NUMBERSIZE); INSIST(buffer[source->length] == '\0'); - result = isc_parse_uint32(&n, buffer, base); + result = isc_parse_uint32(&n, buffer, 10); + if (result == ISC_R_BADNUMBER && hex_allowed) + result = isc_parse_uint32(&n, buffer, 16); if (result != ISC_R_SUCCESS) return (result); if (n > max) @@ -1006,7 +1008,7 @@ dns_mnemonic_fromtext(unsigned int *valuep, isc_textregion_t *source, isc_result_t result; int i; - result = maybe_numeric(valuep, source, 10, max); + result = maybe_numeric(valuep, source, max, ISC_FALSE); if (result != ISC_R_BADNUMBER) return (result); @@ -1288,7 +1290,7 @@ dns_keyflags_fromtext(dns_keyflags_t *flagsp, isc_textregion_t *source) char *text, *end; unsigned int value, mask; - result = maybe_numeric(&value, source, 0, 0xffff); + result = maybe_numeric(&value, source, 0xffff, ISC_TRUE); if (result == ISC_R_SUCCESS) { *flagsp = value; return (ISC_R_SUCCESS);