static inline isc_result_t fromtext_nsec3param(ARGS_FROMTEXT) { isc_token_t token; unsigned int flags = 0; unsigned char hashalg; REQUIRE(type == dns_rdatatype_nsec3param); UNUSED(type); UNUSED(rdclass); UNUSED(callbacks); UNUSED(origin); UNUSED(options); /* Hash. */ RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); RETTOK(dns_hashalg_fromtext(&hashalg, &token.value.as_textregion)); RETERR(uint8_tobuffer(hashalg, target)); /* Flags. */ RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, ISC_FALSE)); flags = token.value.as_ulong; if (flags > 255U) RETTOK(ISC_R_RANGE); RETERR(uint8_tobuffer(flags, target)); /* Iterations. */ RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, ISC_FALSE)); if (token.value.as_ulong > 0xffffU) RETTOK(ISC_R_RANGE); RETERR(uint16_tobuffer(token.value.as_ulong, target)); /* Salt. */ RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); if (token.value.as_textregion.length > (255*2)) RETTOK(DNS_R_TEXTTOOLONG); if (strcmp(DNS_AS_STR(token), "-") == 0) { RETERR(uint8_tobuffer(0, target)); } else { RETERR(uint8_tobuffer(strlen(DNS_AS_STR(token)) / 2, target)); RETERR(isc_hex_decodestring(DNS_AS_STR(token), target)); } return (ISC_R_SUCCESS); }
static inline isc_result_t fromtext_nsec3(ARGS_FROMTEXT) { isc_token_t token; unsigned int flags; unsigned char hashalg; isc_buffer_t b; unsigned char buf[256]; REQUIRE(type == dns_rdatatype_nsec3); UNUSED(type); UNUSED(rdclass); UNUSED(callbacks); UNUSED(origin); UNUSED(options); /* Hash. */ RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); RETTOK(dns_hashalg_fromtext(&hashalg, &token.value.as_textregion)); RETERR(uint8_tobuffer(hashalg, target)); /* Flags. */ RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, ISC_FALSE)); flags = token.value.as_ulong; if (flags > 255U) RETTOK(ISC_R_RANGE); RETERR(uint8_tobuffer(flags, target)); /* Iterations. */ RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, ISC_FALSE)); if (token.value.as_ulong > 0xffffU) RETTOK(ISC_R_RANGE); RETERR(uint16_tobuffer(token.value.as_ulong, target)); /* salt */ RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); if (token.value.as_textregion.length > (255*2)) RETTOK(DNS_R_TEXTTOOLONG); if (strcmp(DNS_AS_STR(token), "-") == 0) { RETERR(uint8_tobuffer(0, target)); } else { RETERR(uint8_tobuffer(strlen(DNS_AS_STR(token)) / 2, target)); RETERR(isc_hex_decodestring(DNS_AS_STR(token), target)); } /* * Next hash a single base32hex word. */ RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); isc_buffer_init(&b, buf, sizeof(buf)); RETTOK(isc_base32hexnp_decodestring(DNS_AS_STR(token), &b)); if (isc_buffer_usedlength(&b) > 0xffU) RETTOK(ISC_R_RANGE); RETERR(uint8_tobuffer(isc_buffer_usedlength(&b), target)); RETERR(mem_tobuffer(target, &buf, isc_buffer_usedlength(&b))); return (typemap_fromtext(lexer, target, ISC_TRUE)); }