]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Only allow hex or decimal when parsing key flags, not octal.
authorBrian Wellington <source@isc.org>
Sun, 17 Mar 2002 18:59:43 +0000 (18:59 +0000)
committerBrian Wellington <source@isc.org>
Sun, 17 Mar 2002 18:59:43 +0000 (18:59 +0000)
lib/dns/rdata.c

index ce2e8a2e48bb4c1ef2f38d70947fca0eff17b90c..edbd7fabb9ad0be31eb567ab813c8bdc33d88aa1 100644 (file)
@@ -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 <config.h>
 #include <ctype.h>
@@ -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);