2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 05:57:52 +00:00

Only allow hex or decimal when parsing key flags, not octal.

This commit is contained in:
Brian Wellington 2002-03-17 18:59:43 +00:00
parent 81e302788a
commit d56fa53141

View 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);