summaryrefslogtreecommitdiffstats
path: root/contrib/bind/bin/named/db_load.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bind/bin/named/db_load.c')
-rw-r--r--contrib/bind/bin/named/db_load.c112
1 files changed, 86 insertions, 26 deletions
diff --git a/contrib/bind/bin/named/db_load.c b/contrib/bind/bin/named/db_load.c
index 305944c..0adb7ab 100644
--- a/contrib/bind/bin/named/db_load.c
+++ b/contrib/bind/bin/named/db_load.c
@@ -1,6 +1,6 @@
#if !defined(lint) && !defined(SABER)
static const char sccsid[] = "@(#)db_load.c 4.38 (Berkeley) 3/2/91";
-static const char rcsid[] = "$Id: db_load.c,v 8.104 2000/07/17 07:48:09 vixie Exp $";
+static const char rcsid[] = "$Id: db_load.c,v 8.110 2001/01/25 05:50:53 marka Exp $";
#endif /* not lint */
/*
@@ -252,6 +252,7 @@ db_load(const char *filename, const char *in_origin,
int genstart, genend, genstep;
char *thisfile;
void *state = NULL;
+ int loggenerr;
empty_from.sin_family = AF_INET;
empty_from.sin_addr.s_addr = htonl(INADDR_ANY);
@@ -270,6 +271,13 @@ db_load(const char *filename, const char *in_origin,
/* Any updates should be saved before we attempt to reload. */
INSIST((zp->z_flags & (Z_NEED_DUMP|Z_NEED_SOAUPDATE)) == 0);
case Z_HINT:
+ if(filename == NULL) {
+ ns_error(ns_log_load,
+ "Required filename not specified for Hint zone");
+ zp->z_flags |= Z_DB_BAD;
+ zp->z_ftime = 0;
+ return (0);
+ }
transport = primary_trans;
break;
case Z_SECONDARY:
@@ -314,7 +322,10 @@ db_load(const char *filename, const char *in_origin,
ns_warning(ns_log_load, "db_load could not open: %s: %s",
filename, strerror(errno));
zp->z_ftime = 0;
- return (-1);
+ if (ininclude)
+ return (-1);
+ errs = -1;
+ goto cleanup;
}
if (zp->z_type == Z_HINT) {
dbflags = DB_NODATA | DB_NOHINTS;
@@ -414,10 +425,21 @@ db_load(const char *filename, const char *in_origin,
}
if (!getword(genrhs, sizeof(genrhs), fp, 2))
ERRTOZ("$GENERATE missing RHS");
+ loggenerr = 1;
for (i = genstart; i <= genend; i += genstep) {
if (genname(genlhs, i, origin, domain,
sizeof domain) == -1)
ERRTOZ("$GENERATE genname LHS failed");
+ if (!ns_samedomain(domain, zp->z_origin)) {
+ /* Log first per $GENERATE. */
+ if (loggenerr) {
+ ns_info(ns_log_load,
+ "%s:%d: $GENERATE LHS out of zone (ignored)",
+ filename, lineno);
+ loggenerr = 0;
+ }
+ continue;
+ }
context = ns_ownercontext(type, transport);
if (!ns_nameok(NULL, domain, class, zp, transport,
context, domain, inaddr_any)) {
@@ -668,7 +690,7 @@ db_load(const char *filename, const char *in_origin,
filename, lineno, domain,
zp->z_origin);
}
- c = getnonblank(fp, filename);
+ c = getnonblank(fp, filename, 0);
if (c == '(') {
multiline = 1;
} else {
@@ -677,7 +699,8 @@ db_load(const char *filename, const char *in_origin,
}
serial = zp->z_serial;
zp->z_serial = getnum(fp, filename,
- GETNUM_SERIAL);
+ GETNUM_SERIAL,
+ &multiline);
if (getnum_error)
errs++;
n = (u_int32_t) zp->z_serial;
@@ -750,7 +773,7 @@ db_load(const char *filename, const char *in_origin,
ttl = n;
n = cp - (char *)data;
if (multiline) {
- buf[0] = getnonblank(fp, filename);
+ buf[0] = getnonblank(fp, filename, 1);
buf[1] = '\0';
if (buf[0] != ')')
ERRTO("SOA \")\"");
@@ -807,7 +830,8 @@ db_load(const char *filename, const char *in_origin,
PUTSHORT((u_int16_t)n, cp);
/* Preference */
- n = getnum(fp, filename, GETNUM_NONE);
+ n = getnum(fp, filename, GETNUM_NONE,
+ &multiline);
if (getnum_error || n > 65536)
ERRTO("NAPTR Preference");
PUTSHORT((u_int16_t)n, cp);
@@ -874,12 +898,14 @@ db_load(const char *filename, const char *in_origin,
PUTSHORT((u_int16_t)n, cp);
if (type == ns_t_srv) {
- n = getnum(fp, filename, GETNUM_NONE);
+ n = getnum(fp, filename, GETNUM_NONE,
+ &multiline);
if (getnum_error || n > 65536)
ERRTO("SRV RR");
PUTSHORT((u_int16_t)n, cp);
- n = getnum(fp, filename, GETNUM_NONE);
+ n = getnum(fp, filename, GETNUM_NONE,
+ &multiline);
if (getnum_error || n > 65536)
ERRTO("SRV RR");
PUTSHORT((u_int16_t)n, cp);
@@ -1095,19 +1121,27 @@ db_load(const char *filename, const char *in_origin,
}
errs += purge_nonglue(zp->z_origin,
(dataflags & DB_F_HINT) ? fcachetab :
- hashtab, zp->z_class);
+ hashtab, zp->z_class,
+ zp->z_type == z_master);
+ cleanup:
while (filenames) {
fn = filenames;
filenames = filenames->next;
freestr(fn->name);
memput(fn, sizeof *fn);
}
- if (errs != 0)
- ns_warning(ns_log_load,
+ if (errs != 0) {
+ if (errs != -1)
+ ns_warning(ns_log_load,
"%s zone \"%s\" (%s) rejected due to errors (serial %u)",
- zoneTypeString(zp->z_type), zp->z_origin,
- p_class(zp->z_class), zp->z_serial);
- else
+ zoneTypeString(zp->z_type),
+ zp->z_origin,
+ p_class(zp->z_class), zp->z_serial);
+ if ((zp->z_flags & Z_NOTIFY) != 0)
+ ns_stopnotify(zp->z_origin, zp->z_class);
+ do_reload(zp->z_origin, zp->z_type, zp->z_class,
+ loading);
+ } else
ns_info(ns_log_load,
"%s zone \"%s\" (%s) loaded (serial %u)",
zoneTypeString(zp->z_type), zp->z_origin,
@@ -1366,7 +1400,7 @@ getttl(FILE *fp, const char *fn, int lineno, u_int32_t *ttl, int *multiline) {
return (-1);
}
if (*multiline) {
- ch = getnonblank(fp, fn);
+ ch = getnonblank(fp, fn, 1);
if (ch == EOF)
return (-1);
if (ch == ';')
@@ -1447,7 +1481,7 @@ getallwords(char *buf, size_t size, FILE *fp, int preserve) {
}
int
-getnum(FILE *fp, const char *src, int opt) {
+getnum(FILE *fp, const char *src, int opt, int *multiline) {
int c, n;
int seendigit = 0;
int seendecimal = 0;
@@ -1461,8 +1495,12 @@ getnum(FILE *fp, const char *src, int opt) {
#endif
for (n = 0; (c = getc(fp)) != EOF; ) {
if (isspace(c)) {
- if (c == '\n')
- lineno++;
+ if (c == '\n') {
+ if (*multiline)
+ lineno++;
+ else if (!seendigit)
+ goto eol;
+ }
if (seendigit)
break;
continue;
@@ -1470,8 +1508,12 @@ getnum(FILE *fp, const char *src, int opt) {
if (c == ';') {
while ((c = getc(fp)) != EOF && c != '\n')
;
- if (c == '\n')
- lineno++;
+ if (c == '\n') {
+ if (*multiline)
+ lineno++;
+ else if (!seendigit)
+ goto eol;
+ }
if (seendigit)
break;
continue;
@@ -1541,32 +1583,50 @@ getnum(FILE *fp, const char *src, int opt) {
src, lineno, n+m);
}
return (n + m);
+
+ eol:
+ ns_error(ns_log_db, "%s:%d: unexpected end of line", src, lineno);
+ getnum_error = 1;
+ (void) ungetc(c, fp);
+ return (0);
}
#ifndef BIND_UPDATE
static
#endif
int
-getnonblank(FILE *fp, const char *src) {
+getnonblank(FILE *fp, const char *src, int multiline) {
int c;
while ((c = getc(fp)) != EOF) {
if (isspace(c)) {
- if (c == '\n')
- lineno++;
+ if (c == '\n') {
+ if (multiline)
+ lineno++;
+ else
+ goto eol;
+ }
continue;
}
if (c == ';') {
while ((c = getc(fp)) != EOF && c != '\n')
;
- if (c == '\n')
- lineno++;
+ if (c == '\n') {
+ if (multiline)
+ lineno++;
+ else
+ goto eol;
+ }
continue;
}
return (c);
}
ns_info(ns_log_db, "%s:%d: unexpected EOF", src, lineno);
return (EOF);
+ eol:
+ ns_error(ns_log_db, "%s:%d: unexpected end of line", src, lineno);
+ /* don't ungetc(c, fp); as the caller will do this. */
+ return(c);
}
/*
@@ -2118,7 +2178,7 @@ parse_sig_rr(char *buf, int buf_len, u_char *data, int data_size,
} else {
/* Parse and output OTTL; scan TEXP */
origTTL = wordtouint32(buf);
- if (0 >= origTTL || wordtouint32_error ||
+ if (origTTL >= 0 || wordtouint32_error ||
(origTTL > 0x7fffffff))
ERRTO("Original TTL value bad");
cp = &data[i];
OpenPOWER on IntegriCloud