diff options
author | Florian Obser <florian@cvs.openbsd.org> | 2020-02-20 18:08:52 +0000 |
---|---|---|
committer | Florian Obser <florian@cvs.openbsd.org> | 2020-02-20 18:08:52 +0000 |
commit | 2e4911c0cef347358c5793261b18050ca03abae8 (patch) | |
tree | c7b1064072e8d65c92cd852bb026f9276d595cdf /usr.bin | |
parent | faae9d14e15359faa73bc4402d283144d04546dc (diff) |
We do not generate DNS records from text representations.
OK millert
Diffstat (limited to 'usr.bin')
81 files changed, 56 insertions, 4397 deletions
diff --git a/usr.bin/dig/lib/dns/gen.c b/usr.bin/dig/lib/dns/gen.c index 2a50ba73194..97e5b04cf64 100644 --- a/usr.bin/dig/lib/dns/gen.c +++ b/usr.bin/dig/lib/dns/gen.c @@ -645,8 +645,6 @@ main(int argc, char **argv) { fputs("\n\n", stdout); - doswitch("FROMTEXTSWITCH", "fromtext", FROMTEXTARGS, - FROMTEXTTYPE, FROMTEXTCLASS, FROMTEXTDEF); doswitch("TOTEXTSWITCH", "totext", TOTEXTARGS, TOTEXTTYPE, TOTEXTCLASS, TOTEXTDEF); doswitch("FROMWIRESWITCH", "fromwire", FROMWIREARGS, diff --git a/usr.bin/dig/lib/dns/include/dns/rdata.h b/usr.bin/dig/lib/dns/include/dns/rdata.h index 720dc637528..b1dec1ca0cd 100644 --- a/usr.bin/dig/lib/dns/include/dns/rdata.h +++ b/usr.bin/dig/lib/dns/include/dns/rdata.h @@ -314,61 +314,6 @@ dns_rdata_towire(dns_rdata_t *rdata, dns_compress_t *cctx, */ isc_result_t -dns_rdata_fromtext(dns_rdata_t *rdata, dns_rdataclass_t rdclass, - dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin, - unsigned int options, - isc_buffer_t *target, dns_rdatacallbacks_t *callbacks); -/*%< - * Convert the textual representation of a DNS rdata into uncompressed wire - * form stored in the target region. Tokens constituting the text of the rdata - * are taken from 'lexer'. - * - * Notes: - *\li Relative domain names in the rdata will have 'origin' appended to them. - * A NULL origin implies "origin == dns_rootname". - * - * - * 'options' - *\li DNS_RDATA_DOWNCASE downcase domain names when they are copied - * into target. - *\li DNS_RDATA_CHECKNAMES perform checknames checks. - *\li DNS_RDATA_CHECKNAMESFAIL fail if the checknames check fail. If - * not set a warning will be issued. - *\li DNS_RDATA_CHECKREVERSE this should set if the owner name ends - * in IP6.ARPA, IP6.INT or IN-ADDR.ARPA. - * - * Requires: - * - *\li 'rdclass' and 'type' are valid. - * - *\li 'lexer' is a valid isc_lex_t. - * - *\li 'target' is a valid region. - * - *\li 'origin' if non NULL it must be absolute. - * - *\li 'callbacks' to be NULL or callbacks->warn and callbacks->error be - * initialized. - * - * Ensures, - * if result is success: - *\li If 'rdata' is not NULL, it is attached to the target. - - *\li The conditions dns_name_fromtext() ensures for names hold - * for all names in the rdata. - - *\li The used space in target is updated. - * - * Result: - *\li Success - *\li Translated result codes from isc_lex_gettoken - *\li Various 'Bad Form' class failures depending on class and type - *\li Bad Form: Input too short - *\li Resource Limit: Not enough space - *\li Resource Limit: Not enough memory - */ - -isc_result_t dns_rdata_totext(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target); /*%< * Convert 'rdata' into text format, storing the result in 'target'. diff --git a/usr.bin/dig/lib/dns/rdata.c b/usr.bin/dig/lib/dns/rdata.c index 345051b3d87..58b7116d5f3 100644 --- a/usr.bin/dig/lib/dns/rdata.c +++ b/usr.bin/dig/lib/dns/rdata.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rdata.c,v 1.8 2020/02/18 18:11:27 florian Exp $ */ +/* $Id: rdata.c,v 1.9 2020/02/20 18:08:51 florian Exp $ */ /*! \file */ @@ -78,11 +78,6 @@ #define DNS_AS_STR(t) ((t).value.as_textregion.base) -#define ARGS_FROMTEXT int rdclass, dns_rdatatype_t type, \ - isc_lex_t *lexer, dns_name_t *origin, \ - unsigned int options, isc_buffer_t *target, \ - dns_rdatacallbacks_t *callbacks - #define ARGS_TOTEXT dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, \ isc_buffer_t *target @@ -128,17 +123,11 @@ static isc_result_t txt_totext(isc_region_t *source, isc_boolean_t quote, isc_buffer_t *target); static isc_result_t -txt_fromtext(isc_textregion_t *source, isc_buffer_t *target); - -static isc_result_t txt_fromwire(isc_buffer_t *source, isc_buffer_t *target); static isc_result_t multitxt_totext(isc_region_t *source, isc_buffer_t *target); -static isc_result_t -multitxt_fromtext(isc_textregion_t *source, isc_buffer_t *target); - static isc_boolean_t name_prefix(dns_name_t *name, dns_name_t *origin, dns_name_t *target); @@ -154,9 +143,6 @@ inet_totext(int af, isc_region_t *src, isc_buffer_t *target); static isc_boolean_t buffer_empty(isc_buffer_t *source); -static void -buffer_fromregion(isc_buffer_t *buffer, isc_region_t *region); - static isc_result_t uint32_tobuffer(uint32_t, isc_buffer_t *target); @@ -184,42 +170,13 @@ uint8_consume_fromregion(isc_region_t *region); static isc_result_t mem_tobuffer(isc_buffer_t *target, void *base, unsigned int length); -static int -hexvalue(char value); - -static int -decvalue(char value); - static isc_result_t btoa_totext(unsigned char *inbuf, int inbuflen, isc_buffer_t *target); static isc_result_t -atob_tobuffer(isc_lex_t *lexer, isc_buffer_t *target); - -static void -default_fromtext_callback(dns_rdatacallbacks_t *callbacks, const char *, ...) - __attribute__((__format__(__printf__, 2, 3))); - -static void -fromtext_error(void (*callback)(dns_rdatacallbacks_t *, const char *, ...), - dns_rdatacallbacks_t *callbacks, const char *name, - unsigned long line, isc_token_t *token, isc_result_t result); - -static void -fromtext_warneof(isc_lex_t *lexer, dns_rdatacallbacks_t *callbacks); - -static isc_result_t rdata_totext(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, isc_buffer_t *target); -static void -warn_badname(dns_name_t *name, isc_lex_t *lexer, - dns_rdatacallbacks_t *callbacks); - -static void -warn_badmx(isc_token_t *token, isc_lex_t *lexer, - dns_rdatacallbacks_t *callbacks); - static uint16_t uint16_consume_fromregion(isc_region_t *region); @@ -228,9 +185,6 @@ unknown_totext(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, isc_buffer_t *target); static inline isc_result_t -generic_fromtext_key(ARGS_FROMTEXT); - -static inline isc_result_t generic_totext_key(ARGS_TOTEXT); static inline isc_result_t @@ -246,9 +200,6 @@ static inline void generic_freestruct_key(ARGS_FREESTRUCT); static isc_result_t -generic_fromtext_txt(ARGS_FROMTEXT); - -static isc_result_t generic_totext_txt(ARGS_TOTEXT); static isc_result_t @@ -270,18 +221,12 @@ static isc_result_t generic_tostruct_ds(ARGS_TOSTRUCT); static isc_result_t -generic_fromtext_ds(ARGS_FROMTEXT); - -static isc_result_t generic_fromwire_ds(ARGS_FROMWIRE); static isc_result_t generic_fromstruct_ds(ARGS_FROMSTRUCT); static isc_result_t -generic_fromtext_tlsa(ARGS_FROMTEXT); - -static isc_result_t generic_totext_tlsa(ARGS_TOTEXT); static isc_result_t @@ -310,85 +255,6 @@ static unsigned char gc_msdcs_offset [] = { 0, 3 }; static dns_name_t const gc_msdcs = DNS_NAME_INITNONABSOLUTE(gc_msdcs_data, gc_msdcs_offset); -/*% - * convert presentation level address to network order binary form. - * \return - * 1 if `src' is a valid [RFC1884 2.2] address, else 0. - * \note - * (1) does not touch `dst' unless it's returning 1. - */ -static inline int -locator_pton(const char *src, unsigned char *dst) { - static const char xdigits_l[] = "0123456789abcdef", - xdigits_u[] = "0123456789ABCDEF"; - unsigned char tmp[NS_LOCATORSZ]; - unsigned char *tp = tmp, *endp; - const char *xdigits; - int ch, seen_xdigits; - unsigned int val; - - memset(tp, '\0', NS_LOCATORSZ); - endp = tp + NS_LOCATORSZ; - seen_xdigits = 0; - val = 0; - while ((ch = *src++) != '\0') { - const char *pch; - - pch = strchr((xdigits = xdigits_l), ch); - if (pch == NULL) - pch = strchr((xdigits = xdigits_u), ch); - if (pch != NULL) { - val <<= 4; - val |= (pch - xdigits); - if (++seen_xdigits > 4) - return (0); - continue; - } - if (ch == ':') { - if (!seen_xdigits) - return (0); - if (tp + NS_INT16SZ > endp) - return (0); - *tp++ = (unsigned char) (val >> 8) & 0xff; - *tp++ = (unsigned char) val & 0xff; - seen_xdigits = 0; - val = 0; - continue; - } - return (0); - } - if (seen_xdigits) { - if (tp + NS_INT16SZ > endp) - return (0); - *tp++ = (unsigned char) (val >> 8) & 0xff; - *tp++ = (unsigned char) val & 0xff; - } - if (tp != endp) - return (0); - memmove(dst, tmp, NS_LOCATORSZ); - return (1); -} - -static inline int -getquad(const void *src, struct in_addr *dst, - isc_lex_t *lexer, dns_rdatacallbacks_t *callbacks) -{ - int result; - struct in_addr tmp; - - result = inet_aton(src, dst); - if (result == 1 && callbacks != NULL && - inet_pton(AF_INET, src, &tmp) != 1) { - const char *name = isc_lex_getsourcename(lexer); - if (name == NULL) - name = "UNKNOWN"; - (*callbacks->warn)(callbacks, "%s:%lu: \"%s\" " - "is not a decimal dotted quad", name, - isc_lex_getsourceline(lexer), src); - } - return (result); -} - static inline isc_result_t name_duporclone(dns_name_t *source, dns_name_t *target) { @@ -407,70 +273,6 @@ mem_maybedup(void *source, size_t length) { } static inline isc_result_t -typemap_fromtext(isc_lex_t *lexer, isc_buffer_t *target, - isc_boolean_t allow_empty) -{ - isc_token_t token; - unsigned char bm[8*1024]; /* 64k bits */ - dns_rdatatype_t covered, max_used; - int octet; - unsigned int max_octet, newend, end; - int window; - isc_boolean_t first = ISC_TRUE; - - max_used = 0; - bm[0] = 0; - end = 0; - - do { - RETERR(isc_lex_getmastertoken(lexer, &token, - isc_tokentype_string, ISC_TRUE)); - if (token.type != isc_tokentype_string) - break; - RETTOK(dns_rdatatype_fromtext(&covered, - &token.value.as_textregion)); - if (covered > max_used) { - newend = covered / 8; - if (newend > end) { - memset(&bm[end + 1], 0, newend - end); - end = newend; - } - max_used = covered; - } - bm[covered/8] |= (0x80>>(covered%8)); - first = ISC_FALSE; - } while (1); - isc_lex_ungettoken(lexer, &token); - if (!allow_empty && first) - return (DNS_R_FORMERR); - - for (window = 0; window < 256 ; window++) { - if (max_used < window * 256) - break; - - max_octet = max_used - (window * 256); - if (max_octet >= 256) - max_octet = 31; - else - max_octet /= 8; - - /* - * Find if we have a type in this window. - */ - for (octet = max_octet; octet >= 0; octet--) { - if (bm[window * 32 + octet] != 0) - break; - } - if (octet < 0) - continue; - RETERR(uint8_tobuffer(window, target)); - RETERR(uint8_tobuffer(octet + 1, target)); - RETERR(mem_tobuffer(target, &bm[window * 32], octet + 1)); - } - return (ISC_R_SUCCESS); -} - -static inline isc_result_t typemap_totext(isc_region_t *sr, dns_rdata_textctx_t *tctx, isc_buffer_t *target) { @@ -560,7 +362,6 @@ typemap_test(isc_region_t *sr, isc_boolean_t allow_empty) { return (ISC_R_SUCCESS); } -static const char hexdigits[] = "0123456789abcdef"; static const char decdigits[] = "0123456789"; #include "code.h" @@ -800,193 +601,6 @@ dns_rdata_towire(dns_rdata_t *rdata, dns_compress_t *cctx, return (result); } -/* - * If the binary data in 'src' is valid uncompressed wire format - * rdata of class 'rdclass' and type 'type', return ISC_R_SUCCESS - * and copy the validated rdata to 'dest'. Otherwise return an error. - */ -static isc_result_t -rdata_validate(isc_buffer_t *src, isc_buffer_t *dest, dns_rdataclass_t rdclass, - dns_rdatatype_t type) -{ - dns_decompress_t dctx; - isc_result_t result; - - dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_NONE); - isc_buffer_setactive(src, isc_buffer_usedlength(src)); - result = dns_rdata_fromwire(NULL, rdclass, type, src, &dctx, 0, dest); - return (result); -} - -static isc_result_t -unknown_fromtext(dns_rdataclass_t rdclass, dns_rdatatype_t type, - isc_lex_t *lexer, isc_buffer_t *target) -{ - isc_result_t result; - isc_buffer_t *buf = NULL; - isc_token_t token; - - if (type == 0 || dns_rdatatype_ismeta(type)) - return (DNS_R_METATYPE); - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - if (token.value.as_ulong > 65535U) - return (ISC_R_RANGE); - result = isc_buffer_allocate(&buf, token.value.as_ulong); - if (result != ISC_R_SUCCESS) - return (result); - - result = isc_hex_tobuffer(lexer, buf, - (unsigned int)token.value.as_ulong); - if (result != ISC_R_SUCCESS) - goto failure; - if (isc_buffer_usedlength(buf) != token.value.as_ulong) { - result = ISC_R_UNEXPECTEDEND; - goto failure; - } - - if (dns_rdatatype_isknown(type)) { - result = rdata_validate(buf, target, rdclass, type); - } else { - isc_region_t r; - isc_buffer_usedregion(buf, &r); - result = isc_buffer_copyregion(target, &r); - } - if (result != ISC_R_SUCCESS) - goto failure; - - isc_buffer_free(&buf); - return (ISC_R_SUCCESS); - - failure: - isc_buffer_free(&buf); - return (result); -} - -isc_result_t -dns_rdata_fromtext(dns_rdata_t *rdata, dns_rdataclass_t rdclass, - dns_rdatatype_t type, isc_lex_t *lexer, - dns_name_t *origin, unsigned int options, - isc_buffer_t *target, dns_rdatacallbacks_t *callbacks) -{ - isc_result_t result = ISC_R_NOTIMPLEMENTED; - isc_region_t region; - isc_buffer_t st; - isc_token_t token; - unsigned int lexoptions = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF | - ISC_LEXOPT_DNSMULTILINE | ISC_LEXOPT_ESCAPE; - char *name; - unsigned long line; - void (*callback)(dns_rdatacallbacks_t *, const char *, ...); - isc_result_t tresult; - unsigned int length; - isc_boolean_t unknown; - - REQUIRE(origin == NULL || dns_name_isabsolute(origin) == ISC_TRUE); - if (rdata != NULL) { - REQUIRE(DNS_RDATA_INITIALIZED(rdata)); - REQUIRE(DNS_RDATA_VALIDFLAGS(rdata)); - } - if (callbacks != NULL) { - REQUIRE(callbacks->warn != NULL); - REQUIRE(callbacks->error != NULL); - } - - st = *target; - - if (callbacks != NULL) - callback = callbacks->error; - else - callback = default_fromtext_callback; - - result = isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring, - ISC_FALSE); - if (result != ISC_R_SUCCESS) { - name = isc_lex_getsourcename(lexer); - line = isc_lex_getsourceline(lexer); - fromtext_error(callback, callbacks, name, line, NULL, result); - return (result); - } - - unknown = ISC_FALSE; - if (token.type == isc_tokentype_string && - strcmp(DNS_AS_STR(token), "\\#") == 0) { - /* - * If this is a TXT record '\#' could be a escaped '#'. - * Look to see if the next token is a number and if so - * treat it as a unknown record format. - */ - if (type == dns_rdatatype_txt) { - result = isc_lex_getmastertoken(lexer, &token, - isc_tokentype_number, - ISC_FALSE); - if (result == ISC_R_SUCCESS) - isc_lex_ungettoken(lexer, &token); - } - - if (result == ISC_R_SUCCESS) { - unknown = ISC_TRUE; - result = unknown_fromtext(rdclass, type, lexer, target); - } else - options |= DNS_RDATA_UNKNOWNESCAPE; - } else - isc_lex_ungettoken(lexer, &token); - - if (!unknown) - FROMTEXTSWITCH - - /* - * Consume to end of line / file. - * If not at end of line initially set error code. - * Call callback via fromtext_error once if there was an error. - */ - do { - name = isc_lex_getsourcename(lexer); - line = isc_lex_getsourceline(lexer); - tresult = isc_lex_gettoken(lexer, lexoptions, &token); - if (tresult != ISC_R_SUCCESS) { - if (result == ISC_R_SUCCESS) - result = tresult; - if (callback != NULL) - fromtext_error(callback, callbacks, name, - line, NULL, result); - break; - } else if (token.type != isc_tokentype_eol && - token.type != isc_tokentype_eof) { - if (result == ISC_R_SUCCESS) - result = DNS_R_EXTRATOKEN; - if (callback != NULL) { - fromtext_error(callback, callbacks, name, - line, &token, result); - callback = NULL; - } - } else if (result != ISC_R_SUCCESS && callback != NULL) { - fromtext_error(callback, callbacks, name, line, - &token, result); - break; - } else { - if (token.type == isc_tokentype_eof) - fromtext_warneof(lexer, callbacks); - break; - } - } while (1); - - length = isc_buffer_usedlength(target) - isc_buffer_usedlength(&st); - if (result == ISC_R_SUCCESS && length > DNS_RDATA_MAXLENGTH) - result = ISC_R_NOSPACE; - - if (rdata != NULL && result == ISC_R_SUCCESS) { - region.base = isc_buffer_used(&st); - region.length = length; - dns_rdata_fromregion(rdata, rdclass, type, ®ion); - } - if (result != ISC_R_SUCCESS) { - *target = st; - } - return (result); -} - static isc_result_t unknown_totext(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, isc_buffer_t *target) @@ -1350,72 +964,6 @@ txt_totext(isc_region_t *source, isc_boolean_t quote, isc_buffer_t *target) { } static isc_result_t -txt_fromtext(isc_textregion_t *source, isc_buffer_t *target) { - isc_region_t tregion; - isc_boolean_t escape; - unsigned int n, nrem; - char *s; - unsigned char *t; - int d; - int c; - - isc_buffer_availableregion(target, &tregion); - s = source->base; - n = source->length; - t = tregion.base; - nrem = tregion.length; - escape = ISC_FALSE; - if (nrem < 1) - return (ISC_R_NOSPACE); - /* - * Length byte. - */ - nrem--; - t++; - /* - * Maximum text string length. - */ - if (nrem > 255) - nrem = 255; - while (n-- != 0) { - c = (*s++) & 0xff; - if (escape && (d = decvalue((char)c)) != -1) { - c = d; - if (n == 0) - return (DNS_R_SYNTAX); - n--; - if ((d = decvalue(*s++)) != -1) - c = c * 10 + d; - else - return (DNS_R_SYNTAX); - if (n == 0) - return (DNS_R_SYNTAX); - n--; - if ((d = decvalue(*s++)) != -1) - c = c * 10 + d; - else - return (DNS_R_SYNTAX); - if (c > 255) - return (DNS_R_SYNTAX); - } else if (!escape && c == '\\') { - escape = ISC_TRUE; - continue; - } - escape = ISC_FALSE; - if (nrem == 0) - return ((tregion.length <= 256U) ? - ISC_R_NOSPACE : DNS_R_SYNTAX); - *t++ = c; - nrem--; - } - if (escape) - return (DNS_R_SYNTAX); - *tregion.base = (unsigned char)(t - tregion.base - 1); - isc_buffer_add(target, *tregion.base + 1); - return (ISC_R_SUCCESS); -} - -static isc_result_t txt_fromwire(isc_buffer_t *source, isc_buffer_t *target) { unsigned int n; isc_region_t sregion; @@ -1498,66 +1046,6 @@ multitxt_totext(isc_region_t *source, isc_buffer_t *target) { return (ISC_R_SUCCESS); } -static isc_result_t -multitxt_fromtext(isc_textregion_t *source, isc_buffer_t *target) { - isc_region_t tregion; - isc_boolean_t escape; - unsigned int n, nrem; - char *s; - unsigned char *t0, *t; - int d; - int c; - - s = source->base; - n = source->length; - escape = ISC_FALSE; - - do { - isc_buffer_availableregion(target, &tregion); - t0 = t = tregion.base; - nrem = tregion.length; - if (nrem < 1) - return (ISC_R_NOSPACE); - - while (n != 0) { - --n; - c = (*s++) & 0xff; - if (escape && (d = decvalue((char)c)) != -1) { - c = d; - if (n == 0) - return (DNS_R_SYNTAX); - n--; - if ((d = decvalue(*s++)) != -1) - c = c * 10 + d; - else - return (DNS_R_SYNTAX); - if (n == 0) - return (DNS_R_SYNTAX); - n--; - if ((d = decvalue(*s++)) != -1) - c = c * 10 + d; - else - return (DNS_R_SYNTAX); - if (c > 255) - return (DNS_R_SYNTAX); - } else if (!escape && c == '\\') { - escape = ISC_TRUE; - continue; - } - escape = ISC_FALSE; - *t++ = c; - nrem--; - if (nrem == 0) - break; - } - if (escape) - return (DNS_R_SYNTAX); - - isc_buffer_add(target, (unsigned int)(t - t0)); - } while (n != 0); - return (ISC_R_SUCCESS); -} - static isc_boolean_t name_prefix(dns_name_t *name, dns_name_t *origin, dns_name_t *target) { int l1, l2; @@ -1624,13 +1112,6 @@ buffer_empty(isc_buffer_t *source) { return((source->current == source->active) ? ISC_TRUE : ISC_FALSE); } -static void -buffer_fromregion(isc_buffer_t *buffer, isc_region_t *region) { - isc_buffer_init(buffer, region->base, region->length); - isc_buffer_add(buffer, region->length); - isc_buffer_setactive(buffer, region->length); -} - static isc_result_t uint32_tobuffer(uint32_t value, isc_buffer_t *target) { isc_region_t region; @@ -1735,37 +1216,6 @@ mem_tobuffer(isc_buffer_t *target, void *base, unsigned int length) { return (ISC_R_SUCCESS); } -static int -hexvalue(char value) { - const char *s; - unsigned char c; - - c = (unsigned char)value; - - if (!isascii(c)) - return (-1); - if (isupper(c)) - c = tolower(c); - if ((s = strchr(hexdigits, c)) == NULL) - return (-1); - return (int)(s - hexdigits); -} - -static int -decvalue(char value) { - const char *s; - - /* - * isascii() is valid for full range of int values, no need to - * mask or cast. - */ - if (!isascii(value)) - return (-1); - if ((s = strchr(decdigits, value)) == NULL) - return (-1); - return (int)(s - decdigits); -} - static const char atob_digits[86] = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`" \ "abcdefghijklmnopqrstu"; @@ -1800,153 +1250,9 @@ struct state { #define times85(x) ((((((x<<2)+x)<<2)+x)<<2)+x) -static isc_result_t byte_atob(int c, isc_buffer_t *target, - struct state *state); -static isc_result_t putbyte(int c, isc_buffer_t *, struct state *state); static isc_result_t byte_btoa(int c, isc_buffer_t *, struct state *state); /* - * Decode ASCII-encoded byte c into binary representation and - * place into *bufp, advancing bufp. - */ -static isc_result_t -byte_atob(int c, isc_buffer_t *target, struct state *state) { - const char *s; - if (c == 'z') { - if (bcount != 0) - return(DNS_R_SYNTAX); - else { - RETERR(putbyte(0, target, state)); - RETERR(putbyte(0, target, state)); - RETERR(putbyte(0, target, state)); - RETERR(putbyte(0, target, state)); - } - } else if ((s = strchr(atob_digits, c)) != NULL) { - if (bcount == 0) { - word = (int32_t)(s - atob_digits); - ++bcount; - } else if (bcount < 4) { - word = times85(word); - word += (int32_t)(s - atob_digits); - ++bcount; - } else { - word = times85(word); - word += (int32_t)(s - atob_digits); - RETERR(putbyte((word >> 24) & 0xff, target, state)); - RETERR(putbyte((word >> 16) & 0xff, target, state)); - RETERR(putbyte((word >> 8) & 0xff, target, state)); - RETERR(putbyte(word & 0xff, target, state)); - word = 0; - bcount = 0; - } - } else - return(DNS_R_SYNTAX); - return(ISC_R_SUCCESS); -} - -/* - * Compute checksum info and place c into target. - */ -static isc_result_t -putbyte(int c, isc_buffer_t *target, struct state *state) { - isc_region_t tr; - - Ceor ^= c; - Csum += c; - Csum += 1; - if ((Crot & 0x80000000)) { - Crot <<= 1; - Crot += 1; - } else { - Crot <<= 1; - } - Crot += c; - isc_buffer_availableregion(target, &tr); - if (tr.length < 1) - return (ISC_R_NOSPACE); - tr.base[0] = c; - isc_buffer_add(target, 1); - return (ISC_R_SUCCESS); -} - -/* - * Read the ASCII-encoded data from inbuf, of length inbuflen, and convert - * it into T_UNSPEC (binary data) in outbuf, not to exceed outbuflen bytes; - * outbuflen must be divisible by 4. (Note: this is because outbuf is filled - * in 4 bytes at a time. If the actual data doesn't end on an even 4-byte - * boundary, there will be no problem...it will be padded with 0 bytes, and - * numbytes will indicate the correct number of bytes. The main point is - * that since the buffer is filled in 4 bytes at a time, even if there is - * not a full 4 bytes of data at the end, there has to be room to 0-pad the - * data, so the buffer must be of size divisible by 4). Place the number of - * output bytes in numbytes, and return a failure/success status. - */ - -static isc_result_t -atob_tobuffer(isc_lex_t *lexer, isc_buffer_t *target) { - long oeor, osum, orot; - struct state statebuf, *state= &statebuf; - isc_token_t token; - char c; - char *e; - - Ceor = Csum = Crot = word = bcount = 0; - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - while (token.value.as_textregion.length != 0) { - if ((c = token.value.as_textregion.base[0]) == 'x') { - break; - } else - RETERR(byte_atob(c, target, state)); - isc_textregion_consume(&token.value.as_textregion, 1); - } - - /* - * Number of bytes. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - if ((token.value.as_ulong % 4) != 0U) { - unsigned long padding = 4 - (token.value.as_ulong % 4); - if (isc_buffer_usedlength(target) < padding) - return (DNS_R_SYNTAX); - isc_buffer_subtract(target, padding); - } - - /* - * Checksum. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - oeor = strtol(DNS_AS_STR(token), &e, 16); - if (*e != 0) - return (DNS_R_SYNTAX); - - /* - * Checksum. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - osum = strtol(DNS_AS_STR(token), &e, 16); - if (*e != 0) - return (DNS_R_SYNTAX); - - /* - * Checksum. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - orot = strtol(DNS_AS_STR(token), &e, 16); - if (*e != 0) - return (DNS_R_SYNTAX); - - if ((oeor != Ceor) || (osum != Csum) || (orot != Crot)) - return(DNS_R_BADCKSUM); - return (ISC_R_SUCCESS); -} - -/* * Encode binary byte c into ASCII representation and place into *bufp, * advancing bufp. */ @@ -2037,112 +1343,6 @@ btoa_totext(unsigned char *inbuf, int inbuflen, isc_buffer_t *target) { return (str_totext(buf, target)); } - -static void -default_fromtext_callback(dns_rdatacallbacks_t *callbacks, const char *fmt, - ...) -{ - va_list ap; - - UNUSED(callbacks); - - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); - fprintf(stderr, "\n"); -} - -static void -fromtext_warneof(isc_lex_t *lexer, dns_rdatacallbacks_t *callbacks) { - if (isc_lex_isfile(lexer) && callbacks != NULL) { - const char *name = isc_lex_getsourcename(lexer); - if (name == NULL) - name = "UNKNOWN"; - (*callbacks->warn)(callbacks, - "%s:%lu: file does not end with newline", - name, isc_lex_getsourceline(lexer)); - } -} - -static void -warn_badmx(isc_token_t *token, isc_lex_t *lexer, - dns_rdatacallbacks_t *callbacks) -{ - const char *file; - unsigned long line; - - if (lexer != NULL) { - file = isc_lex_getsourcename(lexer); - line = isc_lex_getsourceline(lexer); - (*callbacks->warn)(callbacks, "%s:%u: warning: '%s': %s", - file, line, DNS_AS_STR(*token), - dns_result_totext(DNS_R_MXISADDRESS)); - } -} - -static void -warn_badname(dns_name_t *name, isc_lex_t *lexer, - dns_rdatacallbacks_t *callbacks) -{ - const char *file; - unsigned long line; - char namebuf[DNS_NAME_FORMATSIZE]; - - if (lexer != NULL) { - file = isc_lex_getsourcename(lexer); - line = isc_lex_getsourceline(lexer); - dns_name_format(name, namebuf, sizeof(namebuf)); - (*callbacks->warn)(callbacks, "%s:%u: warning: %s: %s", - file, line, namebuf, - dns_result_totext(DNS_R_BADNAME)); - } -} - -static void -fromtext_error(void (*callback)(dns_rdatacallbacks_t *, const char *, ...), - dns_rdatacallbacks_t *callbacks, const char *name, - unsigned long line, isc_token_t *token, isc_result_t result) -{ - if (name == NULL) - name = "UNKNOWN"; - - if (token != NULL) { - switch (token->type) { - case isc_tokentype_eol: - (*callback)(callbacks, "%s: %s:%lu: near eol: %s", - "dns_rdata_fromtext", name, line, - dns_result_totext(result)); - break; - case isc_tokentype_eof: - (*callback)(callbacks, "%s: %s:%lu: near eof: %s", - "dns_rdata_fromtext", name, line, - dns_result_totext(result)); - break; - case isc_tokentype_number: - (*callback)(callbacks, "%s: %s:%lu: near %lu: %s", - "dns_rdata_fromtext", name, line, - token->value.as_ulong, - dns_result_totext(result)); - break; - case isc_tokentype_string: - case isc_tokentype_qstring: - (*callback)(callbacks, "%s: %s:%lu: near '%s': %s", - "dns_rdata_fromtext", name, line, - DNS_AS_STR(*token), - dns_result_totext(result)); - break; - default: - (*callback)(callbacks, "%s: %s:%lu: %s", - "dns_rdata_fromtext", name, line, - dns_result_totext(result)); - break; - } - } else { - (*callback)(callbacks, "dns_rdata_fromtext: %s:%lu: %s", - name, line, dns_result_totext(result)); - } -} - dns_rdatatype_t dns_rdata_covers(dns_rdata_t *rdata) { if (rdata->type == dns_rdatatype_rrsig) diff --git a/usr.bin/dig/lib/dns/rdata/any_255/tsig_250.c b/usr.bin/dig/lib/dns/rdata/any_255/tsig_250.c index 0287ebd8dc7..3a8dc03a8e8 100644 --- a/usr.bin/dig/lib/dns/rdata/any_255/tsig_250.c +++ b/usr.bin/dig/lib/dns/rdata/any_255/tsig_250.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: tsig_250.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: tsig_250.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* Reviewed: Thu Mar 16 13:39:43 PST 2000 by gson */ @@ -25,111 +25,6 @@ (DNS_RDATATYPEATTR_META | DNS_RDATATYPEATTR_NOTQUESTION) static inline isc_result_t -fromtext_any_tsig(ARGS_FROMTEXT) { - isc_token_t token; - dns_name_t name; - uint64_t sigtime; - isc_buffer_t buffer; - dns_rcode_t rcode; - long i; - char *e; - - REQUIRE(type == dns_rdatatype_tsig); - REQUIRE(rdclass == dns_rdataclass_any); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - /* - * Algorithm Name. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - if (origin == NULL) - origin = dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); - - /* - * Time Signed: 48 bits. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - sigtime = strtoull(DNS_AS_STR(token), &e, 10); - if (*e != 0) - RETTOK(DNS_R_SYNTAX); - if ((sigtime >> 48) != 0) - RETTOK(ISC_R_RANGE); - RETERR(uint16_tobuffer((uint16_t)(sigtime >> 32), target)); - RETERR(uint32_tobuffer((uint32_t)(sigtime & 0xffffffffU), target)); - - /* - * Fudge. - */ - 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)); - - /* - * Signature Size. - */ - 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)); - - /* - * Signature. - */ - RETERR(isc_base64_tobuffer(lexer, target, (int)token.value.as_ulong)); - - /* - * Original ID. - */ - 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)); - - /* - * Error. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - if (dns_tsigrcode_fromtext(&rcode, &token.value.as_textregion) - != ISC_R_SUCCESS) - { - i = strtol(DNS_AS_STR(token), &e, 10); - if (*e != 0) - RETTOK(DNS_R_UNKNOWN); - if (i < 0 || i > 0xffff) - RETTOK(ISC_R_RANGE); - rcode = (dns_rcode_t)i; - } - RETERR(uint16_tobuffer(rcode, target)); - - /* - * Other Len. - */ - 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)); - - /* - * Other Data. - */ - return (isc_base64_tobuffer(lexer, target, (int)token.value.as_ulong)); -} - -static inline isc_result_t totext_any_tsig(ARGS_TOTEXT) { isc_region_t sr; isc_region_t sigr; diff --git a/usr.bin/dig/lib/dns/rdata/ch_3/a_1.c b/usr.bin/dig/lib/dns/rdata/ch_3/a_1.c index 191b0059b1e..dc889faa250 100644 --- a/usr.bin/dig/lib/dns/rdata/ch_3/a_1.c +++ b/usr.bin/dig/lib/dns/rdata/ch_3/a_1.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: a_1.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: a_1.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* by Bjorn.Victor@it.uu.se, 2005-05-07 */ /* Based on generic/soa_6.c and generic/mx_15.c */ @@ -27,44 +27,6 @@ #define RRTYPE_A_ATTRIBUTES (0) static inline isc_result_t -fromtext_ch_a(ARGS_FROMTEXT) { - isc_token_t token; - dns_name_t name; - isc_buffer_t buffer; - - REQUIRE(type == dns_rdatatype_a); - REQUIRE(rdclass == dns_rdataclass_ch); /* 3 */ - - UNUSED(type); - UNUSED(callbacks); - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - - /* get domain name */ - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - if (origin == NULL) - origin = dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); - if ((options & DNS_RDATA_CHECKNAMES) != 0 && - (options & DNS_RDATA_CHECKREVERSE) != 0) { - isc_boolean_t ok; - ok = dns_name_ishostname(&name, ISC_FALSE); - if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0) - RETTOK(DNS_R_BADNAME); - if (!ok && callbacks != NULL) - warn_badname(&name, lexer, callbacks); - } - - /* 16-bit octal address */ - RETERR(isc_lex_getoctaltoken(lexer, &token, ISC_FALSE)); - if (token.value.as_ulong > 0xffffU) - RETTOK(ISC_R_RANGE); - return (uint16_tobuffer(token.value.as_ulong, target)); -} - -static inline isc_result_t totext_ch_a(ARGS_TOTEXT) { isc_region_t region; dns_name_t name; diff --git a/usr.bin/dig/lib/dns/rdata/generic/afsdb_18.c b/usr.bin/dig/lib/dns/rdata/generic/afsdb_18.c index 77a27d7a3f7..f1bcabeaaf7 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/afsdb_18.c +++ b/usr.bin/dig/lib/dns/rdata/generic/afsdb_18.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: afsdb_18.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: afsdb_18.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* Reviewed: Wed Mar 15 14:59:00 PST 2000 by explorer */ @@ -26,48 +26,6 @@ #define RRTYPE_AFSDB_ATTRIBUTES (0) static inline isc_result_t -fromtext_afsdb(ARGS_FROMTEXT) { - isc_token_t token; - isc_buffer_t buffer; - dns_name_t name; - isc_boolean_t ok; - - REQUIRE(type == dns_rdatatype_afsdb); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - /* - * Subtype. - */ - 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)); - - /* - * Hostname. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - if (origin == NULL) - origin = dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); - ok = ISC_TRUE; - if ((options & DNS_RDATA_CHECKNAMES) != 0) - ok = dns_name_ishostname(&name, ISC_FALSE); - if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0) - RETTOK(DNS_R_BADNAME); - if (!ok && callbacks != NULL) - warn_badname(&name, lexer, callbacks); - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_afsdb(ARGS_TOTEXT) { dns_name_t name; dns_name_t prefix; diff --git a/usr.bin/dig/lib/dns/rdata/generic/avc_258.c b/usr.bin/dig/lib/dns/rdata/generic/avc_258.c index 36fc17be290..627a4ba9754 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/avc_258.c +++ b/usr.bin/dig/lib/dns/rdata/generic/avc_258.c @@ -20,21 +20,6 @@ #define RRTYPE_AVC_ATTRIBUTES (0) static inline isc_result_t -fromtext_avc(ARGS_FROMTEXT) { - - REQUIRE(type == dns_rdatatype_avc); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - UNUSED(callbacks); - - return (generic_fromtext_txt(rdclass, type, lexer, origin, options, - target, callbacks)); -} - -static inline isc_result_t totext_avc(ARGS_TOTEXT) { UNUSED(tctx); diff --git a/usr.bin/dig/lib/dns/rdata/generic/caa_257.c b/usr.bin/dig/lib/dns/rdata/generic/caa_257.c index 7f2aef0ac70..5b71d897ec9 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/caa_257.c +++ b/usr.bin/dig/lib/dns/rdata/generic/caa_257.c @@ -39,53 +39,6 @@ static unsigned char const alphanumeric[256] = { }; static inline isc_result_t -fromtext_caa(ARGS_FROMTEXT) { - isc_token_t token; - isc_textregion_t tr; - uint8_t flags; - unsigned int i; - - REQUIRE(type == dns_rdatatype_caa); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - UNUSED(callbacks); - - /* Flags. */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - if (token.value.as_ulong > 255U) - RETTOK(ISC_R_RANGE); - flags = (uint8_t)(token.value.as_ulong & 255U); - RETERR(uint8_tobuffer(flags, target)); - - /* - * Tag - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - tr = token.value.as_textregion; - for (i = 0; i < tr.length; i++) - if (!alphanumeric[(unsigned char) tr.base[i]]) - RETTOK(DNS_R_SYNTAX); - RETERR(uint8_tobuffer(tr.length, target)); - RETERR(mem_tobuffer(target, tr.base, tr.length)); - - /* - * Value - */ - RETERR(isc_lex_getmastertoken(lexer, &token, - isc_tokentype_qstring, ISC_FALSE)); - if (token.type != isc_tokentype_qstring && - token.type != isc_tokentype_string) - RETERR(DNS_R_SYNTAX); - RETERR(multitxt_fromtext(&token.value.as_textregion, target)); - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_caa(ARGS_TOTEXT) { isc_region_t region; uint8_t flags; diff --git a/usr.bin/dig/lib/dns/rdata/generic/cdnskey_60.c b/usr.bin/dig/lib/dns/rdata/generic/cdnskey_60.c index 06d2cf5356f..594d065a9ad 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/cdnskey_60.c +++ b/usr.bin/dig/lib/dns/rdata/generic/cdnskey_60.c @@ -24,15 +24,6 @@ #define RRTYPE_CDNSKEY_ATTRIBUTES 0 static inline isc_result_t -fromtext_cdnskey(ARGS_FROMTEXT) { - - REQUIRE(type == dns_rdatatype_cdnskey); - - return (generic_fromtext_key(rdclass, type, lexer, origin, - options, target, callbacks)); -} - -static inline isc_result_t totext_cdnskey(ARGS_TOTEXT) { REQUIRE(rdata != NULL); diff --git a/usr.bin/dig/lib/dns/rdata/generic/cds_59.c b/usr.bin/dig/lib/dns/rdata/generic/cds_59.c index 76c6b34b63f..26bdc211302 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/cds_59.c +++ b/usr.bin/dig/lib/dns/rdata/generic/cds_59.c @@ -27,15 +27,6 @@ #include <dns/ds.h> static inline isc_result_t -fromtext_cds(ARGS_FROMTEXT) { - - REQUIRE(type == dns_rdatatype_cds); - - return (generic_fromtext_ds(rdclass, type, lexer, origin, options, - target, callbacks)); -} - -static inline isc_result_t totext_cds(ARGS_TOTEXT) { REQUIRE(rdata->type == dns_rdatatype_cds); diff --git a/usr.bin/dig/lib/dns/rdata/generic/cert_37.c b/usr.bin/dig/lib/dns/rdata/generic/cert_37.c index 21495fc22e9..95356f07929 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/cert_37.c +++ b/usr.bin/dig/lib/dns/rdata/generic/cert_37.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: cert_37.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: cert_37.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* Reviewed: Wed Mar 15 21:14:32 EST 2000 by tale */ @@ -26,48 +26,6 @@ #define RRTYPE_CERT_ATTRIBUTES (0) static inline isc_result_t -fromtext_cert(ARGS_FROMTEXT) { - isc_token_t token; - dns_secalg_t secalg; - dns_cert_t cert; - - REQUIRE(type == dns_rdatatype_cert); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - UNUSED(callbacks); - - /* - * Cert type. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - RETTOK(dns_cert_fromtext(&cert, &token.value.as_textregion)); - RETERR(uint16_tobuffer(cert, target)); - - /* - * Key tag. - */ - 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)); - - /* - * Algorithm. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - RETTOK(dns_secalg_fromtext(&secalg, &token.value.as_textregion)); - RETERR(mem_tobuffer(target, &secalg, 1)); - - return (isc_base64_tobuffer(lexer, target, -1)); -} - -static inline isc_result_t totext_cert(ARGS_TOTEXT) { isc_region_t sr; char buf[sizeof("64000 ")]; diff --git a/usr.bin/dig/lib/dns/rdata/generic/cname_5.c b/usr.bin/dig/lib/dns/rdata/generic/cname_5.c index 3f3d3312ffc..76d79368c68 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/cname_5.c +++ b/usr.bin/dig/lib/dns/rdata/generic/cname_5.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: cname_5.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: cname_5.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* reviewed: Wed Mar 15 16:48:45 PST 2000 by brister */ @@ -25,29 +25,6 @@ (DNS_RDATATYPEATTR_EXCLUSIVE | DNS_RDATATYPEATTR_SINGLETON) static inline isc_result_t -fromtext_cname(ARGS_FROMTEXT) { - isc_token_t token; - dns_name_t name; - isc_buffer_t buffer; - - REQUIRE(type == dns_rdatatype_cname); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - if (origin == NULL) - origin = dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_cname(ARGS_TOTEXT) { isc_region_t region; dns_name_t name; diff --git a/usr.bin/dig/lib/dns/rdata/generic/csync_62.c b/usr.bin/dig/lib/dns/rdata/generic/csync_62.c index 928a8d9ea2b..6a49c919081 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/csync_62.c +++ b/usr.bin/dig/lib/dns/rdata/generic/csync_62.c @@ -22,34 +22,6 @@ #define RRTYPE_CSYNC_ATTRIBUTES 0 static inline isc_result_t -fromtext_csync(ARGS_FROMTEXT) { - isc_token_t token; - - REQUIRE(type == dns_rdatatype_csync); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - UNUSED(callbacks); - - /* Serial. */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - RETERR(uint32_tobuffer(token.value.as_ulong, target)); - - /* Flags. */ - 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)); - - /* Type Map */ - return (typemap_fromtext(lexer, target, ISC_TRUE)); -} - -static inline isc_result_t totext_csync(ARGS_TOTEXT) { unsigned long num; char buf[sizeof("0123456789")]; /* Also TYPE65535 */ diff --git a/usr.bin/dig/lib/dns/rdata/generic/dlv_32769.c b/usr.bin/dig/lib/dns/rdata/generic/dlv_32769.c index b9770b8453d..7b0d8fddbb5 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/dlv_32769.c +++ b/usr.bin/dig/lib/dns/rdata/generic/dlv_32769.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dlv_32769.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: dlv_32769.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* RFC3658 */ @@ -29,15 +29,6 @@ #include <dns/ds.h> static inline isc_result_t -fromtext_dlv(ARGS_FROMTEXT) { - - REQUIRE(type == dns_rdatatype_dlv); - - return (generic_fromtext_ds(rdclass, type, lexer, origin, options, - target, callbacks)); -} - -static inline isc_result_t totext_dlv(ARGS_TOTEXT) { REQUIRE(rdata->type == dns_rdatatype_dlv); diff --git a/usr.bin/dig/lib/dns/rdata/generic/dname_39.c b/usr.bin/dig/lib/dns/rdata/generic/dname_39.c index 6172b90d0a7..a5d4fbd1da1 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/dname_39.c +++ b/usr.bin/dig/lib/dns/rdata/generic/dname_39.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dname_39.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: dname_39.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* Reviewed: Wed Mar 15 16:52:38 PST 2000 by explorer */ @@ -26,29 +26,6 @@ #define RRTYPE_DNAME_ATTRIBUTES (DNS_RDATATYPEATTR_SINGLETON) static inline isc_result_t -fromtext_dname(ARGS_FROMTEXT) { - isc_token_t token; - dns_name_t name; - isc_buffer_t buffer; - - REQUIRE(type == dns_rdatatype_dname); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - if (origin == NULL) - origin = dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_dname(ARGS_TOTEXT) { isc_region_t region; dns_name_t name; diff --git a/usr.bin/dig/lib/dns/rdata/generic/dnskey_48.c b/usr.bin/dig/lib/dns/rdata/generic/dnskey_48.c index 99c84327a58..f9c33e2ce60 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/dnskey_48.c +++ b/usr.bin/dig/lib/dns/rdata/generic/dnskey_48.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dnskey_48.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: dnskey_48.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* * Reviewed: Wed Mar 15 16:47:10 PST 2000 by halley. @@ -30,15 +30,6 @@ #define RRTYPE_DNSKEY_ATTRIBUTES (DNS_RDATATYPEATTR_DNSSEC) static inline isc_result_t -fromtext_dnskey(ARGS_FROMTEXT) { - - REQUIRE(type == dns_rdatatype_dnskey); - - return (generic_fromtext_key(rdclass, type, lexer, origin, - options, target, callbacks)); -} - -static inline isc_result_t totext_dnskey(ARGS_TOTEXT) { REQUIRE(rdata != NULL); diff --git a/usr.bin/dig/lib/dns/rdata/generic/doa_259.c b/usr.bin/dig/lib/dns/rdata/generic/doa_259.c index 39a5a1a754b..8cdaed46384 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/doa_259.c +++ b/usr.bin/dig/lib/dns/rdata/generic/doa_259.c @@ -20,61 +20,6 @@ #define RRTYPE_DOA_ATTRIBUTES (0) static inline isc_result_t -fromtext_doa(ARGS_FROMTEXT) { - isc_token_t token; - - REQUIRE(type == dns_rdatatype_doa); - - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - UNUSED(callbacks); - - /* - * DOA-ENTERPRISE - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - RETERR(uint32_tobuffer(token.value.as_ulong, target)); - - /* - * DOA-TYPE - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - RETERR(uint32_tobuffer(token.value.as_ulong, target)); - - /* - * DOA-LOCATION - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - if (token.value.as_ulong > 0xffU) { - RETTOK(ISC_R_RANGE); - } - RETERR(uint8_tobuffer(token.value.as_ulong, target)); - - /* - * DOA-MEDIA-TYPE - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring, - ISC_FALSE)); - RETTOK(txt_fromtext(&token.value.as_textregion, target)); - - /* - * DOA-DATA - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - if (strcmp(DNS_AS_STR(token), "-") == 0) { - return (ISC_R_SUCCESS); - } else { - isc_lex_ungettoken(lexer, &token); - return (isc_base64_tobuffer(lexer, target, -1)); - } -} - -static inline isc_result_t totext_doa(ARGS_TOTEXT) { char buf[sizeof("4294967295 ")]; isc_region_t region; diff --git a/usr.bin/dig/lib/dns/rdata/generic/ds_43.c b/usr.bin/dig/lib/dns/rdata/generic/ds_43.c index 1c282c12989..999173c8867 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/ds_43.c +++ b/usr.bin/dig/lib/dns/rdata/generic/ds_43.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: ds_43.c,v 1.2 2020/02/13 08:19:39 florian Exp $ */ +/* $Id: ds_43.c,v 1.3 2020/02/20 18:08:51 florian Exp $ */ /* RFC3658 */ @@ -30,72 +30,6 @@ #include <dns/ds.h> static inline isc_result_t -generic_fromtext_ds(ARGS_FROMTEXT) { - isc_token_t token; - unsigned char c; - int length; - - UNUSED(type); - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - UNUSED(callbacks); - - /* - * Key tag. - */ - 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)); - - /* - * Algorithm. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - RETTOK(dns_secalg_fromtext(&c, &token.value.as_textregion)); - RETERR(mem_tobuffer(target, &c, 1)); - - /* - * Digest type. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - RETTOK(dns_dsdigest_fromtext(&c, &token.value.as_textregion)); - RETERR(mem_tobuffer(target, &c, 1)); - - /* - * Digest. - */ - switch (c) { - case DNS_DSDIGEST_SHA1: - length = ISC_SHA1_DIGESTLENGTH; - break; - case DNS_DSDIGEST_SHA256: - length = ISC_SHA256_DIGESTLENGTH; - break; - case DNS_DSDIGEST_SHA384: - length = ISC_SHA384_DIGESTLENGTH; - break; - default: - length = -1; - break; - } - return (isc_hex_tobuffer(lexer, target, length)); -} - -static inline isc_result_t -fromtext_ds(ARGS_FROMTEXT) { - - REQUIRE(type == dns_rdatatype_ds); - - return (generic_fromtext_ds(rdclass, type, lexer, origin, options, - target, callbacks)); -} - -static inline isc_result_t generic_totext_ds(ARGS_TOTEXT) { isc_region_t sr; char buf[sizeof("64000 ")]; diff --git a/usr.bin/dig/lib/dns/rdata/generic/eui48_108.c b/usr.bin/dig/lib/dns/rdata/generic/eui48_108.c index c94c6774ab2..60bb29edbb7 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/eui48_108.c +++ b/usr.bin/dig/lib/dns/rdata/generic/eui48_108.c @@ -22,38 +22,6 @@ #define RRTYPE_EUI48_ATTRIBUTES (0) static inline isc_result_t -fromtext_eui48(ARGS_FROMTEXT) { - isc_token_t token; - unsigned char eui48[6]; - unsigned int l0, l1, l2, l3, l4, l5; - int n; - - REQUIRE(type == dns_rdatatype_eui48); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - UNUSED(callbacks); - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - n = sscanf(DNS_AS_STR(token), "%2x-%2x-%2x-%2x-%2x-%2x", - &l0, &l1, &l2, &l3, &l4, &l5); - if (n != 6 || l0 > 255U || l1 > 255U || l2 > 255U || l3 > 255U || - l4 > 255U || l5 > 255U) - return (DNS_R_BADEUI); - - eui48[0] = l0; - eui48[1] = l1; - eui48[2] = l2; - eui48[3] = l3; - eui48[4] = l4; - eui48[5] = l5; - return (mem_tobuffer(target, eui48, sizeof(eui48))); -} - -static inline isc_result_t totext_eui48(ARGS_TOTEXT) { char buf[sizeof("xx-xx-xx-xx-xx-xx")]; diff --git a/usr.bin/dig/lib/dns/rdata/generic/eui64_109.c b/usr.bin/dig/lib/dns/rdata/generic/eui64_109.c index 736578280cb..56d3e5a7cb3 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/eui64_109.c +++ b/usr.bin/dig/lib/dns/rdata/generic/eui64_109.c @@ -22,40 +22,6 @@ #define RRTYPE_EUI64_ATTRIBUTES (0) static inline isc_result_t -fromtext_eui64(ARGS_FROMTEXT) { - isc_token_t token; - unsigned char eui64[8]; - unsigned int l0, l1, l2, l3, l4, l5, l6, l7; - int n; - - REQUIRE(type == dns_rdatatype_eui64); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - UNUSED(callbacks); - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - n = sscanf(DNS_AS_STR(token), "%2x-%2x-%2x-%2x-%2x-%2x-%2x-%2x", - &l0, &l1, &l2, &l3, &l4, &l5, &l6, &l7); - if (n != 8 || l0 > 255U || l1 > 255U || l2 > 255U || l3 > 255U || - l4 > 255U || l5 > 255U || l6 > 255U || l7 > 255U) - return (DNS_R_BADEUI); - - eui64[0] = l0; - eui64[1] = l1; - eui64[2] = l2; - eui64[3] = l3; - eui64[4] = l4; - eui64[5] = l5; - eui64[6] = l6; - eui64[7] = l7; - return (mem_tobuffer(target, eui64, sizeof(eui64))); -} - -static inline isc_result_t totext_eui64(ARGS_TOTEXT) { char buf[sizeof("xx-xx-xx-xx-xx-xx-xx-xx")]; diff --git a/usr.bin/dig/lib/dns/rdata/generic/gpos_27.c b/usr.bin/dig/lib/dns/rdata/generic/gpos_27.c index 7e7c890785e..fb1f844f096 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/gpos_27.c +++ b/usr.bin/dig/lib/dns/rdata/generic/gpos_27.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: gpos_27.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: gpos_27.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* reviewed: Wed Mar 15 16:48:45 PST 2000 by brister */ @@ -26,28 +26,6 @@ #define RRTYPE_GPOS_ATTRIBUTES (0) static inline isc_result_t -fromtext_gpos(ARGS_FROMTEXT) { - isc_token_t token; - int i; - - REQUIRE(type == dns_rdatatype_gpos); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - UNUSED(callbacks); - - for (i = 0; i < 3; i++) { - RETERR(isc_lex_getmastertoken(lexer, &token, - isc_tokentype_qstring, - ISC_FALSE)); - RETTOK(txt_fromtext(&token.value.as_textregion, target)); - } - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_gpos(ARGS_TOTEXT) { isc_region_t region; int i; diff --git a/usr.bin/dig/lib/dns/rdata/generic/hinfo_13.c b/usr.bin/dig/lib/dns/rdata/generic/hinfo_13.c index 928c9dfc616..4a087643e3d 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/hinfo_13.c +++ b/usr.bin/dig/lib/dns/rdata/generic/hinfo_13.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: hinfo_13.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: hinfo_13.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* * Reviewed: Wed Mar 15 16:47:10 PST 2000 by halley. @@ -26,28 +26,6 @@ #define RRTYPE_HINFO_ATTRIBUTES (0) static inline isc_result_t -fromtext_hinfo(ARGS_FROMTEXT) { - isc_token_t token; - int i; - - UNUSED(type); - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - UNUSED(callbacks); - - REQUIRE(type == dns_rdatatype_hinfo); - - for (i = 0; i < 2; i++) { - RETERR(isc_lex_getmastertoken(lexer, &token, - isc_tokentype_qstring, - ISC_FALSE)); - RETTOK(txt_fromtext(&token.value.as_textregion, target)); - } - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_hinfo(ARGS_TOTEXT) { isc_region_t region; diff --git a/usr.bin/dig/lib/dns/rdata/generic/hip_55.c b/usr.bin/dig/lib/dns/rdata/generic/hip_55.c index 7253bf727f4..2ef532c2788 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/hip_55.c +++ b/usr.bin/dig/lib/dns/rdata/generic/hip_55.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: hip_55.c,v 1.2 2020/02/12 13:05:04 jsg Exp $ */ +/* $Id: hip_55.c,v 1.3 2020/02/20 18:08:51 florian Exp $ */ /* reviewed: TBC */ @@ -26,101 +26,6 @@ #define RRTYPE_HIP_ATTRIBUTES (0) static inline isc_result_t -fromtext_hip(ARGS_FROMTEXT) { - isc_token_t token; - dns_name_t name; - isc_buffer_t buffer; - isc_buffer_t hit_len; - isc_buffer_t key_len; - unsigned char *start; - size_t len; - - REQUIRE(type == dns_rdatatype_hip); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - /* - * Dummy HIT len. - */ - hit_len = *target; - RETERR(uint8_tobuffer(0, target)); - - /* - * Algorithm. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - if (token.value.as_ulong > 0xffU) - RETTOK(ISC_R_RANGE); - RETERR(uint8_tobuffer(token.value.as_ulong, target)); - - /* - * Dummy KEY len. - */ - key_len = *target; - RETERR(uint16_tobuffer(0, target)); - - /* - * HIT (base16). - */ - start = isc_buffer_used(target); - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - RETTOK(isc_hex_decodestring(DNS_AS_STR(token), target)); - - /* - * Fill in HIT len. - */ - len = (unsigned char *)isc_buffer_used(target) - start; - if (len > 0xffU) - RETTOK(ISC_R_RANGE); - RETERR(uint8_tobuffer((uint32_t)len, &hit_len)); - - /* - * Public key (base64). - */ - start = isc_buffer_used(target); - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - RETTOK(isc_base64_decodestring(DNS_AS_STR(token), target)); - - /* - * Fill in KEY len. - */ - len = (unsigned char *)isc_buffer_used(target) - start; - if (len > 0xffffU) - RETTOK(ISC_R_RANGE); - RETERR(uint16_tobuffer((uint32_t)len, &key_len)); - - if (origin == NULL) - origin = dns_rootname; - - /* - * Rendezvous Servers. - */ - dns_name_init(&name, NULL); - do { - RETERR(isc_lex_getmastertoken(lexer, &token, - isc_tokentype_string, - ISC_TRUE)); - if (token.type != isc_tokentype_string) - break; - buffer_fromregion(&buffer, &token.value.as_region); - RETTOK(dns_name_fromtext(&name, &buffer, origin, options, - target)); - } while (1); - - /* - * Let upper layer handle eol/eof. - */ - isc_lex_ungettoken(lexer, &token); - - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_hip(ARGS_TOTEXT) { isc_region_t region; dns_name_t name; diff --git a/usr.bin/dig/lib/dns/rdata/generic/ipseckey_45.c b/usr.bin/dig/lib/dns/rdata/generic/ipseckey_45.c index 303bd18e03f..1c2c3d5aafa 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/ipseckey_45.c +++ b/usr.bin/dig/lib/dns/rdata/generic/ipseckey_45.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: ipseckey_45.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: ipseckey_45.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ #ifndef RDATA_GENERIC_IPSECKEY_45_C #define RDATA_GENERIC_IPSECKEY_45_C @@ -26,98 +26,6 @@ #define RRTYPE_IPSECKEY_ATTRIBUTES (0) static inline isc_result_t -fromtext_ipseckey(ARGS_FROMTEXT) { - isc_token_t token; - dns_name_t name; - isc_buffer_t buffer; - unsigned int gateway; - struct in_addr addr; - unsigned char addr6[16]; - isc_region_t region; - - REQUIRE(type == dns_rdatatype_ipseckey); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - /* - * Precedence. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - if (token.value.as_ulong > 0xffU) - RETTOK(ISC_R_RANGE); - RETERR(uint8_tobuffer(token.value.as_ulong, target)); - - /* - * Gateway type. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - if (token.value.as_ulong > 0x3U) - RETTOK(ISC_R_RANGE); - RETERR(uint8_tobuffer(token.value.as_ulong, target)); - gateway = token.value.as_ulong; - - /* - * Algorithm. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - if (token.value.as_ulong > 0xffU) - RETTOK(ISC_R_RANGE); - RETERR(uint8_tobuffer(token.value.as_ulong, target)); - - /* - * Gateway. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - - switch (gateway) { - case 0: - if (strcmp(DNS_AS_STR(token), ".") != 0) - RETTOK(DNS_R_SYNTAX); - break; - - case 1: - if (getquad(DNS_AS_STR(token), &addr, lexer, callbacks) != 1) - RETTOK(DNS_R_BADDOTTEDQUAD); - isc_buffer_availableregion(target, ®ion); - if (region.length < 4) - return (ISC_R_NOSPACE); - memmove(region.base, &addr, 4); - isc_buffer_add(target, 4); - break; - - case 2: - if (inet_pton(AF_INET6, DNS_AS_STR(token), addr6) != 1) - RETTOK(DNS_R_BADAAAA); - isc_buffer_availableregion(target, ®ion); - if (region.length < 16) - return (ISC_R_NOSPACE); - memmove(region.base, addr6, 16); - isc_buffer_add(target, 16); - break; - - case 3: - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - if (origin == NULL) - origin = dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, - options, target)); - break; - } - - /* - * Public key. - */ - return (isc_base64_tobuffer(lexer, target, -1)); -} - -static inline isc_result_t totext_ipseckey(ARGS_TOTEXT) { isc_region_t region; dns_name_t name; diff --git a/usr.bin/dig/lib/dns/rdata/generic/isdn_20.c b/usr.bin/dig/lib/dns/rdata/generic/isdn_20.c index 5cda8740baf..8580cfb28d2 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/isdn_20.c +++ b/usr.bin/dig/lib/dns/rdata/generic/isdn_20.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: isdn_20.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: isdn_20.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* Reviewed: Wed Mar 15 16:53:11 PST 2000 by bwelling */ @@ -26,35 +26,6 @@ #define RRTYPE_ISDN_ATTRIBUTES (0) static inline isc_result_t -fromtext_isdn(ARGS_FROMTEXT) { - isc_token_t token; - - REQUIRE(type == dns_rdatatype_isdn); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - UNUSED(callbacks); - - /* ISDN-address */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring, - ISC_FALSE)); - RETTOK(txt_fromtext(&token.value.as_textregion, target)); - - /* sa: optional */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring, - ISC_TRUE)); - if (token.type != isc_tokentype_string && - token.type != isc_tokentype_qstring) { - isc_lex_ungettoken(lexer, &token); - return (ISC_R_SUCCESS); - } - RETTOK(txt_fromtext(&token.value.as_textregion, target)); - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_isdn(ARGS_TOTEXT) { isc_region_t region; diff --git a/usr.bin/dig/lib/dns/rdata/generic/key_25.c b/usr.bin/dig/lib/dns/rdata/generic/key_25.c index ddb4f44a327..958aca5c693 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/key_25.c +++ b/usr.bin/dig/lib/dns/rdata/generic/key_25.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: key_25.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: key_25.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* * Reviewed: Wed Mar 15 16:47:10 PST 2000 by halley. @@ -30,53 +30,6 @@ #define RRTYPE_KEY_ATTRIBUTES (0) static inline isc_result_t -generic_fromtext_key(ARGS_FROMTEXT) { - isc_result_t result; - isc_token_t token; - dns_secalg_t alg; - dns_secproto_t proto; - dns_keyflags_t flags; - - UNUSED(type); - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - UNUSED(callbacks); - - /* flags */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - RETTOK(dns_keyflags_fromtext(&flags, &token.value.as_textregion)); - RETERR(uint16_tobuffer(flags, target)); - - /* protocol */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - RETTOK(dns_secproto_fromtext(&proto, &token.value.as_textregion)); - RETERR(mem_tobuffer(target, &proto, 1)); - - /* algorithm */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - RETTOK(dns_secalg_fromtext(&alg, &token.value.as_textregion)); - RETERR(mem_tobuffer(target, &alg, 1)); - - /* No Key? */ - if ((flags & 0xc000) == 0xc000) - return (ISC_R_SUCCESS); - - result = isc_base64_tobuffer(lexer, target, -1); - if (result != ISC_R_SUCCESS) - return (result); - - /* Ensure there's at least enough data to compute a key ID for MD5 */ - if (alg == DST_ALG_RSAMD5 && isc_buffer_usedlength(target) < 7) - return (ISC_R_UNEXPECTEDEND); - - return (ISC_R_SUCCESS); -} - -static inline isc_result_t generic_totext_key(ARGS_TOTEXT) { isc_region_t sr; char buf[sizeof("[key id = 64000]")]; @@ -216,15 +169,6 @@ generic_fromwire_key(ARGS_FROMWIRE) { } static inline isc_result_t -fromtext_key(ARGS_FROMTEXT) { - - REQUIRE(type == dns_rdatatype_key); - - return (generic_fromtext_key(rdclass, type, lexer, origin, - options, target, callbacks)); -} - -static inline isc_result_t totext_key(ARGS_TOTEXT) { REQUIRE(rdata != NULL); diff --git a/usr.bin/dig/lib/dns/rdata/generic/keydata_65533.c b/usr.bin/dig/lib/dns/rdata/generic/keydata_65533.c index d58d5d49996..b3fb50e8718 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/keydata_65533.c +++ b/usr.bin/dig/lib/dns/rdata/generic/keydata_65533.c @@ -23,74 +23,6 @@ #define RRTYPE_KEYDATA_ATTRIBUTES (0) -static inline isc_result_t -fromtext_keydata(ARGS_FROMTEXT) { - isc_result_t result; - isc_token_t token; - dns_secalg_t alg; - dns_secproto_t proto; - dns_keyflags_t flags; - uint32_t refresh, addhd, removehd; - - REQUIRE(type == dns_rdatatype_keydata); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - UNUSED(callbacks); - - /* refresh timer */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - RETTOK(dns_time32_fromtext(DNS_AS_STR(token), &refresh)); - RETERR(uint32_tobuffer(refresh, target)); - - /* add hold-down */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - RETTOK(dns_time32_fromtext(DNS_AS_STR(token), &addhd)); - RETERR(uint32_tobuffer(addhd, target)); - - /* remove hold-down */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - RETTOK(dns_time32_fromtext(DNS_AS_STR(token), &removehd)); - RETERR(uint32_tobuffer(removehd, target)); - - /* flags */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - RETTOK(dns_keyflags_fromtext(&flags, &token.value.as_textregion)); - RETERR(uint16_tobuffer(flags, target)); - - /* protocol */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - RETTOK(dns_secproto_fromtext(&proto, &token.value.as_textregion)); - RETERR(mem_tobuffer(target, &proto, 1)); - - /* algorithm */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - RETTOK(dns_secalg_fromtext(&alg, &token.value.as_textregion)); - RETERR(mem_tobuffer(target, &alg, 1)); - - /* No Key? */ - if ((flags & 0xc000) == 0xc000) - return (ISC_R_SUCCESS); - - result = isc_base64_tobuffer(lexer, target, -1); - if (result != ISC_R_SUCCESS) - return (result); - - /* Ensure there's at least enough data to compute a key ID for MD5 */ - if (alg == DST_ALG_RSAMD5 && isc_buffer_usedlength(target) < 19) - return (ISC_R_UNEXPECTEDEND); - - return (ISC_R_SUCCESS); -} - /* * ISC_FORMATHTTPTIMESTAMP_SIZE needs to be 30 in C locale and potentially * more for other locales to handle longer national abbreviations when diff --git a/usr.bin/dig/lib/dns/rdata/generic/l32_105.c b/usr.bin/dig/lib/dns/rdata/generic/l32_105.c index cf003f25d63..e9f252952b2 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/l32_105.c +++ b/usr.bin/dig/lib/dns/rdata/generic/l32_105.c @@ -24,39 +24,6 @@ #define RRTYPE_L32_ATTRIBUTES (0) static inline isc_result_t -fromtext_l32(ARGS_FROMTEXT) { - isc_token_t token; - struct in_addr addr; - isc_region_t region; - - REQUIRE(type == dns_rdatatype_l32); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - UNUSED(callbacks); - - 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)); - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - - if (getquad(DNS_AS_STR(token), &addr, lexer, callbacks) != 1) - RETTOK(DNS_R_BADDOTTEDQUAD); - isc_buffer_availableregion(target, ®ion); - if (region.length < 4) - return (ISC_R_NOSPACE); - memmove(region.base, &addr, 4); - isc_buffer_add(target, 4); - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_l32(ARGS_TOTEXT) { isc_region_t region; char buf[sizeof("65000")]; diff --git a/usr.bin/dig/lib/dns/rdata/generic/l64_106.c b/usr.bin/dig/lib/dns/rdata/generic/l64_106.c index 6e9a10a7933..572a07f72d7 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/l64_106.c +++ b/usr.bin/dig/lib/dns/rdata/generic/l64_106.c @@ -24,33 +24,6 @@ #define RRTYPE_L64_ATTRIBUTES (0) static inline isc_result_t -fromtext_l64(ARGS_FROMTEXT) { - isc_token_t token; - unsigned char locator[NS_LOCATORSZ]; - - REQUIRE(type == dns_rdatatype_l64); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - UNUSED(callbacks); - - 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)); - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - - if (locator_pton(DNS_AS_STR(token), locator) != 1) - RETTOK(DNS_R_SYNTAX); - return (mem_tobuffer(target, locator, NS_LOCATORSZ)); -} - -static inline isc_result_t totext_l64(ARGS_TOTEXT) { isc_region_t region; char buf[sizeof("xxxx:xxxx:xxxx:xxxx")]; diff --git a/usr.bin/dig/lib/dns/rdata/generic/loc_29.c b/usr.bin/dig/lib/dns/rdata/generic/loc_29.c index 81b637ee919..fdf88ca6867 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/loc_29.c +++ b/usr.bin/dig/lib/dns/rdata/generic/loc_29.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: loc_29.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: loc_29.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* Reviewed: Wed Mar 15 18:13:09 PST 2000 by explorer */ @@ -26,433 +26,6 @@ #define RRTYPE_LOC_ATTRIBUTES (0) static inline isc_result_t -fromtext_loc(ARGS_FROMTEXT) { - isc_token_t token; - int d1, m1, s1; - int d2, m2, s2; - unsigned char size; - unsigned char hp; - unsigned char vp; - unsigned char version; - isc_boolean_t east = ISC_FALSE; - isc_boolean_t north = ISC_FALSE; - long tmp; - long m; - long cm; - long poweroften[8] = { 1, 10, 100, 1000, - 10000, 100000, 1000000, 10000000 }; - int man; - int exp; - char *e; - int i; - unsigned long latitude; - unsigned long longitude; - unsigned long altitude; - - REQUIRE(type == dns_rdatatype_loc); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - - /* - * Defaults. - */ - m1 = s1 = 0; - m2 = s2 = 0; - size = 0x12; /* 1.00m */ - hp = 0x16; /* 10000.00 m */ - vp = 0x13; /* 10.00 m */ - version = 0; - - /* - * Degrees. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - if (token.value.as_ulong > 90U) - RETTOK(ISC_R_RANGE); - d1 = (int)token.value.as_ulong; - /* - * Minutes. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - if (strcasecmp(DNS_AS_STR(token), "N") == 0) - north = ISC_TRUE; - if (north || strcasecmp(DNS_AS_STR(token), "S") == 0) - goto getlong; - m1 = strtol(DNS_AS_STR(token), &e, 10); - if (*e != 0) - RETTOK(DNS_R_SYNTAX); - if (m1 < 0 || m1 > 59) - RETTOK(ISC_R_RANGE); - if (d1 == 90 && m1 != 0) - RETTOK(ISC_R_RANGE); - - /* - * Seconds. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - if (strcasecmp(DNS_AS_STR(token), "N") == 0) - north = ISC_TRUE; - if (north || strcasecmp(DNS_AS_STR(token), "S") == 0) - goto getlong; - s1 = strtol(DNS_AS_STR(token), &e, 10); - if (*e != 0 && *e != '.') - RETTOK(DNS_R_SYNTAX); - if (s1 < 0 || s1 > 59) - RETTOK(ISC_R_RANGE); - if (*e == '.') { - const char *l; - e++; - for (i = 0; i < 3; i++) { - if (*e == 0) - break; - if ((tmp = decvalue(*e++)) < 0) - RETTOK(DNS_R_SYNTAX); - s1 *= 10; - s1 += tmp; - } - for (; i < 3; i++) - s1 *= 10; - l = e; - while (*e != 0) { - if (decvalue(*e++) < 0) - RETTOK(DNS_R_SYNTAX); - } - if (*l != '\0' && callbacks != NULL) { - const char *file = isc_lex_getsourcename(lexer); - unsigned long line = isc_lex_getsourceline(lexer); - - if (file == NULL) - file = "UNKNOWN"; - (*callbacks->warn)(callbacks, "%s: %s:%u: '%s' extra " - "precision digits ignored", - "dns_rdata_fromtext", file, line, - DNS_AS_STR(token)); - } - } else - s1 *= 1000; - if (d1 == 90 && s1 != 0) - RETTOK(ISC_R_RANGE); - - /* - * Direction. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - if (strcasecmp(DNS_AS_STR(token), "N") == 0) - north = ISC_TRUE; - if (!north && strcasecmp(DNS_AS_STR(token), "S") != 0) - RETTOK(DNS_R_SYNTAX); - - getlong: - /* - * Degrees. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - if (token.value.as_ulong > 180U) - RETTOK(ISC_R_RANGE); - d2 = (int)token.value.as_ulong; - - /* - * Minutes. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - if (strcasecmp(DNS_AS_STR(token), "E") == 0) - east = ISC_TRUE; - if (east || strcasecmp(DNS_AS_STR(token), "W") == 0) - goto getalt; - m2 = strtol(DNS_AS_STR(token), &e, 10); - if (*e != 0) - RETTOK(DNS_R_SYNTAX); - if (m2 < 0 || m2 > 59) - RETTOK(ISC_R_RANGE); - if (d2 == 180 && m2 != 0) - RETTOK(ISC_R_RANGE); - - /* - * Seconds. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - if (strcasecmp(DNS_AS_STR(token), "E") == 0) - east = ISC_TRUE; - if (east || strcasecmp(DNS_AS_STR(token), "W") == 0) - goto getalt; - s2 = strtol(DNS_AS_STR(token), &e, 10); - if (*e != 0 && *e != '.') - RETTOK(DNS_R_SYNTAX); - if (s2 < 0 || s2 > 59) - RETTOK(ISC_R_RANGE); - if (*e == '.') { - const char *l; - e++; - for (i = 0; i < 3; i++) { - if (*e == 0) - break; - if ((tmp = decvalue(*e++)) < 0) - RETTOK(DNS_R_SYNTAX); - s2 *= 10; - s2 += tmp; - } - for (; i < 3; i++) - s2 *= 10; - l = e; - while (*e != 0) { - if (decvalue(*e++) < 0) - RETTOK(DNS_R_SYNTAX); - } - if (*l != '\0' && callbacks != NULL) { - const char *file = isc_lex_getsourcename(lexer); - unsigned long line = isc_lex_getsourceline(lexer); - - if (file == NULL) - file = "UNKNOWN"; - (*callbacks->warn)(callbacks, "%s: %s:%u: '%s' extra " - "precision digits ignored", - "dns_rdata_fromtext", - file, line, DNS_AS_STR(token)); - } - } else - s2 *= 1000; - if (d2 == 180 && s2 != 0) - RETTOK(ISC_R_RANGE); - - /* - * Direction. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - if (strcasecmp(DNS_AS_STR(token), "E") == 0) - east = ISC_TRUE; - if (!east && strcasecmp(DNS_AS_STR(token), "W") != 0) - RETTOK(DNS_R_SYNTAX); - - getalt: - /* - * Altitude. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - m = strtol(DNS_AS_STR(token), &e, 10); - if (*e != 0 && *e != '.' && *e != 'm') - RETTOK(DNS_R_SYNTAX); - if (m < -100000 || m > 42849672) - RETTOK(ISC_R_RANGE); - cm = 0; - if (*e == '.') { - e++; - for (i = 0; i < 2; i++) { - if (*e == 0 || *e == 'm') - break; - if ((tmp = decvalue(*e++)) < 0) - return (DNS_R_SYNTAX); - cm *= 10; - if (m < 0) - cm -= tmp; - else - cm += tmp; - } - for (; i < 2; i++) - cm *= 10; - } - if (*e == 'm') - e++; - if (*e != 0) - RETTOK(DNS_R_SYNTAX); - if (m == -100000 && cm != 0) - RETTOK(ISC_R_RANGE); - if (m == 42849672 && cm > 95) - RETTOK(ISC_R_RANGE); - /* - * Adjust base. - */ - altitude = m + 100000; - altitude *= 100; - altitude += cm; - - /* - * Size: optional. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_TRUE)); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) { - isc_lex_ungettoken(lexer, &token); - goto encode; - } - m = strtol(DNS_AS_STR(token), &e, 10); - if (*e != 0 && *e != '.' && *e != 'm') - RETTOK(DNS_R_SYNTAX); - if (m < 0 || m > 90000000) - RETTOK(ISC_R_RANGE); - cm = 0; - if (*e == '.') { - e++; - for (i = 0; i < 2; i++) { - if (*e == 0 || *e == 'm') - break; - if ((tmp = decvalue(*e++)) < 0) - RETTOK(DNS_R_SYNTAX); - cm *= 10; - cm += tmp; - } - for (; i < 2; i++) - cm *= 10; - } - if (*e == 'm') - e++; - if (*e != 0) - RETTOK(DNS_R_SYNTAX); - /* - * We don't just multiply out as we will overflow. - */ - if (m > 0) { - for (exp = 0; exp < 7; exp++) - if (m < poweroften[exp+1]) - break; - man = m / poweroften[exp]; - exp += 2; - } else { - if (cm >= 10) { - man = cm / 10; - exp = 1; - } else { - man = cm; - exp = 0; - } - } - size = (man << 4) + exp; - - /* - * Horizontal precision: optional. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_TRUE)); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) { - isc_lex_ungettoken(lexer, &token); - goto encode; - } - m = strtol(DNS_AS_STR(token), &e, 10); - if (*e != 0 && *e != '.' && *e != 'm') - RETTOK(DNS_R_SYNTAX); - if (m < 0 || m > 90000000) - RETTOK(ISC_R_RANGE); - cm = 0; - if (*e == '.') { - e++; - for (i = 0; i < 2; i++) { - if (*e == 0 || *e == 'm') - break; - if ((tmp = decvalue(*e++)) < 0) - RETTOK(DNS_R_SYNTAX); - cm *= 10; - cm += tmp; - } - for (; i < 2; i++) - cm *= 10; - } - if (*e == 'm') - e++; - if (*e != 0) - RETTOK(DNS_R_SYNTAX); - /* - * We don't just multiply out as we will overflow. - */ - if (m > 0) { - for (exp = 0; exp < 7; exp++) - if (m < poweroften[exp+1]) - break; - man = m / poweroften[exp]; - exp += 2; - } else if (cm >= 10) { - man = cm / 10; - exp = 1; - } else { - man = cm; - exp = 0; - } - hp = (man << 4) + exp; - - /* - * Vertical precision: optional. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_TRUE)); - if (token.type == isc_tokentype_eol || - token.type == isc_tokentype_eof) { - isc_lex_ungettoken(lexer, &token); - goto encode; - } - m = strtol(DNS_AS_STR(token), &e, 10); - if (*e != 0 && *e != '.' && *e != 'm') - RETTOK(DNS_R_SYNTAX); - if (m < 0 || m > 90000000) - RETTOK(ISC_R_RANGE); - cm = 0; - if (*e == '.') { - e++; - for (i = 0; i < 2; i++) { - if (*e == 0 || *e == 'm') - break; - if ((tmp = decvalue(*e++)) < 0) - RETTOK(DNS_R_SYNTAX); - cm *= 10; - cm += tmp; - } - for (; i < 2; i++) - cm *= 10; - } - if (*e == 'm') - e++; - if (*e != 0) - RETTOK(DNS_R_SYNTAX); - /* - * We don't just multiply out as we will overflow. - */ - if (m > 0) { - for (exp = 0; exp < 7; exp++) - if (m < poweroften[exp+1]) - break; - man = m / poweroften[exp]; - exp += 2; - } else if (cm >= 10) { - man = cm / 10; - exp = 1; - } else { - man = cm; - exp = 0; - } - vp = (man << 4) + exp; - - encode: - RETERR(mem_tobuffer(target, &version, 1)); - RETERR(mem_tobuffer(target, &size, 1)); - RETERR(mem_tobuffer(target, &hp, 1)); - RETERR(mem_tobuffer(target, &vp, 1)); - if (north) - latitude = 0x80000000 + ( d1 * 3600 + m1 * 60 ) * 1000 + s1; - else - latitude = 0x80000000 - ( d1 * 3600 + m1 * 60 ) * 1000 - s1; - RETERR(uint32_tobuffer(latitude, target)); - - if (east) - longitude = 0x80000000 + ( d2 * 3600 + m2 * 60 ) * 1000 + s2; - else - longitude = 0x80000000 - ( d2 * 3600 + m2 * 60 ) * 1000 - s2; - RETERR(uint32_tobuffer(longitude, target)); - - return (uint32_tobuffer(altitude, target)); -} - -static inline isc_result_t totext_loc(ARGS_TOTEXT) { int d1, m1, s1, fs1; int d2, m2, s2, fs2; diff --git a/usr.bin/dig/lib/dns/rdata/generic/lp_107.c b/usr.bin/dig/lib/dns/rdata/generic/lp_107.c index ab811e32432..ce5beb35dea 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/lp_107.c +++ b/usr.bin/dig/lib/dns/rdata/generic/lp_107.c @@ -24,34 +24,6 @@ #define RRTYPE_LP_ATTRIBUTES (0) static inline isc_result_t -fromtext_lp(ARGS_FROMTEXT) { - isc_token_t token; - dns_name_t name; - isc_buffer_t buffer; - - REQUIRE(type == dns_rdatatype_lp); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - 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)); - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - if (origin == NULL) - origin = dns_rootname; - return (dns_name_fromtext(&name, &buffer, origin, options, target)); -} - -static inline isc_result_t totext_lp(ARGS_TOTEXT) { isc_region_t region; dns_name_t name; diff --git a/usr.bin/dig/lib/dns/rdata/generic/mb_7.c b/usr.bin/dig/lib/dns/rdata/generic/mb_7.c index c4c0ab8f197..a4cb57166d0 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/mb_7.c +++ b/usr.bin/dig/lib/dns/rdata/generic/mb_7.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: mb_7.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: mb_7.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* Reviewed: Wed Mar 15 17:31:26 PST 2000 by bwelling */ @@ -24,29 +24,6 @@ #define RRTYPE_MB_ATTRIBUTES (0) static inline isc_result_t -fromtext_mb(ARGS_FROMTEXT) { - isc_token_t token; - dns_name_t name; - isc_buffer_t buffer; - - REQUIRE(type == dns_rdatatype_mb); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - if (origin == NULL) - origin = dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_mb(ARGS_TOTEXT) { isc_region_t region; dns_name_t name; diff --git a/usr.bin/dig/lib/dns/rdata/generic/md_3.c b/usr.bin/dig/lib/dns/rdata/generic/md_3.c index d70e501d864..0aa7e1503e5 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/md_3.c +++ b/usr.bin/dig/lib/dns/rdata/generic/md_3.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: md_3.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: md_3.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* Reviewed: Wed Mar 15 17:48:20 PST 2000 by bwelling */ @@ -24,29 +24,6 @@ #define RRTYPE_MD_ATTRIBUTES (0) static inline isc_result_t -fromtext_md(ARGS_FROMTEXT) { - isc_token_t token; - dns_name_t name; - isc_buffer_t buffer; - - REQUIRE(type == dns_rdatatype_md); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - if (origin == NULL) - origin = dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_md(ARGS_TOTEXT) { isc_region_t region; dns_name_t name; diff --git a/usr.bin/dig/lib/dns/rdata/generic/mf_4.c b/usr.bin/dig/lib/dns/rdata/generic/mf_4.c index 1c8b6d15559..1c8796c9074 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/mf_4.c +++ b/usr.bin/dig/lib/dns/rdata/generic/mf_4.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: mf_4.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: mf_4.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* reviewed: Wed Mar 15 17:47:33 PST 2000 by brister */ @@ -24,29 +24,6 @@ #define RRTYPE_MF_ATTRIBUTES (0) static inline isc_result_t -fromtext_mf(ARGS_FROMTEXT) { - isc_token_t token; - dns_name_t name; - isc_buffer_t buffer; - - REQUIRE(type == dns_rdatatype_mf); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - if (origin == NULL) - origin = dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_mf(ARGS_TOTEXT) { isc_region_t region; dns_name_t name; diff --git a/usr.bin/dig/lib/dns/rdata/generic/mg_8.c b/usr.bin/dig/lib/dns/rdata/generic/mg_8.c index 29b70820739..5bc77c004c9 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/mg_8.c +++ b/usr.bin/dig/lib/dns/rdata/generic/mg_8.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: mg_8.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: mg_8.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* reviewed: Wed Mar 15 17:49:21 PST 2000 by brister */ @@ -24,29 +24,6 @@ #define RRTYPE_MG_ATTRIBUTES (0) static inline isc_result_t -fromtext_mg(ARGS_FROMTEXT) { - isc_token_t token; - dns_name_t name; - isc_buffer_t buffer; - - REQUIRE(type == dns_rdatatype_mg); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - if (origin == NULL) - origin = dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_mg(ARGS_TOTEXT) { isc_region_t region; dns_name_t name; diff --git a/usr.bin/dig/lib/dns/rdata/generic/minfo_14.c b/usr.bin/dig/lib/dns/rdata/generic/minfo_14.c index 08b90b61f07..f8863a1aa79 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/minfo_14.c +++ b/usr.bin/dig/lib/dns/rdata/generic/minfo_14.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: minfo_14.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: minfo_14.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* reviewed: Wed Mar 15 17:45:32 PST 2000 by brister */ @@ -24,42 +24,6 @@ #define RRTYPE_MINFO_ATTRIBUTES (0) static inline isc_result_t -fromtext_minfo(ARGS_FROMTEXT) { - isc_token_t token; - dns_name_t name; - isc_buffer_t buffer; - int i; - isc_boolean_t ok; - - REQUIRE(type == dns_rdatatype_minfo); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - if (origin == NULL) - origin = dns_rootname; - - for (i = 0; i < 2; i++) { - RETERR(isc_lex_getmastertoken(lexer, &token, - isc_tokentype_string, - ISC_FALSE)); - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - RETTOK(dns_name_fromtext(&name, &buffer, origin, - options, target)); - ok = ISC_TRUE; - if ((options & DNS_RDATA_CHECKNAMES) != 0) - ok = dns_name_ismailbox(&name); - if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0) - RETTOK(DNS_R_BADNAME); - if (!ok && callbacks != NULL) - warn_badname(&name, lexer, callbacks); - } - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_minfo(ARGS_TOTEXT) { isc_region_t region; dns_name_t rmail; diff --git a/usr.bin/dig/lib/dns/rdata/generic/mr_9.c b/usr.bin/dig/lib/dns/rdata/generic/mr_9.c index 274990f1e34..e50a46c01ec 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/mr_9.c +++ b/usr.bin/dig/lib/dns/rdata/generic/mr_9.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: mr_9.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: mr_9.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* Reviewed: Wed Mar 15 21:30:35 EST 2000 by tale */ @@ -24,29 +24,6 @@ #define RRTYPE_MR_ATTRIBUTES (0) static inline isc_result_t -fromtext_mr(ARGS_FROMTEXT) { - isc_token_t token; - dns_name_t name; - isc_buffer_t buffer; - - REQUIRE(type == dns_rdatatype_mr); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - if (origin == NULL) - origin = dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_mr(ARGS_TOTEXT) { isc_region_t region; dns_name_t name; diff --git a/usr.bin/dig/lib/dns/rdata/generic/mx_15.c b/usr.bin/dig/lib/dns/rdata/generic/mx_15.c index e6130bc774a..66c49ea166b 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/mx_15.c +++ b/usr.bin/dig/lib/dns/rdata/generic/mx_15.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: mx_15.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: mx_15.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* reviewed: Wed Mar 15 18:05:46 PST 2000 by brister */ @@ -27,68 +27,6 @@ #define RRTYPE_MX_ATTRIBUTES (0) -static isc_boolean_t -check_mx(isc_token_t *token) { - char tmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:123.123.123.123.")]; - struct in_addr addr; - struct in6_addr addr6; - - if (strlcpy(tmp, DNS_AS_STR(*token), sizeof(tmp)) >= sizeof(tmp)) - return (ISC_TRUE); - - if (tmp[strlen(tmp) - 1] == '.') - tmp[strlen(tmp) - 1] = '\0'; - if (inet_aton(tmp, &addr) == 1 || - inet_pton(AF_INET6, tmp, &addr6) == 1) - return (ISC_FALSE); - - return (ISC_TRUE); -} - -static inline isc_result_t -fromtext_mx(ARGS_FROMTEXT) { - isc_token_t token; - dns_name_t name; - isc_buffer_t buffer; - isc_boolean_t ok; - - REQUIRE(type == dns_rdatatype_mx); - - UNUSED(type); - UNUSED(rdclass); - - 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)); - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - - ok = ISC_TRUE; - if ((options & DNS_RDATA_CHECKMX) != 0) - ok = check_mx(&token); - if (!ok && (options & DNS_RDATA_CHECKMXFAIL) != 0) - RETTOK(DNS_R_MXISADDRESS); - if (!ok && callbacks != NULL) - warn_badmx(&token, lexer, callbacks); - - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - if (origin == NULL) - origin = dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); - ok = ISC_TRUE; - if ((options & DNS_RDATA_CHECKNAMES) != 0) - ok = dns_name_ishostname(&name, ISC_FALSE); - if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0) - RETTOK(DNS_R_BADNAME); - if (!ok && callbacks != NULL) - warn_badname(&name, lexer, callbacks); - return (ISC_R_SUCCESS); -} - static inline isc_result_t totext_mx(ARGS_TOTEXT) { isc_region_t region; diff --git a/usr.bin/dig/lib/dns/rdata/generic/naptr_35.c b/usr.bin/dig/lib/dns/rdata/generic/naptr_35.c index 754e4424dc5..35ec2c179e8 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/naptr_35.c +++ b/usr.bin/dig/lib/dns/rdata/generic/naptr_35.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: naptr_35.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: naptr_35.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* Reviewed: Thu Mar 16 16:52:50 PST 2000 by bwelling */ @@ -120,73 +120,6 @@ txt_valid_regex(const unsigned char *txt) { } static inline isc_result_t -fromtext_naptr(ARGS_FROMTEXT) { - isc_token_t token; - dns_name_t name; - isc_buffer_t buffer; - unsigned char *regex; - - REQUIRE(type == dns_rdatatype_naptr); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - /* - * Order. - */ - 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)); - - /* - * Preference. - */ - 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)); - - /* - * Flags. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring, - ISC_FALSE)); - RETTOK(txt_fromtext(&token.value.as_textregion, target)); - - /* - * Service. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring, - ISC_FALSE)); - RETTOK(txt_fromtext(&token.value.as_textregion, target)); - - /* - * Regexp. - */ - regex = isc_buffer_used(target); - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring, - ISC_FALSE)); - RETTOK(txt_fromtext(&token.value.as_textregion, target)); - RETTOK(txt_valid_regex(regex)); - - /* - * Replacement. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - if (origin == NULL) - origin = dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_naptr(ARGS_TOTEXT) { isc_region_t region; dns_name_t name; diff --git a/usr.bin/dig/lib/dns/rdata/generic/nid_104.c b/usr.bin/dig/lib/dns/rdata/generic/nid_104.c index 315d86ab9d1..4afb6361448 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/nid_104.c +++ b/usr.bin/dig/lib/dns/rdata/generic/nid_104.c @@ -24,33 +24,6 @@ #define RRTYPE_NID_ATTRIBUTES (0) static inline isc_result_t -fromtext_nid(ARGS_FROMTEXT) { - isc_token_t token; - unsigned char locator[NS_LOCATORSZ]; - - REQUIRE(type == dns_rdatatype_nid); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - UNUSED(callbacks); - - 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)); - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - - if (locator_pton(DNS_AS_STR(token), locator) != 1) - RETTOK(DNS_R_SYNTAX); - return (mem_tobuffer(target, locator, NS_LOCATORSZ)); -} - -static inline isc_result_t totext_nid(ARGS_TOTEXT) { isc_region_t region; char buf[sizeof("xxxx:xxxx:xxxx:xxxx")]; diff --git a/usr.bin/dig/lib/dns/rdata/generic/ninfo_56.c b/usr.bin/dig/lib/dns/rdata/generic/ninfo_56.c index 4ba33a9b417..830087b349f 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/ninfo_56.c +++ b/usr.bin/dig/lib/dns/rdata/generic/ninfo_56.c @@ -20,21 +20,6 @@ #define RRTYPE_NINFO_ATTRIBUTES (0) static inline isc_result_t -fromtext_ninfo(ARGS_FROMTEXT) { - - REQUIRE(type == dns_rdatatype_ninfo); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - UNUSED(callbacks); - - return (generic_fromtext_txt(rdclass, type, lexer, origin, options, - target, callbacks)); -} - -static inline isc_result_t totext_ninfo(ARGS_TOTEXT) { UNUSED(tctx); diff --git a/usr.bin/dig/lib/dns/rdata/generic/ns_2.c b/usr.bin/dig/lib/dns/rdata/generic/ns_2.c index 03cb80768c5..2a2b44106ef 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/ns_2.c +++ b/usr.bin/dig/lib/dns/rdata/generic/ns_2.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: ns_2.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: ns_2.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* Reviewed: Wed Mar 15 18:15:00 PST 2000 by bwelling */ @@ -24,37 +24,6 @@ #define RRTYPE_NS_ATTRIBUTES (DNS_RDATATYPEATTR_ZONECUTAUTH) static inline isc_result_t -fromtext_ns(ARGS_FROMTEXT) { - isc_token_t token; - dns_name_t name; - isc_buffer_t buffer; - isc_boolean_t ok; - - REQUIRE(type == dns_rdatatype_ns); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - RETERR(isc_lex_getmastertoken(lexer, &token,isc_tokentype_string, - ISC_FALSE)); - - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - if (origin == NULL) - origin = dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); - ok = ISC_TRUE; - if ((options & DNS_RDATA_CHECKNAMES) != 0) - ok = dns_name_ishostname(&name, ISC_FALSE); - if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0) - RETTOK(DNS_R_BADNAME); - if (!ok && callbacks != NULL) - warn_badname(&name, lexer, callbacks); - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_ns(ARGS_TOTEXT) { isc_region_t region; dns_name_t name; diff --git a/usr.bin/dig/lib/dns/rdata/generic/nsec3_50.c b/usr.bin/dig/lib/dns/rdata/generic/nsec3_50.c index 27be10af1c7..be6511bb262 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/nsec3_50.c +++ b/usr.bin/dig/lib/dns/rdata/generic/nsec3_50.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: nsec3_50.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: nsec3_50.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* * Copyright (C) 2004 Nominet, Ltd. @@ -42,70 +42,6 @@ #define RRTYPE_NSEC3_ATTRIBUTES DNS_RDATATYPEATTR_DNSSEC 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)); -} - -static inline isc_result_t totext_nsec3(ARGS_TOTEXT) { isc_region_t sr; unsigned int i, j; diff --git a/usr.bin/dig/lib/dns/rdata/generic/nsec3param_51.c b/usr.bin/dig/lib/dns/rdata/generic/nsec3param_51.c index e33f556ff7f..79640b1046e 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/nsec3param_51.c +++ b/usr.bin/dig/lib/dns/rdata/generic/nsec3param_51.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: nsec3param_51.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: nsec3param_51.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* * Copyright (C) 2004 Nominet, Ltd. @@ -42,56 +42,6 @@ #define RRTYPE_NSEC3PARAM_ATTRIBUTES (DNS_RDATATYPEATTR_DNSSEC) 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 totext_nsec3param(ARGS_TOTEXT) { isc_region_t sr; unsigned int i, j; diff --git a/usr.bin/dig/lib/dns/rdata/generic/nsec_47.c b/usr.bin/dig/lib/dns/rdata/generic/nsec_47.c index 363504f6dda..b5565152d3f 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/nsec_47.c +++ b/usr.bin/dig/lib/dns/rdata/generic/nsec_47.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: nsec_47.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: nsec_47.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* reviewed: Wed Mar 15 18:21:15 PST 2000 by brister */ @@ -30,32 +30,6 @@ #define RRTYPE_NSEC_ATTRIBUTES (DNS_RDATATYPEATTR_DNSSEC) static inline isc_result_t -fromtext_nsec(ARGS_FROMTEXT) { - isc_token_t token; - dns_name_t name; - isc_buffer_t buffer; - - REQUIRE(type == dns_rdatatype_nsec); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - /* - * Next domain. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - if (origin == NULL) - origin = dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); - - return (typemap_fromtext(lexer, target, ISC_FALSE)); -} - -static inline isc_result_t totext_nsec(ARGS_TOTEXT) { isc_region_t sr; dns_name_t name; diff --git a/usr.bin/dig/lib/dns/rdata/generic/null_10.c b/usr.bin/dig/lib/dns/rdata/generic/null_10.c index d85e04b9ce4..88a7c0e7bea 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/null_10.c +++ b/usr.bin/dig/lib/dns/rdata/generic/null_10.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: null_10.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: null_10.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* Reviewed: Thu Mar 16 13:57:50 PST 2000 by explorer */ @@ -24,21 +24,6 @@ #define RRTYPE_NULL_ATTRIBUTES (0) static inline isc_result_t -fromtext_null(ARGS_FROMTEXT) { - REQUIRE(type == dns_rdatatype_null); - - UNUSED(rdclass); - UNUSED(type); - UNUSED(lexer); - UNUSED(origin); - UNUSED(options); - UNUSED(target); - UNUSED(callbacks); - - return (DNS_R_SYNTAX); -} - -static inline isc_result_t totext_null(ARGS_TOTEXT) { REQUIRE(rdata->type == dns_rdatatype_null); diff --git a/usr.bin/dig/lib/dns/rdata/generic/nxt_30.c b/usr.bin/dig/lib/dns/rdata/generic/nxt_30.c index dbe9ac41c92..8cae4c9deb0 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/nxt_30.c +++ b/usr.bin/dig/lib/dns/rdata/generic/nxt_30.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: nxt_30.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: nxt_30.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* reviewed: Wed Mar 15 18:21:15 PST 2000 by brister */ @@ -30,64 +30,6 @@ #define RRTYPE_NXT_ATTRIBUTES (0) static inline isc_result_t -fromtext_nxt(ARGS_FROMTEXT) { - isc_token_t token; - dns_name_t name; - isc_buffer_t buffer; - char *e; - unsigned char bm[8*1024]; /* 64k bits */ - dns_rdatatype_t covered; - dns_rdatatype_t maxcovered = 0; - isc_boolean_t first = ISC_TRUE; - long n; - - REQUIRE(type == dns_rdatatype_nxt); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - /* - * Next domain. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - if (origin == NULL) - origin = dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); - - memset(bm, 0, sizeof(bm)); - do { - RETERR(isc_lex_getmastertoken(lexer, &token, - isc_tokentype_string, ISC_TRUE)); - if (token.type != isc_tokentype_string) - break; - n = strtol(DNS_AS_STR(token), &e, 10); - if (e != DNS_AS_STR(token) && *e == '\0') { - covered = (dns_rdatatype_t)n; - } else if (dns_rdatatype_fromtext(&covered, - &token.value.as_textregion) == DNS_R_UNKNOWN) - RETTOK(DNS_R_UNKNOWN); - /* - * NXT is only specified for types 1..127. - */ - if (covered < 1 || covered > 127) - return (ISC_R_RANGE); - if (first || covered > maxcovered) - maxcovered = covered; - first = ISC_FALSE; - bm[covered/8] |= (0x80>>(covered%8)); - } while (1); - isc_lex_ungettoken(lexer, &token); - if (first) - return (ISC_R_SUCCESS); - n = (maxcovered + 8) / 8; - return (mem_tobuffer(target, bm, n)); -} - -static inline isc_result_t totext_nxt(ARGS_TOTEXT) { isc_region_t sr; unsigned int i, j; diff --git a/usr.bin/dig/lib/dns/rdata/generic/openpgpkey_61.c b/usr.bin/dig/lib/dns/rdata/generic/openpgpkey_61.c index 568c60d4b42..4e732bedc70 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/openpgpkey_61.c +++ b/usr.bin/dig/lib/dns/rdata/generic/openpgpkey_61.c @@ -20,23 +20,6 @@ #define RRTYPE_OPENPGPKEY_ATTRIBUTES 0 static inline isc_result_t -fromtext_openpgpkey(ARGS_FROMTEXT) { - - REQUIRE(type == dns_rdatatype_openpgpkey); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - UNUSED(options); - UNUSED(origin); - - /* - * Keyring. - */ - return (isc_base64_tobuffer(lexer, target, -1)); -} - -static inline isc_result_t totext_openpgpkey(ARGS_TOTEXT) { isc_region_t sr; diff --git a/usr.bin/dig/lib/dns/rdata/generic/opt_41.c b/usr.bin/dig/lib/dns/rdata/generic/opt_41.c index 618e2486988..34015f99c61 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/opt_41.c +++ b/usr.bin/dig/lib/dns/rdata/generic/opt_41.c @@ -26,25 +26,6 @@ DNS_RDATATYPEATTR_NOTQUESTION) static inline isc_result_t -fromtext_opt(ARGS_FROMTEXT) { - /* - * OPT records do not have a text format. - */ - - REQUIRE(type == dns_rdatatype_opt); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(lexer); - UNUSED(origin); - UNUSED(options); - UNUSED(target); - UNUSED(callbacks); - - return (ISC_R_NOTIMPLEMENTED); -} - -static inline isc_result_t totext_opt(ARGS_TOTEXT) { isc_region_t r; isc_region_t or; diff --git a/usr.bin/dig/lib/dns/rdata/generic/proforma.c b/usr.bin/dig/lib/dns/rdata/generic/proforma.c index e0a67f6ceff..c0278bdb1c7 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/proforma.c +++ b/usr.bin/dig/lib/dns/rdata/generic/proforma.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: proforma.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: proforma.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ #ifndef RDATA_GENERIC_#_#_C #define RDATA_GENERIC_#_#_C @@ -22,19 +22,6 @@ #define RRTYPE_#_ATTRIBUTES (0) static inline isc_result_t -fromtext_#(ARGS_FROMTEXT) { - isc_token_t token; - - REQUIRE(type == dns_rdatatype_proforma.c#); - REQUIRE(rdclass == #); - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - - return (ISC_R_NOTIMPLEMENTED); -} - -static inline isc_result_t totext_#(ARGS_TOTEXT) { REQUIRE(rdata->type == dns_rdatatype_proforma.c#); diff --git a/usr.bin/dig/lib/dns/rdata/generic/ptr_12.c b/usr.bin/dig/lib/dns/rdata/generic/ptr_12.c index f2aeb1b2196..353b1332469 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/ptr_12.c +++ b/usr.bin/dig/lib/dns/rdata/generic/ptr_12.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: ptr_12.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: ptr_12.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* Reviewed: Thu Mar 16 14:05:12 PST 2000 by explorer */ @@ -24,39 +24,6 @@ #define RRTYPE_PTR_ATTRIBUTES (0) static inline isc_result_t -fromtext_ptr(ARGS_FROMTEXT) { - isc_token_t token; - dns_name_t name; - isc_buffer_t buffer; - - REQUIRE(type == dns_rdatatype_ptr); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - if (origin == NULL) - origin = dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); - if (rdclass == dns_rdataclass_in && - (options & DNS_RDATA_CHECKNAMES) != 0 && - (options & DNS_RDATA_CHECKREVERSE) != 0) { - isc_boolean_t ok; - ok = dns_name_ishostname(&name, ISC_FALSE); - if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0) - RETTOK(DNS_R_BADNAME); - if (!ok && callbacks != NULL) - warn_badname(&name, lexer, callbacks); - } - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_ptr(ARGS_TOTEXT) { isc_region_t region; dns_name_t name; diff --git a/usr.bin/dig/lib/dns/rdata/generic/rkey_57.c b/usr.bin/dig/lib/dns/rdata/generic/rkey_57.c index 3b6d9c8ad9e..9207ed35338 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/rkey_57.c +++ b/usr.bin/dig/lib/dns/rdata/generic/rkey_57.c @@ -20,15 +20,6 @@ #define RRTYPE_RKEY_ATTRIBUTES 0 static inline isc_result_t -fromtext_rkey(ARGS_FROMTEXT) { - - REQUIRE(type == dns_rdatatype_rkey); - - return (generic_fromtext_key(rdclass, type, lexer, origin, - options, target, callbacks)); -} - -static inline isc_result_t totext_rkey(ARGS_TOTEXT) { REQUIRE(rdata != NULL); diff --git a/usr.bin/dig/lib/dns/rdata/generic/rp_17.c b/usr.bin/dig/lib/dns/rdata/generic/rp_17.c index b699dd6907b..073b63d8c57 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/rp_17.c +++ b/usr.bin/dig/lib/dns/rdata/generic/rp_17.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rp_17.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: rp_17.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* RFC1183 */ @@ -24,42 +24,6 @@ #define RRTYPE_RP_ATTRIBUTES (0) static inline isc_result_t -fromtext_rp(ARGS_FROMTEXT) { - isc_token_t token; - dns_name_t name; - isc_buffer_t buffer; - int i; - isc_boolean_t ok; - - REQUIRE(type == dns_rdatatype_rp); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - if (origin == NULL) - origin = dns_rootname; - - for (i = 0; i < 2; i++) { - RETERR(isc_lex_getmastertoken(lexer, &token, - isc_tokentype_string, - ISC_FALSE)); - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - RETTOK(dns_name_fromtext(&name, &buffer, origin, - options, target)); - ok = ISC_TRUE; - if ((options & DNS_RDATA_CHECKNAMES) != 0 && i == 0) - ok = dns_name_ismailbox(&name); - if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0) - RETTOK(DNS_R_BADNAME); - if (!ok && callbacks != NULL) - warn_badname(&name, lexer, callbacks); - } - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_rp(ARGS_TOTEXT) { isc_region_t region; dns_name_t rmail; diff --git a/usr.bin/dig/lib/dns/rdata/generic/rrsig_46.c b/usr.bin/dig/lib/dns/rdata/generic/rrsig_46.c index e096fcad626..44efce8033a 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/rrsig_46.c +++ b/usr.bin/dig/lib/dns/rdata/generic/rrsig_46.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rrsig_46.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: rrsig_46.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* Reviewed: Fri Mar 17 09:05:02 PST 2000 by gson */ @@ -26,131 +26,6 @@ #define RRTYPE_RRSIG_ATTRIBUTES (DNS_RDATATYPEATTR_DNSSEC) static inline isc_result_t -fromtext_rrsig(ARGS_FROMTEXT) { - isc_token_t token; - unsigned char c; - long i; - dns_rdatatype_t covered; - char *e; - isc_result_t result; - dns_name_t name; - isc_buffer_t buffer; - uint32_t time_signed, time_expire; - - REQUIRE(type == dns_rdatatype_rrsig); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - /* - * Type covered. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - result = dns_rdatatype_fromtext(&covered, &token.value.as_textregion); - if (result != ISC_R_SUCCESS && result != ISC_R_NOTIMPLEMENTED) { - i = strtol(DNS_AS_STR(token), &e, 10); - if (i < 0 || i > 65535) - RETTOK(ISC_R_RANGE); - if (*e != 0) - RETTOK(result); - covered = (dns_rdatatype_t)i; - } - RETERR(uint16_tobuffer(covered, target)); - - /* - * Algorithm. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - RETTOK(dns_secalg_fromtext(&c, &token.value.as_textregion)); - RETERR(mem_tobuffer(target, &c, 1)); - - /* - * Labels. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - if (token.value.as_ulong > 0xffU) - RETTOK(ISC_R_RANGE); - c = (unsigned char)token.value.as_ulong; - RETERR(mem_tobuffer(target, &c, 1)); - - /* - * Original ttl. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - RETERR(uint32_tobuffer(token.value.as_ulong, target)); - - /* - * Signature expiration. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - if (strlen(DNS_AS_STR(token)) <= 10U && - *DNS_AS_STR(token) != '-' && *DNS_AS_STR(token) != '+') { - char *end; - unsigned long u; - uint64_t u64; - - u64 = u = strtoul(DNS_AS_STR(token), &end, 10); - if (u == ULONG_MAX || *end != 0) - RETTOK(DNS_R_SYNTAX); - if (u64 > 0xffffffffUL) - RETTOK(ISC_R_RANGE); - time_expire = u; - } else - RETTOK(dns_time32_fromtext(DNS_AS_STR(token), &time_expire)); - RETERR(uint32_tobuffer(time_expire, target)); - - /* - * Time signed. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - if (strlen(DNS_AS_STR(token)) <= 10U && - *DNS_AS_STR(token) != '-' && *DNS_AS_STR(token) != '+') { - char *end; - unsigned long u; - uint64_t u64; - - u64 = u = strtoul(DNS_AS_STR(token), &end, 10); - if (u == ULONG_MAX || *end != 0) - RETTOK(DNS_R_SYNTAX); - if (u64 > 0xffffffffUL) - RETTOK(ISC_R_RANGE); - time_signed = u; - } else - RETTOK(dns_time32_fromtext(DNS_AS_STR(token), &time_signed)); - RETERR(uint32_tobuffer(time_signed, target)); - - /* - * Key footprint. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - RETERR(uint16_tobuffer(token.value.as_ulong, target)); - - /* - * Signer. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - if (origin == NULL) - origin = dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); - - /* - * Sig. - */ - return (isc_base64_tobuffer(lexer, target, -1)); -} - -static inline isc_result_t totext_rrsig(ARGS_TOTEXT) { isc_region_t sr; char buf[sizeof("4294967295")]; /* Also TYPE65000. */ diff --git a/usr.bin/dig/lib/dns/rdata/generic/rt_21.c b/usr.bin/dig/lib/dns/rdata/generic/rt_21.c index d4d1f7b07a6..b76174b2e93 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/rt_21.c +++ b/usr.bin/dig/lib/dns/rdata/generic/rt_21.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rt_21.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: rt_21.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* reviewed: Thu Mar 16 15:02:31 PST 2000 by brister */ @@ -26,43 +26,6 @@ #define RRTYPE_RT_ATTRIBUTES (0) static inline isc_result_t -fromtext_rt(ARGS_FROMTEXT) { - isc_token_t token; - dns_name_t name; - isc_buffer_t buffer; - isc_boolean_t ok; - - REQUIRE(type == dns_rdatatype_rt); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - 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)); - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - if (origin == NULL) - origin = dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); - ok = ISC_TRUE; - if ((options & DNS_RDATA_CHECKNAMES) != 0) - ok = dns_name_ishostname(&name, ISC_FALSE); - if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0) - RETTOK(DNS_R_BADNAME); - if (!ok && callbacks != NULL) - warn_badname(&name, lexer, callbacks); - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_rt(ARGS_TOTEXT) { isc_region_t region; dns_name_t name; diff --git a/usr.bin/dig/lib/dns/rdata/generic/sig_24.c b/usr.bin/dig/lib/dns/rdata/generic/sig_24.c index fd06409aba8..7e7b96229e5 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/sig_24.c +++ b/usr.bin/dig/lib/dns/rdata/generic/sig_24.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: sig_24.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: sig_24.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* Reviewed: Fri Mar 17 09:05:02 PST 2000 by gson */ @@ -26,105 +26,6 @@ #define RRTYPE_SIG_ATTRIBUTES (0) static inline isc_result_t -fromtext_sig(ARGS_FROMTEXT) { - isc_token_t token; - unsigned char c; - long i; - dns_rdatatype_t covered; - char *e; - isc_result_t result; - dns_name_t name; - isc_buffer_t buffer; - uint32_t time_signed, time_expire; - - REQUIRE(type == dns_rdatatype_sig); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - /* - * Type covered. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - result = dns_rdatatype_fromtext(&covered, &token.value.as_textregion); - if (result != ISC_R_SUCCESS && result != ISC_R_NOTIMPLEMENTED) { - i = strtol(DNS_AS_STR(token), &e, 10); - if (i < 0 || i > 65535) - RETTOK(ISC_R_RANGE); - if (*e != 0) - RETTOK(result); - covered = (dns_rdatatype_t)i; - } - RETERR(uint16_tobuffer(covered, target)); - - /* - * Algorithm. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - RETTOK(dns_secalg_fromtext(&c, &token.value.as_textregion)); - RETERR(mem_tobuffer(target, &c, 1)); - - /* - * Labels. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - if (token.value.as_ulong > 0xffU) - RETTOK(ISC_R_RANGE); - c = (unsigned char)token.value.as_ulong; - RETERR(mem_tobuffer(target, &c, 1)); - - /* - * Original ttl. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - RETERR(uint32_tobuffer(token.value.as_ulong, target)); - - /* - * Signature expiration. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - RETTOK(dns_time32_fromtext(DNS_AS_STR(token), &time_expire)); - RETERR(uint32_tobuffer(time_expire, target)); - - /* - * Time signed. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - RETTOK(dns_time32_fromtext(DNS_AS_STR(token), &time_signed)); - RETERR(uint32_tobuffer(time_signed, target)); - - /* - * Key footprint. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - RETERR(uint16_tobuffer(token.value.as_ulong, target)); - - /* - * Signer. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - if (origin == NULL) - origin = dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); - - /* - * Sig. - */ - return (isc_base64_tobuffer(lexer, target, -1)); -} - -static inline isc_result_t totext_sig(ARGS_TOTEXT) { isc_region_t sr; char buf[sizeof("4294967295")]; diff --git a/usr.bin/dig/lib/dns/rdata/generic/sink_40.c b/usr.bin/dig/lib/dns/rdata/generic/sink_40.c index c4fbd558216..cecff0c3c77 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/sink_40.c +++ b/usr.bin/dig/lib/dns/rdata/generic/sink_40.c @@ -22,42 +22,6 @@ #define RRTYPE_SINK_ATTRIBUTES (0) static inline isc_result_t -fromtext_sink(ARGS_FROMTEXT) { - isc_token_t token; - - REQUIRE(type == dns_rdatatype_sink); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - UNUSED(callbacks); - - /* meaning */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - if (token.value.as_ulong > 0xffU) - RETTOK(ISC_R_RANGE); - RETERR(uint8_tobuffer(token.value.as_ulong, target)); - - /* coding */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - if (token.value.as_ulong > 0xffU) - RETTOK(ISC_R_RANGE); - RETERR(uint8_tobuffer(token.value.as_ulong, target)); - - /* subcoding */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - if (token.value.as_ulong > 0xffU) - RETTOK(ISC_R_RANGE); - RETERR(uint8_tobuffer(token.value.as_ulong, target)); - - return(isc_base64_tobuffer(lexer, target, -1)); -} - -static inline isc_result_t totext_sink(ARGS_TOTEXT) { isc_region_t sr; char buf[sizeof("255 255 255")]; diff --git a/usr.bin/dig/lib/dns/rdata/generic/smimea_53.c b/usr.bin/dig/lib/dns/rdata/generic/smimea_53.c index cfa9175d566..a76e4b2b245 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/smimea_53.c +++ b/usr.bin/dig/lib/dns/rdata/generic/smimea_53.c @@ -20,15 +20,6 @@ #define RRTYPE_SMIMEA_ATTRIBUTES 0 static inline isc_result_t -fromtext_smimea(ARGS_FROMTEXT) { - - REQUIRE(type == dns_rdatatype_smimea); - - return (generic_fromtext_tlsa(rdclass, type, lexer, origin, options, - target, callbacks)); -} - -static inline isc_result_t totext_smimea(ARGS_TOTEXT) { REQUIRE(rdata->type == dns_rdatatype_smimea); diff --git a/usr.bin/dig/lib/dns/rdata/generic/soa_6.c b/usr.bin/dig/lib/dns/rdata/generic/soa_6.c index a0be4a64c26..b1757e3791b 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/soa_6.c +++ b/usr.bin/dig/lib/dns/rdata/generic/soa_6.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: soa_6.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: soa_6.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* Reviewed: Thu Mar 16 15:18:32 PST 2000 by explorer */ @@ -23,65 +23,6 @@ #define RRTYPE_SOA_ATTRIBUTES (DNS_RDATATYPEATTR_SINGLETON) -static inline isc_result_t -fromtext_soa(ARGS_FROMTEXT) { - isc_token_t token; - dns_name_t name; - isc_buffer_t buffer; - int i; - uint32_t n; - isc_boolean_t ok; - - REQUIRE(type == dns_rdatatype_soa); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - if (origin == NULL) - origin = dns_rootname; - - for (i = 0; i < 2; i++) { - RETERR(isc_lex_getmastertoken(lexer, &token, - isc_tokentype_string, - ISC_FALSE)); - - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - RETTOK(dns_name_fromtext(&name, &buffer, origin, - options, target)); - ok = ISC_TRUE; - if ((options & DNS_RDATA_CHECKNAMES) != 0) - switch (i) { - case 0: - ok = dns_name_ishostname(&name, ISC_FALSE); - break; - case 1: - ok = dns_name_ismailbox(&name); - break; - - } - if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0) - RETTOK(DNS_R_BADNAME); - if (!ok && callbacks != NULL) - warn_badname(&name, lexer, callbacks); - } - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - RETERR(uint32_tobuffer(token.value.as_ulong, target)); - - for (i = 0; i < 4; i++) { - RETERR(isc_lex_getmastertoken(lexer, &token, - isc_tokentype_string, - ISC_FALSE)); - RETTOK(dns_counter_fromtext(&token.value.as_textregion, &n)); - RETERR(uint32_tobuffer(n, target)); - } - - return (ISC_R_SUCCESS); -} - static const char *soa_fieldnames[5] = { "serial", "refresh", "retry", "expire", "minimum" }; diff --git a/usr.bin/dig/lib/dns/rdata/generic/spf_99.c b/usr.bin/dig/lib/dns/rdata/generic/spf_99.c index 6619b0936da..26922d3a529 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/spf_99.c +++ b/usr.bin/dig/lib/dns/rdata/generic/spf_99.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: spf_99.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: spf_99.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* Reviewed: Thu Mar 16 15:40:00 PST 2000 by bwelling */ @@ -24,21 +24,6 @@ #define RRTYPE_SPF_ATTRIBUTES (0) static inline isc_result_t -fromtext_spf(ARGS_FROMTEXT) { - - REQUIRE(type == dns_rdatatype_spf); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - UNUSED(callbacks); - - return (generic_fromtext_txt(rdclass, type, lexer, origin, options, - target, callbacks)); -} - -static inline isc_result_t totext_spf(ARGS_TOTEXT) { UNUSED(tctx); diff --git a/usr.bin/dig/lib/dns/rdata/generic/sshfp_44.c b/usr.bin/dig/lib/dns/rdata/generic/sshfp_44.c index faae4365759..79443cd2204 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/sshfp_44.c +++ b/usr.bin/dig/lib/dns/rdata/generic/sshfp_44.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: sshfp_44.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: sshfp_44.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* RFC 4255 */ @@ -24,42 +24,6 @@ #define RRTYPE_SSHFP_ATTRIBUTES (0) static inline isc_result_t -fromtext_sshfp(ARGS_FROMTEXT) { - isc_token_t token; - - REQUIRE(type == dns_rdatatype_sshfp); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - UNUSED(callbacks); - - /* - * Algorithm. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - if (token.value.as_ulong > 0xffU) - RETTOK(ISC_R_RANGE); - RETERR(uint8_tobuffer(token.value.as_ulong, target)); - - /* - * Digest type. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - if (token.value.as_ulong > 0xffU) - RETTOK(ISC_R_RANGE); - RETERR(uint8_tobuffer(token.value.as_ulong, target)); - - /* - * Digest. - */ - return (isc_hex_tobuffer(lexer, target, -1)); -} - -static inline isc_result_t totext_sshfp(ARGS_TOTEXT) { isc_region_t sr; char buf[sizeof("64000 ")]; diff --git a/usr.bin/dig/lib/dns/rdata/generic/ta_32768.c b/usr.bin/dig/lib/dns/rdata/generic/ta_32768.c index 019fb65cf5b..68a20ae3b3f 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/ta_32768.c +++ b/usr.bin/dig/lib/dns/rdata/generic/ta_32768.c @@ -22,15 +22,6 @@ #define RRTYPE_TA_ATTRIBUTES 0 static inline isc_result_t -fromtext_ta(ARGS_FROMTEXT) { - - REQUIRE(type == dns_rdatatype_ta); - - return (generic_fromtext_ds(rdclass, type, lexer, origin, options, - target, callbacks)); -} - -static inline isc_result_t totext_ta(ARGS_TOTEXT) { REQUIRE(rdata->type == dns_rdatatype_ta); diff --git a/usr.bin/dig/lib/dns/rdata/generic/talink_58.c b/usr.bin/dig/lib/dns/rdata/generic/talink_58.c index 6bde9fcaba3..1eceb47e84c 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/talink_58.c +++ b/usr.bin/dig/lib/dns/rdata/generic/talink_58.c @@ -20,36 +20,6 @@ #define RRTYPE_TALINK_ATTRIBUTES 0 static inline isc_result_t -fromtext_talink(ARGS_FROMTEXT) { - isc_token_t token; - dns_name_t name; - isc_buffer_t buffer; - int i; - - REQUIRE(type == dns_rdatatype_talink); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - if (origin == NULL) - origin = dns_rootname; - - for (i = 0; i < 2; i++) { - RETERR(isc_lex_getmastertoken(lexer, &token, - isc_tokentype_string, - ISC_FALSE)); - - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - RETTOK(dns_name_fromtext(&name, &buffer, origin, - options, target)); - } - - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_talink(ARGS_TOTEXT) { isc_region_t dregion; dns_name_t prev; diff --git a/usr.bin/dig/lib/dns/rdata/generic/tkey_249.c b/usr.bin/dig/lib/dns/rdata/generic/tkey_249.c index a684513113a..9d868ddfe1a 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/tkey_249.c +++ b/usr.bin/dig/lib/dns/rdata/generic/tkey_249.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: tkey_249.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: tkey_249.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* * Reviewed: Thu Mar 16 17:35:30 PST 2000 by halley. @@ -28,102 +28,6 @@ #define RRTYPE_TKEY_ATTRIBUTES (DNS_RDATATYPEATTR_META) static inline isc_result_t -fromtext_tkey(ARGS_FROMTEXT) { - isc_token_t token; - dns_rcode_t rcode; - dns_name_t name; - isc_buffer_t buffer; - long i; - char *e; - - REQUIRE(type == dns_rdatatype_tkey); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - /* - * Algorithm. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - if (origin == NULL) - origin = dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); - - - /* - * Inception. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - RETERR(uint32_tobuffer(token.value.as_ulong, target)); - - /* - * Expiration. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - RETERR(uint32_tobuffer(token.value.as_ulong, target)); - - /* - * Mode. - */ - 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)); - - /* - * Error. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - if (dns_tsigrcode_fromtext(&rcode, &token.value.as_textregion) - != ISC_R_SUCCESS) - { - i = strtol(DNS_AS_STR(token), &e, 10); - if (*e != 0) - RETTOK(DNS_R_UNKNOWN); - if (i < 0 || i > 0xffff) - RETTOK(ISC_R_RANGE); - rcode = (dns_rcode_t)i; - } - RETERR(uint16_tobuffer(rcode, target)); - - /* - * Key Size. - */ - 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)); - - /* - * Key Data. - */ - RETERR(isc_base64_tobuffer(lexer, target, (int)token.value.as_ulong)); - - /* - * Other Size. - */ - 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)); - - /* - * Other Data. - */ - return (isc_base64_tobuffer(lexer, target, (int)token.value.as_ulong)); -} - -static inline isc_result_t totext_tkey(ARGS_TOTEXT) { isc_region_t sr, dr; char buf[sizeof("4294967295 ")]; diff --git a/usr.bin/dig/lib/dns/rdata/generic/tlsa_52.c b/usr.bin/dig/lib/dns/rdata/generic/tlsa_52.c index 44a9e87eab2..439a110ab9a 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/tlsa_52.c +++ b/usr.bin/dig/lib/dns/rdata/generic/tlsa_52.c @@ -22,49 +22,6 @@ #define RRTYPE_TLSA_ATTRIBUTES 0 static inline isc_result_t -generic_fromtext_tlsa(ARGS_FROMTEXT) { - isc_token_t token; - - UNUSED(type); - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - UNUSED(callbacks); - - /* - * Certificate Usage. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - if (token.value.as_ulong > 0xffU) - RETTOK(ISC_R_RANGE); - RETERR(uint8_tobuffer(token.value.as_ulong, target)); - - /* - * Selector. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - if (token.value.as_ulong > 0xffU) - RETTOK(ISC_R_RANGE); - RETERR(uint8_tobuffer(token.value.as_ulong, target)); - - /* - * Matching type. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - if (token.value.as_ulong > 0xffU) - RETTOK(ISC_R_RANGE); - RETERR(uint8_tobuffer(token.value.as_ulong, target)); - - /* - * Certificate Association Data. - */ - return (isc_hex_tobuffer(lexer, target, -1)); -} - -static inline isc_result_t generic_totext_tlsa(ARGS_TOTEXT) { isc_region_t sr; char buf[sizeof("64000 ")]; @@ -135,15 +92,6 @@ generic_fromwire_tlsa(ARGS_FROMWIRE) { } static inline isc_result_t -fromtext_tlsa(ARGS_FROMTEXT) { - - REQUIRE(type == dns_rdatatype_tlsa); - - return (generic_fromtext_tlsa(rdclass, type, lexer, origin, options, - target, callbacks)); -} - -static inline isc_result_t totext_tlsa(ARGS_TOTEXT) { REQUIRE(rdata->type == dns_rdatatype_tlsa); diff --git a/usr.bin/dig/lib/dns/rdata/generic/txt_16.c b/usr.bin/dig/lib/dns/rdata/generic/txt_16.c index d258134e547..2d7b6dba849 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/txt_16.c +++ b/usr.bin/dig/lib/dns/rdata/generic/txt_16.c @@ -22,40 +22,6 @@ #define RRTYPE_TXT_ATTRIBUTES (0) static inline isc_result_t -generic_fromtext_txt(ARGS_FROMTEXT) { - isc_token_t token; - int strings; - - UNUSED(type); - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - UNUSED(callbacks); - - strings = 0; - if ((options & DNS_RDATA_UNKNOWNESCAPE) != 0) { - isc_textregion_t r; - DE_CONST("#", r.base); - r.length = 1; - RETERR(txt_fromtext(&r, target)); - strings++; - } - for (;;) { - RETERR(isc_lex_getmastertoken(lexer, &token, - isc_tokentype_qstring, - ISC_TRUE)); - if (token.type != isc_tokentype_qstring && - token.type != isc_tokentype_string) - break; - RETTOK(txt_fromtext(&token.value.as_textregion, target)); - strings++; - } - /* Let upper layer handle eol/eof. */ - isc_lex_ungettoken(lexer, &token); - return (strings == 0 ? ISC_R_UNEXPECTEDEND : ISC_R_SUCCESS); -} - -static inline isc_result_t generic_totext_txt(ARGS_TOTEXT) { isc_region_t region; @@ -90,15 +56,6 @@ generic_fromwire_txt(ARGS_FROMWIRE) { } static inline isc_result_t -fromtext_txt(ARGS_FROMTEXT) { - - REQUIRE(type == dns_rdatatype_txt); - - return (generic_fromtext_txt(rdclass, type, lexer, origin, options, - target, callbacks)); -} - -static inline isc_result_t totext_txt(ARGS_TOTEXT) { REQUIRE(rdata->type == dns_rdatatype_txt); diff --git a/usr.bin/dig/lib/dns/rdata/generic/unspec_103.c b/usr.bin/dig/lib/dns/rdata/generic/unspec_103.c index bd473485338..149f617e800 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/unspec_103.c +++ b/usr.bin/dig/lib/dns/rdata/generic/unspec_103.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: unspec_103.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: unspec_103.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ #ifndef RDATA_GENERIC_UNSPEC_103_C #define RDATA_GENERIC_UNSPEC_103_C @@ -22,20 +22,6 @@ #define RRTYPE_UNSPEC_ATTRIBUTES (0) static inline isc_result_t -fromtext_unspec(ARGS_FROMTEXT) { - - REQUIRE(type == dns_rdatatype_unspec); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - UNUSED(callbacks); - - return (atob_tobuffer(lexer, target)); -} - -static inline isc_result_t totext_unspec(ARGS_TOTEXT) { REQUIRE(rdata->type == dns_rdatatype_unspec); diff --git a/usr.bin/dig/lib/dns/rdata/generic/uri_256.c b/usr.bin/dig/lib/dns/rdata/generic/uri_256.c index 5fccc2da176..1f5b5bb61dc 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/uri_256.c +++ b/usr.bin/dig/lib/dns/rdata/generic/uri_256.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: uri_256.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: uri_256.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ #ifndef GENERIC_URI_256_C #define GENERIC_URI_256_C 1 @@ -22,47 +22,6 @@ #define RRTYPE_URI_ATTRIBUTES (0) static inline isc_result_t -fromtext_uri(ARGS_FROMTEXT) { - isc_token_t token; - - REQUIRE(type == dns_rdatatype_uri); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - UNUSED(callbacks); - - /* - * Priority - */ - 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)); - - /* - * Weight - */ - 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)); - - /* - * Target URI - */ - RETERR(isc_lex_getmastertoken(lexer, &token, - isc_tokentype_qstring, ISC_FALSE)); - if (token.type != isc_tokentype_qstring) - RETTOK(DNS_R_SYNTAX); - RETTOK(multitxt_fromtext(&token.value.as_textregion, target)); - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_uri(ARGS_TOTEXT) { isc_region_t region; unsigned short priority, weight; diff --git a/usr.bin/dig/lib/dns/rdata/generic/x25_19.c b/usr.bin/dig/lib/dns/rdata/generic/x25_19.c index d41371c4563..198e196a92f 100644 --- a/usr.bin/dig/lib/dns/rdata/generic/x25_19.c +++ b/usr.bin/dig/lib/dns/rdata/generic/x25_19.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: x25_19.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: x25_19.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* Reviewed: Thu Mar 16 16:15:57 PST 2000 by bwelling */ @@ -26,30 +26,6 @@ #define RRTYPE_X25_ATTRIBUTES (0) static inline isc_result_t -fromtext_x25(ARGS_FROMTEXT) { - isc_token_t token; - unsigned int i; - - REQUIRE(type == dns_rdatatype_x25); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - UNUSED(callbacks); - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring, - ISC_FALSE)); - if (token.value.as_textregion.length < 4) - RETTOK(DNS_R_SYNTAX); - for (i = 0; i < token.value.as_textregion.length; i++) - if (!isdigit(token.value.as_textregion.base[i] & 0xff)) - RETTOK(ISC_R_RANGE); - RETTOK(txt_fromtext(&token.value.as_textregion, target)); - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_x25(ARGS_TOTEXT) { isc_region_t region; diff --git a/usr.bin/dig/lib/dns/rdata/hs_4/a_1.c b/usr.bin/dig/lib/dns/rdata/hs_4/a_1.c index 330d21750aa..2b9649eac91 100644 --- a/usr.bin/dig/lib/dns/rdata/hs_4/a_1.c +++ b/usr.bin/dig/lib/dns/rdata/hs_4/a_1.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: a_1.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: a_1.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* reviewed: Thu Mar 16 15:58:36 PST 2000 by brister */ @@ -26,33 +26,6 @@ #define RRTYPE_A_ATTRIBUTES (0) static inline isc_result_t -fromtext_hs_a(ARGS_FROMTEXT) { - isc_token_t token; - struct in_addr addr; - isc_region_t region; - - REQUIRE(type == dns_rdatatype_a); - REQUIRE(rdclass == dns_rdataclass_hs); - - UNUSED(type); - UNUSED(origin); - UNUSED(options); - UNUSED(rdclass); - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - - if (getquad(DNS_AS_STR(token), &addr, lexer, callbacks) != 1) - RETTOK(DNS_R_BADDOTTEDQUAD); - isc_buffer_availableregion(target, ®ion); - if (region.length < 4) - return (ISC_R_NOSPACE); - memmove(region.base, &addr, 4); - isc_buffer_add(target, 4); - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_hs_a(ARGS_TOTEXT) { isc_region_t region; diff --git a/usr.bin/dig/lib/dns/rdata/in_1/a6_38.c b/usr.bin/dig/lib/dns/rdata/in_1/a6_38.c index faeff1645d4..cd5ce99c276 100644 --- a/usr.bin/dig/lib/dns/rdata/in_1/a6_38.c +++ b/usr.bin/dig/lib/dns/rdata/in_1/a6_38.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: a6_38.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: a6_38.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* RFC2874 */ @@ -26,76 +26,6 @@ #define RRTYPE_A6_ATTRIBUTES (0) static inline isc_result_t -fromtext_in_a6(ARGS_FROMTEXT) { - isc_token_t token; - unsigned char addr[16]; - unsigned char prefixlen; - unsigned char octets; - unsigned char mask; - dns_name_t name; - isc_buffer_t buffer; - isc_boolean_t ok; - - REQUIRE(type == dns_rdatatype_a6); - REQUIRE(rdclass == dns_rdataclass_in); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - /* - * Prefix length. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, - ISC_FALSE)); - if (token.value.as_ulong > 128U) - RETTOK(ISC_R_RANGE); - - prefixlen = (unsigned char)token.value.as_ulong; - RETERR(mem_tobuffer(target, &prefixlen, 1)); - - /* - * Suffix. - */ - if (prefixlen != 128) { - /* - * Prefix 0..127. - */ - octets = prefixlen/8; - /* - * Octets 0..15. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, - isc_tokentype_string, - ISC_FALSE)); - if (inet_pton(AF_INET6, DNS_AS_STR(token), addr) != 1) - RETTOK(DNS_R_BADAAAA); - mask = 0xff >> (prefixlen % 8); - addr[octets] &= mask; - RETERR(mem_tobuffer(target, &addr[octets], 16 - octets)); - } - - if (prefixlen == 0) - return (ISC_R_SUCCESS); - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - if (origin == NULL) - origin = dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); - ok = ISC_TRUE; - if ((options & DNS_RDATA_CHECKNAMES) != 0) - ok = dns_name_ishostname(&name, ISC_FALSE); - if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0) - RETTOK(DNS_R_BADNAME); - if (!ok && callbacks != NULL) - warn_badname(&name, lexer, callbacks); - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_in_a6(ARGS_TOTEXT) { isc_region_t sr, ar; unsigned char addr[16]; diff --git a/usr.bin/dig/lib/dns/rdata/in_1/a_1.c b/usr.bin/dig/lib/dns/rdata/in_1/a_1.c index f61d084a523..50d9dd30976 100644 --- a/usr.bin/dig/lib/dns/rdata/in_1/a_1.c +++ b/usr.bin/dig/lib/dns/rdata/in_1/a_1.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: a_1.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: a_1.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* Reviewed: Thu Mar 16 16:52:50 PST 2000 by bwelling */ @@ -28,33 +28,6 @@ #define RRTYPE_A_ATTRIBUTES (0) static inline isc_result_t -fromtext_in_a(ARGS_FROMTEXT) { - isc_token_t token; - struct in_addr addr; - isc_region_t region; - - REQUIRE(type == dns_rdatatype_a); - REQUIRE(rdclass == dns_rdataclass_in); - - UNUSED(type); - UNUSED(origin); - UNUSED(options); - UNUSED(rdclass); - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - - if (getquad(DNS_AS_STR(token), &addr, lexer, callbacks) != 1) - RETTOK(DNS_R_BADDOTTEDQUAD); - isc_buffer_availableregion(target, ®ion); - if (region.length < 4) - return (ISC_R_NOSPACE); - memmove(region.base, &addr, 4); - isc_buffer_add(target, 4); - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_in_a(ARGS_TOTEXT) { isc_region_t region; diff --git a/usr.bin/dig/lib/dns/rdata/in_1/aaaa_28.c b/usr.bin/dig/lib/dns/rdata/in_1/aaaa_28.c index 14ad878c138..9f33fa093d4 100644 --- a/usr.bin/dig/lib/dns/rdata/in_1/aaaa_28.c +++ b/usr.bin/dig/lib/dns/rdata/in_1/aaaa_28.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: aaaa_28.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: aaaa_28.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* Reviewed: Thu Mar 16 16:52:50 PST 2000 by bwelling */ @@ -28,34 +28,6 @@ #define RRTYPE_AAAA_ATTRIBUTES (0) static inline isc_result_t -fromtext_in_aaaa(ARGS_FROMTEXT) { - isc_token_t token; - unsigned char addr[16]; - isc_region_t region; - - REQUIRE(type == dns_rdatatype_aaaa); - REQUIRE(rdclass == dns_rdataclass_in); - - UNUSED(type); - UNUSED(origin); - UNUSED(options); - UNUSED(rdclass); - UNUSED(callbacks); - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - - if (inet_pton(AF_INET6, DNS_AS_STR(token), addr) != 1) - RETTOK(DNS_R_BADAAAA); - isc_buffer_availableregion(target, ®ion); - if (region.length < 16) - return (ISC_R_NOSPACE); - memmove(region.base, addr, 16); - isc_buffer_add(target, 16); - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_in_aaaa(ARGS_TOTEXT) { isc_region_t region; diff --git a/usr.bin/dig/lib/dns/rdata/in_1/apl_42.c b/usr.bin/dig/lib/dns/rdata/in_1/apl_42.c index f712390fa10..0da03ca71c6 100644 --- a/usr.bin/dig/lib/dns/rdata/in_1/apl_42.c +++ b/usr.bin/dig/lib/dns/rdata/in_1/apl_42.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: apl_42.c,v 1.2 2020/02/12 13:05:04 jsg Exp $ */ +/* $Id: apl_42.c,v 1.3 2020/02/20 18:08:51 florian Exp $ */ /* RFC3123 */ @@ -24,89 +24,6 @@ #define RRTYPE_APL_ATTRIBUTES (0) static inline isc_result_t -fromtext_in_apl(ARGS_FROMTEXT) { - isc_token_t token; - unsigned char addr[16]; - unsigned long afi; - uint8_t prefix; - uint8_t len; - isc_boolean_t neg; - char *cp, *ap, *slash; - int n; - - REQUIRE(type == dns_rdatatype_apl); - REQUIRE(rdclass == dns_rdataclass_in); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - UNUSED(callbacks); - - do { - RETERR(isc_lex_getmastertoken(lexer, &token, - isc_tokentype_string, ISC_TRUE)); - if (token.type != isc_tokentype_string) - break; - - cp = DNS_AS_STR(token); - neg = ISC_TF(*cp == '!'); - if (neg) - cp++; - afi = strtoul(cp, &ap, 10); - if (*ap++ != ':' || cp == ap) - RETTOK(DNS_R_SYNTAX); - if (afi > 0xffffU) - RETTOK(ISC_R_RANGE); - slash = strchr(ap, '/'); - if (slash == NULL || slash == ap) - RETTOK(DNS_R_SYNTAX); - RETTOK(isc_parse_uint8(&prefix, slash + 1, 10)); - switch (afi) { - case 1: - *slash = '\0'; - n = inet_pton(AF_INET, ap, addr); - *slash = '/'; - if (n != 1) - RETTOK(DNS_R_BADDOTTEDQUAD); - if (prefix > 32) - RETTOK(ISC_R_RANGE); - for (len = 4; len > 0; len--) - if (addr[len - 1] != 0) - break; - break; - - case 2: - *slash = '\0'; - n = inet_pton(AF_INET6, ap, addr); - *slash = '/'; - if (n != 1) - RETTOK(DNS_R_BADAAAA); - if (prefix > 128) - RETTOK(ISC_R_RANGE); - for (len = 16; len > 0; len--) - if (addr[len - 1] != 0) - break; - break; - - default: - RETTOK(ISC_R_NOTIMPLEMENTED); - } - RETERR(uint16_tobuffer(afi, target)); - RETERR(uint8_tobuffer(prefix, target)); - RETERR(uint8_tobuffer(len | ((neg) ? 0x80 : 0), target)); - RETERR(mem_tobuffer(target, addr, len)); - } while (1); - - /* - * Let upper layer handle eol/eof. - */ - isc_lex_ungettoken(lexer, &token); - - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_in_apl(ARGS_TOTEXT) { isc_region_t sr; isc_region_t ir; diff --git a/usr.bin/dig/lib/dns/rdata/in_1/dhcid_49.c b/usr.bin/dig/lib/dns/rdata/in_1/dhcid_49.c index 222e8f11cfa..a0a7ac0a520 100644 --- a/usr.bin/dig/lib/dns/rdata/in_1/dhcid_49.c +++ b/usr.bin/dig/lib/dns/rdata/in_1/dhcid_49.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dhcid_49.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: dhcid_49.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* RFC 4701 */ @@ -24,21 +24,6 @@ #define RRTYPE_DHCID_ATTRIBUTES 0 static inline isc_result_t -fromtext_in_dhcid(ARGS_FROMTEXT) { - - REQUIRE(type == dns_rdatatype_dhcid); - REQUIRE(rdclass == dns_rdataclass_in); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(origin); - UNUSED(options); - UNUSED(callbacks); - - return (isc_base64_tobuffer(lexer, target, -1)); -} - -static inline isc_result_t totext_in_dhcid(ARGS_TOTEXT) { isc_region_t sr, sr2; char buf[sizeof(" ; 64000 255 64000")]; diff --git a/usr.bin/dig/lib/dns/rdata/in_1/kx_36.c b/usr.bin/dig/lib/dns/rdata/in_1/kx_36.c index 460268a9d30..83734c9a70e 100644 --- a/usr.bin/dig/lib/dns/rdata/in_1/kx_36.c +++ b/usr.bin/dig/lib/dns/rdata/in_1/kx_36.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: kx_36.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: kx_36.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* Reviewed: Thu Mar 16 17:24:54 PST 2000 by explorer */ @@ -26,35 +26,6 @@ #define RRTYPE_KX_ATTRIBUTES (0) static inline isc_result_t -fromtext_in_kx(ARGS_FROMTEXT) { - isc_token_t token; - dns_name_t name; - isc_buffer_t buffer; - - REQUIRE(type == dns_rdatatype_kx); - REQUIRE(rdclass == dns_rdataclass_in); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - 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)); - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - if (origin == NULL) - origin = dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_in_kx(ARGS_TOTEXT) { isc_region_t region; dns_name_t name; diff --git a/usr.bin/dig/lib/dns/rdata/in_1/nsap-ptr_23.c b/usr.bin/dig/lib/dns/rdata/in_1/nsap-ptr_23.c index 8abf3628a1c..dc8ef2dee5a 100644 --- a/usr.bin/dig/lib/dns/rdata/in_1/nsap-ptr_23.c +++ b/usr.bin/dig/lib/dns/rdata/in_1/nsap-ptr_23.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: nsap-ptr_23.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: nsap-ptr_23.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* Reviewed: Fri Mar 17 10:16:02 PST 2000 by gson */ @@ -26,30 +26,6 @@ #define RRTYPE_NSAP_PTR_ATTRIBUTES (0) static inline isc_result_t -fromtext_in_nsap_ptr(ARGS_FROMTEXT) { - isc_token_t token; - dns_name_t name; - isc_buffer_t buffer; - - REQUIRE(type == dns_rdatatype_nsap_ptr); - REQUIRE(rdclass == dns_rdataclass_in); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - if (origin == NULL) - origin = dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_in_nsap_ptr(ARGS_TOTEXT) { isc_region_t region; dns_name_t name; diff --git a/usr.bin/dig/lib/dns/rdata/in_1/nsap_22.c b/usr.bin/dig/lib/dns/rdata/in_1/nsap_22.c index 95321ae6215..c3639499d69 100644 --- a/usr.bin/dig/lib/dns/rdata/in_1/nsap_22.c +++ b/usr.bin/dig/lib/dns/rdata/in_1/nsap_22.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: nsap_22.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: nsap_22.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* Reviewed: Fri Mar 17 10:41:07 PST 2000 by gson */ @@ -26,55 +26,6 @@ #define RRTYPE_NSAP_ATTRIBUTES (0) static inline isc_result_t -fromtext_in_nsap(ARGS_FROMTEXT) { - isc_token_t token; - isc_textregion_t *sr; - int n; - isc_boolean_t valid = ISC_FALSE; - int digits = 0; - unsigned char c = 0; - - REQUIRE(type == dns_rdatatype_nsap); - REQUIRE(rdclass == dns_rdataclass_in); - - UNUSED(type); - UNUSED(origin); - UNUSED(options); - UNUSED(rdclass); - UNUSED(callbacks); - - /* 0x<hex.string.with.periods> */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - sr = &token.value.as_textregion; - if (sr->length < 2) - RETTOK(ISC_R_UNEXPECTEDEND); - if (sr->base[0] != '0' || (sr->base[1] != 'x' && sr->base[1] != 'X')) - RETTOK(DNS_R_SYNTAX); - isc_textregion_consume(sr, 2); - while (sr->length > 0) { - if (sr->base[0] == '.') { - isc_textregion_consume(sr, 1); - continue; - } - if ((n = hexvalue(sr->base[0])) == -1) - RETTOK(DNS_R_SYNTAX); - c <<= 4; - c += n; - if (++digits == 2) { - RETERR(mem_tobuffer(target, &c, 1)); - valid = ISC_TRUE; - digits = 0; - c = 0; - } - isc_textregion_consume(sr, 1); - } - if (digits != 0 || !valid) - RETTOK(ISC_R_UNEXPECTEDEND); - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_in_nsap(ARGS_TOTEXT) { isc_region_t region; char buf[sizeof("xx")]; diff --git a/usr.bin/dig/lib/dns/rdata/in_1/px_26.c b/usr.bin/dig/lib/dns/rdata/in_1/px_26.c index dffba87320e..7c539f6c9b7 100644 --- a/usr.bin/dig/lib/dns/rdata/in_1/px_26.c +++ b/usr.bin/dig/lib/dns/rdata/in_1/px_26.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: px_26.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: px_26.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* Reviewed: Mon Mar 20 10:44:27 PST 2000 */ @@ -26,51 +26,6 @@ #define RRTYPE_PX_ATTRIBUTES (0) static inline isc_result_t -fromtext_in_px(ARGS_FROMTEXT) { - isc_token_t token; - dns_name_t name; - isc_buffer_t buffer; - - REQUIRE(type == dns_rdatatype_px); - REQUIRE(rdclass == dns_rdataclass_in); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - if (origin == NULL) - origin = dns_rootname; - - /* - * Preference. - */ - 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)); - - /* - * MAP822. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); - - /* - * MAPX400. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_in_px(ARGS_TOTEXT) { isc_region_t region; dns_name_t name; diff --git a/usr.bin/dig/lib/dns/rdata/in_1/srv_33.c b/usr.bin/dig/lib/dns/rdata/in_1/srv_33.c index 7aeef8e1788..14c14071d58 100644 --- a/usr.bin/dig/lib/dns/rdata/in_1/srv_33.c +++ b/usr.bin/dig/lib/dns/rdata/in_1/srv_33.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: srv_33.c,v 1.1 2020/02/07 09:58:53 florian Exp $ */ +/* $Id: srv_33.c,v 1.2 2020/02/20 18:08:51 florian Exp $ */ /* Reviewed: Fri Mar 17 13:01:00 PST 2000 by bwelling */ @@ -26,67 +26,6 @@ #define RRTYPE_SRV_ATTRIBUTES (0) static inline isc_result_t -fromtext_in_srv(ARGS_FROMTEXT) { - isc_token_t token; - dns_name_t name; - isc_buffer_t buffer; - isc_boolean_t ok; - - REQUIRE(type == dns_rdatatype_srv); - REQUIRE(rdclass == dns_rdataclass_in); - - UNUSED(type); - UNUSED(rdclass); - UNUSED(callbacks); - - /* - * Priority. - */ - 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)); - - /* - * Weight. - */ - 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)); - - /* - * Port. - */ - 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)); - - /* - * Target. - */ - RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - dns_name_init(&name, NULL); - buffer_fromregion(&buffer, &token.value.as_region); - if (origin == NULL) - origin = dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); - ok = ISC_TRUE; - if ((options & DNS_RDATA_CHECKNAMES) != 0) - ok = dns_name_ishostname(&name, ISC_FALSE); - if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0) - RETTOK(DNS_R_BADNAME); - if (!ok && callbacks != NULL) - warn_badname(&name, lexer, callbacks); - return (ISC_R_SUCCESS); -} - -static inline isc_result_t totext_in_srv(ARGS_TOTEXT) { isc_region_t region; dns_name_t name; diff --git a/usr.bin/dig/lib/dns/rdata/in_1/wks_11.c b/usr.bin/dig/lib/dns/rdata/in_1/wks_11.c index 3d5209aeb8d..0db69b99d41 100644 --- a/usr.bin/dig/lib/dns/rdata/in_1/wks_11.c +++ b/usr.bin/dig/lib/dns/rdata/in_1/wks_11.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: wks_11.c,v 1.2 2020/02/13 16:57:04 florian Exp $ */ +/* $Id: wks_11.c,v 1.3 2020/02/20 18:08:51 florian Exp $ */ /* Reviewed: Fri Mar 17 15:01:49 PST 2000 by explorer */ @@ -29,129 +29,6 @@ #define RRTYPE_WKS_ATTRIBUTES (0) -static isc_boolean_t -mygetprotobyname(const char *name, long *proto) { - struct protoent *pe; - - pe = getprotobyname(name); - if (pe != NULL) - *proto = pe->p_proto; - return (ISC_TF(pe != NULL)); -} - -static isc_boolean_t -mygetservbyname(const char *name, const char *proto, long *port) { - struct servent *se; - - se = getservbyname(name, proto); - if (se != NULL) - *port = ntohs(se->s_port); - return (ISC_TF(se != NULL)); -} - -static inline isc_result_t -fromtext_in_wks(ARGS_FROMTEXT) { - isc_token_t token; - isc_region_t region; - struct in_addr addr; - char *e; - long proto; - unsigned char bm[8*1024]; /* 64k bits */ - long port; - long maxport = -1; - const char *ps = NULL; - unsigned int n; - char service[32]; - int i; - isc_result_t result; - - REQUIRE(type == dns_rdatatype_wks); - REQUIRE(rdclass == dns_rdataclass_in); - - UNUSED(type); - UNUSED(origin); - UNUSED(options); - UNUSED(rdclass); - - /* - * IPv4 dotted quad. - */ - CHECK(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - - isc_buffer_availableregion(target, ®ion); - if (getquad(DNS_AS_STR(token), &addr, lexer, callbacks) != 1) - CHECKTOK(DNS_R_BADDOTTEDQUAD); - if (region.length < 4) - return (ISC_R_NOSPACE); - memmove(region.base, &addr, 4); - isc_buffer_add(target, 4); - - /* - * Protocol. - */ - CHECK(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, - ISC_FALSE)); - - proto = strtol(DNS_AS_STR(token), &e, 10); - if (*e == 0) - ; - else if (!mygetprotobyname(DNS_AS_STR(token), &proto)) - CHECKTOK(DNS_R_UNKNOWNPROTO); - - if (proto < 0 || proto > 0xff) - CHECKTOK(ISC_R_RANGE); - - if (proto == IPPROTO_TCP) - ps = "tcp"; - else if (proto == IPPROTO_UDP) - ps = "udp"; - - CHECK(uint8_tobuffer(proto, target)); - - memset(bm, 0, sizeof(bm)); - do { - CHECK(isc_lex_getmastertoken(lexer, &token, - isc_tokentype_string, ISC_TRUE)); - if (token.type != isc_tokentype_string) - break; - - /* - * Lowercase the service string as some getservbyname() are - * case sensitive and the database is usually in lowercase. - */ - strncpy(service, DNS_AS_STR(token), sizeof(service)); - service[sizeof(service)-1] = '\0'; - for (i = strlen(service) - 1; i >= 0; i--) - if (isupper(service[i]&0xff)) - service[i] = tolower(service[i]&0xff); - - port = strtol(DNS_AS_STR(token), &e, 10); - if (*e == 0) - ; - else if (!mygetservbyname(service, ps, &port) && - !mygetservbyname(DNS_AS_STR(token), ps, &port)) - CHECKTOK(DNS_R_UNKNOWNSERVICE); - if (port < 0 || port > 0xffff) - CHECKTOK(ISC_R_RANGE); - if (port > maxport) - maxport = port; - bm[port / 8] |= (0x80 >> (port % 8)); - } while (1); - - /* - * Let upper layer handle eol/eof. - */ - isc_lex_ungettoken(lexer, &token); - - n = (maxport + 8) / 8; - result = mem_tobuffer(target, bm, n); - - cleanup: - - return (result); -} - static inline isc_result_t totext_in_wks(ARGS_TOTEXT) { isc_region_t sr; |