Commit f4d9f465 authored by James Brister's avatar James Brister
Browse files

327. [bug] rndc.conf parser wasn't correctly recognising an IP

                        address where a host specification was required.
parent 838f13fb
327. [bug] rndc.conf parser wasn't correctly recognising an IP
address where a host specification was required.
326. [func] 'keys' in an 'inet' control statement is now
required and must have at least one item in it.
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: confndc.c,v 1.20 2000/07/10 11:27:11 tale Exp $ */
/* $Id: confndc.c,v 1.21 2000/07/11 20:13:09 brister Exp $ */
/*
** options {
......@@ -144,51 +144,39 @@ static struct keywordtoken misc_tokens[] = {
static isc_result_t
parse_file(ndcpcontext *pctx, dns_c_ndcctx_t **context);
static isc_result_t parse_file(ndcpcontext *pctx, dns_c_ndcctx_t **context);
static isc_result_t
parse_statement(ndcpcontext *pctx);
static isc_result_t
parse_options(ndcpcontext *pctx, dns_c_ndcopts_t **opts);
static isc_result_t
parse_serverstmt(ndcpcontext *pctx, dns_c_ndcserver_t **server);
static isc_result_t
parse_keystmt(ndcpcontext *pctx, dns_c_kdeflist_t *keys);
static isc_result_t parse_statement(ndcpcontext *pctx);
static isc_result_t parse_options(ndcpcontext *pctx, dns_c_ndcopts_t **opts);
static isc_result_t parse_serverstmt(ndcpcontext *pctx, dns_c_ndcserver_t **server);
static isc_result_t parse_keystmt(ndcpcontext *pctx, dns_c_kdeflist_t *keys);
static const char *
keyword2str(isc_int32_t val);
static isc_boolean_t
eat(ndcpcontext *pctx, isc_uint32_t token);
static isc_boolean_t
eat_eos(ndcpcontext *pctx);
static isc_boolean_t
eat_lbrace(ndcpcontext *pctx);
static isc_boolean_t
eat_rbrace(ndcpcontext *pctx);
static const char * keyword2str(isc_int32_t val);
static isc_boolean_t eat(ndcpcontext *pctx, isc_uint32_t token);
static isc_boolean_t eat_eos(ndcpcontext *pctx);
static isc_boolean_t eat_lbrace(ndcpcontext *pctx);
static isc_boolean_t eat_rbrace(ndcpcontext *pctx);
static isc_boolean_t
looking_at(ndcpcontext *pctx, isc_uint32_t token);
static isc_boolean_t
looking_at_anystring(ndcpcontext *pctx);
static isc_boolean_t looking_at(ndcpcontext *pctx, isc_uint32_t token);
static isc_boolean_t looking_at_anystring(ndcpcontext *pctx);
static isc_result_t
parser_setup(ndcpcontext *pctx, isc_mem_t *mem, const char *filename);
static void
parser_complain(isc_boolean_t is_warning, isc_boolean_t print_last_token,
ndcpcontext *pctx, const char *format, va_list args);
static void
parser_error(ndcpcontext *pctx, isc_boolean_t lasttoken, const char *fmt, ...);
static void
parser_warn(ndcpcontext *pctx, isc_boolean_t lasttoken, const char *fmt, ...);
static isc_boolean_t
is_ip6addr(const char *string, struct in6_addr *addr);
static isc_boolean_t
is_ip4addr(const char *string, struct in_addr *addr);
static isc_result_t
getnexttoken(ndcpcontext *pctx);
static void
syntax_error(ndcpcontext *pctx, isc_uint32_t keyword);
static isc_boolean_t looking_at_stringoripaddr(ndcpcontext *pctx);
static isc_result_t parser_setup(ndcpcontext *pctx, isc_mem_t *mem,
const char *filename);
static void parser_complain(isc_boolean_t is_warning,
isc_boolean_t print_last_token,
ndcpcontext *pctx, const char *format,
va_list args);
static void parser_error(ndcpcontext *pctx, isc_boolean_t lasttoken,
const char *fmt, ...);
static void parser_warn(ndcpcontext *pctx, isc_boolean_t lasttoken,
const char *fmt, ...);
static isc_boolean_t is_ip6addr(const char *string, struct in6_addr *addr);
static isc_boolean_t is_ip4addr(const char *string, struct in_addr *addr);
static isc_result_t getnexttoken(ndcpcontext *pctx);
static void syntax_error(ndcpcontext *pctx, isc_uint32_t keyword);
/* *********************************************************************** */
......@@ -950,7 +938,7 @@ parse_options(ndcpcontext *pctx, dns_c_ndcopts_t **opts) {
switch (option) {
case L_DEFAULT_SERVER:
if (!looking_at_anystring(pctx))
if (!looking_at_stringoripaddr(pctx))
return (result);
result = dns_c_ndcopts_setdefserver(newopts,
......@@ -1067,7 +1055,7 @@ parse_serverstmt(ndcpcontext *pctx, dns_c_ndcserver_t **server) {
break;
case L_HOST:
if (!looking_at_anystring(pctx)) {
if (!looking_at_stringoripaddr(pctx)) {
result = ISC_R_FAILURE;
goto done;
}
......@@ -1347,6 +1335,20 @@ looking_at_anystring(ndcpcontext *pctx) {
return (ISC_TRUE);
}
static isc_boolean_t
looking_at_stringoripaddr(ndcpcontext *pctx) {
if (pctx->currtok != L_STRING && pctx->currtok != L_QSTRING &&
pctx->currtok != L_IP4ADDR && pctx->currtok != L_IP6ADDR) {
parser_error(pctx, ISC_TRUE,
"expected a hostname or an ip address");
return (ISC_FALSE);
}
return (ISC_TRUE);
}
static isc_boolean_t
eat_lbrace(ndcpcontext *pctx) {
return (eat(pctx, L_LBRACE));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment