From d1e971ba027a8d320cc87a02a71158970bd03308 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Sun, 9 Jul 2000 12:52:34 +0000 Subject: [PATCH] 316. [bug] EOF mid line should be a error. 315. [bug] Handle non-empty blanks lines. --- CHANGES | 4 ++++ lib/dns/master.c | 50 +++++++++++++++++++++++++++++++++++++----------- 2 files changed, 43 insertions(+), 11 deletions(-) diff --git a/CHANGES b/CHANGES index 662c05e8c6..0dbcb80a34 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ + 316. [bug] EOF mid line should be a error. + + 315. [bug] Handle non-empty blanks lines. + 314. [func] Inet controls named.conf statement can now have any non-negative number of keys specified. diff --git a/lib/dns/master.c b/lib/dns/master.c index d57bea0c0f..1de15751a7 100644 --- a/lib/dns/master.c +++ b/lib/dns/master.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: master.c,v 1.55 2000/06/29 15:55:19 marka Exp $ */ +/* $Id: master.c,v 1.56 2000/07/09 12:52:34 marka Exp $ */ #include @@ -186,6 +186,7 @@ load(isc_lex_t *lex, dns_name_t *top, dns_name_t *origin, isc_boolean_t finish_origin = ISC_FALSE; isc_boolean_t finish_include = ISC_FALSE; isc_boolean_t read_till_eol = ISC_FALSE; + isc_boolean_t initialws; char *include_file = NULL; isc_token_t token; isc_result_t result = ISC_R_UNEXPECTED; @@ -253,9 +254,18 @@ load(isc_lex_t *lex, dns_name_t *top, dns_name_t *origin, memset(name_in_use, 0, NBUFS * sizeof(isc_boolean_t)); do { + initialws = ISC_FALSE; GETTOKEN(lex, ISC_LEXOPT_INITIALWS, &token, ISC_TRUE); if (token.type == isc_tokentype_eof) { + if (read_till_eol) { + (*callbacks->error)(callbacks, + "dns_master_load: %s:%lu: unexpected end of file", + isc_lex_getsourcename(lex), + isc_lex_getsourceline(lex)); + result = ISC_R_UNEXPECTEDEND; + goto cleanup; + } done = ISC_TRUE; continue; } @@ -269,18 +279,10 @@ load(isc_lex_t *lex, dns_name_t *top, dns_name_t *origin, continue; if (token.type == isc_tokentype_initialws) { - if (!current_known) { - (*callbacks->error)(callbacks, - "%s: %s:%lu: No current owner name", - "dns_master_load", - isc_lex_getsourcename(lex), - isc_lex_getsourceline(lex)); - result = DNS_R_NOOWNER; - goto cleanup; - } /* * Still working on the same name. */ + initialws = ISC_TRUE; } else if (token.type == isc_tokentype_string) { /* @@ -545,7 +547,33 @@ load(isc_lex_t *lex, dns_name_t *top, dns_name_t *origin, type = 0; rdclass = 0; - GETTOKEN(lex, 0, &token, ISC_FALSE); + GETTOKEN(lex, 0, &token, initialws); + + if (initialws) { + if (token.type == isc_tokentype_eol) { + read_till_eol = ISC_FALSE; + continue; /* blank line */ + } + + if (token.type == isc_tokentype_eof) { + (*callbacks->error)(callbacks, + "dns_master_load: %s:%lu: unexpected end of file", + isc_lex_getsourcename(lex), + isc_lex_getsourceline(lex)); + result = ISC_R_UNEXPECTEDEND; + goto cleanup; + } + + if (!current_known) { + (*callbacks->error)(callbacks, + "%s: %s:%lu: No current owner name", + "dns_master_load", + isc_lex_getsourcename(lex), + isc_lex_getsourceline(lex)); + result = DNS_R_NOOWNER; + goto cleanup; + } + } if (dns_rdataclass_fromtext(&rdclass, &token.value.as_textregion)