From 3d5cad69ec20157912e95cf3b79316dfb0a314f3 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 20 Jan 1999 05:20:24 +0000 Subject: [PATCH] Adjusted error codes. txt_fromwire() was not coping with a zero length active buffer. --- bin/tests/rdata_test.c | 63 ++++++++++++++++++------- lib/dns/gen.c | 39 ++++++++------- lib/dns/include/dns/result.h | 7 +-- lib/dns/rdata.c | 81 ++++++++++++++++++++++---------- lib/dns/rdata/generic/cname_5.c | 34 ++++++++------ lib/dns/rdata/generic/cname_5.h | 34 ++++++++------ lib/dns/rdata/generic/hinfo_13.c | 47 +++++++++++------- lib/dns/rdata/generic/hinfo_13.h | 47 +++++++++++------- lib/dns/rdata/generic/mb_7.c | 34 ++++++++------ lib/dns/rdata/generic/mb_7.h | 34 ++++++++------ lib/dns/rdata/generic/md_3.c | 34 ++++++++------ lib/dns/rdata/generic/md_3.h | 34 ++++++++------ lib/dns/rdata/generic/mf_4.c | 36 +++++++------- lib/dns/rdata/generic/mf_4.h | 36 +++++++------- lib/dns/rdata/generic/mg_8.c | 36 +++++++------- lib/dns/rdata/generic/mg_8.h | 36 +++++++------- lib/dns/rdata/generic/minfo_14.c | 45 +++++++++++------- lib/dns/rdata/generic/minfo_14.h | 45 +++++++++++------- lib/dns/rdata/generic/mr_9.c | 34 ++++++++------ lib/dns/rdata/generic/mr_9.h | 34 ++++++++------ lib/dns/rdata/generic/mx_15.c | 51 ++++++++++++-------- lib/dns/rdata/generic/mx_15.h | 51 ++++++++++++-------- lib/dns/rdata/generic/ns_2.c | 34 ++++++++------ lib/dns/rdata/generic/ns_2.h | 34 ++++++++------ lib/dns/rdata/generic/null_10.c | 22 ++++----- lib/dns/rdata/generic/null_10.h | 22 ++++----- lib/dns/rdata/generic/proforma.c | 35 +++++++------- lib/dns/rdata/generic/proforma.h | 35 +++++++------- lib/dns/rdata/generic/ptr_12.c | 34 ++++++++------ lib/dns/rdata/generic/ptr_12.h | 34 ++++++++------ lib/dns/rdata/generic/soa_6.c | 66 ++++++++++++++++---------- lib/dns/rdata/generic/soa_6.h | 66 ++++++++++++++++---------- lib/dns/rdata/generic/txt_16.c | 28 +++++------ lib/dns/rdata/generic/txt_16.h | 28 +++++------ lib/dns/rdata/in_1/a_1.c | 56 ++++++++++++---------- lib/dns/rdata/in_1/a_1.h | 56 ++++++++++++---------- lib/dns/result.c | 3 ++ 37 files changed, 858 insertions(+), 587 deletions(-) diff --git a/bin/tests/rdata_test.c b/bin/tests/rdata_test.c index 22c75157d7..65521888b3 100644 --- a/bin/tests/rdata_test.c +++ b/bin/tests/rdata_test.c @@ -54,11 +54,21 @@ main(int argc, char *argv[]) { int wire = 0; dns_compress_t cctx; dns_decompress_t dctx; + int trunc = 0; + int add = 0; + int len; + int zero = 0; + int debug = 0; - while ((c = getopt(argc, argv, "qsw")) != -1) { + while ((c = getopt(argc, argv, "dqswtaz")) != -1) { switch (c) { + case 'd': + debug = 1; + quiet = 0; + break; case 'q': quiet = 1; + debug = 0; break; case 's': stats = 1; @@ -66,6 +76,15 @@ main(int argc, char *argv[]) { case 'w': wire = 1; break; + case 't': + trunc = 1; + break; + case 'a': + add = 1; + break; + case 'z': + zero = 1; + break; } } @@ -81,15 +100,14 @@ main(int argc, char *argv[]) { specials[')'] = 1; specials['"'] = 1; isc_lex_setspecials(lex, specials); - options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF | - ISC_LEXOPT_INITIALWS | ISC_LEXOPT_QSTRING; + options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; isc_lex_setcomments(lex, ISC_LEXCOMMENT_DNSMASTERFILE); RUNTIME_CHECK(isc_lex_openstream(lex, stdin) == ISC_R_SUCCESS); while ((result = isc_lex_gettoken(lex, options | ISC_LEXOPT_NUMBER, &token)) == ISC_R_SUCCESS) { - /* fprintf(stdout, "token.type = %d\n", token.type); */ + if (debug) fprintf(stdout, "token.type = %d\n", token.type); if (token.type == isc_tokentype_special) { if (token.value.as_char == '(') { parens++; @@ -130,10 +148,9 @@ main(int argc, char *argv[]) { NULL, ISC_FALSE, &dbuf); if (result != DNS_R_SUCCESS) { fprintf(stdout, - "dns_rdata_fromtext != DNS_R_SUCCESS\n"); + "dns_rdata_fromtext returned %s(%d)\n", + dns_result_totext(result), result); fflush(stdout); - - need_eol = 1; continue; } @@ -141,20 +158,32 @@ main(int argc, char *argv[]) { if (wire) { isc_buffer_init(&wbuf, wirebuf, sizeof(wirebuf), ISC_BUFFERTYPE_BINARY); - if (dns_rdata_towire(&rdata, &cctx, &wbuf) - != DNS_R_SUCCESS) { + result = dns_rdata_towire(&rdata, &cctx, &wbuf); + if (result != DNS_R_SUCCESS) { fprintf(stdout, - "dns_rdata_towire != DNS_R_SUCCESS\n"); - fflush(stdout); + "dns_rdata_towire returned %s(%d)\n", + dns_result_totext(result), result); continue; } + len = wbuf.used - dbuf.current; + if (zero) + len = 0; + if (trunc) + len = (len * 3) / 4; + if (add) { + isc_buffer_add(&wbuf, len / 4 + 1); + len += len / 4 + 1; + } + isc_buffer_setactive(&wbuf, len); dns_rdata_init(&rdata); isc_buffer_init(&dbuf, inbuf, sizeof(inbuf), ISC_BUFFERTYPE_BINARY); - if (dns_rdata_fromwire(&rdata, 1, type, &wbuf, &dctx, - ISC_FALSE, &dbuf) != DNS_R_SUCCESS) { + result = dns_rdata_fromwire(&rdata, 1, type, &wbuf, + &dctx, ISC_FALSE, &dbuf); + if (result != DNS_R_SUCCESS) { fprintf(stdout, - "dns_rdata_fromwire != DNS_R_SUCCESS\n"); + "dns_rdata_fromwire returned %s(%d)\n", + dns_result_totext(result), result); fflush(stdout); continue; } @@ -162,8 +191,10 @@ main(int argc, char *argv[]) { isc_buffer_init(&tbuf, outbuf, sizeof(outbuf), ISC_BUFFERTYPE_TEXT); - if (dns_rdata_totext(&rdata, &tbuf) != DNS_R_SUCCESS) - fprintf(stdout, "dns_rdata_totext != DNS_R_SUCCESS\n"); + result = dns_rdata_totext(&rdata, &tbuf); + if (result != DNS_R_SUCCESS) + fprintf(stdout, "dns_rdata_totext returned %s(%d)\n", + dns_result_totext(result), result); else fprintf(stdout, "\"%.*s\"\n", (int)tbuf.used, (char*)tbuf.base); diff --git a/lib/dns/gen.c b/lib/dns/gen.c index 6375f2e848..bbcc2cf2cf 100644 --- a/lib/dns/gen.c +++ b/lib/dns/gen.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: gen.c,v 1.6 1999/01/19 05:38:31 marka Exp $ */ + /* $Id: gen.c,v 1.7 1999/01/20 05:20:18 marka Exp $ */ #include @@ -32,43 +32,43 @@ #define FROMTEXTARGS "class, type, lexer, origin, downcase, target" #define FROMTEXTCLASS "class" #define FROMTEXTTYPE "type" -#define FROMTEXTDEF "DNS_R_DEFAULT" +#define FROMTEXTDEF "use_default = ISC_TRUE" #define TOTEXTDECL "dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target" #define TOTEXTARGS "rdata, origin, target" #define TOTEXTCLASS "rdata->class" #define TOTEXTTYPE "rdata->type" -#define TOTEXTDEF "DNS_R_DEFAULT" +#define TOTEXTDEF "use_default = ISC_TRUE" #define FROMWIREDECL "dns_rdataclass_t class, dns_rdatatype_t type, isc_buffer_t *source, dns_decompress_t *dctx, isc_boolean_t downcase, isc_buffer_t *target" #define FROMWIREARGS "class, type, source, dctx, downcase, target" #define FROMWIRECLASS "class" #define FROMWIRETYPE "type" -#define FROMWIREDEF "DNS_R_DEFAULT" +#define FROMWIREDEF "use_default = ISC_TRUE" #define TOWIREDECL "dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target" #define TOWIREARGS "rdata, cctx, target" #define TOWIRECLASS "rdata->class" #define TOWIRETYPE "rdata->type" -#define TOWIREDEF "DNS_R_DEFAULT" +#define TOWIREDEF "use_default = ISC_TRUE" #define FROMSTRUCTDECL "dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target" #define FROMSTRUCTARGS "class, type, source, target" #define FROMSTRUCTCLASS "class" #define FROMSTRUCTTYPE "type" -#define FROMSTRUCTDEF "DNS_R_DEFAULT" +#define FROMSTRUCTDEF "use_default = ISC_TRUE" #define TOSTRUCTDECL "dns_rdata_t *rdata, void *target" #define TOSTRUCTARGS "rdata, target" #define TOSTRUCTCLASS "rdata->class" #define TOSTRUCTTYPE "rdata->type" -#define TOSTRUCTDEF "DNS_R_DEFAULT" +#define TOSTRUCTDEF "use_default = ISC_TRUE" #define COMPAREDECL "dns_rdata_t *rdata1, dns_rdata_t *rdata2" #define COMPAREARGS "rdata1, rdata2" #define COMPARECLASS "rdata1->class" #define COMPARETYPE "rdata1->type" -#define COMPAREDEF "-2" +#define COMPAREDEF "use_default = ISC_TRUE" char copyright[] = "/*\n\ @@ -141,8 +141,7 @@ doswitch(char *name, char *function, char *args, first = 0; } if (tt->type != lasttype && subswitch) { - fprintf(stdout, "\t\tdefault: result = %s; break; \\\n", - res); + fprintf(stdout, "\t\tdefault: %s; break; \\\n", res); fputs(/*{*/ "\t\t} \\\n", stdout); fputs("\t\tbreak; \\\n", stdout); subswitch = 0; @@ -165,14 +164,14 @@ doswitch(char *name, char *function, char *args, lasttype = tt->type; } if (subswitch) { - fprintf(stdout, "\t\tdefault: result = %s; break; \\\n", res); + fprintf(stdout, "\t\tdefault: %s; break; \\\n", res); fputs(/*{*/ "\t\t}\n", stdout); fputs("\t\tbreak; \\\n", stdout); } if (first) - fprintf(stdout, "\n#define %s result = %s;\n", name, res); + fprintf(stdout, "\n#define %s %s;\n", name, res); else { - fprintf(stdout, "\tdefault: result = %s; break; \\\n", res); + fprintf(stdout, "\tdefault: %s; break; \\\n", res); fputs(/*{*/ "\t}\n", stdout); } } @@ -215,23 +214,23 @@ add(int class, char *classname, int type, char *typename, char *dirname) { tt = types; oldtt = NULL; - while (tt && (tt->type < type)) { + while ((tt != NULL) && (tt->type < type)) { oldtt = tt; tt = tt->next; } - while (tt && (tt->type == type) && (tt->class < class)) { + while ((tt != NULL) && (tt->type == type) && (tt->class < class)) { if (strcmp(tt->typename, typename) != 0) exit(1); oldtt = tt; tt = tt->next; } - if (tt && (tt->type == type) && (tt->class == class)) + if ((tt != NULL) && (tt->type == type) && (tt->class == class)) exit(1); newtt->next = tt; - if (oldtt) + if (oldtt != NULL) oldtt->next = newtt; else types = newtt; @@ -246,18 +245,18 @@ add(int class, char *classname, int type, char *typename, char *dirname) { cc = classes; oldcc = NULL; - while (cc && (cc->type < type)) { + while ((cc != NULL) && (cc->type < type)) { oldcc = cc; cc = cc->next; } - if (cc && cc->type == type) { + if ((cc != NULL) && cc->type == type) { free((char *)newcc); return; } newcc->next = cc; - if (oldcc) + if (oldcc != NULL) oldcc->next = newcc; else classes = newcc; diff --git a/lib/dns/include/dns/result.h b/lib/dns/include/dns/result.h index a93537f650..70ea0b60fa 100644 --- a/lib/dns/include/dns/result.h +++ b/lib/dns/include/dns/result.h @@ -37,10 +37,11 @@ typedef unsigned int dns_result_t; #define DNS_R_TOOMANYHOPS 14 #define DNS_R_DISALLOWED 15 #define DNS_R_NOMORE 16 -#define DNS_R_WIRE 17 -#define DNS_R_DEFAULT 18 +#define DNS_R_EXTRATOKEN 17 +#define DNS_R_EXTRADATA 18 +#define DNS_R_TEXTTOLONG 19 -#define DNS_R_LASTENTRY 18 /* Last entry on list. */ +#define DNS_R_LASTENTRY 19 /* Last entry on list. */ #define DNS_R_UNEXPECTED 0xFFFFFFFFL diff --git a/lib/dns/rdata.c b/lib/dns/rdata.c index 51ae8f3ff6..5e5ba8c9f1 100644 --- a/lib/dns/rdata.c +++ b/lib/dns/rdata.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: rdata.c,v 1.4 1999/01/20 02:41:10 halley Exp $ */ + /* $Id: rdata.c,v 1.5 1999/01/20 05:20:18 marka Exp $ */ #include #include @@ -71,8 +71,9 @@ dns_rdata_init(dns_rdata_t *rdata) { int dns_rdata_compare(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { - int result; + int result = 0; int l; + isc_boolean_t use_default = ISC_FALSE; REQUIRE(rdata1 != NULL); REQUIRE(rdata2 != NULL); @@ -87,7 +88,7 @@ dns_rdata_compare(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { COMPARESWITCH - if (result == -2) { + if (use_default) { l = (rdata1->length > rdata2->length) ? rdata1->length : rdata2->length; if ((result = memcmp(rdata1->data, rdata2->data, l)) == 0) @@ -127,10 +128,11 @@ dns_rdata_fromwire(dns_rdata_t *rdata, dns_decompress_t *dctx, isc_boolean_t downcase, isc_buffer_t *target) { - dns_result_t result; + dns_result_t result = DNS_R_NOTIMPLEMENTED; isc_region_t region; isc_buffer_t ss; isc_buffer_t st; + isc_boolean_t use_default = ISC_FALSE; ss = *source; st = *target; @@ -138,12 +140,12 @@ dns_rdata_fromwire(dns_rdata_t *rdata, FROMWIRESWITCH - if (result == DNS_R_DEFAULT) - result = DNS_R_NOTIMPLEMENTED; + if (use_default) + (void)NULL; /* We should have consumed all out buffer */ - if (!buffer_empty(source)) - result = DNS_R_WIRE; + if (result == DNS_R_SUCCESS && !buffer_empty(source)) + result = DNS_R_EXTRADATA; if (rdata && result == DNS_R_SUCCESS) { region.length = target->used - st.used; @@ -160,11 +162,12 @@ dns_rdata_fromwire(dns_rdata_t *rdata, dns_result_t dns_rdata_towire(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { - dns_result_t result; + dns_result_t result = DNS_R_NOTIMPLEMENTED; + isc_boolean_t use_default = ISC_FALSE; TOWIRESWITCH - if (result == DNS_R_DEFAULT) { + if (use_default) { if (target->length < rdata->length) return (DNS_R_NOSPACE); memcpy(target->base, rdata->data, rdata->length); @@ -180,17 +183,39 @@ dns_rdata_fromtext(dns_rdata_t *rdata, isc_lex_t *lexer, dns_name_t *origin, isc_boolean_t downcase, isc_buffer_t *target) { - dns_result_t result; + dns_result_t result = DNS_R_NOTIMPLEMENTED; isc_region_t region; isc_buffer_t st; + isc_boolean_t use_default = ISC_FALSE; + isc_token_t token; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; st = *target; region.base = target->base + target->used; FROMTEXTSWITCH - if (result == DNS_R_DEFAULT) - result = DNS_R_NOTIMPLEMENTED; + if (use_default) + (void)NULL; + + /* + * Consume to end of line / file. + * If not at end of line initially set error code. + */ + do { + if (isc_lex_gettoken(lexer, options, &token) + != ISC_R_SUCCESS) { + if (result == DNS_R_SUCCESS) + result = DNS_R_UNEXPECTED; + break; + } else if (token.type != isc_tokentype_eol && + token.type != isc_tokentype_eof) { + fprintf(stderr, "token_type = %d\n", token.type); + if (result == DNS_R_SUCCESS) + result = DNS_R_EXTRATOKEN; + } else + break; + } while (1); if (rdata != NULL && result == DNS_R_SUCCESS) { region.length = target->used - st.used; @@ -204,13 +229,15 @@ dns_rdata_fromtext(dns_rdata_t *rdata, dns_result_t dns_rdata_totext(dns_rdata_t *rdata, isc_buffer_t *target) { - dns_result_t result; + dns_result_t result = DNS_R_NOTIMPLEMENTED; dns_name_t *origin = NULL; + isc_boolean_t use_default = ISC_FALSE; TOTEXTSWITCH - if (result == DNS_R_DEFAULT) - result = DNS_R_NOTIMPLEMENTED; + if (use_default) + (void)NULL; + return (result); } @@ -219,17 +246,18 @@ dns_rdata_fromstruct(dns_rdata_t *rdata, dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - dns_result_t result; + dns_result_t result = DNS_R_NOTIMPLEMENTED; isc_buffer_t st; isc_region_t region; + isc_boolean_t use_default = ISC_FALSE; region.base = target->base + target->used; st = *target; FROMSTRUCTSWITCH - if (result == DNS_R_DEFAULT) - result = DNS_R_NOTIMPLEMENTED; + if (use_default) + (void)NULL; if (rdata != NULL && result == DNS_R_SUCCESS) { region.length = target->used - st.used; @@ -242,12 +270,14 @@ dns_rdata_fromstruct(dns_rdata_t *rdata, dns_result_t dns_rdata_tostruct(dns_rdata_t *rdata, void *target) { - dns_result_t result; + dns_result_t result = DNS_R_NOTIMPLEMENTED; + isc_boolean_t use_default = ISC_FALSE; TOSTRUCTSWITCH - if (result == DNS_R_DEFAULT) - result = DNS_R_NOTIMPLEMENTED; + if (use_default) + (void)NULL; + return (result); } @@ -314,7 +344,7 @@ txt_fromtext(isc_textregion_t *source, isc_buffer_t *target) { if (tregion.length < source->length + 1) return (DNS_R_NOSPACE); if (source->length > 255) - return (DNS_R_UNKNOWN); + return (DNS_R_TEXTTOLONG); *tregion.base = source->length; memcpy(tregion.base + 1, source->base, source->length); isc_buffer_add(target, source->length + 1); @@ -328,9 +358,11 @@ txt_fromwire(isc_buffer_t *source, isc_buffer_t *target) { isc_region_t tregion; isc_buffer_active(source, &sregion); + if (sregion.length == 0) + return(DNS_R_UNEXPECTEDEND); n = *sregion.base + 1; if (n > sregion.length) - return (DNS_R_UNKNOWN); + return (DNS_R_UNEXPECTEDEND); isc_buffer_available(target, &tregion); if (n > tregion.length) @@ -396,6 +428,7 @@ buffer_fromregion(isc_buffer_t *buffer, isc_region_t *region, isc_buffer_init(buffer, region->base, region->length, type); isc_buffer_add(buffer, region->length); + isc_buffer_setactive(buffer, region->length); } static isc_result_t diff --git a/lib/dns/rdata/generic/cname_5.c b/lib/dns/rdata/generic/cname_5.c index 437b7de01f..50b5dd24ad 100644 --- a/lib/dns/rdata/generic/cname_5.c +++ b/lib/dns/rdata/generic/cname_5.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: cname_5.c,v 1.3 1999/01/19 06:49:29 marka Exp $ */ + /* $Id: cname_5.c,v 1.4 1999/01/20 05:20:19 marka Exp $ */ #ifndef RDATA_GENERIC_CNAME_5_H #define RDATA_GENERIC_CNAME_5_H @@ -27,15 +27,21 @@ fromtext_cname(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 5); + REQUIRE(type == 5); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -51,7 +57,7 @@ totext_cname(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { dns_name_t prefix; isc_boolean_t sub; - INSIST(rdata->type == 5); + REQUIRE(rdata->type == 5); dns_name_init(&name, NULL); dns_name_init(&prefix, NULL); @@ -70,7 +76,7 @@ fromwire_cname(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { dns_name_t name; - INSIST(type == 5); + REQUIRE(type == 5); class = class; /*unused*/ dns_name_init(&name, NULL); @@ -82,7 +88,7 @@ towire_cname(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_name_t name; isc_region_t region; - INSIST(rdata->type == 5); + REQUIRE(rdata->type == 5); dns_name_init(&name, NULL); dns_rdata_toregion(rdata, ®ion); @@ -98,9 +104,9 @@ compare_cname(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { isc_region_t region1; isc_region_t region2; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == 5); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == 5); dns_name_init(&name1, NULL); dns_name_init(&name2, NULL); @@ -118,7 +124,7 @@ static dns_result_t fromstruct_cname(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 5); + REQUIRE(type == 5); class = class; /*unused*/ @@ -131,7 +137,7 @@ fromstruct_cname(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_cname(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 5); + REQUIRE(rdata->type == 5); target = target; diff --git a/lib/dns/rdata/generic/cname_5.h b/lib/dns/rdata/generic/cname_5.h index 8292750844..2a3b23bba4 100644 --- a/lib/dns/rdata/generic/cname_5.h +++ b/lib/dns/rdata/generic/cname_5.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: cname_5.h,v 1.3 1999/01/19 06:49:29 marka Exp $ */ + /* $Id: cname_5.h,v 1.4 1999/01/20 05:20:19 marka Exp $ */ #ifndef RDATA_GENERIC_CNAME_5_H #define RDATA_GENERIC_CNAME_5_H @@ -27,15 +27,21 @@ fromtext_cname(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 5); + REQUIRE(type == 5); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -51,7 +57,7 @@ totext_cname(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { dns_name_t prefix; isc_boolean_t sub; - INSIST(rdata->type == 5); + REQUIRE(rdata->type == 5); dns_name_init(&name, NULL); dns_name_init(&prefix, NULL); @@ -70,7 +76,7 @@ fromwire_cname(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { dns_name_t name; - INSIST(type == 5); + REQUIRE(type == 5); class = class; /*unused*/ dns_name_init(&name, NULL); @@ -82,7 +88,7 @@ towire_cname(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_name_t name; isc_region_t region; - INSIST(rdata->type == 5); + REQUIRE(rdata->type == 5); dns_name_init(&name, NULL); dns_rdata_toregion(rdata, ®ion); @@ -98,9 +104,9 @@ compare_cname(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { isc_region_t region1; isc_region_t region2; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == 5); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == 5); dns_name_init(&name1, NULL); dns_name_init(&name2, NULL); @@ -118,7 +124,7 @@ static dns_result_t fromstruct_cname(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 5); + REQUIRE(type == 5); class = class; /*unused*/ @@ -131,7 +137,7 @@ fromstruct_cname(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_cname(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 5); + REQUIRE(rdata->type == 5); target = target; diff --git a/lib/dns/rdata/generic/hinfo_13.c b/lib/dns/rdata/generic/hinfo_13.c index 50778be6fc..20ef187842 100644 --- a/lib/dns/rdata/generic/hinfo_13.c +++ b/lib/dns/rdata/generic/hinfo_13.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: hinfo_13.c,v 1.4 1999/01/19 06:49:29 marka Exp $ */ + /* $Id: hinfo_13.c,v 1.5 1999/01/20 05:20:20 marka Exp $ */ #ifndef RDATA_GENERIC_HINFO_13_H #define RDATA_GENERIC_HINFO_13_H @@ -26,26 +26,37 @@ fromtext_hinfo(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { isc_token_t token; dns_result_t result; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 13); + REQUIRE(type == 13); class = class; /*unused*/ origin = origin; /*unused*/ downcase = downcase; /*unused*/ - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } result = txt_fromtext(&token.value.as_textregion, target); if (result != DNS_R_SUCCESS) return (result); - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } return (txt_fromtext(&token.value.as_textregion, target)); } @@ -54,7 +65,7 @@ totext_hinfo(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { isc_region_t region; dns_result_t result; - INSIST(rdata->type == 13); + REQUIRE(rdata->type == 13); origin = origin; /*unused*/ @@ -78,7 +89,7 @@ fromwire_hinfo(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { dns_result_t result; - INSIST(type == 13); + REQUIRE(type == 13); dctx = dctx; /* unused */ class = class; /* unused */ @@ -95,7 +106,7 @@ static dns_result_t towire_hinfo(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { isc_region_t region; - INSIST(rdata->type == 13); + REQUIRE(rdata->type == 13); cctx = cctx; @@ -114,9 +125,9 @@ compare_hinfo(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { int l; int result; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == 13); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == 13); l = (rdata1->length < rdata2->length) ? rdata1->length : rdata2->length; result = memcmp(rdata1->data, rdata2->data, l); @@ -133,7 +144,7 @@ static dns_result_t fromstruct_hinfo(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 13); + REQUIRE(type == 13); class = class; /*unused*/ @@ -146,7 +157,7 @@ fromstruct_hinfo(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_hinfo(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 13); + REQUIRE(rdata->type == 13); target = target; diff --git a/lib/dns/rdata/generic/hinfo_13.h b/lib/dns/rdata/generic/hinfo_13.h index e1af2752f8..3d819afabe 100644 --- a/lib/dns/rdata/generic/hinfo_13.h +++ b/lib/dns/rdata/generic/hinfo_13.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: hinfo_13.h,v 1.4 1999/01/19 06:49:29 marka Exp $ */ + /* $Id: hinfo_13.h,v 1.5 1999/01/20 05:20:20 marka Exp $ */ #ifndef RDATA_GENERIC_HINFO_13_H #define RDATA_GENERIC_HINFO_13_H @@ -26,26 +26,37 @@ fromtext_hinfo(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { isc_token_t token; dns_result_t result; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 13); + REQUIRE(type == 13); class = class; /*unused*/ origin = origin; /*unused*/ downcase = downcase; /*unused*/ - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } result = txt_fromtext(&token.value.as_textregion, target); if (result != DNS_R_SUCCESS) return (result); - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } return (txt_fromtext(&token.value.as_textregion, target)); } @@ -54,7 +65,7 @@ totext_hinfo(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { isc_region_t region; dns_result_t result; - INSIST(rdata->type == 13); + REQUIRE(rdata->type == 13); origin = origin; /*unused*/ @@ -78,7 +89,7 @@ fromwire_hinfo(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { dns_result_t result; - INSIST(type == 13); + REQUIRE(type == 13); dctx = dctx; /* unused */ class = class; /* unused */ @@ -95,7 +106,7 @@ static dns_result_t towire_hinfo(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { isc_region_t region; - INSIST(rdata->type == 13); + REQUIRE(rdata->type == 13); cctx = cctx; @@ -114,9 +125,9 @@ compare_hinfo(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { int l; int result; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == 13); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == 13); l = (rdata1->length < rdata2->length) ? rdata1->length : rdata2->length; result = memcmp(rdata1->data, rdata2->data, l); @@ -133,7 +144,7 @@ static dns_result_t fromstruct_hinfo(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 13); + REQUIRE(type == 13); class = class; /*unused*/ @@ -146,7 +157,7 @@ fromstruct_hinfo(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_hinfo(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 13); + REQUIRE(rdata->type == 13); target = target; diff --git a/lib/dns/rdata/generic/mb_7.c b/lib/dns/rdata/generic/mb_7.c index 1037faa319..3b60818369 100644 --- a/lib/dns/rdata/generic/mb_7.c +++ b/lib/dns/rdata/generic/mb_7.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: mb_7.c,v 1.3 1999/01/19 06:49:29 marka Exp $ */ + /* $Id: mb_7.c,v 1.4 1999/01/20 05:20:20 marka Exp $ */ #ifndef RDATA_GENERIC_MB_7_H #define RDATA_GENERIC_MB_7_H @@ -27,15 +27,21 @@ fromtext_mb(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 7); + REQUIRE(type == 7); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -51,7 +57,7 @@ totext_mb(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { dns_name_t prefix; isc_boolean_t sub; - INSIST(rdata->type == 7); + REQUIRE(rdata->type == 7); dns_name_init(&name, NULL); dns_name_init(&prefix, NULL); @@ -70,7 +76,7 @@ fromwire_mb(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { dns_name_t name; - INSIST(type == 7); + REQUIRE(type == 7); class = class; /*unused*/ @@ -83,7 +89,7 @@ towire_mb(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_name_t name; isc_region_t region; - INSIST(rdata->type == 7); + REQUIRE(rdata->type == 7); dns_name_init(&name, NULL); dns_rdata_toregion(rdata, ®ion); @@ -99,9 +105,9 @@ compare_mb(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { isc_region_t region1; isc_region_t region2; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == 7); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == 7); dns_name_init(&name1, NULL); dns_name_init(&name2, NULL); @@ -119,7 +125,7 @@ static dns_result_t fromstruct_mb(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 7); + REQUIRE(type == 7); class = class; /*unused*/ @@ -132,7 +138,7 @@ fromstruct_mb(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_mb(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 7); + REQUIRE(rdata->type == 7); target = target; diff --git a/lib/dns/rdata/generic/mb_7.h b/lib/dns/rdata/generic/mb_7.h index 75fb79c820..0bb0189139 100644 --- a/lib/dns/rdata/generic/mb_7.h +++ b/lib/dns/rdata/generic/mb_7.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: mb_7.h,v 1.3 1999/01/19 06:49:29 marka Exp $ */ + /* $Id: mb_7.h,v 1.4 1999/01/20 05:20:20 marka Exp $ */ #ifndef RDATA_GENERIC_MB_7_H #define RDATA_GENERIC_MB_7_H @@ -27,15 +27,21 @@ fromtext_mb(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 7); + REQUIRE(type == 7); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -51,7 +57,7 @@ totext_mb(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { dns_name_t prefix; isc_boolean_t sub; - INSIST(rdata->type == 7); + REQUIRE(rdata->type == 7); dns_name_init(&name, NULL); dns_name_init(&prefix, NULL); @@ -70,7 +76,7 @@ fromwire_mb(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { dns_name_t name; - INSIST(type == 7); + REQUIRE(type == 7); class = class; /*unused*/ @@ -83,7 +89,7 @@ towire_mb(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_name_t name; isc_region_t region; - INSIST(rdata->type == 7); + REQUIRE(rdata->type == 7); dns_name_init(&name, NULL); dns_rdata_toregion(rdata, ®ion); @@ -99,9 +105,9 @@ compare_mb(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { isc_region_t region1; isc_region_t region2; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == 7); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == 7); dns_name_init(&name1, NULL); dns_name_init(&name2, NULL); @@ -119,7 +125,7 @@ static dns_result_t fromstruct_mb(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 7); + REQUIRE(type == 7); class = class; /*unused*/ @@ -132,7 +138,7 @@ fromstruct_mb(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_mb(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 7); + REQUIRE(rdata->type == 7); target = target; diff --git a/lib/dns/rdata/generic/md_3.c b/lib/dns/rdata/generic/md_3.c index e3229ef5f6..eb6298bfa6 100644 --- a/lib/dns/rdata/generic/md_3.c +++ b/lib/dns/rdata/generic/md_3.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: md_3.c,v 1.3 1999/01/19 06:49:29 marka Exp $ */ + /* $Id: md_3.c,v 1.4 1999/01/20 05:20:20 marka Exp $ */ #ifndef RDATA_GENERIC_MD_3_H #define RDATA_GENERIC_MD_3_H @@ -28,16 +28,22 @@ fromtext_md(dns_rdataclass_t class, dns_rdatatype_t type, isc_result_t result; dns_name_t name; isc_buffer_t buffer; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 3); + REQUIRE(type == 3); class = class; /*unused*/ - result = isc_lex_gettoken(lexer, 0, &token); + result = isc_lex_gettoken(lexer, options, &token); if (result != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -53,7 +59,7 @@ totext_md(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { dns_name_t prefix; isc_boolean_t sub; - INSIST(rdata->type == 3); + REQUIRE(rdata->type == 3); dns_name_init(&name, NULL); dns_rdata_toregion(rdata, ®ion); @@ -70,7 +76,7 @@ fromwire_md(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { dns_name_t name; - INSIST(type == 3); + REQUIRE(type == 3); class = class; /*unused*/ @@ -83,7 +89,7 @@ towire_md(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_name_t name; isc_region_t region; - INSIST(rdata->type == 3); + REQUIRE(rdata->type == 3); dns_name_init(&name, NULL); dns_rdata_toregion(rdata, ®ion); @@ -99,9 +105,9 @@ compare_md(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { isc_region_t region1; isc_region_t region2; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == 3); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == 3); dns_name_init(&name1, NULL); dns_name_init(&name2, NULL); @@ -119,7 +125,7 @@ static dns_result_t fromstruct_md(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 3); + REQUIRE(type == 3); class = class; /*unused*/ @@ -132,7 +138,7 @@ fromstruct_md(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_md(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 3); + REQUIRE(rdata->type == 3); target = target; diff --git a/lib/dns/rdata/generic/md_3.h b/lib/dns/rdata/generic/md_3.h index 076c25cf66..5db3922d90 100644 --- a/lib/dns/rdata/generic/md_3.h +++ b/lib/dns/rdata/generic/md_3.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: md_3.h,v 1.3 1999/01/19 06:49:29 marka Exp $ */ + /* $Id: md_3.h,v 1.4 1999/01/20 05:20:20 marka Exp $ */ #ifndef RDATA_GENERIC_MD_3_H #define RDATA_GENERIC_MD_3_H @@ -28,16 +28,22 @@ fromtext_md(dns_rdataclass_t class, dns_rdatatype_t type, isc_result_t result; dns_name_t name; isc_buffer_t buffer; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 3); + REQUIRE(type == 3); class = class; /*unused*/ - result = isc_lex_gettoken(lexer, 0, &token); + result = isc_lex_gettoken(lexer, options, &token); if (result != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -53,7 +59,7 @@ totext_md(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { dns_name_t prefix; isc_boolean_t sub; - INSIST(rdata->type == 3); + REQUIRE(rdata->type == 3); dns_name_init(&name, NULL); dns_rdata_toregion(rdata, ®ion); @@ -70,7 +76,7 @@ fromwire_md(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { dns_name_t name; - INSIST(type == 3); + REQUIRE(type == 3); class = class; /*unused*/ @@ -83,7 +89,7 @@ towire_md(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_name_t name; isc_region_t region; - INSIST(rdata->type == 3); + REQUIRE(rdata->type == 3); dns_name_init(&name, NULL); dns_rdata_toregion(rdata, ®ion); @@ -99,9 +105,9 @@ compare_md(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { isc_region_t region1; isc_region_t region2; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == 3); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == 3); dns_name_init(&name1, NULL); dns_name_init(&name2, NULL); @@ -119,7 +125,7 @@ static dns_result_t fromstruct_md(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 3); + REQUIRE(type == 3); class = class; /*unused*/ @@ -132,7 +138,7 @@ fromstruct_md(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_md(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 3); + REQUIRE(rdata->type == 3); target = target; diff --git a/lib/dns/rdata/generic/mf_4.c b/lib/dns/rdata/generic/mf_4.c index c8d8a6be39..ca5974e58b 100644 --- a/lib/dns/rdata/generic/mf_4.c +++ b/lib/dns/rdata/generic/mf_4.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: mf_4.c,v 1.3 1999/01/19 06:49:30 marka Exp $ */ + /* $Id: mf_4.c,v 1.4 1999/01/20 05:20:20 marka Exp $ */ #ifndef RDATA_GENERIC_MF_4_H #define RDATA_GENERIC_MF_4_H @@ -25,19 +25,23 @@ fromtext_mf(dns_rdataclass_t class, dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin, isc_boolean_t downcase, isc_buffer_t *target) { isc_token_t token; - isc_result_t result; dns_name_t name; isc_buffer_t buffer; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 4); + REQUIRE(type == 4); class = class; /*unused*/ - result = isc_lex_gettoken(lexer, 0, &token); - if (result != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -53,7 +57,7 @@ totext_mf(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { dns_name_t prefix; isc_boolean_t sub; - INSIST(rdata->type == 4); + REQUIRE(rdata->type == 4); dns_name_init(&name, NULL); dns_rdata_toregion(rdata, ®ion); @@ -70,7 +74,7 @@ fromwire_mf(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { dns_name_t name; - INSIST(type == 4); + REQUIRE(type == 4); class = class; /*unused*/ @@ -83,7 +87,7 @@ towire_mf(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_name_t name; isc_region_t region; - INSIST(rdata->type == 4); + REQUIRE(rdata->type == 4); dns_name_init(&name, NULL); dns_rdata_toregion(rdata, ®ion); @@ -99,9 +103,9 @@ compare_mf(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { isc_region_t region1; isc_region_t region2; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == 4); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == 4); dns_name_init(&name1, NULL); dns_name_init(&name2, NULL); @@ -119,7 +123,7 @@ static dns_result_t fromstruct_mf(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 4); + REQUIRE(type == 4); class = class; /*unused*/ @@ -132,7 +136,7 @@ fromstruct_mf(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_mf(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 4); + REQUIRE(rdata->type == 4); target = target; diff --git a/lib/dns/rdata/generic/mf_4.h b/lib/dns/rdata/generic/mf_4.h index a3c79a8691..7d50002a00 100644 --- a/lib/dns/rdata/generic/mf_4.h +++ b/lib/dns/rdata/generic/mf_4.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: mf_4.h,v 1.3 1999/01/19 06:49:30 marka Exp $ */ + /* $Id: mf_4.h,v 1.4 1999/01/20 05:20:20 marka Exp $ */ #ifndef RDATA_GENERIC_MF_4_H #define RDATA_GENERIC_MF_4_H @@ -25,19 +25,23 @@ fromtext_mf(dns_rdataclass_t class, dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin, isc_boolean_t downcase, isc_buffer_t *target) { isc_token_t token; - isc_result_t result; dns_name_t name; isc_buffer_t buffer; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 4); + REQUIRE(type == 4); class = class; /*unused*/ - result = isc_lex_gettoken(lexer, 0, &token); - if (result != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -53,7 +57,7 @@ totext_mf(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { dns_name_t prefix; isc_boolean_t sub; - INSIST(rdata->type == 4); + REQUIRE(rdata->type == 4); dns_name_init(&name, NULL); dns_rdata_toregion(rdata, ®ion); @@ -70,7 +74,7 @@ fromwire_mf(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { dns_name_t name; - INSIST(type == 4); + REQUIRE(type == 4); class = class; /*unused*/ @@ -83,7 +87,7 @@ towire_mf(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_name_t name; isc_region_t region; - INSIST(rdata->type == 4); + REQUIRE(rdata->type == 4); dns_name_init(&name, NULL); dns_rdata_toregion(rdata, ®ion); @@ -99,9 +103,9 @@ compare_mf(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { isc_region_t region1; isc_region_t region2; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == 4); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == 4); dns_name_init(&name1, NULL); dns_name_init(&name2, NULL); @@ -119,7 +123,7 @@ static dns_result_t fromstruct_mf(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 4); + REQUIRE(type == 4); class = class; /*unused*/ @@ -132,7 +136,7 @@ fromstruct_mf(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_mf(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 4); + REQUIRE(rdata->type == 4); target = target; diff --git a/lib/dns/rdata/generic/mg_8.c b/lib/dns/rdata/generic/mg_8.c index 30b288b675..32fa90222a 100644 --- a/lib/dns/rdata/generic/mg_8.c +++ b/lib/dns/rdata/generic/mg_8.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: mg_8.c,v 1.3 1999/01/19 06:49:30 marka Exp $ */ + /* $Id: mg_8.c,v 1.4 1999/01/20 05:20:21 marka Exp $ */ #ifndef RDATA_GENERIC_MG_8_H #define RDATA_GENERIC_MG_8_H @@ -25,19 +25,23 @@ fromtext_mg(dns_rdataclass_t class, dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin, isc_boolean_t downcase, isc_buffer_t *target) { isc_token_t token; - isc_result_t result; dns_name_t name; isc_buffer_t buffer; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 8); + REQUIRE(type == 8); class = class; /*unused*/ - result = isc_lex_gettoken(lexer, 0, &token); - if (result != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -53,7 +57,7 @@ totext_mg(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { dns_name_t prefix; isc_boolean_t sub; - INSIST(rdata->type == 8); + REQUIRE(rdata->type == 8); dns_name_init(&name, NULL); dns_name_init(&prefix, NULL); @@ -72,7 +76,7 @@ fromwire_mg(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { dns_name_t name; - INSIST(type == 8); + REQUIRE(type == 8); class = class; /*unused*/ @@ -85,7 +89,7 @@ towire_mg(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_name_t name; isc_region_t region; - INSIST(rdata->type == 8); + REQUIRE(rdata->type == 8); dns_name_init(&name, NULL); dns_rdata_toregion(rdata, ®ion); @@ -101,9 +105,9 @@ compare_mg(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { isc_region_t region1; isc_region_t region2; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == 8); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == 8); dns_name_init(&name1, NULL); dns_name_init(&name2, NULL); @@ -121,7 +125,7 @@ static dns_result_t fromstruct_mg(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 8); + REQUIRE(type == 8); class = class; /*unused*/ @@ -134,7 +138,7 @@ fromstruct_mg(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_mg(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 8); + REQUIRE(rdata->type == 8); target = target; diff --git a/lib/dns/rdata/generic/mg_8.h b/lib/dns/rdata/generic/mg_8.h index 3dee5bbdab..cedaa29381 100644 --- a/lib/dns/rdata/generic/mg_8.h +++ b/lib/dns/rdata/generic/mg_8.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: mg_8.h,v 1.3 1999/01/19 06:49:30 marka Exp $ */ + /* $Id: mg_8.h,v 1.4 1999/01/20 05:20:21 marka Exp $ */ #ifndef RDATA_GENERIC_MG_8_H #define RDATA_GENERIC_MG_8_H @@ -25,19 +25,23 @@ fromtext_mg(dns_rdataclass_t class, dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin, isc_boolean_t downcase, isc_buffer_t *target) { isc_token_t token; - isc_result_t result; dns_name_t name; isc_buffer_t buffer; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 8); + REQUIRE(type == 8); class = class; /*unused*/ - result = isc_lex_gettoken(lexer, 0, &token); - if (result != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -53,7 +57,7 @@ totext_mg(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { dns_name_t prefix; isc_boolean_t sub; - INSIST(rdata->type == 8); + REQUIRE(rdata->type == 8); dns_name_init(&name, NULL); dns_name_init(&prefix, NULL); @@ -72,7 +76,7 @@ fromwire_mg(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { dns_name_t name; - INSIST(type == 8); + REQUIRE(type == 8); class = class; /*unused*/ @@ -85,7 +89,7 @@ towire_mg(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_name_t name; isc_region_t region; - INSIST(rdata->type == 8); + REQUIRE(rdata->type == 8); dns_name_init(&name, NULL); dns_rdata_toregion(rdata, ®ion); @@ -101,9 +105,9 @@ compare_mg(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { isc_region_t region1; isc_region_t region2; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == 8); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == 8); dns_name_init(&name1, NULL); dns_name_init(&name2, NULL); @@ -121,7 +125,7 @@ static dns_result_t fromstruct_mg(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 8); + REQUIRE(type == 8); class = class; /*unused*/ @@ -134,7 +138,7 @@ fromstruct_mg(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_mg(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 8); + REQUIRE(rdata->type == 8); target = target; diff --git a/lib/dns/rdata/generic/minfo_14.c b/lib/dns/rdata/generic/minfo_14.c index 607371a26b..31e28047db 100644 --- a/lib/dns/rdata/generic/minfo_14.c +++ b/lib/dns/rdata/generic/minfo_14.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: minfo_14.c,v 1.3 1999/01/19 06:49:30 marka Exp $ */ + /* $Id: minfo_14.c,v 1.4 1999/01/20 05:20:21 marka Exp $ */ #ifndef RDATA_GENERIC_MINFO_14_H #define RDATA_GENERIC_MINFO_14_H @@ -28,15 +28,21 @@ fromtext_minfo(dns_rdataclass_t class, dns_rdatatype_t type, dns_result_t result; dns_name_t name; isc_buffer_t buffer; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 14); + REQUIRE(type == 14); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -46,10 +52,15 @@ fromtext_minfo(dns_rdataclass_t class, dns_rdatatype_t type, if (result != DNS_R_SUCCESS) return (result); - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + return (DNS_R_UNEXPECTED); dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -67,7 +78,7 @@ totext_minfo(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { dns_result_t result; isc_boolean_t sub; - INSIST(rdata->type == 14); + REQUIRE(rdata->type == 14); dns_name_init(&rmail, NULL); dns_name_init(&email, NULL); @@ -107,7 +118,7 @@ fromwire_minfo(dns_rdataclass_t class, dns_rdatatype_t type, dns_name_t email; dns_result_t result; - INSIST(type == 14); + REQUIRE(type == 14); class = class; /*unused*/ @@ -128,7 +139,7 @@ towire_minfo(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_name_t email; dns_result_t result; - INSIST(rdata->type == 14); + REQUIRE(rdata->type == 14); dns_name_init(&rmail, NULL); dns_name_init(&email, NULL); @@ -158,9 +169,9 @@ compare_minfo(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { dns_name_t name2; int result; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == 14); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == 14); dns_name_init(&name1, NULL); dns_name_init(&name2, NULL); @@ -192,7 +203,7 @@ static dns_result_t fromstruct_minfo(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 14); + REQUIRE(type == 14); class = class; /*unused*/ @@ -205,7 +216,7 @@ fromstruct_minfo(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_minfo(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 14); + REQUIRE(rdata->type == 14); target = target; diff --git a/lib/dns/rdata/generic/minfo_14.h b/lib/dns/rdata/generic/minfo_14.h index 3d4a99045c..95022dd702 100644 --- a/lib/dns/rdata/generic/minfo_14.h +++ b/lib/dns/rdata/generic/minfo_14.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: minfo_14.h,v 1.3 1999/01/19 06:49:30 marka Exp $ */ + /* $Id: minfo_14.h,v 1.4 1999/01/20 05:20:21 marka Exp $ */ #ifndef RDATA_GENERIC_MINFO_14_H #define RDATA_GENERIC_MINFO_14_H @@ -28,15 +28,21 @@ fromtext_minfo(dns_rdataclass_t class, dns_rdatatype_t type, dns_result_t result; dns_name_t name; isc_buffer_t buffer; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 14); + REQUIRE(type == 14); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -46,10 +52,15 @@ fromtext_minfo(dns_rdataclass_t class, dns_rdatatype_t type, if (result != DNS_R_SUCCESS) return (result); - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + return (DNS_R_UNEXPECTED); dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -67,7 +78,7 @@ totext_minfo(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { dns_result_t result; isc_boolean_t sub; - INSIST(rdata->type == 14); + REQUIRE(rdata->type == 14); dns_name_init(&rmail, NULL); dns_name_init(&email, NULL); @@ -107,7 +118,7 @@ fromwire_minfo(dns_rdataclass_t class, dns_rdatatype_t type, dns_name_t email; dns_result_t result; - INSIST(type == 14); + REQUIRE(type == 14); class = class; /*unused*/ @@ -128,7 +139,7 @@ towire_minfo(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_name_t email; dns_result_t result; - INSIST(rdata->type == 14); + REQUIRE(rdata->type == 14); dns_name_init(&rmail, NULL); dns_name_init(&email, NULL); @@ -158,9 +169,9 @@ compare_minfo(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { dns_name_t name2; int result; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == 14); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == 14); dns_name_init(&name1, NULL); dns_name_init(&name2, NULL); @@ -192,7 +203,7 @@ static dns_result_t fromstruct_minfo(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 14); + REQUIRE(type == 14); class = class; /*unused*/ @@ -205,7 +216,7 @@ fromstruct_minfo(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_minfo(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 14); + REQUIRE(rdata->type == 14); target = target; diff --git a/lib/dns/rdata/generic/mr_9.c b/lib/dns/rdata/generic/mr_9.c index b47c82fc1f..8227793410 100644 --- a/lib/dns/rdata/generic/mr_9.c +++ b/lib/dns/rdata/generic/mr_9.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: mr_9.c,v 1.3 1999/01/19 06:49:31 marka Exp $ */ + /* $Id: mr_9.c,v 1.4 1999/01/20 05:20:21 marka Exp $ */ #ifndef RDATA_GENERIC_MR_9_H #define RDATA_GENERIC_MR_9_H @@ -27,15 +27,21 @@ fromtext_mr(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 9); + REQUIRE(type == 9); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -51,7 +57,7 @@ totext_mr(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { dns_name_t prefix; isc_boolean_t sub; - INSIST(rdata->type == 9); + REQUIRE(rdata->type == 9); dns_name_init(&name, NULL); dns_name_init(&prefix, NULL); @@ -70,7 +76,7 @@ fromwire_mr(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { dns_name_t name; - INSIST(type == 9); + REQUIRE(type == 9); class = class; /*unused*/ @@ -83,7 +89,7 @@ towire_mr(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_name_t name; isc_region_t region; - INSIST(rdata->type == 9); + REQUIRE(rdata->type == 9); dns_name_init(&name, NULL); dns_rdata_toregion(rdata, ®ion); @@ -99,9 +105,9 @@ compare_mr(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { isc_region_t region1; isc_region_t region2; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == 9); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == 9); dns_name_init(&name1, NULL); dns_name_init(&name2, NULL); @@ -119,7 +125,7 @@ static dns_result_t fromstruct_mr(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 9); + REQUIRE(type == 9); class = class; /*unused*/ @@ -132,7 +138,7 @@ fromstruct_mr(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_mr(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 9); + REQUIRE(rdata->type == 9); target = target; diff --git a/lib/dns/rdata/generic/mr_9.h b/lib/dns/rdata/generic/mr_9.h index d45efbe760..8dd68cc5bf 100644 --- a/lib/dns/rdata/generic/mr_9.h +++ b/lib/dns/rdata/generic/mr_9.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: mr_9.h,v 1.3 1999/01/19 06:49:31 marka Exp $ */ + /* $Id: mr_9.h,v 1.4 1999/01/20 05:20:21 marka Exp $ */ #ifndef RDATA_GENERIC_MR_9_H #define RDATA_GENERIC_MR_9_H @@ -27,15 +27,21 @@ fromtext_mr(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 9); + REQUIRE(type == 9); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -51,7 +57,7 @@ totext_mr(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { dns_name_t prefix; isc_boolean_t sub; - INSIST(rdata->type == 9); + REQUIRE(rdata->type == 9); dns_name_init(&name, NULL); dns_name_init(&prefix, NULL); @@ -70,7 +76,7 @@ fromwire_mr(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { dns_name_t name; - INSIST(type == 9); + REQUIRE(type == 9); class = class; /*unused*/ @@ -83,7 +89,7 @@ towire_mr(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_name_t name; isc_region_t region; - INSIST(rdata->type == 9); + REQUIRE(rdata->type == 9); dns_name_init(&name, NULL); dns_rdata_toregion(rdata, ®ion); @@ -99,9 +105,9 @@ compare_mr(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { isc_region_t region1; isc_region_t region2; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == 9); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == 9); dns_name_init(&name1, NULL); dns_name_init(&name2, NULL); @@ -119,7 +125,7 @@ static dns_result_t fromstruct_mr(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 9); + REQUIRE(type == 9); class = class; /*unused*/ @@ -132,7 +138,7 @@ fromstruct_mr(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_mr(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 9); + REQUIRE(rdata->type == 9); target = target; diff --git a/lib/dns/rdata/generic/mx_15.c b/lib/dns/rdata/generic/mx_15.c index 95d0877d19..6e01629d38 100644 --- a/lib/dns/rdata/generic/mx_15.c +++ b/lib/dns/rdata/generic/mx_15.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: mx_15.c,v 1.5 1999/01/20 02:41:10 halley Exp $ */ + /* $Id: mx_15.c,v 1.6 1999/01/20 05:20:22 marka Exp $ */ #ifndef RDATA_GENERIC_MX_15_H #define RDATA_GENERIC_MX_15_H @@ -28,24 +28,37 @@ fromtext_mx(dns_rdataclass_t class, dns_rdatatype_t type, dns_name_t name; isc_buffer_t buffer; dns_result_t result; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 15); + REQUIRE(type == 15); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, ISC_LEXOPT_NUMBER, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_number) - return (DNS_R_UNKNOWN); + options |= ISC_LEXOPT_NUMBER; + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_number) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } result = uint16_fromtext(token.value.as_ulong, target); if (result != DNS_R_SUCCESS) return (result); - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + options &= ~ISC_LEXOPT_NUMBER; + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -64,7 +77,7 @@ totext_mx(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { char buf[sizeof "64000"]; unsigned short num; - INSIST(rdata->type == 15); + REQUIRE(rdata->type == 15); dns_name_init(&name, NULL); dns_name_init(&prefix, NULL); @@ -94,7 +107,7 @@ fromwire_mx(dns_rdataclass_t class, dns_rdatatype_t type, isc_region_t sregion; isc_region_t tregion; - INSIST(type == 15); + REQUIRE(type == 15); class = class; /* unused */ dns_name_init(&name, NULL); @@ -104,7 +117,7 @@ fromwire_mx(dns_rdataclass_t class, dns_rdatatype_t type, if (tregion.length < 2) return (DNS_R_NOSPACE); if (sregion.length < 2) - return (DNS_R_WIRE); + return (DNS_R_UNEXPECTEDEND); memcpy(tregion.base, sregion.base, 2); isc_buffer_forward(source, 2); isc_buffer_add(target, 2); @@ -118,7 +131,7 @@ towire_mx(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_result_t result; isc_region_t tr; - INSIST(rdata->type == 15); + REQUIRE(rdata->type == 15); isc_buffer_available(target, &tr); dns_rdata_toregion(rdata, ®ion); @@ -143,9 +156,9 @@ compare_mx(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { isc_region_t region2; int result; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == 15); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == 15); result = memcmp(rdata1->data, rdata2->data, 2); if (result != 0) @@ -170,7 +183,7 @@ static dns_result_t fromstruct_mx(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 15); + REQUIRE(type == 15); class = class; /*unused*/ @@ -183,7 +196,7 @@ fromstruct_mx(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_mx(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 15); + REQUIRE(rdata->type == 15); target = target; diff --git a/lib/dns/rdata/generic/mx_15.h b/lib/dns/rdata/generic/mx_15.h index a9bae9d3a7..a073b8a804 100644 --- a/lib/dns/rdata/generic/mx_15.h +++ b/lib/dns/rdata/generic/mx_15.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: mx_15.h,v 1.5 1999/01/20 02:41:10 halley Exp $ */ + /* $Id: mx_15.h,v 1.6 1999/01/20 05:20:22 marka Exp $ */ #ifndef RDATA_GENERIC_MX_15_H #define RDATA_GENERIC_MX_15_H @@ -28,24 +28,37 @@ fromtext_mx(dns_rdataclass_t class, dns_rdatatype_t type, dns_name_t name; isc_buffer_t buffer; dns_result_t result; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 15); + REQUIRE(type == 15); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, ISC_LEXOPT_NUMBER, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_number) - return (DNS_R_UNKNOWN); + options |= ISC_LEXOPT_NUMBER; + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_number) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } result = uint16_fromtext(token.value.as_ulong, target); if (result != DNS_R_SUCCESS) return (result); - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + options &= ~ISC_LEXOPT_NUMBER; + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -64,7 +77,7 @@ totext_mx(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { char buf[sizeof "64000"]; unsigned short num; - INSIST(rdata->type == 15); + REQUIRE(rdata->type == 15); dns_name_init(&name, NULL); dns_name_init(&prefix, NULL); @@ -94,7 +107,7 @@ fromwire_mx(dns_rdataclass_t class, dns_rdatatype_t type, isc_region_t sregion; isc_region_t tregion; - INSIST(type == 15); + REQUIRE(type == 15); class = class; /* unused */ dns_name_init(&name, NULL); @@ -104,7 +117,7 @@ fromwire_mx(dns_rdataclass_t class, dns_rdatatype_t type, if (tregion.length < 2) return (DNS_R_NOSPACE); if (sregion.length < 2) - return (DNS_R_WIRE); + return (DNS_R_UNEXPECTEDEND); memcpy(tregion.base, sregion.base, 2); isc_buffer_forward(source, 2); isc_buffer_add(target, 2); @@ -118,7 +131,7 @@ towire_mx(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_result_t result; isc_region_t tr; - INSIST(rdata->type == 15); + REQUIRE(rdata->type == 15); isc_buffer_available(target, &tr); dns_rdata_toregion(rdata, ®ion); @@ -143,9 +156,9 @@ compare_mx(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { isc_region_t region2; int result; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == 15); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == 15); result = memcmp(rdata1->data, rdata2->data, 2); if (result != 0) @@ -170,7 +183,7 @@ static dns_result_t fromstruct_mx(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 15); + REQUIRE(type == 15); class = class; /*unused*/ @@ -183,7 +196,7 @@ fromstruct_mx(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_mx(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 15); + REQUIRE(rdata->type == 15); target = target; diff --git a/lib/dns/rdata/generic/ns_2.c b/lib/dns/rdata/generic/ns_2.c index 738c85a664..fecba0912d 100644 --- a/lib/dns/rdata/generic/ns_2.c +++ b/lib/dns/rdata/generic/ns_2.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: ns_2.c,v 1.3 1999/01/19 06:49:31 marka Exp $ */ + /* $Id: ns_2.c,v 1.4 1999/01/20 05:20:22 marka Exp $ */ #ifndef RDATA_GENERIC_NS_2_H #define RDATA_GENERIC_NS_2_H @@ -27,15 +27,21 @@ fromtext_ns(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 2); + REQUIRE(type == 2); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -51,7 +57,7 @@ totext_ns(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { dns_name_t prefix; isc_boolean_t sub; - INSIST(rdata->type == 2); + REQUIRE(rdata->type == 2); dns_name_init(&name, NULL); dns_name_init(&prefix, NULL); @@ -70,7 +76,7 @@ fromwire_ns(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { dns_name_t name; - INSIST(type == 2); + REQUIRE(type == 2); class = class; /*unused*/ @@ -83,7 +89,7 @@ towire_ns(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_name_t name; isc_region_t region; - INSIST(rdata->type == 2); + REQUIRE(rdata->type == 2); dns_name_init(&name, NULL); dns_rdata_toregion(rdata, ®ion); @@ -99,9 +105,9 @@ compare_ns(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { isc_region_t region1; isc_region_t region2; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == 2); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == 2); dns_name_init(&name1, NULL); dns_name_init(&name2, NULL); @@ -119,7 +125,7 @@ static dns_result_t fromstruct_ns(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 2); + REQUIRE(type == 2); class = class; /*unused*/ @@ -132,7 +138,7 @@ fromstruct_ns(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_ns(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 2); + REQUIRE(rdata->type == 2); target = target; diff --git a/lib/dns/rdata/generic/ns_2.h b/lib/dns/rdata/generic/ns_2.h index 569aa59d20..56ace09e08 100644 --- a/lib/dns/rdata/generic/ns_2.h +++ b/lib/dns/rdata/generic/ns_2.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: ns_2.h,v 1.3 1999/01/19 06:49:31 marka Exp $ */ + /* $Id: ns_2.h,v 1.4 1999/01/20 05:20:22 marka Exp $ */ #ifndef RDATA_GENERIC_NS_2_H #define RDATA_GENERIC_NS_2_H @@ -27,15 +27,21 @@ fromtext_ns(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 2); + REQUIRE(type == 2); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -51,7 +57,7 @@ totext_ns(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { dns_name_t prefix; isc_boolean_t sub; - INSIST(rdata->type == 2); + REQUIRE(rdata->type == 2); dns_name_init(&name, NULL); dns_name_init(&prefix, NULL); @@ -70,7 +76,7 @@ fromwire_ns(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { dns_name_t name; - INSIST(type == 2); + REQUIRE(type == 2); class = class; /*unused*/ @@ -83,7 +89,7 @@ towire_ns(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_name_t name; isc_region_t region; - INSIST(rdata->type == 2); + REQUIRE(rdata->type == 2); dns_name_init(&name, NULL); dns_rdata_toregion(rdata, ®ion); @@ -99,9 +105,9 @@ compare_ns(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { isc_region_t region1; isc_region_t region2; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == 2); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == 2); dns_name_init(&name1, NULL); dns_name_init(&name2, NULL); @@ -119,7 +125,7 @@ static dns_result_t fromstruct_ns(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 2); + REQUIRE(type == 2); class = class; /*unused*/ @@ -132,7 +138,7 @@ fromstruct_ns(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_ns(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 2); + REQUIRE(rdata->type == 2); target = target; diff --git a/lib/dns/rdata/generic/null_10.c b/lib/dns/rdata/generic/null_10.c index 15100c4a3d..6bd5b1101e 100644 --- a/lib/dns/rdata/generic/null_10.c +++ b/lib/dns/rdata/generic/null_10.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: null_10.c,v 1.3 1999/01/19 06:49:31 marka Exp $ */ + /* $Id: null_10.c,v 1.4 1999/01/20 05:20:22 marka Exp $ */ #ifndef RDATA_GENERIC_NULL_10_H #define RDATA_GENERIC_NULL_10_H @@ -25,7 +25,7 @@ fromtext_null(dns_rdataclass_t class, dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin, isc_boolean_t downcase, isc_buffer_t *target) { - INSIST(type == 10); + REQUIRE(type == 10); class = class; /*unused*/ type = type; /*unused*/ @@ -41,8 +41,8 @@ static dns_result_t totext_null(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { - INSIST(rdata->type == 10); - INSIST(rdata->length == 0); + REQUIRE(rdata->type == 10); + REQUIRE(rdata->length == 0); origin = origin; /*unused*/ target = target; /*unused*/ @@ -55,7 +55,7 @@ fromwire_null(dns_rdataclass_t class, dns_rdatatype_t type, isc_buffer_t *source, dns_decompress_t *dctx, isc_boolean_t downcase, isc_buffer_t *target) { - INSIST(type == 10); + REQUIRE(type == 10); class = class; /*unused*/ dctx = dctx; /*unused*/ @@ -69,7 +69,7 @@ fromwire_null(dns_rdataclass_t class, dns_rdatatype_t type, static dns_result_t towire_null(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { - INSIST(rdata->type == 10); + REQUIRE(rdata->type == 10); cctx = cctx; /*unused*/ target = target; /*unused*/ @@ -80,9 +80,9 @@ towire_null(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { static int compare_null(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { - INSIST(rdata1->type == rdata1->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == 10); + REQUIRE(rdata1->type == rdata1->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == 10); return (0); } @@ -91,7 +91,7 @@ static dns_result_t fromstruct_null(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 10); + REQUIRE(type == 10); class = class; /*unused*/ @@ -104,7 +104,7 @@ fromstruct_null(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_null(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 10); + REQUIRE(rdata->type == 10); target = target; diff --git a/lib/dns/rdata/generic/null_10.h b/lib/dns/rdata/generic/null_10.h index 3550bc6ec0..87eb3394f6 100644 --- a/lib/dns/rdata/generic/null_10.h +++ b/lib/dns/rdata/generic/null_10.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: null_10.h,v 1.3 1999/01/19 06:49:31 marka Exp $ */ + /* $Id: null_10.h,v 1.4 1999/01/20 05:20:22 marka Exp $ */ #ifndef RDATA_GENERIC_NULL_10_H #define RDATA_GENERIC_NULL_10_H @@ -25,7 +25,7 @@ fromtext_null(dns_rdataclass_t class, dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin, isc_boolean_t downcase, isc_buffer_t *target) { - INSIST(type == 10); + REQUIRE(type == 10); class = class; /*unused*/ type = type; /*unused*/ @@ -41,8 +41,8 @@ static dns_result_t totext_null(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { - INSIST(rdata->type == 10); - INSIST(rdata->length == 0); + REQUIRE(rdata->type == 10); + REQUIRE(rdata->length == 0); origin = origin; /*unused*/ target = target; /*unused*/ @@ -55,7 +55,7 @@ fromwire_null(dns_rdataclass_t class, dns_rdatatype_t type, isc_buffer_t *source, dns_decompress_t *dctx, isc_boolean_t downcase, isc_buffer_t *target) { - INSIST(type == 10); + REQUIRE(type == 10); class = class; /*unused*/ dctx = dctx; /*unused*/ @@ -69,7 +69,7 @@ fromwire_null(dns_rdataclass_t class, dns_rdatatype_t type, static dns_result_t towire_null(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { - INSIST(rdata->type == 10); + REQUIRE(rdata->type == 10); cctx = cctx; /*unused*/ target = target; /*unused*/ @@ -80,9 +80,9 @@ towire_null(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { static int compare_null(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { - INSIST(rdata1->type == rdata1->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == 10); + REQUIRE(rdata1->type == rdata1->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == 10); return (0); } @@ -91,7 +91,7 @@ static dns_result_t fromstruct_null(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 10); + REQUIRE(type == 10); class = class; /*unused*/ @@ -104,7 +104,7 @@ fromstruct_null(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_null(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 10); + REQUIRE(rdata->type == 10); target = target; diff --git a/lib/dns/rdata/generic/proforma.c b/lib/dns/rdata/generic/proforma.c index d4ef620058..19c6e6f3fa 100644 --- a/lib/dns/rdata/generic/proforma.c +++ b/lib/dns/rdata/generic/proforma.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: proforma.c,v 1.3 1999/01/19 06:49:32 marka Exp $ */ + /* $Id: proforma.c,v 1.4 1999/01/20 05:20:23 marka Exp $ */ #ifndef RDATA_GENERIC_#_#_H #define RDATA_GENERIC_#_#_H @@ -24,9 +24,10 @@ static dns_result_t fromtext_#(dns_rdataclass_t class, dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin, isc_boolean_t downcase, isc_buffer_t *target) { + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == #); - INSIST(class == #); + REQUIRE(type == #); + REQUIRE(class == #); return (DNS_R_NOTIMPLEMENTED); } @@ -34,8 +35,8 @@ fromtext_#(dns_rdataclass_t class, dns_rdatatype_t type, static dns_result_t totext_#(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { - INSIST(rdata->type == #); - INSIST(rdata->class == #); + REQUIRE(rdata->type == #); + REQUIRE(rdata->class == #); return (DNS_R_NOTIMPLEMENTED); } @@ -45,8 +46,8 @@ fromwire_#(dns_rdataclass_t class, dns_rdatatype_t type, isc_buffer_t *source, dns_decompress_t *dctx, isc_boolean_t downcase, isc_buffer_t *target) { - INSIST(type == #); - INSIST(class == #); + REQUIRE(type == #); + REQUIRE(class == #); return (DNS_R_NOTIMPLEMENTED); } @@ -54,8 +55,8 @@ fromwire_#(dns_rdataclass_t class, dns_rdatatype_t type, static dns_result_t towire_#(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { - INSIST(rdata->type == #); - INSIST(rdata->class == #); + REQUIRE(rdata->type == #); + REQUIRE(rdata->class == #); return (DNS_R_NOTIMPLEMENTED); } @@ -63,10 +64,10 @@ towire_#(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { static int compare_#(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == #); - INSIST(rdata1->class == #); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == #); + REQUIRE(rdata1->class == #); return (-2); } @@ -75,8 +76,8 @@ static dns_result_t fromstruct_#(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == #); - INSIST(class == #); + REQUIRE(type == #); + REQUIRE(class == #); return (DNS_R_NOTIMPLEMENTED); } @@ -84,8 +85,8 @@ fromstruct_#(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_#(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == #); - INSIST(rdata->class == #); + REQUIRE(rdata->type == #); + REQUIRE(rdata->class == #); return (DNS_R_NOTIMPLEMENTED); } diff --git a/lib/dns/rdata/generic/proforma.h b/lib/dns/rdata/generic/proforma.h index 4c323a6b30..e3e6e9df13 100644 --- a/lib/dns/rdata/generic/proforma.h +++ b/lib/dns/rdata/generic/proforma.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: proforma.h,v 1.3 1999/01/19 06:49:32 marka Exp $ */ + /* $Id: proforma.h,v 1.4 1999/01/20 05:20:23 marka Exp $ */ #ifndef RDATA_GENERIC_#_#_H #define RDATA_GENERIC_#_#_H @@ -24,9 +24,10 @@ static dns_result_t fromtext_#(dns_rdataclass_t class, dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin, isc_boolean_t downcase, isc_buffer_t *target) { + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == #); - INSIST(class == #); + REQUIRE(type == #); + REQUIRE(class == #); return (DNS_R_NOTIMPLEMENTED); } @@ -34,8 +35,8 @@ fromtext_#(dns_rdataclass_t class, dns_rdatatype_t type, static dns_result_t totext_#(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { - INSIST(rdata->type == #); - INSIST(rdata->class == #); + REQUIRE(rdata->type == #); + REQUIRE(rdata->class == #); return (DNS_R_NOTIMPLEMENTED); } @@ -45,8 +46,8 @@ fromwire_#(dns_rdataclass_t class, dns_rdatatype_t type, isc_buffer_t *source, dns_decompress_t *dctx, isc_boolean_t downcase, isc_buffer_t *target) { - INSIST(type == #); - INSIST(class == #); + REQUIRE(type == #); + REQUIRE(class == #); return (DNS_R_NOTIMPLEMENTED); } @@ -54,8 +55,8 @@ fromwire_#(dns_rdataclass_t class, dns_rdatatype_t type, static dns_result_t towire_#(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { - INSIST(rdata->type == #); - INSIST(rdata->class == #); + REQUIRE(rdata->type == #); + REQUIRE(rdata->class == #); return (DNS_R_NOTIMPLEMENTED); } @@ -63,10 +64,10 @@ towire_#(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { static int compare_#(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == #); - INSIST(rdata1->class == #); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == #); + REQUIRE(rdata1->class == #); return (-2); } @@ -75,8 +76,8 @@ static dns_result_t fromstruct_#(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == #); - INSIST(class == #); + REQUIRE(type == #); + REQUIRE(class == #); return (DNS_R_NOTIMPLEMENTED); } @@ -84,8 +85,8 @@ fromstruct_#(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_#(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == #); - INSIST(rdata->class == #); + REQUIRE(rdata->type == #); + REQUIRE(rdata->class == #); return (DNS_R_NOTIMPLEMENTED); } diff --git a/lib/dns/rdata/generic/ptr_12.c b/lib/dns/rdata/generic/ptr_12.c index 82cd364996..1993feb1d7 100644 --- a/lib/dns/rdata/generic/ptr_12.c +++ b/lib/dns/rdata/generic/ptr_12.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: ptr_12.c,v 1.3 1999/01/19 06:49:32 marka Exp $ */ + /* $Id: ptr_12.c,v 1.4 1999/01/20 05:20:23 marka Exp $ */ #ifndef RDATA_GENERIC_PTR_12_H #define RDATA_GENERIC_PTR_12_H @@ -27,15 +27,21 @@ fromtext_ptr(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 12); + REQUIRE(type == 12); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -51,7 +57,7 @@ totext_ptr(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { dns_name_t prefix; isc_boolean_t sub; - INSIST(rdata->type == 12); + REQUIRE(rdata->type == 12); dns_name_init(&name, NULL); dns_name_init(&prefix, NULL); @@ -70,7 +76,7 @@ fromwire_ptr(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { dns_name_t name; - INSIST(type == 12); + REQUIRE(type == 12); class = class; /* unused */ @@ -83,7 +89,7 @@ towire_ptr(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_name_t name; isc_region_t region; - INSIST(rdata->type == 12); + REQUIRE(rdata->type == 12); dns_name_init(&name, NULL); dns_rdata_toregion(rdata, ®ion); @@ -99,9 +105,9 @@ compare_ptr(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { isc_region_t region1; isc_region_t region2; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == 12); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == 12); dns_name_init(&name1, NULL); dns_name_init(&name2, NULL); @@ -119,7 +125,7 @@ static dns_result_t fromstruct_ptr(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 12); + REQUIRE(type == 12); class = class; /*unused*/ @@ -132,7 +138,7 @@ fromstruct_ptr(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_ptr(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 12); + REQUIRE(rdata->type == 12); target = target; diff --git a/lib/dns/rdata/generic/ptr_12.h b/lib/dns/rdata/generic/ptr_12.h index dc09d8d00a..8278e003f7 100644 --- a/lib/dns/rdata/generic/ptr_12.h +++ b/lib/dns/rdata/generic/ptr_12.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: ptr_12.h,v 1.3 1999/01/19 06:49:32 marka Exp $ */ + /* $Id: ptr_12.h,v 1.4 1999/01/20 05:20:23 marka Exp $ */ #ifndef RDATA_GENERIC_PTR_12_H #define RDATA_GENERIC_PTR_12_H @@ -27,15 +27,21 @@ fromtext_ptr(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; dns_name_t name; isc_buffer_t buffer; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 12); + REQUIRE(type == 12); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -51,7 +57,7 @@ totext_ptr(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { dns_name_t prefix; isc_boolean_t sub; - INSIST(rdata->type == 12); + REQUIRE(rdata->type == 12); dns_name_init(&name, NULL); dns_name_init(&prefix, NULL); @@ -70,7 +76,7 @@ fromwire_ptr(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { dns_name_t name; - INSIST(type == 12); + REQUIRE(type == 12); class = class; /* unused */ @@ -83,7 +89,7 @@ towire_ptr(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_name_t name; isc_region_t region; - INSIST(rdata->type == 12); + REQUIRE(rdata->type == 12); dns_name_init(&name, NULL); dns_rdata_toregion(rdata, ®ion); @@ -99,9 +105,9 @@ compare_ptr(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { isc_region_t region1; isc_region_t region2; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == 12); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == 12); dns_name_init(&name1, NULL); dns_name_init(&name2, NULL); @@ -119,7 +125,7 @@ static dns_result_t fromstruct_ptr(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 12); + REQUIRE(type == 12); class = class; /*unused*/ @@ -132,7 +138,7 @@ fromstruct_ptr(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_ptr(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 12); + REQUIRE(rdata->type == 12); target = target; diff --git a/lib/dns/rdata/generic/soa_6.c b/lib/dns/rdata/generic/soa_6.c index e47c423ae3..d3fd1ebf36 100644 --- a/lib/dns/rdata/generic/soa_6.c +++ b/lib/dns/rdata/generic/soa_6.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: soa_6.c,v 1.5 1999/01/20 02:41:11 halley Exp $ */ + /* $Id: soa_6.c,v 1.6 1999/01/20 05:20:23 marka Exp $ */ #ifndef RDATA_GENERIC_SOA_6_H #define RDATA_GENERIC_SOA_6_H @@ -29,15 +29,21 @@ fromtext_soa(dns_rdataclass_t class, dns_rdatatype_t type, isc_buffer_t buffer; dns_result_t result; int i; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 6); + REQUIRE(type == 6); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -47,10 +53,15 @@ fromtext_soa(dns_rdataclass_t class, dns_rdatatype_t type, if (result != DNS_R_SUCCESS) return (result); - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -60,12 +71,17 @@ fromtext_soa(dns_rdataclass_t class, dns_rdatatype_t type, if (result != DNS_R_SUCCESS) return (result); + options |= ISC_LEXOPT_NUMBER; for (i = 0; i < 5; i++) { - if (isc_lex_gettoken(lexer, ISC_LEXOPT_NUMBER, &token) - != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_number) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_number) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } result = uint32_fromtext(token.value.as_ulong, target); if (result != DNS_R_SUCCESS) @@ -84,7 +100,7 @@ totext_soa(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { isc_boolean_t sub; int i; - INSIST(rdata->type == 6); + REQUIRE(rdata->type == 6); dns_name_init(&mname, NULL); dns_name_init(&rname, NULL); @@ -140,7 +156,7 @@ fromwire_soa(dns_rdataclass_t class, dns_rdatatype_t type, isc_region_t sregion; isc_region_t tregion; - INSIST(type == 6); + REQUIRE(type == 6); class = class; /*unused*/ @@ -158,8 +174,8 @@ fromwire_soa(dns_rdataclass_t class, dns_rdatatype_t type, isc_buffer_active(source, &sregion); isc_buffer_available(target, &tregion); - if (sregion.length != 20) - return (DNS_R_WIRE); + if (sregion.length < 20) + return (DNS_R_UNEXPECTEDEND); if (tregion.length < 20) return (DNS_R_NOSPACE); @@ -177,7 +193,7 @@ towire_soa(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_name_t rname; dns_result_t result; - INSIST(rdata->type == 6); + REQUIRE(rdata->type == 6); dns_name_init(&mname, NULL); dns_name_init(&rname, NULL); @@ -212,9 +228,9 @@ compare_soa(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { dns_name_t name2; int result; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == 6); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == 6); dns_name_init(&name1, NULL); dns_name_init(&name2, NULL); @@ -256,7 +272,7 @@ static dns_result_t fromstruct_soa(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 6); + REQUIRE(type == 6); class = class; /*unused*/ @@ -269,7 +285,7 @@ fromstruct_soa(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_soa(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 6); + REQUIRE(rdata->type == 6); target = target; diff --git a/lib/dns/rdata/generic/soa_6.h b/lib/dns/rdata/generic/soa_6.h index 025e198c9e..9b30bd6cc6 100644 --- a/lib/dns/rdata/generic/soa_6.h +++ b/lib/dns/rdata/generic/soa_6.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: soa_6.h,v 1.5 1999/01/20 02:41:11 halley Exp $ */ + /* $Id: soa_6.h,v 1.6 1999/01/20 05:20:23 marka Exp $ */ #ifndef RDATA_GENERIC_SOA_6_H #define RDATA_GENERIC_SOA_6_H @@ -29,15 +29,21 @@ fromtext_soa(dns_rdataclass_t class, dns_rdatatype_t type, isc_buffer_t buffer; dns_result_t result; int i; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 6); + REQUIRE(type == 6); class = class; /*unused*/ - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -47,10 +53,15 @@ fromtext_soa(dns_rdataclass_t class, dns_rdatatype_t type, if (result != DNS_R_SUCCESS) return (result); - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region, @@ -60,12 +71,17 @@ fromtext_soa(dns_rdataclass_t class, dns_rdatatype_t type, if (result != DNS_R_SUCCESS) return (result); + options |= ISC_LEXOPT_NUMBER; for (i = 0; i < 5; i++) { - if (isc_lex_gettoken(lexer, ISC_LEXOPT_NUMBER, &token) - != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_number) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_number) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } result = uint32_fromtext(token.value.as_ulong, target); if (result != DNS_R_SUCCESS) @@ -84,7 +100,7 @@ totext_soa(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { isc_boolean_t sub; int i; - INSIST(rdata->type == 6); + REQUIRE(rdata->type == 6); dns_name_init(&mname, NULL); dns_name_init(&rname, NULL); @@ -140,7 +156,7 @@ fromwire_soa(dns_rdataclass_t class, dns_rdatatype_t type, isc_region_t sregion; isc_region_t tregion; - INSIST(type == 6); + REQUIRE(type == 6); class = class; /*unused*/ @@ -158,8 +174,8 @@ fromwire_soa(dns_rdataclass_t class, dns_rdatatype_t type, isc_buffer_active(source, &sregion); isc_buffer_available(target, &tregion); - if (sregion.length != 20) - return (DNS_R_WIRE); + if (sregion.length < 20) + return (DNS_R_UNEXPECTEDEND); if (tregion.length < 20) return (DNS_R_NOSPACE); @@ -177,7 +193,7 @@ towire_soa(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { dns_name_t rname; dns_result_t result; - INSIST(rdata->type == 6); + REQUIRE(rdata->type == 6); dns_name_init(&mname, NULL); dns_name_init(&rname, NULL); @@ -212,9 +228,9 @@ compare_soa(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { dns_name_t name2; int result; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->type == 6); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->type == 6); dns_name_init(&name1, NULL); dns_name_init(&name2, NULL); @@ -256,7 +272,7 @@ static dns_result_t fromstruct_soa(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 6); + REQUIRE(type == 6); class = class; /*unused*/ @@ -269,7 +285,7 @@ fromstruct_soa(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_soa(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 6); + REQUIRE(rdata->type == 6); target = target; diff --git a/lib/dns/rdata/generic/txt_16.c b/lib/dns/rdata/generic/txt_16.c index 220a3c3a8c..e84a1a55e7 100644 --- a/lib/dns/rdata/generic/txt_16.c +++ b/lib/dns/rdata/generic/txt_16.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: txt_16.c,v 1.4 1999/01/19 06:49:33 marka Exp $ */ + /* $Id: txt_16.c,v 1.5 1999/01/20 05:20:24 marka Exp $ */ #ifndef RDATA_GENERIC_TXT_16_H #define RDATA_GENERIC_TXT_16_H @@ -26,21 +26,21 @@ fromtext_txt(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { isc_token_t token; dns_result_t result; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 16); + REQUIRE(type == 16); class = class; /*unused*/ origin = origin; /*unused*/ downcase = downcase; /*unused*/ - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); while (token.type == isc_tokentype_string) { result = txt_fromtext(&token.value.as_textregion, target); if (result != DNS_R_SUCCESS) return (result); - if (isc_lex_gettoken(lexer, ISC_LEXOPT_EOL | ISC_LEXOPT_EOF, - &token) != ISC_R_SUCCESS) + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) return (DNS_R_UNKNOWN); } /* Let upper layer handle eol/eof. */ @@ -53,7 +53,7 @@ totext_txt(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { isc_region_t region; dns_result_t result; - INSIST(rdata->type == 16); + REQUIRE(rdata->type == 16); origin = origin; /*unused*/ @@ -79,7 +79,7 @@ fromwire_txt(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { dns_result_t result; - INSIST(type == 16); + REQUIRE(type == 16); dctx = dctx; /*unused*/ class = class; /*unused*/ @@ -97,7 +97,7 @@ static dns_result_t towire_txt(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { isc_region_t region; - INSIST(rdata->type == 16); + REQUIRE(rdata->type == 16); cctx = cctx; /*unused*/ @@ -115,9 +115,9 @@ compare_txt(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { int l; int result; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->class == 16); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->class == 16); l = (rdata1->length < rdata2->length) ? rdata1->length : rdata2->length; result = memcmp(rdata1->data, rdata2->data, l); @@ -134,7 +134,7 @@ static dns_result_t fromstruct_txt(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 16); + REQUIRE(type == 16); class = class; /*unused*/ @@ -147,7 +147,7 @@ fromstruct_txt(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_txt(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 16); + REQUIRE(rdata->type == 16); target = target; diff --git a/lib/dns/rdata/generic/txt_16.h b/lib/dns/rdata/generic/txt_16.h index 89407f160a..02ae74207b 100644 --- a/lib/dns/rdata/generic/txt_16.h +++ b/lib/dns/rdata/generic/txt_16.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: txt_16.h,v 1.4 1999/01/19 06:49:33 marka Exp $ */ + /* $Id: txt_16.h,v 1.5 1999/01/20 05:20:24 marka Exp $ */ #ifndef RDATA_GENERIC_TXT_16_H #define RDATA_GENERIC_TXT_16_H @@ -26,21 +26,21 @@ fromtext_txt(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { isc_token_t token; dns_result_t result; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 16); + REQUIRE(type == 16); class = class; /*unused*/ origin = origin; /*unused*/ downcase = downcase; /*unused*/ - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); while (token.type == isc_tokentype_string) { result = txt_fromtext(&token.value.as_textregion, target); if (result != DNS_R_SUCCESS) return (result); - if (isc_lex_gettoken(lexer, ISC_LEXOPT_EOL | ISC_LEXOPT_EOF, - &token) != ISC_R_SUCCESS) + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) return (DNS_R_UNKNOWN); } /* Let upper layer handle eol/eof. */ @@ -53,7 +53,7 @@ totext_txt(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { isc_region_t region; dns_result_t result; - INSIST(rdata->type == 16); + REQUIRE(rdata->type == 16); origin = origin; /*unused*/ @@ -79,7 +79,7 @@ fromwire_txt(dns_rdataclass_t class, dns_rdatatype_t type, isc_boolean_t downcase, isc_buffer_t *target) { dns_result_t result; - INSIST(type == 16); + REQUIRE(type == 16); dctx = dctx; /*unused*/ class = class; /*unused*/ @@ -97,7 +97,7 @@ static dns_result_t towire_txt(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { isc_region_t region; - INSIST(rdata->type == 16); + REQUIRE(rdata->type == 16); cctx = cctx; /*unused*/ @@ -115,9 +115,9 @@ compare_txt(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { int l; int result; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->class); - INSIST(rdata1->class == 16); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->class); + REQUIRE(rdata1->class == 16); l = (rdata1->length < rdata2->length) ? rdata1->length : rdata2->length; result = memcmp(rdata1->data, rdata2->data, l); @@ -134,7 +134,7 @@ static dns_result_t fromstruct_txt(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 16); + REQUIRE(type == 16); class = class; /*unused*/ @@ -147,7 +147,7 @@ fromstruct_txt(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_txt(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 16); + REQUIRE(rdata->type == 16); target = target; diff --git a/lib/dns/rdata/in_1/a_1.c b/lib/dns/rdata/in_1/a_1.c index 77aef68e01..e8d425b089 100644 --- a/lib/dns/rdata/in_1/a_1.c +++ b/lib/dns/rdata/in_1/a_1.c @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: a_1.c,v 1.4 1999/01/20 02:41:11 halley Exp $ */ + /* $Id: a_1.c,v 1.5 1999/01/20 05:20:24 marka Exp $ */ #ifndef RDATA_IN_1_A_1_H #define RDATA_IN_1_A_1_H @@ -33,20 +33,26 @@ fromtext_in_a(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; struct in_addr addr; isc_region_t region; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 1); - INSIST(class == 1); + REQUIRE(type == 1); + REQUIRE(class == 1); origin = origin; /*unused*/ downcase = downcase; /*unused*/ - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } if (inet_aton(token.value.as_pointer , &addr) != 1) - return (DNS_R_UNKNOWN); + return (DNS_R_UNEXPECTED); isc_buffer_available(target, ®ion); if (region.length < 4) return (DNS_R_NOSPACE); @@ -59,9 +65,9 @@ static dns_result_t totext_in_a(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { isc_region_t region; - INSIST(rdata->type == 1); - INSIST(rdata->class == 1); - INSIST(rdata->length == 4); + REQUIRE(rdata->type == 1); + REQUIRE(rdata->class == 1); + REQUIRE(rdata->length == 4); origin = origin; /* unused */ @@ -81,8 +87,8 @@ fromwire_in_a(dns_rdataclass_t class, dns_rdatatype_t type, isc_region_t sregion; isc_region_t tregion; - INSIST(type == 1); - INSIST(class == 1); + REQUIRE(type == 1); + REQUIRE(class == 1); dctx = dctx; /* unused */ downcase = downcase; /* unused */ @@ -90,8 +96,8 @@ fromwire_in_a(dns_rdataclass_t class, dns_rdatatype_t type, isc_buffer_active(source, &sregion); isc_buffer_available(target, &tregion); - if (sregion.length != 4) - return (DNS_R_WIRE); + if (sregion.length < 4) + return (DNS_R_UNEXPECTEDEND); if (tregion.length < 4) return (DNS_R_NOSPACE); @@ -105,8 +111,8 @@ static dns_result_t towire_in_a(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { isc_region_t region; - INSIST(rdata->type == 1); - INSIST(rdata->class == 1); + REQUIRE(rdata->type == 1); + REQUIRE(rdata->class == 1); cctx = cctx; /*unused*/ @@ -122,10 +128,10 @@ static int compare_in_a(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { int result; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->type); - INSIST(rdata1->type == 1); - INSIST(rdata1->class == 1); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->type); + REQUIRE(rdata1->type == 1); + REQUIRE(rdata1->class == 1); result = memcmp(rdata1->data, rdata2->data, 4); if (result != 0) @@ -138,8 +144,8 @@ static dns_result_t fromstruct_in_a(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 1); - INSIST(class == 1); + REQUIRE(type == 1); + REQUIRE(class == 1); source = source; target = target; @@ -150,8 +156,8 @@ fromstruct_in_a(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_in_a(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 1); - INSIST(rdata->class == 1); + REQUIRE(rdata->type == 1); + REQUIRE(rdata->class == 1); target = target; diff --git a/lib/dns/rdata/in_1/a_1.h b/lib/dns/rdata/in_1/a_1.h index 9313344469..102f15cf05 100644 --- a/lib/dns/rdata/in_1/a_1.h +++ b/lib/dns/rdata/in_1/a_1.h @@ -15,7 +15,7 @@ * SOFTWARE. */ - /* $Id: a_1.h,v 1.4 1999/01/20 02:41:11 halley Exp $ */ + /* $Id: a_1.h,v 1.5 1999/01/20 05:20:24 marka Exp $ */ #ifndef RDATA_IN_1_A_1_H #define RDATA_IN_1_A_1_H @@ -33,20 +33,26 @@ fromtext_in_a(dns_rdataclass_t class, dns_rdatatype_t type, isc_token_t token; struct in_addr addr; isc_region_t region; + unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF; - INSIST(type == 1); - INSIST(class == 1); + REQUIRE(type == 1); + REQUIRE(class == 1); origin = origin; /*unused*/ downcase = downcase; /*unused*/ - if (isc_lex_gettoken(lexer, 0, &token) != ISC_R_SUCCESS) - return (DNS_R_UNKNOWN); - if (token.type != isc_tokentype_string) - return (DNS_R_UNKNOWN); + if (isc_lex_gettoken(lexer, options, &token) != ISC_R_SUCCESS) + return (DNS_R_UNEXPECTED); + if (token.type != isc_tokentype_string) { + isc_lex_ungettoken(lexer, &token); + if (token.type == isc_tokentype_eol || + token.type == isc_tokentype_eof) + return(DNS_R_UNEXPECTEDEND); + return (DNS_R_UNEXPECTED); + } if (inet_aton(token.value.as_pointer , &addr) != 1) - return (DNS_R_UNKNOWN); + return (DNS_R_UNEXPECTED); isc_buffer_available(target, ®ion); if (region.length < 4) return (DNS_R_NOSPACE); @@ -59,9 +65,9 @@ static dns_result_t totext_in_a(dns_rdata_t *rdata, dns_name_t *origin, isc_buffer_t *target) { isc_region_t region; - INSIST(rdata->type == 1); - INSIST(rdata->class == 1); - INSIST(rdata->length == 4); + REQUIRE(rdata->type == 1); + REQUIRE(rdata->class == 1); + REQUIRE(rdata->length == 4); origin = origin; /* unused */ @@ -81,8 +87,8 @@ fromwire_in_a(dns_rdataclass_t class, dns_rdatatype_t type, isc_region_t sregion; isc_region_t tregion; - INSIST(type == 1); - INSIST(class == 1); + REQUIRE(type == 1); + REQUIRE(class == 1); dctx = dctx; /* unused */ downcase = downcase; /* unused */ @@ -90,8 +96,8 @@ fromwire_in_a(dns_rdataclass_t class, dns_rdatatype_t type, isc_buffer_active(source, &sregion); isc_buffer_available(target, &tregion); - if (sregion.length != 4) - return (DNS_R_WIRE); + if (sregion.length < 4) + return (DNS_R_UNEXPECTEDEND); if (tregion.length < 4) return (DNS_R_NOSPACE); @@ -105,8 +111,8 @@ static dns_result_t towire_in_a(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) { isc_region_t region; - INSIST(rdata->type == 1); - INSIST(rdata->class == 1); + REQUIRE(rdata->type == 1); + REQUIRE(rdata->class == 1); cctx = cctx; /*unused*/ @@ -122,10 +128,10 @@ static int compare_in_a(dns_rdata_t *rdata1, dns_rdata_t *rdata2) { int result; - INSIST(rdata1->type == rdata2->type); - INSIST(rdata1->class == rdata2->type); - INSIST(rdata1->type == 1); - INSIST(rdata1->class == 1); + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->class == rdata2->type); + REQUIRE(rdata1->type == 1); + REQUIRE(rdata1->class == 1); result = memcmp(rdata1->data, rdata2->data, 4); if (result != 0) @@ -138,8 +144,8 @@ static dns_result_t fromstruct_in_a(dns_rdataclass_t class, dns_rdatatype_t type, void *source, isc_buffer_t *target) { - INSIST(type == 1); - INSIST(class == 1); + REQUIRE(type == 1); + REQUIRE(class == 1); source = source; target = target; @@ -150,8 +156,8 @@ fromstruct_in_a(dns_rdataclass_t class, dns_rdatatype_t type, void *source, static dns_result_t tostruct_in_a(dns_rdata_t *rdata, void *target) { - INSIST(rdata->type == 1); - INSIST(rdata->class == 1); + REQUIRE(rdata->type == 1); + REQUIRE(rdata->class == 1); target = target; diff --git a/lib/dns/result.c b/lib/dns/result.c index 762cc1e8d3..b4c91c8070 100644 --- a/lib/dns/result.c +++ b/lib/dns/result.c @@ -37,6 +37,9 @@ static char *text_table[DNS_R_LASTENTRY + 1] = { "too many hops", /* 14 */ "disallowed (by application policy)", /* 15 */ "no more list elements", /* 16 */ + "extra input text", /* 17 */ + "extra input data", /* 18 */ + "text too long", /* 19 */ }; char *