sync w/ 8.3.5

This commit is contained in:
itojun 2003-06-03 07:33:24 +00:00
parent 261b3b5bbe
commit 8912e04d45
93 changed files with 1458 additions and 1503 deletions

3
dist/bind/README vendored
View File

@ -10,6 +10,9 @@ artifacts including BIND, INN, and DHCP.
Note that BIND 8 is in "end-of-life", having been replaced by BIND 9. See
http://www.isc.org/ for more details.
BIND 8.3.5 Highlights
Maintenance release.
BIND 8.3.4 Highlights
Security Fix DoS and buffer overrun.

2
dist/bind/Version vendored
View File

@ -1 +1 @@
8.3.4-REL
8.3.5-REL

View File

@ -1,7 +1,7 @@
/* $NetBSD: dig.c,v 1.6 2002/09/06 04:50:02 itojun Exp $ */
/* $NetBSD: dig.c,v 1.7 2003/06/03 07:33:26 itojun Exp $ */
#ifndef lint
static const char rcsid[] = "Id: dig.c,v 8.57 2002/06/18 02:26:49 marka Exp";
static const char rcsid[] = "Id: dig.c,v 8.62.6.3 2003/06/02 10:06:30 marka Exp";
#endif
/*
@ -179,6 +179,7 @@ static const char rcsid[] = "Id: dig.c,v 8.57 2002/06/18 02:26:49 marka Exp";
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h> /* time(2), ctime(3) */
#include "port_after.h"
@ -208,15 +209,23 @@ static const char rcsid[] = "Id: dig.c,v 8.57 2002/06/18 02:26:49 marka Exp";
#define SAVEENV "DiG.env"
#define DIG_MAXARGS 30
#ifndef DIG_PING
#define DIG_PING "ping"
#endif
#ifndef DIG_TAIL
#define DIG_TAIL "tail"
#endif
#ifndef DIG_PINGFMT
#define DIG_PINGFMT "%s -s %s 56 3 | %s -3"
#endif
static int eecode = 0;
static FILE * qfp;
static char *defsrv, *srvmsg;
static char defbuf[40] = "default -- ";
static char srvbuf[1024];
static char myhostname[MAXHOSTNAMELEN];
static struct sockaddr_in myaddress;
static struct sockaddr_in6 myaddress6;
static u_int32_t ixfr_serial;
static char ubuf[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:123.123.123.123")];
/* stuff for nslookup modules */
struct __res_state res;
@ -262,7 +271,7 @@ main(int argc, char **argv) {
} packet_;
#define header (packet_.header_)
#define packet (packet_.packet_)
u_char answer[64*1024];
u_char answer[NS_MAXMSG];
int n;
char doping[90];
char pingstr[50];
@ -297,6 +306,7 @@ main(int argc, char **argv) {
ns_tsig_key key;
char *keyfile = NULL, *keyname = NULL;
const char *pingfmt = NULL;
res_ninit(&res);
res.pfcode = PRF_DEF;
@ -317,7 +327,6 @@ main(int argc, char **argv) {
myaddress6.sin6_addr = in6addr_any;
myaddress6.sin6_port = 0; /*INPORT_ANY*/;
defsrv = strcat(defbuf, inet_ntoa(res.nsaddr.sin_addr));
res_x = res;
/*
@ -365,7 +374,6 @@ main(int argc, char **argv) {
vtmp++;
}
res.id = 1;
gettimeofday(&tv1, NULL);
/*
@ -410,6 +418,11 @@ main(int argc, char **argv) {
* deal with ....
*/
while (*(++argv) != NULL && **argv != '\0') {
if (strlen(cmd) + strlen(*argv) + 2 > sizeof (cmd)) {
fprintf(stderr,
"Argument too large for input buffer\n");
exit(1);
}
strcat(cmd, *argv);
strcat(cmd, " ");
if (**argv == '@') {
@ -525,10 +538,14 @@ main(int argc, char **argv) {
port = htons(atoi(*argv));
break;
case 'P':
if (argv[0][2] != '\0')
if (argv[0][2] != '\0') {
strcpy(pingstr, argv[0]+2);
else
strcpy(pingstr, "ping -s");
pingfmt =
"%s %s 56 3 | %s -3";
} else {
strcpy(pingstr, DIG_PING);
pingfmt = DIG_PINGFMT;
}
break;
case 'n':
if (argv[0][2] != '\0')
@ -771,8 +788,6 @@ main(int argc, char **argv) {
* able to "put the resolver to work".
*/
srvbuf[0] = 0;
srvmsg = defsrv;
if (srv != NULL) {
int nscount = 0;
union res_sockaddr_union u[MAXNS];
@ -805,31 +820,13 @@ main(int argc, char **argv) {
case AF_INET:
u[nscount].sin =
*(struct sockaddr_in*)cur->ai_addr;
u[nscount++].sin6.sin6_port =
u[nscount++].sin.sin_port =
port;
break;
}
}
if (nscount != 0) {
char buf[80];
if (nscount != 0)
res_setservers(&res, u, nscount);
srvmsg = strcat(srvbuf, srv);
strcat(srvbuf, " ");
buf[0] = '\0';
switch (u[0].sin.sin_family) {
case AF_INET:
inet_ntop(AF_INET,
&u[0].sin.sin_addr,
buf, sizeof(buf));
break;
case AF_INET6:
inet_ntop(AF_INET6,
&u[0].sin6.sin6_addr,
buf, sizeof(buf));
break;
}
strcat(srvbuf, buf);
}
freeaddrinfo(answer);
} else {
res = res_t;
@ -838,7 +835,6 @@ main(int argc, char **argv) {
"; Bad server: %s -- using default server and timer opts\n",
srv);
fflush(stderr);
srvmsg = defsrv;
srv = NULL;
}
printf("; (%d server%s found)\n",
@ -851,7 +847,7 @@ main(int argc, char **argv) {
int nscount;
union res_sockaddr_union u[MAXNS];
nscount = res_getservers(&res, u, MAXNS);
for (i = 0; i < res.nscount; i++) {
for (i = 0; i < nscount; i++) {
int x;
if (keyfile)
@ -863,24 +859,11 @@ main(int argc, char **argv) {
&u[i].sin,
NULL);
if (res.pfcode & RES_PRF_STATS) {
char buf[80];
exectime = time(NULL);
buf[0] = '\0';
switch (u[i].sin.sin_family) {
case AF_INET:
inet_ntop(AF_INET,
&u[i].sin.sin_addr,
buf, sizeof(buf));
break;
case AF_INET6:
inet_ntop(AF_INET6,
&u[i].sin6.sin6_addr,
buf, sizeof(buf));
break;
}
printf(";; FROM: %s to SERVER: %s\n",
myhostname,
buf);
p_sockun(u[RES_GETLAST(res)],
ubuf, sizeof(ubuf)));
printf(";; WHEN: %s", ctime(&exectime));
}
if (!x)
@ -946,12 +929,10 @@ main(int argc, char **argv) {
if ((bytes_in = n) < 0) {
fflush(stdout);
n = 0 - n;
msg[0]=0;
if (keyfile)
strcat(msg,";; res_nsendsigned to server ");
strcpy(msg, ";; res_nsendsigned");
else
strcat(msg,";; res_nsend to server ");
strcat(msg,srvmsg);
strcat(msg, ";; res_nsend");
perror(msg);
fflush(stderr);
@ -965,13 +946,17 @@ main(int argc, char **argv) {
(void) gettimeofday(&end_time, NULL);
if (res.pfcode & RES_PRF_STATS) {
union res_sockaddr_union u[MAXNS];
(void) res_getservers(&res, u, MAXNS);
query_time = difftv(start_time, end_time);
printf(";; Total query time: ");
prnttime(query_time);
putchar('\n');
exectime = time(NULL);
printf(";; FROM: %s to SERVER: %s\n",
myhostname, srvmsg);
printf(";; FROM: %s to SERVER: %s\n", myhostname,
p_sockun(u[RES_GETLAST(res)],
ubuf, sizeof(ubuf)));
printf(";; WHEN: %s", ctime(&exectime));
printf(";; MSG SIZE sent: %d rcvd: %d\n",
bytes_out, bytes_in);
@ -982,9 +967,8 @@ main(int argc, char **argv) {
* Argh ... not particularly elegant. Should put in *real* ping code.
* Would necessitate root priviledges for icmp port though!
*/
if (*pingstr) {
sprintf(doping,"%s %s 56 3 | tail -3",pingstr,
(srv==NULL)?(defsrv+10):srv);
if (*pingstr && srv != NULL) {
sprintf(doping, pingfmt, pingstr, srv, DIG_TAIL);
system(doping);
}
putchar('\n');
@ -1040,7 +1024,7 @@ where: server,\n\
fputs("\
notes: defname and search don't work; use fully-qualified names.\n\
this is DiG version " VSTRING "\n\
Id: dig.c,v 8.57 2002/06/18 02:26:49 marka Exp\n\
Id: dig.c,v 8.62.6.3 2003/06/02 10:06:30 marka Exp\n\
", stderr);
}
@ -1385,7 +1369,7 @@ printZone(ns_type xfr, const char *zone, const struct sockaddr_in *sin,
sizeof myaddress) < 0){
int e = errno;
fprintf(stderr, ";; bind(%s:%u): %s\n",
fprintf(stderr, ";; bind(%s port %u): %s\n",
inet_ntoa(myaddress.sin_addr),
ntohs(myaddress.sin_port),
strerror(e));
@ -1409,7 +1393,7 @@ printZone(ns_type xfr, const char *zone, const struct sockaddr_in *sin,
int e = errno;
char buf[80];
fprintf(stderr, ";; bind(%s:%u): %s\n",
fprintf(stderr, ";; bind(%s port %u): %s\n",
inet_ntop(AF_INET6, &myaddress6.sin6_addr,
buf, sizeof(buf)),
ntohs(myaddress6.sin6_port),

View File

@ -1,7 +1,7 @@
/* $NetBSD: dnsquery.c,v 1.4 2002/06/20 11:42:55 itojun Exp $ */
/* $NetBSD: dnsquery.c,v 1.5 2003/06/03 07:33:28 itojun Exp $ */
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "Id: dnsquery.c,v 8.19 2002/04/12 03:03:48 marka Exp";
static const char rcsid[] = "Id: dnsquery.c,v 8.19.10.1 2003/06/02 09:15:45 marka Exp";
#endif /* not lint */
/*
@ -87,7 +87,7 @@ main(int argc, char *argv[]) {
int c, n;
int nameservers = 0, class, type, len;
union res_sockaddr_union q_nsaddr[MAXNS];
extern int optind, opterr;
extern int optind;
extern char *optarg;
int stream = 0, debug = 0;

View File

@ -1,7 +1,7 @@
/* $NetBSD: host.c,v 1.6 2002/06/20 11:42:55 itojun Exp $ */
/* $NetBSD: host.c,v 1.7 2003/06/03 07:33:28 itojun Exp $ */
#ifndef lint
static const char rcsid[] = "Id: host.c,v 8.53 2002/06/18 02:34:02 marka Exp";
static const char rcsid[] = "Id: host.c,v 8.55.8.1 2003/06/02 09:24:38 marka Exp";
#endif /* not lint */
/*
@ -138,7 +138,7 @@ static const char copyright[] =
#define ERROR -3
#define NONAUTH -4
#define MY_PACKETSZ 64*1024 /* need this to hold tcp answers */
#define MY_PACKETSZ NS_MAXMSG
typedef union {
HEADER qb1;
@ -228,7 +228,7 @@ Usage: %s [-adlrwv] [-t querytype] [-c class] host [server]\n\
int
main(int argc, char **argv) {
struct sockaddr_storage addr;
struct hostent *hp;
int ok = 0;
char *s;
int waitmode = 0;
int ncnames, ch;
@ -385,7 +385,6 @@ main(int argc, char **argv) {
}
freeaddrinfo(answer);
}
hp = NULL;
res.res_h_errno = TRY_AGAIN;
/*
* We handle default domains ourselves, thank you.
@ -395,10 +394,10 @@ main(int argc, char **argv) {
if (list)
exit(ListHosts(getdomain, querytype ? querytype : ns_t_a));
ncnames = 5; nkeychains = 18;
while (hp == NULL && res.res_h_errno == TRY_AGAIN) {
while (ok == 0 && res.res_h_errno == TRY_AGAIN) {
if (!ip) {
cname = NULL;
hp = (struct hostent *)(unsigned long)gethostinfo(getdomain);
ok = gethostinfo(getdomain);
getdomain[0] = 0; /* clear this query */
if (sigchase && (chase_step & SD_RR)) {
if (nkeychains-- == 0) {
@ -415,7 +414,7 @@ main(int argc, char **argv) {
strcpy (getdomain, chase_domain);
strcat (getdomain, ".");
querytype = ns_t_sig;
} else if (hp && !(chase_step & SD_SIG) &&
} else if (ok != 0 && !(chase_step & SD_SIG) &&
(chase_step & SD_BADSIG)) {
printf ("%s for %s not found, last verified key %s\n",
chase_step & SD_SIG ? "Key" : "Signature",
@ -439,21 +438,17 @@ main(int argc, char **argv) {
sym_ntos(__p_type_syms, chase_type, NULL),
getdomain);
}
hp = NULL;
ok = 0;
res.res_h_errno = TRY_AGAIN;
continue;
}
} else {
if (addrinfo(&addr) == 0)
hp = NULL;
else
hp = (struct hostent *)1; /* XXX */
}
} else
ok = addrinfo(&addr);
if (!waitmode)
break;
}
if (hp == NULL) {
if (ok == 0) {
hperror(res.res_h_errno);
exit(1);
}
@ -751,14 +746,14 @@ printinfo(const querybuf *answer, const u_char *eom, int filter, int isls,
case SERVFAIL:
res.res_h_errno = TRY_AGAIN;
return (0);
case NOERROR:
res.res_h_errno = NO_DATA;
return (0);
case FORMERR:
case NOTIMP:
case REFUSED:
res.res_h_errno = NO_RECOVERY;
return (0);
case NOERROR:
res.res_h_errno = NO_DATA;
return (0);
case FORMERR:
case NOTIMP:
case REFUSED:
res.res_h_errno = NO_RECOVERY;
return (0);
}
return (0);
}
@ -1055,7 +1050,7 @@ pr_rr(const u_char *cp, const u_char *msg, FILE *file, int filter) {
}
if (doprint)
fprintf(file, "(\n\t\t\t%lu\t;serial (version)",
fprintf(file, " (\n\t\t\t%lu\t;serial (version)",
ns_get32(cp));
cp += INT32SZ;
if (doprint)
@ -1417,7 +1412,8 @@ pr_rr(const u_char *cp, const u_char *msg, FILE *file, int filter) {
}
default:
fprintf (stderr, "Unknown algorithm %d\n", n);
if (doprint && verbose)
fprintf (stderr, "Unknown algorithm %d\n", n);
cp = cp1 + dlen;
break;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: named-xfer.c,v 1.6 2002/06/28 06:11:51 itojun Exp $ */
/* $NetBSD: named-xfer.c,v 1.7 2003/06/03 07:33:42 itojun Exp $ */
/*
* The original version of named-xfer by Kevin Dunlap.
@ -132,7 +132,7 @@ char copyright[] =
#if !defined(lint) && !defined(SABER)
static const char sccsid[] = "@(#)named-xfer.c 4.18 (Berkeley) 3/7/91";
static const char rcsid[] = "Id: named-xfer.c,v 8.121 2002/06/26 03:27:22 marka Exp";
static const char rcsid[] = "Id: named-xfer.c,v 8.122.8.2 2003/06/02 05:59:56 marka Exp";
#endif /* not lint */
#include "port_before.h"
@ -244,8 +244,9 @@ LIST(tsig_node) tsig_list;
/*
* Debugging printf.
*/
void
dprintf(int level, const char *format, ...) {
static void lprintf(int level, const char *format, ...) ISC_FORMAT_PRINTF(2, 3);
static void
lprintf(int level, const char *format, ...) {
va_list ap;
va_start(ap, format);
@ -598,15 +599,15 @@ main(int argc, char *argv[]) {
#endif /* SIGUSR1&&SIGUSR2 */
if (dbfile)
dprintf(1, "domain `%s'; file `%s'; serial %u\n",
lprintf(1, "domain `%s'; file `%s'; serial %u\n",
domain, dbfile, serial_no);
if (ixfrfile)
dprintf(1, "domain `%s'; ixfrfile `%s'; serial %u\n",
lprintf(1, "domain `%s'; ixfrfile `%s'; serial %u\n",
domain, ixfrfile, serial_no);
if (tsigfile)
dprintf(1, "tsigfile `%s'\n", tsigfile);
lprintf(1, "tsigfile `%s'\n", tsigfile);
buildservicelist();
buildprotolist();
@ -628,7 +629,7 @@ main(int argc, char *argv[]) {
zp->z_source = dbfile;
zp->z_axfr_src = axfr_src;
zp->z_addrcnt = 0;
dprintf(1, "zone found (%d): \"%s\", source = %s\n",
lprintf(1, "zone found (%d): \"%s\", source = %s\n",
zp->z_type,
(zp->z_origin[0] == '\0') ? "." : zp->z_origin,
zp->z_source);
@ -672,15 +673,15 @@ main(int argc, char *argv[]) {
memcpy(&zp->z_addr[zp->z_addrcnt],
hp->h_addr,
INADDRSZ);
dprintf(1, "Arg: \"%s\" %s\n", tm,((tmpsupportixfr) ? "IXFR":"AXFR"));
lprintf(1, "Arg: \"%s\" %s\n", tm,((tmpsupportixfr) ? "IXFR":"AXFR"));
}
if (++zp->z_addrcnt >= NSMAX) {
zp->z_addrcnt = NSMAX;
dprintf(1, "NSMAX reached\n");
lprintf(1, "NSMAX reached\n");
break;
}
}
dprintf(1, "addrcnt = %d\n", zp->z_addrcnt);
lprintf(1, "addrcnt = %d\n", zp->z_addrcnt);
res_ninit(&res);
res.options &= ~(RES_DEFNAMES | RES_DNSRCH | RES_RECURSE);
@ -892,7 +893,7 @@ make_query(int fd, struct zoneinfo *zp, int type, u_int32_t serial_no,
if (type == T_IXFR) {
hp = (HEADER *) buf;
cp = buf;
dprintf(1, "len = %d\n", n);
lprintf(1, "len = %d\n", n);
hp->nscount = htons(1+ntohs(hp->nscount));
cp += n;
n = dn_comp(zp->z_origin, cp, bufsize - (cp - buf), NULL, NULL);
@ -913,7 +914,7 @@ make_query(int fd, struct zoneinfo *zp, int type, u_int32_t serial_no,
PUTLONG(0xABCD, cp); /* Expire */
PUTLONG(0x1776, cp); /* Min TTL */
n = cp - buf;
dprintf(1, "len = %d\n", cp-buf);
lprintf(1, "len = %d\n", cp-buf);
}
tsig_signed = 0;
@ -1118,7 +1119,7 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
for (cnt = 0; cnt < zp->z_addrcnt; cnt++) {
methode = servermethode[cnt];
sin.sin_addr = zp->z_addr[cnt];
dprintf(3, "address [%s] %s\n",
lprintf(3, "address [%s] %s\n",
inet_ntoa(sin.sin_addr),
(methode == ISIXFR) ? "IXFR":"AXFR");
}
@ -1158,7 +1159,7 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
sin.sin_family = AF_INET;
sin.sin_port = 0; /* "ANY" */
sin.sin_addr = z_axfr_src;
dprintf(2, "binding to address [%s]\n",
lprintf(2, "binding to address [%s]\n",
inet_ntoa(sin.sin_addr));
if (bind(s, (struct sockaddr *)&sin, sizeof sin) < 0)
syslog(LOG_INFO, "warning: bind(%s) failed",
@ -1168,11 +1169,11 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
sin.sin_family = AF_INET;
sin.sin_port = port;
sin.sin_addr = zp->z_addr[cnt];
dprintf(2, "connecting to server #%d [%s].%d\n",
lprintf(2, "connecting to server #%d [%s].%d\n",
cnt + 1, inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
if (z_axfr_src.s_addr != 0) {
dprintf(2, "connect failed, trying w/o -x");
lprintf(2, "connect failed, trying w/o -x");
z_axfr_src.s_addr = 0;
(void) my_close(s);
goto try_again;
@ -1371,7 +1372,7 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
}
}
if ((loop_cnt >= 1) && (soa_cnt < 2)) {
dprintf(1,
lprintf(1,
"server %s %d rejected IXFR and responded with AXFR\n",
inet_ntoa(sin.sin_addr), soa_cnt);
methode = ISNOTIXFR;
@ -1381,7 +1382,7 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
break;
}
/* Skip to next record, if any. */
dprintf(1, "skipping %s %s RR in response\n",
lprintf(1, "skipping %s %s RR in response\n",
name2, p_type(type));
tmp = cp4 + dlen;
loop_cnt++;
@ -1393,7 +1394,7 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
if (check_serial &&
!SEQ_GT(zp_start.z_serial, query_serial)) {
(void) my_close(s);
dprintf(1,
lprintf(1,
"zone up-to-date, serial %u\n",
zp_start.z_serial);
if (ixfp) {
@ -1542,7 +1543,7 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
soa_cnt = 0;
goto axfr_response;
}
dprintf(1, "need update, serial %u\n",
lprintf(1, "need update, serial %u\n",
zp_start.z_serial);
soa_cnt = 0;
hp = (HEADER *) buf;
@ -1566,14 +1567,16 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
serial_no, tsig_key,
buf, bufsize);
syslog(LOG_INFO,
"send %s query %d to %s",
p_type(query_type),
cnt, inet_ntoa(sin.sin_addr));
dprintf(1,
"send %s query %d to %s for %s",
p_type(query_type),
cnt, inet_ntoa(sin.sin_addr),
(*zp->z_origin != '\0') ?
zp->z_origin : ".");
lprintf(1,
"send %s query to %s\n",
p_type(query_type),
inet_ntoa(sin.sin_addr));
dprintf(1,"bufsize = %d\n", bufsize);
lprintf(1,"bufsize = %d\n", bufsize);
if (n < 0) {
if (!quiet) {
if (zp->z_type == Z_STUB)
@ -1647,7 +1650,7 @@ receive:
axfr_response:
if (query_type == T_IXFR)
if (hp->rcode != NOERROR) {
dprintf(1,
lprintf(1,
"server %s did not support IXFR\n",
inet_ntoa(sin.sin_addr));
methode = ISNOTIXFR;
@ -1657,7 +1660,7 @@ axfr_response:
if (ntohs(hp->qdcount) == 1) {
if ((query_type == T_IXFR) &&
(methode == ISIXFR)) {
dprintf(1,
lprintf(1,
"server %s rejected IXFR and responded with AXFR\n",
inet_ntoa(sin.sin_addr));
methode = ISNOTIXFR;
@ -1807,10 +1810,10 @@ axfr_response:
(void) fclose(ixfp);
ixfp = NULL;
}
dprintf(2, "error receiving zone transfer\n");
lprintf(2, "error receiving zone transfer\n");
} else if (zp_start.z_serial == serial_no) {
(void) my_close(s);
dprintf(1, "zone up-to-date, serial %u\n",
lprintf(1, "zone up-to-date, serial %u\n",
zp_start.z_serial);
if (ixfp) {
(void) fclose(ixfp);
@ -1830,7 +1833,7 @@ axfr_response:
} else {
if (zp_finish.z_serial == query_serial) {
(void) my_close(s);
dprintf(1, "zone up-to-date, serial %u\n",
lprintf(1, "zone up-to-date, serial %u\n",
zp_start.z_serial);
if (ixfp) {
(void) fclose(ixfp);
@ -1845,7 +1848,7 @@ axfr_response:
"serial from [%s], zone %s: %u lower than current: %u\n",
inet_ntoa(sin.sin_addr), zp->z_origin,
zp_finish.z_serial, query_serial);
dprintf(1,
lprintf(1,
"serial from [%s], zone %s: %u lower than current: %u\n",
inet_ntoa(sin.sin_addr), zp->z_origin,
zp_finish.z_serial, query_serial);
@ -1885,7 +1888,7 @@ axfr_response:
soa_cnt = 0;
goto axfr_response;
}
dprintf(1, "We have an IXFR\n");
lprintf(1, "We have an IXFR\n");
loop_cnt = 0;
while (SEQ_GT(zp_finish.z_serial, serial_no)) {
/*
@ -2057,7 +2060,7 @@ writemsg(int rfd, const u_char *msg, int msglen) {
u_char len[INT16SZ];
int ret;
__putshort(msglen, len);
ns_put16(msglen, len);
iov[0].iov_base = (char *)len;
iov[0].iov_len = INT16SZ;
DE_CONST(msg, iov[1].iov_base);
@ -2173,7 +2176,7 @@ print_output(struct zoneinfo *zp, u_int32_t serial_no, u_char *msg,
}
escaped = (*origin++ == '\\') && !escaped;
}
dprintf(3, "print_output: dname %s type %d class %d ttl %u\n",
lprintf(3, "print_output: dname %s type %d class %d ttl %u\n",
dname, type, class, ttl);
/*
* Convert the resource record data into the internal database format.
@ -2432,13 +2435,13 @@ print_output(struct zoneinfo *zp, u_int32_t serial_no, u_char *msg,
}
if (n > MAXDATA) {
dprintf(1, "update type %d: %d bytes is too much data\n",
lprintf(1, "update type %d: %d bytes is too much data\n",
type, n);
hp->rcode = FORMERR;
return (-1);
}
if (cp != rdatap + dlen) {
dprintf(1,
lprintf(1,
"encoded rdata length is %u, but actual length was %u\n",
dlen, (u_int)(cp - rdatap));
hp->rcode = FORMERR;
@ -2519,10 +2522,10 @@ print_output(struct zoneinfo *zp, u_int32_t serial_no, u_char *msg,
} else
soa_cnt++;
} else {
dprintf(2, "SOA, serial %u\n",
lprintf(2, "SOA, serial %u\n",
zp_finish.z_serial);
if (zp_start.z_serial != zp_finish.z_serial) {
dprintf(1, "serial changed, restart\n");
lprintf(1, "serial changed, restart\n");
restarts++;
if (restarts > MAX_XFER_RESTARTS) {
syslog(LOG_INFO,
@ -3192,13 +3195,13 @@ ixfr_log(const u_char *msg, int len, int *delete, FILE *file,
ns_rr rr;
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
dprintf(1, "ixfr_log() failed\n");
lprintf(1, "ixfr_log() failed\n");
return (-1);
}
if (ns_initparse(msg, len, &handle) < 0) {
fprintf(file, ";; ns_initparse: %s\n", strerror(errno));
dprintf(1, "ixfr_log() failed\n");
lprintf(1, "ixfr_log() failed\n");
return (-1);
}
opcode = (ns_opcode) ns_msg_getflag(handle, ns_f_opcode);
@ -3209,7 +3212,7 @@ ixfr_log(const u_char *msg, int len, int *delete, FILE *file,
{
(void) fprintf(file,"ns_parserr() failed");
dprintf(1, "ixfr_log() failed\n");
lprintf(1, "ixfr_log() failed\n");
return (-1);
}
type = (ns_type)rr.type;

View File

@ -1,8 +1,8 @@
/* $NetBSD: db_defs.h,v 1.6 2002/11/17 14:09:52 itojun Exp $ */
/* $NetBSD: db_defs.h,v 1.7 2003/06/03 07:33:29 itojun Exp $ */
/*
* from db.h 4.16 (Berkeley) 6/1/90
* Id: db_defs.h,v 8.47.4.1 2002/11/14 13:22:24 marka Exp
* Id: db_defs.h,v 8.48 2002/11/17 14:51:50 marka Exp
*/
/*

View File

@ -1,7 +1,7 @@
/* $NetBSD: db_ixfr.c,v 1.4 2002/06/20 11:42:56 itojun Exp $ */
/* $NetBSD: db_ixfr.c,v 1.5 2003/06/03 07:33:29 itojun Exp $ */
#if !defined(lint) && !defined(SABER)
static char rcsid[] = "Id: db_ixfr.c,v 8.31 2002/01/02 04:47:10 marka Exp";
static char rcsid[] = "Id: db_ixfr.c,v 8.32 2002/07/08 06:26:04 marka Exp";
#endif
/*
@ -859,8 +859,9 @@ ixfr_getdelta(struct zoneinfo *zp, FILE *fp, const char *filename, char *origin,
err++;
break;
}
n = strtoul(buf, &cp, 10);
if (n > 0xffff || *cp != '\0') {
errno = 0;
n = strtoul(buf, &cp, 10);
if (errno != 0 || n > 0xffff || *cp != '\0') {
err++;
break;
}

View File

@ -1,8 +1,8 @@
/* $NetBSD: db_load.c,v 1.6 2003/01/28 22:19:22 wiz Exp $ */
/* $NetBSD: db_load.c,v 1.7 2003/06/03 07:33:30 itojun Exp $ */
#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.121 2001/11/12 21:22:22 marka Exp";
static const char rcsid[] = "Id: db_load.c,v 8.123 2002/08/20 04:27:23 marka Exp";
#endif /* not lint */
/*
@ -1099,8 +1099,9 @@ db_load(const char *filename, const char *in_origin,
if (!getword(buf, sizeof buf, fp, 0) ||
!isdigit((unsigned char)buf[0]))
ERRTO("opaque length");
errno = 0;
n = strtoul(buf, &cp, 10);
if (n > 0xffff || *cp != '\0')
if (errno != 0 || n > 0xffff || *cp != '\0')
ERRTO("opaque length");
multiline = 0;
i = isc_gethexstring(data, sizeof(data), n, fp,
@ -1192,10 +1193,8 @@ db_load(const char *filename, const char *in_origin,
zp->z_origin, filename, msg);
}
}
errs += purge_nonglue(zp->z_origin,
(dataflags & DB_F_HINT) ? fcachetab :
hashtab, zp->z_class,
zp->z_type == z_master);
errs += purge_nonglue(zp, (dataflags & DB_F_HINT) ? fcachetab :
hashtab, zp->z_type == z_master);
cleanup:
while (filenames) {
fn = filenames;
@ -1212,8 +1211,7 @@ db_load(const char *filename, const char *in_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);
do_reload(zp, loading);
} else
ns_info(ns_log_load,
"%s zone \"%s\" (%s) loaded (serial %u)",

View File

@ -1,8 +1,8 @@
/* $NetBSD: db_sec.c,v 1.5 2002/11/17 14:09:52 itojun Exp $ */
/* $NetBSD: db_sec.c,v 1.6 2003/06/03 07:33:31 itojun Exp $ */
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "Id: db_sec.c,v 8.35.4.2 2002/11/14 13:24:44 marka Exp";
static const char rcsid[] = "Id: db_sec.c,v 8.36 2002/11/17 14:51:50 marka Exp";
#endif /* not lint */
/*

View File

@ -1,7 +1,7 @@
/* $NetBSD: ns_config.c,v 1.7 2002/06/20 11:42:56 itojun Exp $ */
/* $NetBSD: ns_config.c,v 1.8 2003/06/03 07:33:31 itojun Exp $ */
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "Id: ns_config.c,v 8.135 2002/05/24 03:04:59 marka Exp";
static const char rcsid[] = "Id: ns_config.c,v 8.136.8.1 2003/06/02 09:56:34 marka Exp";
#endif /* not lint */
/*
@ -564,7 +564,7 @@ update_zone_info(struct zoneinfo *zp, struct zoneinfo *new_zp) {
if (zp->z_source) {
zp->z_source = freestr(zp->z_source);
ns_stopxfrs(zp);
purge_zone(zp->z_origin, fcachetab, zp->z_class);
purge_zone(zp, fcachetab);
}
zp->z_source = new_zp->z_source;
new_zp->z_source = NULL;
@ -671,8 +671,7 @@ update_zone_info(struct zoneinfo *zp, struct zoneinfo *new_zp) {
* reloading so that NS records are present
* during the zone transfer.
*/
do_reload(zp->z_origin, zp->z_type,
zp->z_class, 1);
do_reload(zp, 1);
}
}
if (zp->z_source == NULL) {
@ -1152,6 +1151,7 @@ new_options() {
#ifdef BIND_NOTIFY
op->notify = notify_yes;
#endif
op->edns_udp_size = EDNS_MESSAGE_SZ;
return (op);
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: ns_ctl.c,v 1.6 2002/06/28 06:11:48 itojun Exp $ */
/* $NetBSD: ns_ctl.c,v 1.7 2003/06/03 07:33:32 itojun Exp $ */
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "Id: ns_ctl.c,v 8.47 2002/06/24 07:11:07 marka Exp";
static const char rcsid[] = "Id: ns_ctl.c,v 8.48 2002/07/29 02:06:56 marka Exp";
#endif /* not lint */
/*
@ -1128,7 +1128,7 @@ verb_args(struct ctl_sctx *ctl, struct ctl_sess *sess,
*/
cp = saved_argv[pvt->argc++];
tp = pvt->text;
while (cp && *cp != NULL)
while (cp && *cp != '\0')
if (*cp == '%' || *cp == ' ' ||
!isprint((unsigned char)*cp)) {
if (tp >= pvt->text + sizeof(pvt->text) - 4)

View File

@ -1,8 +1,8 @@
/* $NetBSD: ns_defs.h,v 1.8 2002/11/17 14:09:52 itojun Exp $ */
/* $NetBSD: ns_defs.h,v 1.9 2003/06/03 07:33:33 itojun Exp $ */
/*
* from ns.h 4.33 (Berkeley) 8/23/90
* Id: ns_defs.h,v 8.121.2.1 2002/11/14 13:28:12 marka Exp
* Id: ns_defs.h,v 8.124.6.1 2003/06/02 09:56:34 marka Exp
*/
/*
@ -452,7 +452,8 @@ struct qserv {
struct timeval stime; /* time first query started */
unsigned int forwarder:1; /* this entry is for a forwarder */
unsigned int noedns:1; /* don't try edns */
unsigned int nretry:30; /* # of times addr retried */
unsigned int lame:1; /* this server was lame, try it last */
unsigned int nretry:29; /* # of times addr retried */
u_int32_t serial; /* valid if Q_ZSERIAL */
};
@ -795,6 +796,7 @@ typedef struct options {
u_int lame_ttl;
int minroots;
u_int16_t preferred_glue;
u_int16_t edns_udp_size;
enum notify notify;
} *options;
@ -888,6 +890,7 @@ typedef enum ns_logging_categories {
ns_log_load,
ns_log_resp_checks,
ns_log_control,
ns_log_update_security,
ns_log_max_category
} ns_logging_categories;

View File

@ -1,8 +1,8 @@
/* $NetBSD: ns_forw.c,v 1.5 2002/06/20 11:42:57 itojun Exp $ */
/* $NetBSD: ns_forw.c,v 1.6 2003/06/03 07:33:33 itojun Exp $ */
#if !defined(lint) && !defined(SABER)
static const char sccsid[] = "@(#)ns_forw.c 4.32 (Berkeley) 3/3/91";
static const char rcsid[] = "Id: ns_forw.c,v 8.91 2002/05/24 03:04:57 marka Exp";
static const char rcsid[] = "Id: ns_forw.c,v 8.92.6.1 2003/06/02 09:56:34 marka Exp";
#endif /* not lint */
/*
@ -242,7 +242,8 @@ ns_forw(struct databuf *nsp[], u_char *msg, int msglen,
if (!qp->q_addr[0].noedns)
smsglen += ns_add_opt(smsg, smsg + smsglen, smsgsize, 0, 0,
EDNS_MESSAGE_SZ, 0, NULL, 0);
server_options->edns_udp_size,
0, NULL, 0);
if (key != NULL) {
n = ns_sign(smsg, &smsglen, smsgsize, NOERROR, key, NULL, 0,
@ -467,14 +468,14 @@ nslookup(struct databuf *nsp[], struct qinfo *qp,
struct hashbuf *tmphtp;
char *dname;
const char *fname;
int oldn, naddr, class, found_arr, potential_ns, lame_ns;
int oldn, naddr, class, found_arr, potential_ns;
time_t curtime;
int found_auth6;
ns_debug(ns_log_default, 3, "nslookup(nsp=%p, qp=%p, \"%s\", d=%d)",
nsp, qp, syslogdname, qp->q_distance);
lame_ns = potential_ns = 0;
potential_ns = 0;
naddr = n = qp->q_naddr;
curtime = (u_long) tt.tv_sec;
while ((nsdp = *nsp++) != NULL && n < NSMAX) {
@ -494,18 +495,6 @@ nslookup(struct databuf *nsp[], struct qinfo *qp,
}
}
/* skip lame servers */
if ((nsdp->d_flags & DB_F_LAME) != 0) {
time_t when;
when = db_lame_find(qp->q_domain, nsdp);
if (when != 0 && when > tt.tv_sec) {
ns_debug(ns_log_default, 3,
"skipping lame NS");
lame_ns++;
goto skipserver;
}
}
found_arr = 0;
found_auth6 = 0;
tmphtp = ((nsdp->d_flags & DB_F_HINT) ?fcachetab :hashtab);
@ -619,6 +608,13 @@ nslookup(struct databuf *nsp[], struct qinfo *qp,
if (si && (si->flags & SERVER_INFO_EDNS) == 0)
qs->noedns = 1;
}
qs->lame = 0;
if ((nsdp->d_flags & DB_F_LAME) != 0) {
time_t when;
when = db_lame_find(qp->q_domain, nsdp);
if (when != 0 && when > tt.tv_sec)
qs->lame = 1;
}
qs->nretry = 0;
/*
* If this A RR has no RTT, initialize its RTT to a
@ -710,15 +706,13 @@ nslookup(struct databuf *nsp[], struct qinfo *qp,
qp->q_naddr = n;
if (n == 0 && potential_ns == 0 && !NS_ZFWDTAB(qp->q_fzone)) {
static const char *complaint = "No possible A RRs";
if (lame_ns != 0)
complaint = "All possible A RR's lame";
if (sysloginfo && syslogdname &&
!haveComplained((u_long)syslogdname, (u_long)complaint))
{
ns_info(ns_log_default, "%s: query(%s) %s",
sysloginfo, syslogdname, complaint);
}
return ((lame_ns == 0) ? -1 : -2);
return (-1);
}
/* Update the refcounts before the sort. */
for (i = naddr; i < (u_int)n; i++) {
@ -794,6 +788,11 @@ int
qcomp(struct qserv *qs1, struct qserv *qs2) {
u_int rtt1, rtt2, rttr1, rttr2;
/* sort lame servers to last */
if (qs1->lame != qs2->lame)
return (qs1->lame - qs2->lame);
/* sort by rtt */
if (qs1->nsdata == NULL) {
rtt1 = 0;
rttr1 = 0;
@ -970,6 +969,23 @@ retry(struct qinfo *qp, int samehost) {
if (qp->q_naddr > 0) {
qp->q_addr[n].noedns = 1;
++qp->q_addr[n].nretry;
/*
* Look for a non-lame server.
*/
do {
if (++n >= (int)qp->q_naddr)
n = 0;
if ((qp->q_flags & Q_ZSERIAL) != 0 &&
qp->q_addr[n].serial != 0)
continue;
if (qp->q_addr[n].lame)
continue;
if (qp->q_addr[n].nretry < MAXRETRY)
goto found;
} while (n != qp->q_curaddr);
/*
* Look for any server including lame servers.
*/
do {
if (++n >= (int)qp->q_naddr)
n = 0;
@ -1073,7 +1089,8 @@ retry(struct qinfo *qp, int samehost) {
if (!qp->q_addr[n].noedns)
smsglen += ns_add_opt(smsg, smsg + smsglen, smsgsize, 0, 0,
EDNS_MESSAGE_SZ, 0, NULL, 0);
server_options->edns_udp_size,
0, NULL, 0);
if (key != NULL) {
n = ns_sign(smsg, &smsglen, smsgsize, NOERROR, key, NULL, 0,

View File

@ -1,4 +1,4 @@
/* $NetBSD: ns_func.h,v 1.7 2002/06/20 11:42:57 itojun Exp $ */
/* $NetBSD: ns_func.h,v 1.8 2003/06/03 07:33:33 itojun Exp $ */
/*
* Copyright (c) 1985, 1990
@ -92,7 +92,7 @@
/* ns_func.h - declarations for ns_*.c's externally visible functions
*
* Id: ns_func.h,v 8.117 2002/04/25 05:27:07 marka Exp
* Id: ns_func.h,v 8.120.8.1 2003/06/02 05:19:56 marka Exp
*/
/* ++from ns_glue.c++ */
@ -124,7 +124,6 @@ char * __newstr_record(size_t, int, const char *, int);
char * __savestr_record(const char *, int, const char *, int);
u_char * ina_put(struct in_addr ina, u_char *data);
u_char * savebuf(const u_char *, size_t, int);
void dprintf(int level, const char *format, ...) ISC_FORMAT_PRINTF(2, 3);
#ifdef DEBUG_STRINGS
char * debug_newstr(size_t, int, const char *, int);
char * debug_savestr(const char *, int, const char *, int);
@ -169,7 +168,7 @@ int send_msg(u_char *, int, struct qinfo *);
int findns(struct namebuf **, int,
struct databuf **, int *, int);
int finddata(struct namebuf *, int, int, HEADER *,
char **, int *, int *);
char **, int *, int *, int, int);
int add_data(struct namebuf *,
struct databuf **,
u_char *, int, int *);
@ -306,7 +305,7 @@ void ns_cleancache(evContext ctx, void *uap,
struct timespec inter);
void clean_cache_from(char *dname, struct hashbuf *htp);
void remove_zone(struct zoneinfo *, const char *);
void purge_zone(const char *, struct hashbuf *, int);
void purge_zone(struct zoneinfo *, struct hashbuf *);
void loadxfer(void);
void qserial_retrytime(struct zoneinfo *, time_t);
void qserial_query(struct zoneinfo *);
@ -336,8 +335,8 @@ void ns_heartbeat(evContext ctx, void *uap,
void make_new_zones(void);
void free_zone(struct zoneinfo *);
struct zoneinfo * find_auth_zone(const char *, ns_class);
int purge_nonglue(const char *dname, struct hashbuf *htp,
int class, int log);
int purge_nonglue(struct zoneinfo *, struct hashbuf *htp,
int log);
/* --from ns_maint.c-- */
/* ++from ns_sort.c++ */
@ -349,7 +348,6 @@ void sort_response(u_char *, u_char *, int,
void ns_refreshtime(struct zoneinfo *, time_t);
void ns_retrytime(struct zoneinfo *, time_t);
time_t ns_init(const char *);
void purgeandload(struct zoneinfo *zp);
enum context ns_ptrcontext(const char *owner);
enum context ns_ownercontext(int type, enum transport);
int ns_nameok(const struct qinfo *qry, const char *name,
@ -359,7 +357,7 @@ int ns_nameok(const struct qinfo *qry, const char *name,
struct in_addr source);
int ns_wildcard(const char *name);
void zoneinit(struct zoneinfo *);
void do_reload(const char *, int, int, int);
void do_reload(struct zoneinfo *, int);
void ns_shutdown(void);
/* --from ns_init.c-- */

View File

@ -1,8 +1,8 @@
/* $NetBSD: ns_glob.h,v 1.4 2002/06/20 11:42:57 itojun Exp $ */
/* $NetBSD: ns_glob.h,v 1.5 2003/06/03 07:33:34 itojun Exp $ */
/*
* from ns.h 4.33 (Berkeley) 8/23/90
* Id: ns_glob.h,v 8.58 2002/06/05 04:53:50 marka Exp
* Id: ns_glob.h,v 8.59 2002/07/19 22:44:08 marka Exp
*/
/*
@ -311,6 +311,7 @@ DECL const struct ns_sym category_constants[]
{ ns_log_load, "load" },
{ ns_log_resp_checks, "response-checks" },
{ ns_log_control, "control" },
{ ns_log_update_security, "update-security" },
{ 0, NULL }
}
#endif

View File

@ -1,8 +1,8 @@
/* $NetBSD: ns_init.c,v 1.4 2002/06/20 11:42:57 itojun Exp $ */
/* $NetBSD: ns_init.c,v 1.5 2003/06/03 07:33:34 itojun Exp $ */
#if !defined(lint) && !defined(SABER)
static const char sccsid[] = "@(#)ns_init.c 4.38 (Berkeley) 3/21/91";
static const char rcsid[] = "Id: ns_init.c,v 8.76 2001/12/19 01:41:51 marka Exp";
static const char rcsid[] = "Id: ns_init.c,v 8.77 2002/08/20 04:27:23 marka Exp";
#endif /* not lint */
/*
@ -109,6 +109,7 @@ static const char rcsid[] = "Id: ns_init.c,v 8.76 2001/12/19 01:41:51 marka Exp"
#ifdef DEBUG
static void content_zone(int, int);
#endif
static void purgeandload(struct zoneinfo *zp);
/*
* Set new refresh time for zone. Use a random number in the last half of
@ -239,7 +240,7 @@ zoneinit(struct zoneinfo *zp) {
result = stat(zp->z_source, &sb);
if (result != -1) {
ns_stopxfrs(zp);
purge_zone(zp->z_origin, hashtab, zp->z_class);
purge_zone(zp, hashtab);
}
if (result == -1 ||
db_load(zp->z_source, zp->z_origin, zp, NULL, ISNOTIXFR))
@ -267,8 +268,11 @@ zoneinit(struct zoneinfo *zp) {
* delegation to that child when it was first loaded.
*/
void
do_reload(const char *domain, int type, int class, int mark) {
do_reload(struct zoneinfo *ozp, int mark) {
struct zoneinfo *zp;
const char *domain = ozp->z_origin;
int type = ozp->z_type;
int class = ozp->z_class;
ns_debug(ns_log_config, 1, "do_reload: %s %d %d %d",
*domain ? domain : ".", type, class, mark);
@ -297,9 +301,9 @@ do_reload(const char *domain, int type, int class, int mark) {
*/
ns_stopxfrs(zp);
if (type == z_hint || (type == z_stub && *domain == 0))
purge_zone(domain, fcachetab, class);
purge_zone(ozp, fcachetab);
else
purge_zone(domain, hashtab, class);
purge_zone(ozp, hashtab);
/*
* Reload
@ -328,7 +332,7 @@ do_reload(const char *domain, int type, int class, int mark) {
domain = ""; /* root zone */
zp = find_zone(domain, class);
if (zp != NULL) {
if (zp != NULL && zp->z_type != Z_HINT) {
ns_debug(ns_log_config, 1, "do_reload: matched %s",
*domain ? domain : ".");
if (mark)
@ -340,7 +344,7 @@ do_reload(const char *domain, int type, int class, int mark) {
}
}
void
static void
purgeandload(struct zoneinfo *zp) {
#ifdef BIND_UPDATE
@ -357,9 +361,9 @@ purgeandload(struct zoneinfo *zp) {
ns_stopxfrs(zp);
if (zp->z_type == Z_HINT)
purge_zone(zp->z_origin, fcachetab, zp->z_class);
purge_zone(zp, fcachetab);
else
purge_zone(zp->z_origin, hashtab, zp->z_class);
purge_zone(zp, hashtab);
zp->z_flags &= ~Z_AUTH;
@ -565,10 +569,9 @@ ns_shutdown() {
if (zp->z_type) {
if (zp->z_type != z_hint && zp->z_type != z_cache) {
ns_stopxfrs(zp);
purge_zone(zp->z_origin, hashtab, zp->z_class);
purge_zone(zp, hashtab);
} else if (zp->z_type == z_hint)
purge_zone(zp->z_origin, fcachetab,
zp->z_class);
purge_zone(zp, fcachetab);
free_zone_contents(zp, 1);
}
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: ns_ixfr.c,v 1.5 2002/06/20 11:42:57 itojun Exp $ */
/* $NetBSD: ns_ixfr.c,v 1.6 2003/06/03 07:33:35 itojun Exp $ */
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "Id: ns_ixfr.c,v 8.32 2002/05/18 01:02:57 marka Exp";
static const char rcsid[] = "Id: ns_ixfr.c,v 8.33 2003/02/24 23:36:01 marka Exp";
#endif /* not lint */
/*
@ -410,6 +410,7 @@ ixfr_log_maint(struct zoneinfo *zp) {
int len;
struct stat db_sb;
struct stat sb;
size_t check_size;
static char buf[MAXBSIZE];
ns_debug(ns_log_default, 3, "ixfr_log_maint(%s)", zp->z_origin);
@ -444,22 +445,14 @@ ixfr_log_maint(struct zoneinfo *zp) {
return (-1);
}
ns_debug(ns_log_default, 3, "%s, size %llu max %ld\n", zp->z_ixfr_base,
(unsigned long long)sb.st_size,
(long)zp->z_max_log_size_ixfr);
if (zp->z_max_log_size_ixfr) {
if (sb.st_size > zp->z_max_log_size_ixfr)
seek = sb.st_size -
(size_t)(zp->z_max_log_size_ixfr +
(zp->z_max_log_size_ixfr * 0.10) );
else
seek = 0;
} else {
if (sb.st_size > (db_sb.st_size * 0.50))
seek = sb.st_size - (size_t)((db_sb.st_size * 0.50)
+ ((db_sb.st_size * zp->z_max_log_size_ixfr) * 0.10));
else
seek = 0;
}
(unsigned long long)sb.st_size, (long)zp->z_max_log_size_ixfr);
check_size = zp->z_max_log_size_ixfr;
if (!check_size)
check_size = db_sb.st_size / 2;
if (sb.st_size > check_size)
seek = (sb.st_size - check_size) + (check_size / 10);
else
seek = 0;
ns_debug(ns_log_default, 3, "seek: %ld", (long)seek);
if (seek < 1) {
ns_debug(ns_log_default, 3, "%s does not need to be reduced",

View File

@ -1,7 +1,7 @@
/* $NetBSD: ns_lexer.c,v 1.4 2002/06/20 11:42:57 itojun Exp $ */
/* $NetBSD: ns_lexer.c,v 1.5 2003/06/03 07:33:36 itojun Exp $ */
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "Id: ns_lexer.c,v 8.31 2002/05/24 03:05:03 marka Exp";
static const char rcsid[] = "Id: ns_lexer.c,v 8.31.10.1 2003/06/02 09:56:35 marka Exp";
#endif /* not lint */
/*
@ -259,6 +259,7 @@ static struct keyword keywords[] = {
{"dump-file", T_DUMP_FILE},
{"dynamic", T_DYNAMIC},
{"edns", T_EDNS},
{"edns-udp-size", T_EDNS_UDP_SIZE},
{"explicit", T_EXPLICIT},
{"fail", T_FAIL},
{"fake-iquery", T_FAKE_IQUERY},

View File

@ -1,8 +1,8 @@
/* $NetBSD: ns_main.c,v 1.13 2002/06/28 06:11:49 itojun Exp $ */
/* $NetBSD: ns_main.c,v 1.14 2003/06/03 07:33:36 itojun Exp $ */
#if !defined(lint) && !defined(SABER)
static const char sccsid[] = "@(#)ns_main.c 4.55 (Berkeley) 7/1/91";
static const char rcsid[] = "Id: ns_main.c,v 8.160 2002/06/24 07:06:55 marka Exp";
static const char rcsid[] = "Id: ns_main.c,v 8.162.6.1 2003/06/02 05:59:55 marka Exp";
#endif /* not lint */
/*
@ -143,6 +143,10 @@ char copyright[] =
#include "named.h"
#undef MAIN_PROGRAM
#ifdef TRUCLUSTER5
# include <clua/clua.h>
#endif
typedef void (*handler)(void);
typedef struct _savedg {
@ -195,7 +199,8 @@ static int sq_dowrite(struct qstream *);
static void use_desired_debug(void);
static void stream_write(evContext, void *, int, int);
static interface * if_find(struct in_addr, u_int16_t port);
static interface * if_find(struct in_addr, u_int16_t port,
int anyport);
static void deallocate_everything(void),
stream_accept(evContext, void *, int,
@ -1260,6 +1265,11 @@ getnetconf(int periodic_scan) {
ip_match_element ime;
u_char *mask_ptr;
struct in_addr mask;
#ifdef TRUCLUSTER5
struct sockaddr clua_addr;
int clua_cnt, clua_tot;
#endif
int clua_buf;
if (iflist_initialized) {
if (iflist_dont_rescan)
@ -1289,8 +1299,19 @@ getnetconf(int periodic_scan) {
free_ip_match_list(local_networks);
local_networks = new_ip_match_list();
#ifdef TRUCLUSTER5
/* Find out how many cluster aliases there are */
clua_cnt = 0;
clua_tot = 0;
while (clua_getaliasaddress(&clua_addr, &clua_cnt) == CLUA_SUCCESS)
clua_tot ++;
clua_buf = clua_tot * sizeof(ifreq);
#else
clua_buf = 0;
#endif
for (;;) {
buf = memget(bufsiz);
buf = memget(bufsiz + clua_buf);
if (!buf)
ns_panic(ns_log_default, 1, "memget(interface)");
ifc.ifc_len = bufsiz;
@ -1325,10 +1346,29 @@ getnetconf(int periodic_scan) {
if (bufsiz > 1000000)
ns_panic(ns_log_default, 1,
"get interface configuration: maximum buffer size exceeded");
memput(buf, bufsiz);
memput(buf, bufsiz + clua_buf);
bufsiz += 4096;
}
#ifdef TRUCLUSTER5
/* Get the cluster aliases and create interface entries for them */
clua_cnt = 0;
while (clua_tot--) {
memset(&ifreq, 0, sizeof (ifreq));
if (clua_getaliasaddress(&ifreq.ifr_addr, &clua_cnt) !=
CLUA_SUCCESS)
/*
* It is possible the count of aliases has changed; if
* it has increased, they won't be found this pass.
* If has decreased, stop the loop early. */
break;
strcpy(ifreq.ifr_name, "lo0");
memcpy(ifc.ifc_buf + ifc.ifc_len, &ifreq, sizeof (ifreq));
ifc.ifc_len += sizeof (ifreq);
bufsiz += sizeof (ifreq);
}
#endif
ns_debug(ns_log_default, 2, "getnetconf: SIOCGIFCONF: ifc_len = %d",
ifc.ifc_len);
@ -1400,7 +1440,7 @@ getnetconf(int periodic_scan) {
* point interfaces, then the local address
* may appear more than once.
*/
ifp = if_find(ina, li->port);
ifp = if_find(ina, li->port, 0);
if (ifp != NULL) {
ns_debug(ns_log_default, 1,
"dup interface addr [%s].%u (%s)",
@ -1837,7 +1877,7 @@ opensocket_f() {
* we'll notice we're in trouble if it goes away.
*/
ifp = if_find(server_options->query_source.sin_addr,
server_options->query_source.sin_port);
server_options->query_source.sin_port, 0);
if (ifp != NULL) {
ifp->flags |= INTERFACE_FORWARDING;
prev_ifp = ifp;
@ -2157,7 +2197,7 @@ sq_write(struct qstream *qs, const u_char *buf, int len) {
return (-1);
}
}
__putshort(len, qs->s_wbuf_free);
ns_put16(len, qs->s_wbuf_free);
qs->s_wbuf_free += NS_INT16SZ;
memcpy(qs->s_wbuf_free, buf, len);
qs->s_wbuf_free += len;
@ -2304,26 +2344,25 @@ net_mask(struct in_addr ina) {
int
aIsUs(struct in_addr addr) {
if (ina_hlong(addr) == INADDR_ANY || if_find(addr, 0) != NULL)
if (ina_hlong(addr) == INADDR_ANY || if_find(addr, 0, 1) != NULL)
return (1);
return (0);
}
/* interface *
* if_find(addr, port)
* if_find(addr, port, anyport)
* scan our list of interface addresses for "addr" and port.
* port == 0 means match any port
* returns:
* pointer to interface with this address/port, or NULL if there isn't
* one.
*/
static interface *
if_find(struct in_addr addr, u_int16_t port) {
if_find(struct in_addr addr, u_int16_t port, int anyport) {
interface *ifp;
for (ifp = HEAD(iflist); ifp != NULL; ifp = NEXT(ifp, link))
if (ina_equal(addr, ifp->addr))
if (port == 0 || ifp->port == port)
if (anyport || ifp->port == port)
break;
return (ifp);
}

View File

@ -1,8 +1,8 @@
/* $NetBSD: ns_maint.c,v 1.6 2002/06/28 06:11:50 itojun Exp $ */
/* $NetBSD: ns_maint.c,v 1.7 2003/06/03 07:33:37 itojun Exp $ */
#if !defined(lint) && !defined(SABER)
static const char sccsid[] = "@(#)ns_maint.c 4.39 (Berkeley) 3/2/91";
static const char rcsid[] = "Id: ns_maint.c,v 8.136 2002/06/26 03:27:20 marka Exp";
static const char rcsid[] = "Id: ns_maint.c,v 8.137.8.1 2003/06/02 05:34:25 marka Exp";
#endif /* not lint */
/*
@ -136,7 +136,7 @@ static void startxfer(struct zoneinfo *),
abortxfer(struct zoneinfo *),
purge_z_2(struct hashbuf *, int);
static int purge_nonglue_2(const char *, struct hashbuf *,
int, int, int);
int, int, int, int);
#ifndef HAVE_SPAWNXFER
static pid_t spawnxfer(char **, struct zoneinfo *);
@ -183,7 +183,7 @@ zone_maint(struct zoneinfo *zp) {
if ((zp->z_flags & Z_NOTIFY) != 0)
ns_stopnotify(zp->z_origin, zp->z_class);
/* calls purge_zone */
do_reload(zp->z_origin, zp->z_type, zp->z_class, 0);
do_reload(zp, 0);
/* reset zone state */
if (!haveComplained((u_long)zp, (u_long)stale)) {
ns_notice(ns_log_default,
@ -908,7 +908,7 @@ startxfer(struct zoneinfo *zp) {
last = &buffer[sizeof buffer - 1]; /* leave room for \0 */
for (i = 0; i < argc; i++) {
len = strlen(argv[i]);
if (curr + len + 1 >= last) {
if (len + 1 >= last - curr) {
ns_debug(ns_log_xfer_in, 1,
"xfer args debug printout truncated");
break;
@ -1217,7 +1217,7 @@ remove_zone(struct zoneinfo *zp, const char *verb) {
zp->z_xferpid = 0;
ns_need(main_need_tryxfer);
}
do_reload(zp->z_origin, zp->z_type, zp->z_class, 1);
do_reload(zp, 1);
ns_notice(ns_log_config, "%s zone \"%s\" (%s) %s",
zoneTypeString(zp->z_type), zp->z_origin,
p_class(zp->z_class), verb);
@ -1230,17 +1230,30 @@ remove_zone(struct zoneinfo *zp, const char *verb) {
}
int
purge_nonglue(const char *dname, struct hashbuf *htp, int class, int log) {
purge_nonglue(struct zoneinfo *zp, struct hashbuf *htp, int log) {
const char *dname = zp->z_origin;
const char *fname;
struct namebuf *np;
struct hashbuf *phtp = htp;
int root_zone = 0;
int errs = 0;
int zone = zp - zones;
struct databuf *pdp, *dp;
int class = zp->z_class;
ns_debug(ns_log_default, 1, "purge_zone(%s,%d)", dname, class);
ns_debug(ns_log_default, 1, "purge_nonglue(%s/%d)", dname, class);
if ((np = nlookup(dname, &phtp, &fname, 0)) && dname == fname &&
!ns_wildcard(NAME(*np))) {
for (pdp = NULL, dp = np->n_data; dp != NULL; (void)NULL) {
if (dp->d_class == class && dp->d_zone != zone)
dp = rm_datum(dp, np, pdp, NULL);
else {
pdp = dp;
dp = dp->d_next;
}
}
if (*dname == '\0')
root_zone = 1;
@ -1251,7 +1264,7 @@ purge_nonglue(const char *dname, struct hashbuf *htp, int class, int log) {
h = htp;
else
h = np->n_hash;
errs += purge_nonglue_2(dname, h, class, 0, log);
errs += purge_nonglue_2(dname, h, class, 0, log, zone);
if (h->h_cnt == 0 && !root_zone) {
rm_hash(np->n_hash);
np->n_hash = NULL;
@ -1292,7 +1305,7 @@ valid_glue(struct databuf *dp, char *name, int belowcut) {
static int
purge_nonglue_2(const char *dname, struct hashbuf *htp, int class,
int belowcut, int log)
int belowcut, int log, int zone)
{
struct databuf *dp, *pdp;
struct namebuf *np, *pnp, *npn;
@ -1317,10 +1330,16 @@ purge_nonglue_2(const char *dname, struct hashbuf *htp, int class,
for (pdp = NULL, dp = np->n_data;
dp != NULL;
(void)NULL) {
if (dp->d_class == class &&
zonecut &&
int delete = 0;
if (!zonecut &&
dp->d_class == class &&
dp->d_zone != zone)
delete = 1;
if (zonecut &&
dp->d_class == class &&
!valid_glue(dp, name, belowcut)) {
if (log)
if (log &&
dp->d_zone == zone) {
ns_error(ns_log_load,
"zone: %s/%s: non-glue record %s bottom of zone: %s/%s",
*dname ? dname : ".",
@ -1329,11 +1348,14 @@ purge_nonglue_2(const char *dname, struct hashbuf *htp, int class,
"at",
*name ? name : ".",
p_type(dp->d_type));
errs++;
}
delete = 1;
}
if (delete)
dp = rm_datum(dp, np, pdp,
NULL);
if (log)
errs++;
} else {
else {
pdp = dp;
dp = dp->d_next;
}
@ -1348,7 +1370,7 @@ purge_nonglue_2(const char *dname, struct hashbuf *htp, int class,
class,
zonecut ||
belowcut,
log);
log, zone);
/* if now empty, free it */
if (np->n_hash->h_cnt == 0) {
@ -1371,18 +1393,20 @@ purge_nonglue_2(const char *dname, struct hashbuf *htp, int class,
}
void
purge_zone(const char *dname, struct hashbuf *htp, int class) {
purge_zone(struct zoneinfo *zp, struct hashbuf *htp) {
const char *fname;
struct databuf *dp, *pdp;
struct namebuf *np;
struct hashbuf *phtp = htp;
int root_zone = 0;
int zone = zp - zones;
char *dname = zp->z_origin;
ns_debug(ns_log_default, 1, "purge_zone(%s,%d)", dname, class);
ns_debug(ns_log_default, 1, "purge_zone(%s)", dname);
if ((np = nlookup(dname, &phtp, &fname, 0)) && dname == fname &&
!ns_wildcard(NAME(*np))) {
for (pdp = NULL, dp = np->n_data; dp != NULL; (void)NULL) {
if (dp->d_class == class)
if (dp->d_zone == zone)
dp = rm_datum(dp, np, pdp, NULL);
else {
pdp = dp;
@ -1400,7 +1424,7 @@ purge_zone(const char *dname, struct hashbuf *htp, int class) {
h = htp;
else
h = np->n_hash;
purge_z_2(h, class);
purge_z_2(h, zone);
if (h->h_cnt == 0 && !root_zone) {
rm_hash(np->n_hash);
np->n_hash = NULL;
@ -1413,10 +1437,7 @@ purge_zone(const char *dname, struct hashbuf *htp, int class) {
}
static void
purge_z_2(htp, class)
struct hashbuf *htp;
int class;
{
purge_z_2(struct hashbuf *htp, int zone) {
struct databuf *dp, *pdp;
struct namebuf *np, *pnp, *npn;
struct namebuf **npp, **nppend;
@ -1424,27 +1445,25 @@ purge_z_2(htp, class)
nppend = htp->h_tab + htp->h_size;
for (npp = htp->h_tab; npp < nppend; npp++) {
for (pnp = NULL, np = *npp; np != NULL; np = npn) {
if (!bottom_of_zone(np->n_data, class)) {
for (pdp = NULL, dp = np->n_data;
dp != NULL;
(void)NULL) {
if (dp->d_class == class)
dp = rm_datum(dp, np, pdp,
NULL);
else {
pdp = dp;
dp = dp->d_next;
}
for (pdp = NULL, dp = np->n_data;
dp != NULL;
(void)NULL) {
if (dp->d_zone == zone)
dp = rm_datum(dp, np, pdp,
NULL);
else {
pdp = dp;
dp = dp->d_next;
}
if (np->n_hash) {
/* call recursively to rm subdomains */
purge_z_2(np->n_hash, class);
}
if (np->n_hash) {
/* call recursively to rm subdomains */
purge_z_2(np->n_hash, zone);
/* if now empty, free it */
if (np->n_hash->h_cnt == 0) {
rm_hash(np->n_hash);
np->n_hash = NULL;
}
/* if now empty, free it */
if (np->n_hash->h_cnt == 0) {
rm_hash(np->n_hash);
np->n_hash = NULL;
}
}
@ -1806,12 +1825,12 @@ loadxfer(void) {
isixfr = ISIXFR;
} else {
tmpnom = zp->z_source;
purge_zone(zp->z_origin, hashtab, zp->z_class);
purge_zone(zp, hashtab);
isixfr = ISNOTIXFR;
}
if (zp->z_xferpid == XFER_ISAXFRIXFR) {
tmpnom= zp->z_source;
purge_zone(zp->z_origin, hashtab, zp->z_class);
purge_zone(zp, hashtab);
isixfr = ISNOTIXFR;
}
@ -1894,7 +1913,7 @@ reload_master(struct zoneinfo *zp) {
(zp->z_flags & Z_NEED_DUMP) != 0))
(void) zonedump(zp, ISNOTIXFR);
#endif
purge_zone(zp->z_origin, hashtab, zp->z_class);
purge_zone(zp, hashtab);
ns_debug(ns_log_config, 1, "reloading zone");
#ifdef BIND_UPDATE
if ((zp->z_flags & Z_DYNAMIC) != 0) {

View File

@ -1,7 +1,7 @@
/* $NetBSD: ns_ncache.c,v 1.5 2002/11/17 14:09:52 itojun Exp $ */
/* $NetBSD: ns_ncache.c,v 1.6 2003/06/03 07:33:38 itojun Exp $ */
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "Id: ns_ncache.c,v 8.29.4.1 2002/11/14 13:41:31 marka Exp";
static const char rcsid[] = "Id: ns_ncache.c,v 8.30 2002/11/17 14:51:51 marka Exp";
#endif /* not lint */
/*

View File

@ -1,8 +1,8 @@
/* $NetBSD: ns_parser.y,v 1.5 2002/06/20 11:42:58 itojun Exp $ */
/* $NetBSD: ns_parser.y,v 1.6 2003/06/03 07:33:38 itojun Exp $ */
%{
#if !defined(lint) && !defined(SABER)
static char rcsid[] = "Id: ns_parser.y,v 8.80 2002/05/24 03:05:01 marka Exp";
static char rcsid[] = "Id: ns_parser.y,v 8.81.8.1 2003/06/02 09:56:35 marka Exp";
#endif /* not lint */
/*
@ -162,6 +162,7 @@ int yyparse();
%token T_MAX_NCACHE_TTL T_HAS_OLD_CLIENTS T_RFC2308_TYPE1
%token T_LAME_TTL T_MIN_ROOTS
%token T_TREAT_CR_AS_SPACE
%token T_EDNS_UDP_SIZE
/* Items used for the "logging" statement: */
%token T_LOGGING T_CATEGORY T_CHANNEL T_SEVERITY T_DYNAMIC
@ -613,6 +614,16 @@ option: /* Empty */
if ($2 >= 1)
current_options->minroots = $2;
}
|
| T_EDNS_UDP_SIZE L_NUMBER
{
if ($2 < 512)
current_options->edns_udp_size = 512;
else if ($2 > EDNS_MESSAGE_SZ)
current_options->edns_udp_size = EDNS_MESSAGE_SZ;
else
current_options->edns_udp_size = $2;
}
| error
;
@ -715,6 +726,7 @@ ordering_type: /* nothing */
}
(void)freestr($2);
}
;
ordering_name: /* nothing */
{
@ -730,7 +742,7 @@ ordering_name: /* nothing */
}
/* XXX Should do any more name validation here? */
}
;
rrset_ordering_element: ordering_class ordering_type ordering_name T_ORDER L_STRING
{
@ -753,7 +765,7 @@ rrset_ordering_element: ordering_class ordering_type ordering_name T_ORDER L_STR
$$ = new_rrset_order_element($1, $2, $3, o);
}
}
;
transfer_format: T_ONE_ANSWER
{
@ -1438,7 +1450,7 @@ key_list: key_list_element L_EOS
| error
;
dummy_key_list_element: key_ref;
dummy_key_list_element: key_ref { /* empty */ } ;
dummy_key_list: dummy_key_list_element L_EOS
| dummy_key_list dummy_key_list_element L_EOS

View File

@ -1,8 +1,8 @@
/* $NetBSD: ns_req.c,v 1.7 2002/11/17 14:09:52 itojun Exp $ */
/* $NetBSD: ns_req.c,v 1.8 2003/06/03 07:33:39 itojun Exp $ */
#if !defined(lint) && !defined(SABER)
static const char sccsid[] = "@(#)ns_req.c 4.47 (Berkeley) 7/1/91";
static const char rcsid[] = "Id: ns_req.c,v 8.169.2.1 2002/11/14 13:02:48 marka Exp";
static const char rcsid[] = "Id: ns_req.c,v 8.175.6.2 2003/06/02 09:56:35 marka Exp";
#endif /* not lint */
/*
@ -565,8 +565,9 @@ ns_req(u_char *msg, int msglen, int buflen, struct qstream *qsp,
ns_name_rollback(cp, (const u_char **)dnptrs,
(const u_char **)dnptrs_end);
if (opt > 0) {
n = ns_add_opt(msg, cp, buflen_orig, 0,
rcode, EDNS_MESSAGE_SZ, 0, NULL, 0);
n = ns_add_opt(msg, cp, buflen_orig, 0, rcode,
server_options->edns_udp_size,
0, NULL, 0);
if (n < 0) {
hp->qdcount = htons(0);
goto sign_again;
@ -606,8 +607,9 @@ ns_req(u_char *msg, int msglen, int buflen, struct qstream *qsp,
msglen += n;
if (opt > 0) {
buflen += opt_size;
n = ns_add_opt(msg, cp, msglen + buflen, 0,
rcode, EDNS_MESSAGE_SZ, 0, NULL, 0);
n = ns_add_opt(msg, cp, msglen + buflen, 0, rcode,
server_options->edns_udp_size,
0, NULL, 0);
INSIST(n > 0);
cp += n;
buflen -= n;
@ -858,6 +860,9 @@ req_query(HEADER *hp, u_char **cpp, u_char *eom, struct qstream *qsp,
DST_KEY *in_key = (in_tsig != NULL) ? in_tsig->key : NULL;
int access_class;
int adjustlen = 0;
int pass = 0;
char tsig_keyname_mesg[15+MAXDNAME] = "";
int glueok;
nameserIncr(from.sin_addr, nssRcvdQ);
@ -902,7 +907,6 @@ req_query(HEADER *hp, u_char **cpp, u_char *eom, struct qstream *qsp,
return (Finish);
}
*cpp += n;
answers = *cpp;
if (*cpp + 2 * INT16SZ > eom) {
ns_debug(ns_log_default, 1,
"FORMERR Query message length short");
@ -1019,6 +1023,7 @@ req_query(HEADER *hp, u_char **cpp, u_char *eom, struct qstream *qsp,
#endif /*QRYLOG*/
try_again:
pass++;
foundname = 0;
ns_debug(ns_log_default, 1, "req: nlookup(%s) id %d type=%d class=%d",
dname, ntohs(hp->id), type, class);
@ -1305,13 +1310,19 @@ req_query(HEADER *hp, u_char **cpp, u_char *eom, struct qstream *qsp,
return (Refuse);
}
if (type == ns_t_ixfr) {
ns_info(ns_log_security, "approved %s from %s for \"%s\"",
(ixfr_found) ? p_type(type) : "IXFR/AXFR",
sin_ntoa(from), *dname ? dname : ".");
} else
ns_info(ns_log_security, "approved %s from %s for \"%s\"",
p_type(type), sin_ntoa(from), *dname ? dname : ".");
if (in_key != NULL)
sprintf(tsig_keyname_mesg, " (TSIG key \"%s\")",
in_key->dk_key_name);
if (type == ns_t_ixfr)
ns_info(ns_log_security, "approved %s from %s for \"%s\"%s",
(ixfr_found) ? p_type(type) : "IXFR/AXFR",
sin_ntoa(from), *dname ? dname : ".",
tsig_keyname_mesg);
else
ns_info(ns_log_security, "approved %s from %s for \"%s\"%s",
p_type(type), sin_ntoa(from), *dname ? dname : ".",
tsig_keyname_mesg);
}
/*
@ -1356,7 +1367,7 @@ req_query(HEADER *hp, u_char **cpp, u_char *eom, struct qstream *qsp,
(dp->d_class == class)) {
#ifdef RETURNSOA
n = finddata(np, class, T_SOA, hp, &dname,
buflenp, &count);
buflenp, &count, pass, 1);
if (n != 0) {
if (count) {
*cpp += n;
@ -1394,8 +1405,9 @@ req_query(HEADER *hp, u_char **cpp, u_char *eom, struct qstream *qsp,
* If not NXDOMAIN, the NOERROR_NODATA record might be
* anywhere in the chain. Have to go through the grind.
*/
n = finddata(np, class, type, hp, &dname, buflenp, &count);
glueok = !NS_OPTION_P(OPTION_NORECURSE);
n = finddata(np, class, type, hp, &dname, buflenp, &count, pass,
glueok);
if (n == 0) {
/*
* NO data available. Refuse transfer requests, or
@ -1511,7 +1523,8 @@ req_query(HEADER *hp, u_char **cpp, u_char *eom, struct qstream *qsp,
ns_debug(ns_log_default, 3, "req: leaving (%s, rcode %d)",
dname, hp->rcode);
if (class != C_ANY) {
hp->aa = 1;
if (!cname)
hp->aa = 1;
if (np && (!foundname || !founddata)) {
n = doaddauth(hp, *cpp, *buflenp, np, nsp[0]);
*cpp += n;
@ -2325,9 +2338,9 @@ doaddinfo(HEADER *hp, u_char *msg, int msglen) {
loop:
for (ap = addinfo, i = 0; i < addcount; ap++, i++) {
int auth = 0,
drop = 0,
founda = 0,
foundaaaa = 0,
founda6 = 0,
foundcname = 0,
save_count = count,
save_msglen = msglen;
@ -2355,12 +2368,11 @@ loop:
if (dp->d_class != ap->a_class)
continue;
if (dp->d_rcode == NXDOMAIN) {
founda = founda6 = foundaaaa = 1;
founda = foundaaaa = 1;
continue;
}
switch (dp->d_type) {
case ns_t_a: founda = 1; break;
case ns_t_a6: founda6 = 1; break;
case ns_t_aaaa: foundaaaa = 1; break;
}
if (!dp->d_rcode && dp->d_type == T_CNAME) {
@ -2368,8 +2380,7 @@ loop:
break;
}
if (auth == 0 && ap->a_type == T_A &&
(dp->d_type == ns_t_a || dp->d_type == ns_t_a6 ||
dp->d_type == ns_t_aaaa) &&
(dp->d_type == ns_t_a || dp->d_type == ns_t_aaaa) &&
(zones[dp->d_zone].z_type == z_master ||
zones[dp->d_zone].z_type == z_slave))
auth = 1;
@ -2387,8 +2398,7 @@ loop:
}
if (ap->a_type == T_A &&
!match(dp, (int)ap->a_class, T_A) &&
!match(dp, (int)ap->a_class, T_AAAA) &&
!match(dp, (int)ap->a_class, ns_t_a6)) {
!match(dp, (int)ap->a_class, T_AAAA)) {
continue;
}
if (ap->a_type == T_KEY &&
@ -2399,6 +2409,8 @@ loop:
continue;
if (dp->d_rcode)
continue;
if (drop)
continue;
/*
* Should be smart and eliminate duplicate
* data here. XXX
@ -2428,7 +2440,14 @@ loop:
cp = save_cp;
msglen = save_msglen;
count = save_count;
break;
/*
* Continue processing list to prevent
* unnecessary fetches for glue.
* Prevent partial RRsets being sent by
* setting drop.
*/
drop = 1;
continue;
}
ns_debug(ns_log_default, 5,
"addinfo: adding address data n = %d", n);
@ -2448,10 +2467,6 @@ loop:
(void) sysquery(ap->a_dname, (int)ap->a_class,
ns_t_aaaa, NULL, NULL, 0,
ns_port, QUERY, 0);
if (!founda6 && !auth)
(void) sysquery(ap->a_dname, (int)ap->a_class,
ns_t_a6, NULL, NULL, 0, ns_port,
QUERY, 0);
}
if (foundcname) {
if (!haveComplained(nhash(ap->a_dname),

View File

@ -1,8 +1,8 @@
/* $NetBSD: ns_resp.c,v 1.9 2002/11/17 14:09:53 itojun Exp $ */
/* $NetBSD: ns_resp.c,v 1.10 2003/06/03 07:33:40 itojun Exp $ */
#if !defined(lint) && !defined(SABER)
static const char sccsid[] = "@(#)ns_resp.c 4.65 (Berkeley) 3/3/91";
static const char rcsid[] = "Id: ns_resp.c,v 8.178.2.2 2002/11/14 13:39:13 marka Exp";
static const char rcsid[] = "Id: ns_resp.c,v 8.186.6.4 2003/06/02 09:56:35 marka Exp";
#endif /* not lint */
/*
@ -272,7 +272,6 @@ ns_resp(u_char *msg, int msglen, struct sockaddr_in from, struct qstream *qsp)
int i, c, n, qdcount, ancount, aucount, nscount, arcount, arfirst;
int soacount;
u_int qtype, qclass;
int restart; /* flag for processing cname response */
int validanswer, dbflags;
int cname, lastwascname, externalcname;
int count, founddata, foundname;
@ -283,7 +282,7 @@ ns_resp(u_char *msg, int msglen, struct sockaddr_in from, struct qstream *qsp)
char *dname, tmpdomain[MAXDNAME];
const char *fname;
const char *formerrmsg = "brain damage";
u_char newmsg[EDNS_MESSAGE_SZ];
u_char newmsg[NS_MAXMSG];
u_char **dpp, *tp;
time_t rtrip;
struct hashbuf *htp;
@ -300,6 +299,7 @@ ns_resp(u_char *msg, int msglen, struct sockaddr_in from, struct qstream *qsp)
time_t tsig_time;
DST_KEY *key;
int expect_cname;
int pass = 0;
nameserIncr(from.sin_addr, nssRcvdR);
nsp[0] = NULL;
@ -907,7 +907,6 @@ tcp_retry:
tp = cp;
restart = 0;
validanswer = -1;
nscount = 0;
soacount = 0;
@ -1003,6 +1002,10 @@ tcp_retry:
tname = NULL;
}
/* Cache for current tick. */
if (type == T_SOA)
dp->d_ttl = tt.tv_sec;
dp->d_cred = (hp->aa && ns_samename(name, qname) == 1)
? DB_C_AUTH
: DB_C_ANSWER;
@ -1050,6 +1053,9 @@ tcp_retry:
}
if (type == T_SOA) {
soacount++;
/* -ve caching only. */
db_detach(&dp);
continue;
}
break;
case T_NXT:
@ -1184,38 +1190,6 @@ tcp_retry:
return;
}
if (ancount && count && validanswer != 1) {
/*
* Everything passed validation but we didn't get the
* final answer. The response must have contained
* a dangling CNAME. Force a restart of the query.
*
* Don't set restart if count==0, since this means
* the response was truncated in the answer section,
* causing us to set count to 0 which will cause
* validanswer to be 0 as well even though the answer
* section probably contained valid RRs (just not
* a complete set).
* XXX - this works right if we can just forward this
* response to the client, but not if we found a CNAME
* in a prior response and restarted the query.
*/
restart = 1;
}
if (!restart && !qp->q_cmsglen && ancount > 1 && qtype == T_A)
sort_response(tp, eom, ancount, &qp->q_from);
/*
* An answer to a T_ANY query or a successful answer to a
* regular query with no indirection, then just return answer.
*/
if (!restart && ancount && (qtype == T_ANY || !qp->q_cmsglen)) {
ns_debug(ns_log_default, 3,
"resp: got as much answer as there is");
goto return_msg;
}
/*
* We might want to cache this negative answer.
*
@ -1291,11 +1265,20 @@ tcp_retry:
goto servfail;
}
cp += n + QFIXEDSZ;
buflen = sizeof(newmsg) - (cp - newmsg);
buflen = (qp->q_stream != NULL) ? NS_MAXMSG :
MIN(EDNS_MESSAGE_SZ, qp->q_udpsize);
buflen -= (cp - newmsg);
/*
* Reserve space for TSIG / EDNS
*/
if (qp->q_tsig != NULL)
buflen -= qp->q_tsig->tsig_size;
if ((qp->q_flags & Q_EDNS) != 0)
buflen -= 11;
cname = 0;
try_again:
pass++;
ns_debug(ns_log_default, 1, "resp: nlookup(%s) qtype=%d", dname,
qtype);
foundname = 0;
@ -1318,7 +1301,7 @@ tcp_retry:
(dp->d_class == (int)qclass)) {
#ifdef RETURNSOA
n = finddata(np, qclass, T_SOA, hp, &dname,
&buflen, &count);
&buflen, &count, pass, 1);
if ( n != 0) {
if (count) {
cp += n;
@ -1350,7 +1333,7 @@ tcp_retry:
goto fetch_ns;
}
}
n = finddata(np, qclass, qtype, hp, &dname, &buflen, &count);
n = finddata(np, qclass, qtype, hp, &dname, &buflen, &count, pass, 1);
if (n == 0)
goto fetch_ns; /* NO data available */
if (hp->rcode) {
@ -1401,7 +1384,8 @@ tcp_retry:
if (!foundname)
hp->rcode = NXDOMAIN;
if (qclass != C_ANY) {
hp->aa = 1;
if (!cname)
hp->aa = 1;
if (np && (!foundname || !founddata)) {
n = doaddauth(hp, cp, buflen, np, nsp[0]);
cp += n;
@ -1555,7 +1539,8 @@ tcp_retry:
if (!qp->q_addr[0].noedns)
smsglen += ns_add_opt(smsg, smsg + smsglen, smsgsize, 0, 0,
EDNS_MESSAGE_SZ, 0, NULL, 0);
server_options->edns_udp_size,
0, NULL, 0);
if (key != NULL) {
n = ns_sign(smsg, &smsglen, smsgsize, NOERROR, key, NULL, 0,
sig, &siglen, 0);
@ -2241,7 +2226,7 @@ send_msg(u_char *msg, int msglen, struct qinfo *qp) {
if (qp->q_flags & Q_SYSTEM)
return (1);
trunc = (qp->q_stream != NULL) ? 65535 : qp->q_udpsize;
trunc = (qp->q_stream != NULL) ? NS_MAXMSG : qp->q_udpsize;
if (qp->q_tsig != NULL)
adjust += qp->q_tsig->tsig_size;
if ((qp->q_flags & Q_EDNS) != 0)
@ -2285,8 +2270,9 @@ send_msg(u_char *msg, int msglen, struct qinfo *qp) {
msgsize = msglen; /* silence compiler */
if ((qp->q_flags & Q_EDNS) != 0)
msglen += ns_add_opt(msg, msg + msglen, msgsize, 0,
hp->rcode, EDNS_MESSAGE_SZ, 0, NULL, 0);
msglen += ns_add_opt(msg, msg + msglen, msgsize, 0, hp->rcode,
server_options->edns_udp_size,
0, NULL, 0);
if (qp->q_tsig != NULL) {
u_char sig[TSIG_SIG_SIZE];
@ -2494,6 +2480,7 @@ sysquery(const char *dname, int class, int type,
qs->stime = tt;
qs->forwarder = 0;
qs->noedns = 1; /* XXXMPA */
qs->lame = 0;
qs->nretry = 0;
}
qp->q_naddr = nsc;
@ -2583,7 +2570,8 @@ sysquery(const char *dname, int class, int type,
if (!qp->q_addr[0].noedns)
smsglen += ns_add_opt(smsg, smsg + smsglen, smsgsize, 0, 0,
EDNS_MESSAGE_SZ, 0, NULL, 0);
server_options->edns_udp_size,
0, NULL, 0);
if (key != NULL) {
n = ns_sign(smsg, &smsglen, smsgsize, NOERROR, key, NULL, 0,
@ -2910,7 +2898,8 @@ findns(struct namebuf **npp, int class,
}
ns_debug(ns_log_default, 1,
"findns: No root nameservers for class %s?", p_class(class));
if ((unsigned)class < MAXCLASS && norootlogged[class] == 0) {
if (!NS_OPTION_P(OPTION_FORWARD_ONLY) &&
(unsigned)class < MAXCLASS && norootlogged[class] == 0) {
norootlogged[class] = 1;
ns_info(ns_log_default, "No root nameservers for class %s",
p_class(class));
@ -2926,7 +2915,8 @@ findns(struct namebuf **npp, int class,
*/
int
finddata(struct namebuf *np, int class, int type,
HEADER *hp, char **dnamep, int *lenp, int *countp)
HEADER *hp, char **dnamep, int *lenp, int *countp, int pass,
int glueok)
{
struct databuf *dp;
char *cp;
@ -2964,18 +2954,8 @@ finddata(struct namebuf *np, int class, int type,
cp = ((char *)hp) + *countp;
foundcname = 0;
for (dp = np->n_data; dp != NULL; dp = dp->d_next) {
if (!wanted(dp, class, type)) {
if (type == T_CNAME && class == dp->d_class) {
/* any data means no CNAME exists */
if (dp->d_type != T_NXT &&
dp->d_type != T_KEY &&
dp->d_type != T_SIG) {
ret = 0;
goto done;
}
}
if (!wanted(dp, class, type))
continue;
}
if (dp->d_cred == DB_C_ADDITIONAL) {
#ifdef NOADDITIONAL
continue;
@ -3005,7 +2985,7 @@ finddata(struct namebuf *np, int class, int type,
*dnamep, type, class);
continue;
}
if (type == T_ANY)
if (type == T_ANY && dp->d_type != T_ANY)
continue;
hp->rcode = NOERROR_NODATA;
if (dp->d_size == 0) { /* !RETURNSOA */
@ -3040,6 +3020,10 @@ finddata(struct namebuf *np, int class, int type,
(!((dp->d_type == T_SIG) || (dp->d_type == T_KEY))) )
continue;
/* Don't return glue (NS/A/AAAA) */
if (!glueok && findMyZone(np, class) == DB_Z_CACHE)
continue;
if (!defer) {
if (foundcname != 0 && dp->d_type == T_CNAME)
continue;
@ -3058,6 +3042,16 @@ finddata(struct namebuf *np, int class, int type,
if (dp->d_type == T_CNAME) {
foundcname = 1;
#define SETAA(pass, class, dp) \
(pass == 1 && class != C_ANY && dp->d_zone != DB_Z_CACHE && \
(zones[dp->d_zone].z_type == z_master || \
zones[dp->d_zone].z_type == z_slave) && \
(zones[dp->d_zone].z_flags & Z_AUTH) != 0)
if (SETAA(pass, class, dp))
hp->aa = 1;
#define FOLLOWCNAME(type) \
(type != T_KEY) && (type != T_SIG) && (type != T_NXT) && (type != T_ANY)
/* don't alias if querying for key, sig, nxt, or any */
@ -3066,8 +3060,13 @@ finddata(struct namebuf *np, int class, int type,
new_dnamep = (char *)dp->d_data;
}
} else {
if (dp->d_type == T_CNAME)
if (dp->d_type == T_CNAME) {
foundcname = 1;
if (SETAA(pass, class, dp))
hp->aa = 1;
}
found[found_count++] = dp;
}
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: ns_update.c,v 1.5 2002/06/20 11:42:58 itojun Exp $ */
/* $NetBSD: ns_update.c,v 1.6 2003/06/03 07:33:41 itojun Exp $ */
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "Id: ns_update.c,v 8.104 2002/05/18 01:02:59 marka Exp";
static const char rcsid[] = "Id: ns_update.c,v 8.106 2002/07/19 22:44:07 marka Exp";
#endif /* not lint */
/*
@ -1213,7 +1213,7 @@ req_update_private(HEADER *hp, u_char *cp, u_char *eom, u_char *msg,
*/
if (!ip_addr_or_key_allowed(zp->z_update_acl, from.sin_addr, in_key)) {
ns_notice(ns_log_security,
ns_notice(ns_log_update_security,
"denied update from %s for \"%s\" %s",
sin_ntoa(from), *dname ? dname : ".", p_class(class));
nameserIncr(from.sin_addr, nssRcvdUUpd);
@ -2640,8 +2640,10 @@ merge_logs(struct zoneinfo *zp, char *logname) {
err++;
break;
}
errno = 0;
n = strtoul(buf, &cp, 10);
if (n > 0xffff || *cp != '\0') {
if (errno != 0 || n > 0xffff ||
*cp != '\0') {
err++;
break;
}

View File

@ -1,7 +1,7 @@
/* $NetBSD: ndc.c,v 1.7 2002/06/28 06:11:52 itojun Exp $ */
/* $NetBSD: ndc.c,v 1.8 2003/06/03 07:33:43 itojun Exp $ */
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "Id: ndc.c,v 1.22 2002/06/24 07:28:55 marka Exp";
static const char rcsid[] = "Id: ndc.c,v 1.25 2003/04/03 05:42:10 marka Exp";
#endif /* not lint */
/*
@ -285,7 +285,7 @@ getargs_closure(void *arg, const char *msg, int flags) {
}
len = 0;
cp = msg + 4;
while (*cp != NULL) {
while (*cp != '\0') {
c = *cp;
if (c == '%') {
cp2 = strchr(hexdigits, cp[1]);
@ -327,7 +327,7 @@ getargs_closure(void *arg, const char *msg, int flags) {
}
cp = msg + 4;
tp = argv->argv[i];
while (*cp != NULL) {
while (*cp != '\0') {
c = *cp;
if (c == '%') {
cp2 = strchr(hexdigits, cp[1]);
@ -376,6 +376,8 @@ get_args(char **restp) {
len = 0;
for (i = 1 ; i < argv.argc && argv.argv[i] != NULL; i++)
len += strlen(argv.argv[i]) + 1;
if (len == 0)
len = 1;
rest = malloc(len);
if (rest == NULL) {
result = 0;
@ -388,7 +390,8 @@ get_args(char **restp) {
*p++ = ' ';
}
if (p != rest)
p[-1] = '\0';
p--;
p[0] = '\0';
*restp = rest;
err:

View File

@ -1,4 +1,4 @@
/* $NetBSD: getinfo.c,v 1.5 2002/06/20 11:43:00 itojun Exp $ */
/* $NetBSD: getinfo.c,v 1.6 2003/06/03 07:33:43 itojun Exp $ */
/*
* Copyright (c) 1985, 1989
@ -55,7 +55,7 @@
#ifndef lint
static const char sccsid[] = "@(#)getinfo.c 5.26 (Berkeley) 3/21/91";
static const char rcsid[] = "Id: getinfo.c,v 8.27 2002/05/22 04:06:57 marka Exp";
static const char rcsid[] = "Id: getinfo.c,v 8.29.8.2 2003/06/02 09:24:39 marka Exp";
#endif /* not lint */
/*
@ -113,7 +113,7 @@ ServerTable server[MAXSERVERS];
typedef union {
HEADER qb1;
u_char qb2[64*1024];
u_char qb2[NS_MAXMSG];
} querybuf;
typedef union {
@ -151,14 +151,14 @@ GetAnswer(union res_sockaddr_union *nsAddrPtr, int queryType,
register const u_char *cp;
querybuf answer;
char **aliasPtr;
u_char *eom, *bp;
u_char *eom, *bp, *ep;
char **addrPtr;
int *lenPtr;
int *typePtr;
char *namePtr;
char *dnamePtr;
int type, class;
int qdcount, ancount, arcount, nscount, buflen;
int qdcount, ancount, arcount, nscount;
int origClass = 0;
int numAliases = 0;
int numAddresses = 0;
@ -213,9 +213,9 @@ GetAnswer(union res_sockaddr_union *nsAddrPtr, int queryType,
}
bp = hostbuf;
buflen = sizeof(hostbuf);
cp = (u_char *) &answer + HFIXEDSZ;
bp = hostbuf;
ep = hostbuf + sizeof(hostbuf);
cp = (u_char *) &answer + HFIXEDSZ;
/* Skip over question section. */
while (qdcount-- > 0) {
@ -258,7 +258,7 @@ GetAnswer(union res_sockaddr_union *nsAddrPtr, int queryType,
printedAnswers = TRUE;
} else {
while (--ancount >= 0 && cp < eom) {
n = dn_expand(answer.qb2, eom, cp, (char *)bp, buflen);
n = dn_expand(answer.qb2, eom, cp, (char *)bp, ep - bp);
if (n < 0)
return(ERROR);
cp += n;
@ -283,13 +283,12 @@ GetAnswer(union res_sockaddr_union *nsAddrPtr, int queryType,
host_aliases_len[numAliases] = s;
numAliases++;
bp += s;
buflen -= s;
continue;
} else if (type == T_PTR) {
/*
* Found a "pointer" to the real name.
*/
n = dn_expand(answer.qb2, eom, cp, (char *)bp, buflen);
n = dn_expand(answer.qb2, eom, cp, (char *)bp, ep - bp);
if (n < 0) {
cp += n;
continue;
@ -469,7 +468,7 @@ GetAnswer(union res_sockaddr_union *nsAddrPtr, int queryType,
* that serve the requested domain.
*/
n = dn_expand(answer.qb2, eom, cp, (char *)bp, buflen);
n = dn_expand(answer.qb2, eom, cp, (char *)bp, ep - bp);
if (n < 0) {
return(ERROR);
}
@ -492,7 +491,7 @@ GetAnswer(union res_sockaddr_union *nsAddrPtr, int queryType,
} else {
Boolean found;
n = dn_expand(answer.qb2, eom, cp, (char *)bp, buflen);
n = dn_expand(answer.qb2, eom, cp, (char *)bp, ep - bp);
if (n < 0) {
return(ERROR);
}
@ -548,7 +547,7 @@ GetAnswer(union res_sockaddr_union *nsAddrPtr, int queryType,
}
} else {
while (--arcount >= 0 && cp < eom) {
n = dn_expand(answer.qb2, eom, cp, (char *)bp, buflen);
n = dn_expand(answer.qb2, eom, cp, (char *)bp, ep - bp);
if (n < 0) {
break;
}
@ -946,7 +945,7 @@ GetHostInfoByAddr(union res_sockaddr_union *nsAddrPtr,
p[9] & 0xf, (p[9] >> 4) & 0xf,
p[8] & 0xf, (p[8] >> 4) & 0xf,
p[7] & 0xf, (p[7] >> 4) & 0xf,
p[6] & 0xf, (p[4] >> 4) & 0xf,
p[6] & 0xf, (p[6] >> 4) & 0xf,
p[5] & 0xf, (p[5] >> 4) & 0xf,
p[4] & 0xf, (p[4] >> 4) & 0xf,
p[3] & 0xf, (p[3] >> 4) & 0xf,
@ -966,7 +965,7 @@ GetHostInfoByAddr(union res_sockaddr_union *nsAddrPtr,
p[9] & 0xf, (p[9] >> 4) & 0xf,
p[8] & 0xf, (p[8] >> 4) & 0xf,
p[7] & 0xf, (p[7] >> 4) & 0xf,
p[6] & 0xf, (p[4] >> 4) & 0xf,
p[6] & 0xf, (p[6] >> 4) & 0xf,
p[5] & 0xf, (p[5] >> 4) & 0xf,
p[4] & 0xf, (p[4] >> 4) & 0xf,
p[3] & 0xf, (p[3] >> 4) & 0xf,
@ -1019,7 +1018,7 @@ GetHostInfoByAddr(union res_sockaddr_union *nsAddrPtr,
n = GetAnswer(nsAddrPtr, T_PTR, (char *) &buf, n, 1, hostPtr, 1, 0);
if (n == SUCCESS) {
hostPtr->addrList = (AddrInfo **)Calloc(2, sizeof(AddrInfo *));
hostPtr->addrList[0] = (AddrInfo *)Calloc(1, sizeof(AddrInfo *));
hostPtr->addrList[0] = (AddrInfo *)Calloc(1, sizeof(AddrInfo));
hostPtr->addrList[0]->addr = Calloc(16, sizeof(char));
memcpy(hostPtr->addrList[0]->addr, p, 16);
hostPtr->addrList[0]->addrType = AF_INET6;

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.3 2002/06/20 11:43:00 itojun Exp $ */
/* $NetBSD: main.c,v 1.4 2003/06/03 07:33:44 itojun Exp $ */
/*
* Copyright (c) 1985, 1989
@ -79,7 +79,7 @@ char copyright[] =
#ifndef lint
static const char sccsid[] = "@(#)main.c 5.42 (Berkeley) 3/3/91";
static const char rcsid[] = "Id: main.c,v 8.24 2002/05/26 03:12:20 marka Exp";
static const char rcsid[] = "Id: main.c,v 8.25 2003/01/26 11:38:56 marka Exp";
#endif /* not lint */
/*
@ -613,7 +613,7 @@ SetDefaultServer(string, local)
UnionFromAddr(&servAddr, defaultPtr->addrList[0]->addrType,
defaultPtr->addrList[0]->addr);
} else {
UnionFromAddr(&servAddr, defaultPtr->addrList[0]->addrType,
UnionFromAddr(&servAddr, defaultPtr->servers[0]->addrList[0]->addrType,
defaultPtr->servers[0]->addrList[0]->addr);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: send.c,v 1.4 2002/06/20 11:43:00 itojun Exp $ */
/* $NetBSD: send.c,v 1.5 2003/06/03 07:33:45 itojun Exp $ */
/*
* Copyright (c) 1985, 1989
@ -55,7 +55,7 @@
#ifndef lint
static const char sccsid[] = "@(#)send.c 5.18 (Berkeley) 3/2/91";
static const char rcsid[] = "Id: send.c,v 8.14 2002/05/10 04:35:09 marka Exp";
static const char rcsid[] = "Id: send.c,v 8.14.10.1 2003/06/02 05:59:56 marka Exp";
#endif /* not lint */
/*
@ -183,7 +183,7 @@ SendRequest(union res_sockaddr_union *nsAddrPtr, const u_char *buf,
/*
* Send length & message
*/
__putshort(buflen, (u_char *)&len);
ns_put16(buflen, (u_char *)&len);
iov[0].iov_base = (caddr_t)&len;
iov[0].iov_len = INT16SZ;
DE_CONST(buf, iov[1].iov_base);

View File

@ -1,7 +1,7 @@
/* $NetBSD: nsupdate.c,v 1.5 2002/07/04 23:30:39 itojun Exp $ */
/* $NetBSD: nsupdate.c,v 1.6 2003/06/03 07:33:45 itojun Exp $ */
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "Id: nsupdate.c,v 8.27 2001/06/18 14:43:46 marka Exp";
static const char rcsid[] = "Id: nsupdate.c,v 8.30 2003/04/03 05:51:07 marka Exp";
#endif /* not lint */
/*
@ -157,9 +157,6 @@ main(int argc, char **argv) {
struct map *mp;
ns_updrec *rrecp;
ns_updque listuprec;
extern int getopt();
extern char *optarg;
extern int optind, opterr, optopt;
ns_tsig_key key;
char *keyfile=NULL, *keyname=NULL;

View File

@ -1,11 +1,11 @@
#!/bin/sh
#
# $NetBSD: probe_ipv6,v 1.4 2002/06/20 11:42:54 itojun Exp $
# $NetBSD: probe_ipv6,v 1.5 2003/06/03 07:33:26 itojun Exp $
#
set -e
PATH=/bin:/usr/bin:$PATH; export PATH
trap "rm -f tmp$$a.c tmp$$b.c tmp$$a.o tmp$$b.o" 0
trap "rm -f tmp$$[abc].[oc]" 0
target=port_ipv6
new=new_${target}.h
old=${target}.h
@ -22,6 +22,13 @@ cat > tmp$$b.c <<EOF
struct in6_addr xx;
EOF
cat > tmp$$c.c <<EOF
#include <sys/types.h>
#include <netinet/in.h>
struct sockaddr_in6 xx;
main() { xx.sin6_scope_id = 0; }
EOF
cat > ${new} <<EOF
/* This file is automatically generated. Do Not Edit. */
@ -40,6 +47,12 @@ then
else
echo "#define in6_addr in_addr6" >> ${new}
fi
if ${CC} -c tmp$$c.c > /dev/null 2>&1
then
echo "#define HAVE_SIN6_SCOPE_ID" >> ${new}
else
echo "#undef HAVE_SIN6_SCOPE_ID" >> ${new}
fi
else
echo "#undef HAS_INET6_STRUCTS" >> ${new}
fi

View File

@ -1,4 +1,4 @@
/* $NetBSD: nameser.h,v 1.4 2002/06/20 11:43:01 itojun Exp $ */
/* $NetBSD: nameser.h,v 1.5 2003/06/03 07:33:48 itojun Exp $ */
/*
* Copyright (c) 1983, 1989, 1993
@ -51,7 +51,7 @@
*/
/*
* Id: nameser.h,v 8.47 2002/04/30 03:43:53 marka Exp
* Id: nameser.h,v 8.48.8.2 2003/06/02 09:24:40 marka Exp
*/
#ifndef _ARPA_NAMESER_H_
@ -80,8 +80,9 @@
/*
* Define constants based on RFC 883, RFC 1034, RFC 1035
*/
#define NS_PACKETSZ 512 /* maximum packet size */
#define NS_PACKETSZ 512 /* default UDP packet size */
#define NS_MAXDNAME 1025 /* maximum domain name */
#define NS_MAXMSG 65535 /* maximum message size */
#define NS_MAXCDNAME 255 /* maximum compressed domain name */
#define NS_MAXLABEL 63 /* maximum length of domain label */
#define NS_HFIXEDSZ 12 /* #/bytes of fixed data in header */
@ -296,6 +297,7 @@ typedef enum __ns_type {
ns_t_dname = 39, /* Non-terminal DNAME (for IPv6) */
ns_t_sink = 40, /* Kitchen sink (experimentatl) */
ns_t_opt = 41, /* EDNS0 option (meta-RR) */
ns_t_apl = 42, /* Address prefix list (RFC 3123) */
ns_t_tkey = 249, /* Transaction key */
ns_t_tsig = 250, /* Transaction signature. */
ns_t_ixfr = 251, /* Incremental zone transfer. */
@ -400,7 +402,7 @@ typedef enum __ns_cert_types {
/* Signatures */
#define NS_MD5RSA_MIN_BITS 512 /* Size of a mod or exp in bits */
#define NS_MD5RSA_MAX_BITS 2552
#define NS_MD5RSA_MAX_BITS 4096
/* Total of binary mod and exp */
#define NS_MD5RSA_MAX_BYTES ((NS_MD5RSA_MAX_BITS+7/8)*2+3)
/* Max length of text sig block */

View File

@ -1,4 +1,4 @@
/* $NetBSD: nameser_compat.h,v 1.2 2002/06/20 11:43:01 itojun Exp $ */
/* $NetBSD: nameser_compat.h,v 1.3 2003/06/03 07:33:48 itojun Exp $ */
/* Copyright (c) 1983, 1989
* The Regents of the University of California. All rights reserved.
@ -34,7 +34,7 @@
/*
* from nameser.h 8.1 (Berkeley) 6/2/93
* Id: nameser_compat.h,v 8.14 2002/05/18 01:39:11 marka Exp
* Id: nameser_compat.h,v 8.15 2002/07/17 07:01:02 marka Exp
*/
#ifndef _ARPA_NAMESER_COMPAT_
@ -140,6 +140,7 @@ typedef struct {
#define RRFIXEDSZ NS_RRFIXEDSZ
#define INT32SZ NS_INT32SZ
#define INT16SZ NS_INT16SZ
#define INT8SZ NS_INT8SZ
#define INADDRSZ NS_INADDRSZ
#define IN6ADDRSZ NS_IN6ADDRSZ
#define INDIR_MASK NS_CMPRSFLGS

View File

@ -1,4 +1,4 @@
/* $NetBSD: hesiod.h,v 1.1.1.2 2003/06/03 07:04:45 itojun Exp $ */
/* $NetBSD: hesiod.h,v 1.2 2003/06/03 07:33:46 itojun Exp $ */
/*
* Copyright (c) 1996,1999 by Internet Software Consortium.

View File

@ -1,4 +1,4 @@
/* $NetBSD: irp.h,v 1.1.1.2 2003/06/03 07:04:45 itojun Exp $ */
/* $NetBSD: irp.h,v 1.2 2003/06/03 07:33:46 itojun Exp $ */
/*
* Copyright (c) 1999 by Internet Software Consortium.

View File

@ -1,4 +1,4 @@
/* $NetBSD: irs.h,v 1.3 2002/06/20 11:43:01 itojun Exp $ */
/* $NetBSD: irs.h,v 1.4 2003/06/03 07:33:47 itojun Exp $ */
/*
* Copyright (c) 1996,1999 by Internet Software Consortium.
@ -18,7 +18,7 @@
*/
/*
* Id: irs.h,v 8.6 2001/05/29 05:47:00 marka Exp
* Id: irs.h,v 8.7.6.2 2003/06/02 06:06:58 marka Exp
*/
#ifndef _IRS_H_INCLUDED
@ -32,7 +32,6 @@
#include <netdb.h>
#include <resolv.h>
#include <pwd.h>
#include <netgroup.h>
/*
* This is the group map class.
@ -201,18 +200,58 @@ struct nwent {
#define irs_dns_acc __irs_dns_acc
#define irs_nis_acc __irs_nis_acc
#define irs_irp_acc __irs_irp_acc
#define irs_destroy __irs_destroy
#define irs_dns_gr __irs_dns_gr
#define irs_dns_ho __irs_dns_ho
#define irs_dns_nw __irs_dns_nw
#define irs_dns_pr __irs_dns_pr
#define irs_dns_pw __irs_dns_pw
#define irs_dns_sv __irs_dns_sv
#define irs_gen_gr __irs_gen_gr
#define irs_gen_ho __irs_gen_ho
#define irs_gen_ng __irs_gen_ng
#define irs_gen_nw __irs_gen_nw
#define irs_gen_pr __irs_gen_pr
#define irs_gen_pw __irs_gen_pw
#define irs_gen_sv __irs_gen_sv
#define irs_irp_get_full_response __irs_irp_get_full_response
#define irs_irp_gr __irs_irp_gr
#define irs_irp_ho __irs_irp_ho
#define irs_irp_is_connected __irs_irp_is_connected
#define irs_irp_ng __irs_irp_ng
#define irs_irp_nw __irs_irp_nw
#define irs_irp_pr __irs_irp_pr
#define irs_irp_pw __irs_irp_pw
#define irs_irp_read_line __irs_irp_read_line
#define irs_irp_sv __irs_irp_sv
#define irs_lcl_gr __irs_lcl_gr
#define irs_lcl_ho __irs_lcl_ho
#define irs_lcl_ng __irs_lcl_ng
#define irs_lcl_nw __irs_lcl_nw
#define irs_lcl_pr __irs_lcl_pr
#define irs_lcl_pw __irs_lcl_pw
#define irs_lcl_sv __irs_lcl_sv
#define irs_nis_gr __irs_nis_gr
#define irs_nis_ho __irs_nis_ho
#define irs_nis_ng __irs_nis_ng
#define irs_nis_nw __irs_nis_nw
#define irs_nis_pr __irs_nis_pr
#define irs_nis_pw __irs_nis_pw
#define irs_nis_sv __irs_nis_sv
#define net_data_create __net_data_create
#define net_data_destroy __net_data_destroy
#define net_data_minimize __net_data_minimize
/*
* Externs.
*/
extern struct irs_acc * irs_gen_acc __P((const char *options,
const char *conf_file));
extern struct irs_acc * irs_lcl_acc __P((const char *options));
extern struct irs_acc * irs_dns_acc __P((const char *options));
extern struct irs_acc * irs_nis_acc __P((const char *options));
extern struct irs_acc * irs_irp_acc __P((const char *options));
extern struct irs_acc * irs_gen_acc __P((const char *, const char *));
extern struct irs_acc * irs_lcl_acc __P((const char *));
extern struct irs_acc * irs_dns_acc __P((const char *));
extern struct irs_acc * irs_nis_acc __P((const char *));
extern struct irs_acc * irs_irp_acc __P((const char *));
extern void irs_destroy(void);
extern void irs_destroy __P((void));
/*
* These forward declarations are for the semi-private functions in
@ -231,102 +270,78 @@ struct net_data; /* forward */
* the default interface will use net_data_create by default. Servers will
* probably want net_data_init (one call per client)
*/
struct net_data *net_data_create(const char *conf_file);
struct net_data *net_data_init(const char *conf_file);
void net_data_destroy(void *p);
struct net_data *net_data_create __P((const char *));
struct net_data *net_data_init __P((const char *));
void net_data_destroy __P((void *));
extern struct group *getgrent_p __P((struct net_data *net_data));
extern struct group *getgrnam_p __P((const char *name,
struct net_data *net_data));
extern struct group *getgrgid_p __P((gid_t gid,
struct net_data *net_data));
extern int setgroupent_p __P((int stayopen,
struct net_data *net_data));
extern void endgrent_p __P((struct net_data *net_data));
extern int getgrouplist_p __P((const char *name,
gid_t basegid,
gid_t *groups,
int *ngroups,
struct net_data *net_data));
extern struct group *getgrent_p __P((struct net_data *));
extern struct group *getgrnam_p __P((const char *, struct net_data *));
extern struct group *getgrgid_p __P((gid_t, struct net_data *));
extern int setgroupent_p __P((int, struct net_data *));
extern void endgrent_p __P((struct net_data *));
extern int getgrouplist_p __P((const char *, gid_t, gid_t *, int *,
struct net_data *));
#ifdef SETGRENT_VOID
extern void setgrent_p __P((struct net_data *net_data));
extern void setgrent_p __P((struct net_data *));
#else
extern int setgrent_p __P((struct net_data *net_data));
extern int setgrent_p __P((struct net_data *));
#endif
extern struct hostent *gethostbyname_p __P((const char *name,
struct net_data *net_data));
extern struct hostent *gethostbyname2_p __P((const char *name, int af,
struct net_data *net_data));
extern struct hostent *gethostbyaddr_p __P((const char *addr, int len,
int af,
struct net_data *net_data));
extern struct hostent *gethostent_p __P((struct net_data *net_data));
extern void sethostent_p __P((int stayopen,
struct net_data *net_data));
extern void endhostent_p __P((struct net_data *net_data));
extern struct hostent *getipnodebyname_p __P((const char *name, int af,
int flags, int *errp,
struct net_data *net_data));
extern struct hostent *getipnodebyaddr_p __P((const void *addr, size_t len,
int af, int *errp,
struct net_data *net_data));
extern struct hostent *gethostbyname_p __P((const char *,
struct net_data *));
extern struct hostent *gethostbyname2_p __P((const char *, int,
struct net_data *));
extern struct hostent *gethostbyaddr_p __P((const char *, int, int,
struct net_data *));
extern struct hostent *gethostent_p __P((struct net_data *));
extern void sethostent_p __P((int, struct net_data *));
extern void endhostent_p __P((struct net_data *));
extern struct hostent *getipnodebyname_p __P((const char *, int, int, int *,
struct net_data *));
extern struct hostent *getipnodebyaddr_p __P((const void *, size_t,
int, int *, struct net_data *));
extern struct netent *getnetent_p __P((struct net_data *net_data));
extern struct netent *getnetbyname_p __P((const char *name,
struct net_data *net_data));
extern struct netent *getnetbyaddr_p __P((unsigned long net, int type,
struct net_data *net_data));
extern void setnetent_p __P((int stayopen,
struct net_data *net_data));
extern void endnetent_p __P((struct net_data *net_data));
extern struct netent *getnetent_p __P((struct net_data *));
extern struct netent *getnetbyname_p __P((const char *, struct net_data *));
extern struct netent *getnetbyaddr_p __P((unsigned long, int,
struct net_data *));
extern void setnetent_p __P((int, struct net_data *));
extern void endnetent_p __P((struct net_data *));
extern void setnetgrent_p __P((const char *netgroup,
struct net_data *net_data));
extern void endnetgrent_p __P((struct net_data *net_data));
extern int innetgr_p __P((const char *netgroup,
const char *host,
const char *user,
const char *domain,
struct net_data *net_data));
extern int getnetgrent_p __P((const char **host, const char **user,
const char **domain,
struct net_data *net_data));
extern void setnetgrent_p __P((const char *, struct net_data *));
extern void endnetgrent_p __P((struct net_data *));
extern int innetgr_p __P((const char *, const char *, const char *,
const char *, struct net_data *));
extern int getnetgrent_p __P((const char **, const char **,
const char **, struct net_data *));
extern struct protoent *getprotoent_p __P((struct net_data *net_data));
extern struct protoent *getprotobyname_p __P((const char *name,
struct net_data *net_data));
extern struct protoent *getprotobynumber_p __P((int proto,
struct net_data *net_data));
extern void setprotoent_p __P((int stayopen,
struct net_data *net_data));
extern void endprotoent_p __P((struct net_data *net_data));
extern struct protoent *getprotoent_p __P((struct net_data *));
extern struct protoent *getprotobyname_p __P((const char *,
struct net_data *));
extern struct protoent *getprotobynumber_p __P((int, struct net_data *));
extern void setprotoent_p __P((int, struct net_data *));
extern void endprotoent_p __P((struct net_data *));
extern struct passwd *getpwent_p __P((struct net_data *net_data));
extern struct passwd *getpwnam_p __P((const char *name,
struct net_data *net_data));
extern struct passwd *getpwuid_p __P((uid_t uid,
struct net_data *net_data));
extern int setpassent_p __P((int stayopen,
struct net_data *net_data));
extern void endpwent_p __P((struct net_data *net_data));
extern struct passwd *getpwent_p __P((struct net_data *));
extern struct passwd *getpwnam_p __P((const char *, struct net_data *));
extern struct passwd *getpwuid_p __P((uid_t, struct net_data *));
extern int setpassent_p __P((int, struct net_data *));
extern void endpwent_p __P((struct net_data *));
#ifdef SETPWENT_VOID
extern void setpwent_p __P((struct net_data *net_data));
extern void setpwent_p __P((struct net_data *));
#else
extern int setpwent_p __P((struct net_data *net_data));
extern int setpwent_p __P((struct net_data *));
#endif
extern struct servent *getservent_p __P((struct net_data *net_data));
extern struct servent *getservbyname_p __P((const char *name,
const char *proto,
struct net_data *net_data));
extern struct servent *getservbyport_p __P((int port, const char *proto,
struct net_data *net_data));
extern void setservent_p __P((int stayopen,
struct net_data *net_data));
extern void endservent_p __P((struct net_data *net_data));
extern struct servent *getservent_p __P((struct net_data *));
extern struct servent *getservbyname_p __P((const char *, const char *,
struct net_data *));
extern struct servent *getservbyport_p __P((int, const char *,
struct net_data *));
extern void setservent_p __P((int, struct net_data *));
extern void endservent_p __P((struct net_data *));
#endif /*_IRS_H_INCLUDED*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: ctl.h,v 1.3 2002/06/20 11:43:02 itojun Exp $ */
/* $NetBSD: ctl.h,v 1.4 2003/06/03 07:33:49 itojun Exp $ */
#ifndef ISC_CTL_H
#define ISC_CTL_H
@ -21,7 +21,7 @@
*/
/*
* Id: ctl.h,v 8.11 2001/08/10 02:40:49 marka Exp
* Id: ctl.h,v 8.11.10.1 2003/06/02 06:04:03 marka Exp
*/
#include <sys/types.h>
@ -44,11 +44,11 @@ struct ctl_verb;
enum ctl_severity { ctl_debug, ctl_warning, ctl_error };
typedef void (*ctl_logfunc)(enum ctl_severity, const char *fmt, ...);
typedef void (*ctl_logfunc)(enum ctl_severity, const char *, ...);
typedef void (*ctl_verbfunc)(struct ctl_sctx *, struct ctl_sess *,
const struct ctl_verb *, const char *rest,
u_int respflags, const void *respctx, void *uctx);
const struct ctl_verb *, const char *,
u_int, const void *, void *);
typedef void (*ctl_srvrdone)(struct ctl_sctx *, struct ctl_sess *, void *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: dst.h,v 1.1.1.2 2003/06/03 07:04:47 itojun Exp $ */
/* $NetBSD: dst.h,v 1.2 2003/06/03 07:33:49 itojun Exp $ */
#ifndef DST_H
#define DST_H

View File

@ -1,4 +1,4 @@
/* $NetBSD: eventlib.h,v 1.2 2002/06/20 11:43:02 itojun Exp $ */
/* $NetBSD: eventlib.h,v 1.3 2003/06/03 07:33:50 itojun Exp $ */
/*
* Copyright (c) 1995-1999 by Internet Software Consortium
@ -20,7 +20,7 @@
/* eventlib.h - exported interfaces for eventlib
* vix 09sep95 [initial]
*
* Id: eventlib.h,v 1.23 2001/05/29 05:47:09 marka Exp
* Id: eventlib.h,v 1.23.10.1 2003/06/02 06:04:03 marka Exp
*/
#ifndef _EVENTLIB_H
@ -52,14 +52,13 @@ typedef struct { void *opaque; } evEvent;
#define evInitID(id) ((id)->opaque = NULL)
#define evTestID(id) ((id).opaque != NULL)
typedef void (*evConnFunc)__P((evContext ctx, void *uap, int fd,
const void *la, int lalen,
const void *ra, int ralen));
typedef void (*evFileFunc)__P((evContext ctx, void *uap, int fd, int evmask));
typedef void (*evStreamFunc)__P((evContext ctx, void *uap, int fd, int bytes));
typedef void (*evTimerFunc)__P((evContext ctx, void *uap,
struct timespec due, struct timespec inter));
typedef void (*evWaitFunc)__P((evContext ctx, void *uap, const void *tag));
typedef void (*evConnFunc)__P((evContext, void *, int, const void *, int,
const void *, int));
typedef void (*evFileFunc)__P((evContext, void *, int, int));
typedef void (*evStreamFunc)__P((evContext, void *, int, int));
typedef void (*evTimerFunc)__P((evContext, void *,
struct timespec, struct timespec));
typedef void (*evWaitFunc)__P((evContext, void *, const void *));
typedef struct { unsigned char mask[256/8]; } evByteMask;
#define EV_BYTEMASK_BYTE(b) ((b) / 8)
@ -89,14 +88,14 @@ typedef struct { unsigned char mask[256/8]; } evByteMask;
#define evMainLoop __evMainLoop
#define evHighestFD __evHighestFD
int evCreate __P((evContext *ctx));
void evSetDebug __P((evContext ctx, int lev, FILE *out));
int evDestroy __P((evContext ctx));
int evGetNext __P((evContext ctx, evEvent *ev, int options));
int evDispatch __P((evContext ctx, evEvent ev));
void evDrop __P((evContext ctx, evEvent ev));
int evMainLoop __P((evContext ctx));
int evHighestFD __P((evContext ctx));
int evCreate __P((evContext *));
void evSetDebug __P((evContext, int, FILE *));
int evDestroy __P((evContext));
int evGetNext __P((evContext, evEvent *, int));
int evDispatch __P((evContext, evEvent));
void evDrop __P((evContext, evEvent));
int evMainLoop __P((evContext));
int evHighestFD __P((evContext));
/* ev_connects.c */
#define evListen __evListen
@ -106,11 +105,10 @@ int evHighestFD __P((evContext ctx));
#define evUnhold __evUnhold
#define evTryAccept __evTryAccept
int evListen __P((evContext ctx, int fd, int maxconn,
evConnFunc func, void *uap, evConnID *id));
int evConnect __P((evContext ctx, int fd, const void *ra, int ralen,
evConnFunc func, void *uap, evConnID *id));
int evCancelConn __P((evContext ctx, evConnID id));
int evListen __P((evContext, int, int, evConnFunc, void *, evConnID *));
int evConnect __P((evContext, int, const void *, int,
evConnFunc, void *, evConnID *));
int evCancelConn __P((evContext, evConnID));
int evHold __P((evContext, evConnID));
int evUnhold __P((evContext, evConnID));
int evTryAccept __P((evContext, evConnID, int *));
@ -119,9 +117,8 @@ int evTryAccept __P((evContext, evConnID, int *));
#define evSelectFD __evSelectFD
#define evDeselectFD __evDeselectFD
int evSelectFD __P((evContext ctx, int fd, int eventmask,
evFileFunc func, void *uap, evFileID *id));
int evDeselectFD __P((evContext ctx, evFileID id));
int evSelectFD __P((evContext, int, int, evFileFunc, void *, evFileID *));
int evDeselectFD __P((evContext, evFileID));
/* ev_streams.c */
#define evConsIovec __evConsIovec
@ -131,14 +128,14 @@ int evDeselectFD __P((evContext ctx, evFileID id));
#define evUntimeRW __evUntimeRW
#define evCancelRW __evCancelRW
struct iovec evConsIovec __P((void *buf, size_t cnt));
int evWrite __P((evContext ctx, int fd, const struct iovec *iov, int cnt,
evStreamFunc func, void *uap, evStreamID *id));
int evRead __P((evContext ctx, int fd, const struct iovec *iov, int cnt,
evStreamFunc func, void *uap, evStreamID *id));
int evTimeRW __P((evContext ctx, evStreamID id, evTimerID timer));
int evUntimeRW __P((evContext ctx, evStreamID id));
int evCancelRW __P((evContext ctx, evStreamID id));
struct iovec evConsIovec __P((void *, size_t));
int evWrite __P((evContext, int, const struct iovec *, int,
evStreamFunc func, void *, evStreamID *));
int evRead __P((evContext, int, const struct iovec *, int,
evStreamFunc func, void *, evStreamID *));
int evTimeRW __P((evContext, evStreamID, evTimerID timer));
int evUntimeRW __P((evContext, evStreamID));
int evCancelRW __P((evContext, evStreamID));
/* ev_timers.c */
#define evConsTime __evConsTime
@ -159,17 +156,16 @@ int evCancelRW __P((evContext ctx, evStreamID id));
#define evTouchIdleTimer __evTouchIdleTimer
struct timespec evConsTime __P((time_t sec, long nsec));
struct timespec evAddTime __P((struct timespec add1, struct timespec add2));
struct timespec evSubTime __P((struct timespec minu, struct timespec subtra));
struct timespec evAddTime __P((struct timespec, struct timespec));
struct timespec evSubTime __P((struct timespec, struct timespec));
struct timespec evNowTime __P((void));
struct timespec evLastEventTime __P((evContext));
struct timespec evTimeSpec __P((struct timeval));
struct timeval evTimeVal __P((struct timespec));
int evCmpTime __P((struct timespec a, struct timespec b));
int evSetTimer __P((evContext ctx, evTimerFunc func, void *uap,
struct timespec due, struct timespec inter,
evTimerID *id));
int evClearTimer __P((evContext ctx, evTimerID id));
int evCmpTime __P((struct timespec, struct timespec));
int evSetTimer __P((evContext, evTimerFunc, void *, struct timespec,
struct timespec, evTimerID *));
int evClearTimer __P((evContext, evTimerID));
int evResetTimer __P((evContext, evTimerID, evTimerFunc, void *,
struct timespec, struct timespec));
int evSetIdleTimer __P((evContext, evTimerFunc, void *, struct timespec,
@ -185,10 +181,9 @@ int evTouchIdleTimer __P((evContext, evTimerID));
#define evUnwait __evUnwait
#define evDefer __evDefer
int evWaitFor __P((evContext ctx, const void *tag, evWaitFunc func, void *uap,
evWaitID *id));
int evDo __P((evContext ctx, const void *tag));
int evUnwait __P((evContext ctx, evWaitID id));
int evWaitFor __P((evContext, const void *, evWaitFunc, void *, evWaitID *));
int evDo __P((evContext, const void *));
int evUnwait __P((evContext, evWaitID));
int evDefer __P((evContext, evWaitFunc, void *));
#ifdef __EVENTLIB_P_DEFINED

View File

@ -1,4 +1,4 @@
/* $NetBSD: irpmarshall.h,v 1.2 2002/06/20 11:43:02 itojun Exp $ */
/* $NetBSD: irpmarshall.h,v 1.3 2003/06/03 07:33:50 itojun Exp $ */
/*
* Copyright (c) 1999 by Internet Software Consortium.
@ -18,7 +18,7 @@
*/
/*
* Id: irpmarshall.h,v 8.2 2001/05/29 05:47:10 marka Exp
* Id: irpmarshall.h,v 8.2.10.1 2003/06/02 06:04:03 marka Exp
*/
#ifndef _IRPMARSHALL_H_INCLUDED
@ -47,24 +47,23 @@
(x == AF_INET6 ? "AF_INET6" : "UNKNOWN"))
/* See comment below on usage */
int irp_marshall_pw(const struct passwd *pw, char **buffer, size_t *len);
int irp_unmarshall_pw(struct passwd *pw, char *buffer);
int irp_marshall_gr(const struct group *gr, char **buffer, size_t *len);
int irp_unmarshall_gr(struct group *gr, char *buffer);
int irp_marshall_sv(const struct servent *sv, char **buffer, size_t *len);
int irp_unmarshall_sv(struct servent *sv, char *buffer);
int irp_marshall_pr(struct protoent *pr, char **buffer, size_t *len);
int irp_unmarshall_pr(struct protoent *pr, char *buffer);
int irp_marshall_ho(struct hostent *ho, char **buffer, size_t *len);
int irp_unmarshall_ho(struct hostent *ho, char *buffer);
int irp_marshall_ng(const char *host, const char *user, const char *domain,
char **buffer, size_t *len);
int irp_unmarshall_ng(const char **host, const char **user,
const char **domain, char *buffer);
int irp_marshall_nw(struct nwent *ne, char **buffer, size_t *len);
int irp_unmarshall_nw(struct nwent *ne, char *buffer);
int irp_marshall_ne(struct netent *ne, char **buffer, size_t *len);
int irp_unmarshall_ne(struct netent *ne, char *buffer);
int irp_marshall_pw(const struct passwd *, char **, size_t *);
int irp_unmarshall_pw(struct passwd *, char *);
int irp_marshall_gr(const struct group *, char **, size_t *);
int irp_unmarshall_gr(struct group *, char *);
int irp_marshall_sv(const struct servent *, char **, size_t *);
int irp_unmarshall_sv(struct servent *, char *);
int irp_marshall_pr(struct protoent *, char **, size_t *);
int irp_unmarshall_pr(struct protoent *, char *);
int irp_marshall_ho(struct hostent *, char **, size_t *);
int irp_unmarshall_ho(struct hostent *, char *);
int irp_marshall_ng(const char *, const char *, const char *,
char **, size_t *);
int irp_unmarshall_ng(const char **, const char **, const char **, char *);
int irp_marshall_nw(struct nwent *, char **, size_t *);
int irp_unmarshall_nw(struct nwent *, char *);
int irp_marshall_ne(struct netent *, char **, size_t *);
int irp_unmarshall_ne(struct netent *, char *);
/*
* Functions to marshall and unmarshall various system data structures. We

View File

@ -1,4 +1,4 @@
/* $NetBSD: logging.h,v 1.4 2002/06/20 11:43:02 itojun Exp $ */
/* $NetBSD: logging.h,v 1.5 2003/06/03 07:33:50 itojun Exp $ */
/*
* Copyright (c) 1996-1999 by Internet Software Consortium.
@ -85,12 +85,12 @@ int log_check(log_context, int, int);
#ifdef __GNUC__
void log_vwrite(log_context, int, int, const char *,
va_list args)
__attribute__((__format__(__printf__, 4, 0)));
__attribute__((__format__(__printf__, 4, 0)));
void log_write(log_context, int, int, const char *, ...)
__attribute__((__format__(__printf__, 4, 5)));
#else
void log_vwrite(log_context, int, int, const char *,
va_list args)
va_list args);
void log_write(log_context, int, int, const char *, ...);
#endif
int log_new_context(int, char **, log_context *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: misc.h,v 1.3 2002/06/20 11:43:02 itojun Exp $ */
/* $NetBSD: misc.h,v 1.4 2003/06/03 07:33:51 itojun Exp $ */
/*
* Copyright (c) 1995-1999 by Internet Software Consortium
@ -18,7 +18,7 @@
*/
/*
* Id: misc.h,v 8.5 2001/06/18 06:40:43 marka Exp
* Id: misc.h,v 8.5.10.1 2003/06/02 06:04:03 marka Exp
*/
#ifndef _ISC_MISC_H
@ -29,7 +29,7 @@
#define bitncmp __bitncmp
/*#define isc_movefile __isc_movefile */
extern int bitncmp(const void *l, const void *r, int n);
extern int bitncmp(const void *, const void *, int);
extern int isc_movefile(const char *, const char *);
extern int isc_gethexstring(unsigned char *, size_t, int, FILE *,

View File

@ -1,4 +1,4 @@
/* $NetBSD: tree.h,v 1.1.1.2 2003/06/03 07:04:47 itojun Exp $ */
/* $NetBSD: tree.h,v 1.2 2003/06/03 07:33:51 itojun Exp $ */
/* tree.h - declare structures used by tree library
*

View File

@ -1,4 +1,4 @@
/* $NetBSD: netgroup.h,v 1.1.1.2 2003/06/03 07:04:45 itojun Exp $ */
/* $NetBSD: netgroup.h,v 1.2 2003/06/03 07:33:47 itojun Exp $ */
#ifndef netgroup_h
#define netgroup_h

View File

@ -1,4 +1,4 @@
/* $NetBSD: port_after.h,v 1.5 2002/06/20 11:43:01 itojun Exp $ */
/* $NetBSD: port_after.h,v 1.6 2003/06/03 07:33:47 itojun Exp $ */
#ifndef PORT_AFTER_H
#define PORT_AFTER_H
@ -20,6 +20,7 @@
#define HAVE_CHROOT
#define CAN_CHANGE_ID
#define __BIND_RES_TEXT
#define USE_IFNAMELINKID
#define _TIMEZONE timezone

View File

@ -1,4 +1,4 @@
/* $NetBSD: resolv.h,v 1.7 2002/06/20 11:43:01 itojun Exp $ */
/* $NetBSD: resolv.h,v 1.8 2003/06/03 07:33:47 itojun Exp $ */
/*
* Copyright (c) 1983, 1987, 1989
@ -52,7 +52,7 @@
/*
* @(#)resolv.h 8.1 (Berkeley) 6/2/93
* Id: resolv.h,v 8.48 2002/05/31 06:05:29 marka Exp
* Id: resolv.h,v 8.50.6.2 2003/06/02 06:01:16 marka Exp
*/
#ifndef _RESOLV_H_
@ -77,14 +77,12 @@
* is new enough to contain a certain feature.
*/
#define __RES 19991006
#define __RES 20030124
/* XXX NetBSD: avoid conflicting with the libc (bind4) resolver */
#define __h_errno_set bind___h_errno_set
#define _res bind__res
#define _res_opcodes bind__res_opcodes
#define res_send_setrhook bind_res_send_setrhook
#define res_send_setqhook bind_res_send_setqhook
#define _getlong bind__getlong
#define _getshort bind__getshort
#define inet_addr bind_inet_addr
@ -180,7 +178,7 @@ __END_DECLS
/*
* Resolver configuration file.
* Normally not present, but may contain the address of the
* inital name server(s) to query and the domain search list.
* initial name server(s) to query and the domain search list.
*/
#ifndef _PATH_RESCONF
@ -190,19 +188,13 @@ __END_DECLS
typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error }
res_sendhookact;
typedef res_sendhookact (*res_send_qhook)__P((struct sockaddr * const *ns,
const u_char **query,
int *querylen,
u_char *ans,
int anssiz,
int *resplen));
typedef res_sendhookact (*res_send_qhook)__P((struct sockaddr * const *,
const u_char **, int *,
u_char *, int, int *));
typedef res_sendhookact (*res_send_rhook)__P((const struct sockaddr *ns,
const u_char *query,
int querylen,
u_char *ans,
int anssiz,
int *resplen));
typedef res_sendhookact (*res_send_rhook)__P((const struct sockaddr *,
const u_char *, int, u_char *,
int, int *));
struct res_sym {
int number; /* Identifying number, like T_MX */
@ -229,7 +221,7 @@ struct res_sym {
struct __res_state_ext;
struct __res_state {
int retrans; /* retransmition time interval */
int retrans; /* retransmission time interval */
int retry; /* number of times to retransmit */
#ifdef sun
u_int options; /* option flags - see below. */
@ -294,6 +286,10 @@ union res_sockaddr_union {
#define RES_F_VC 0x00000001 /* socket is TCP */
#define RES_F_CONN 0x00000002 /* socket is connected */
#define RES_F_EDNS0ERR 0x00000004 /* EDNS0 caused errors */
#define RES_F__UNUSED 0x00000008 /* (unused) */
#define RES_F_LASTMASK 0x000000F0 /* ordinal server of last res_nsend */
#define RES_F_LASTSHIFT 4 /* bit position of LASTMASK "flag" */
#define RES_GETLAST(res) (((res)._flags & RES_F_LASTMASK) >> RES_F_LASTSHIFT)
/* res_findzonecut2() options */
#define RES_EXHAUSTIVE 0x00000001 /* always do all queries */
@ -321,13 +317,10 @@ union res_sockaddr_union {
#define RES_NOCHECKNAME 0x00008000 /* do not check names for sanity. */
#define RES_KEEPTSIG 0x00010000 /* do not strip TSIG records */
#define RES_BLAST 0x00020000 /* blast all recursive servers */
#define RES_NO_NIBBLE 0x00040000 /* disable IPv6 nibble mode reverse */
#define RES_NO_BITSTRING 0x00080000 /* disable IPv6 bitstring mode reverse */
#define RES_NOTLDQUERY 0x00100000 /* don't unqualified name as a tld */
#define RES_USE_DNSSEC 0x00200000 /* use DNSSEC using OK bit in OPT */
/* KAME extensions: use higher bit to avoid conflict with ISC use */
#define RES_USE_DNAME 0x10000000 /* use DNAME */
#define RES_USE_A6 0x20000000 /* use A6 */
#define RES_USE_EDNS0 0x40000000 /* use EDNS0 if configured */
#define RES_NO_NIBBLE2 0x80000000 /* disable alternate nibble lookup */
@ -436,6 +429,7 @@ extern const struct res_sym __p_rcode_syms[];
#define p_time __p_time
#define p_type __p_type
#define p_rcode __p_rcode
#define p_sockun __p_sockun
#define putlong __putlong
#define putshort __putshort
#define res_dnok __res_dnok
@ -467,6 +461,18 @@ extern const struct res_sym __p_rcode_syms[];
#define res_nametotype __res_nametotype
#define res_setservers __res_setservers
#define res_getservers __res_getservers
#define res_buildprotolist __res_buildprotolist
#define res_destroyprotolist __res_destroyprotolist
#define res_destroyservicelist __res_destroyservicelist
#define res_get_nibblesuffix __res_get_nibblesuffix
#define res_get_nibblesuffix2 __res_get_nibblesuffix2
#define res_ourserver_p __res_ourserver_p
#define res_protocolname __res_protocolname
#define res_protocolnumber __res_protocolnumber
#define res_send_setqhook __res_send_setqhook
#define res_send_setrhook __res_send_setrhook
#define res_servicename __res_servicename
#define res_servicenumber __res_servicenumber
__BEGIN_DECLS
int res_hnok __P((const char *));
int res_ownok __P((const char *));
@ -477,25 +483,26 @@ const char * sym_ntos __P((const struct res_sym *, int, int *));
const char * sym_ntop __P((const struct res_sym *, int, int *));
int b64_ntop __P((u_char const *, size_t, char *, size_t));
int b64_pton __P((char const *, u_char *, size_t));
int loc_aton __P((const char *ascii, u_char *binary));
const char * loc_ntoa __P((const u_char *binary, char *ascii));
int loc_aton __P((const char *, u_char *));
const char * loc_ntoa __P((const u_char *, char *));
int dn_skipname __P((const u_char *, const u_char *));
void putlong __P((u_int32_t, u_char *));
void putshort __P((u_int16_t, u_char *));
#ifndef __ultrix__
u_int16_t _getshort __P((const u_char *src));
u_int32_t _getlong __P((const u_char *src));
u_int16_t _getshort __P((const u_char *));
u_int32_t _getlong __P((const u_char *));
#endif
const char * p_class __P((int));
const char * p_time __P((u_int32_t));
const char * p_type __P((int));
const char * p_rcode __P((int));
const char * p_sockun __P((union res_sockaddr_union, char *, size_t));
const u_char * p_cdnname __P((const u_char *, const u_char *, int, FILE *));
const u_char * p_cdname __P((const u_char *, const u_char *, FILE *));
const u_char * p_fqnname __P((const u_char *cp, const u_char *msg,
const u_char * p_fqnname __P((const u_char *, const u_char *,
int, char *, int));
const u_char * p_fqname __P((const u_char *, const u_char *, FILE *));
const char * p_option __P((u_long option));
const char * p_option __P((u_long));
char * p_secstodate __P((u_long));
int dn_count_labels __P((const char *));
int dn_comp __P((const char *, u_char *, int,
@ -503,11 +510,11 @@ int dn_comp __P((const char *, u_char *, int,
int dn_expand __P((const u_char *, const u_char *, const u_char *,
char *, int));
u_int res_randomid __P((void));
int res_nameinquery __P((const char *, int, int,
const u_char *, const u_char *));
int res_nameinquery __P((const char *, int, int, const u_char *,
const u_char *));
int res_queriesmatch __P((const u_char *, const u_char *,
const u_char *, const u_char *));
const char * p_section __P((int section, int opcode));
const char * p_section __P((int, int));
/* Things involving a resolver context. */
int res_ninit __P((res_state));
int res_nisourserver __P((const res_state,
@ -516,16 +523,15 @@ void fp_resstat __P((const res_state, FILE *));
void res_pquery __P((const res_state, const u_char *, int, FILE *));
const char * res_hostalias __P((const res_state, const char *,
char *, size_t));
int res_nquery __P((res_state,
const char *, int, int, u_char *, int));
int res_nsearch __P((res_state, const char *, int,
int, u_char *, int));
int res_nquerydomain __P((res_state,
const char *, const char *, int, int,
u_char *, int));
int res_nmkquery __P((res_state,
int, const char *, int, int, const u_char *,
int, const u_char *, u_char *, int));
int res_nquery __P((res_state, const char *, int, int,
u_char *, int));
int res_nsearch __P((res_state, const char *, int, int, u_char *,
int));
int res_nquerydomain __P((res_state, const char *, const char *,
int, int, u_char *, int));
int res_nmkquery __P((res_state, int, const char *, int, int,
const u_char *, int, const u_char *,
u_char *, int));
int res_nsend __P((res_state, const u_char *, int, u_char *, int));
int res_nsendsigned __P((res_state, const u_char *, int,
ns_tsig_key *, u_char *, int));
@ -536,20 +542,19 @@ int res_findzonecut2 __P((res_state, const char *, ns_class, int,
union res_sockaddr_union *, int));
void res_nclose __P((res_state));
int res_nopt __P((res_state, int, u_char *, int, int));
void res_send_setqhook __P((res_send_qhook hook));
void res_send_setrhook __P((res_send_rhook hook));
void res_send_setqhook __P((res_send_qhook));
void res_send_setrhook __P((res_send_rhook));
int __res_vinit __P((res_state, int));
void res_destroyservicelist __P((void));
const char * res_servicename __P((u_int16_t port, const char *proto));
const char * res_protocolname __P((int num));
const char * res_servicename __P((u_int16_t, const char *));
const char * res_protocolname __P((int));
void res_destroyprotolist __P((void));
void res_buildprotolist __P((void));
const char * res_get_nibblesuffix __P((res_state));
const char * res_get_nibblesuffix2 __P((res_state));
const char * res_get_bitstringsuffix __P((res_state));
void res_ndestroy __P((res_state));
u_int16_t res_nametoclass __P((const char *buf, int *success));
u_int16_t res_nametotype __P((const char *buf, int *success));
u_int16_t res_nametoclass __P((const char *, int *));
u_int16_t res_nametotype __P((const char *, int *));
void res_setservers __P((res_state,
const union res_sockaddr_union *, int));
int res_getservers __P((res_state,

View File

@ -1,4 +1,4 @@
/* $NetBSD: strtoul.c,v 1.1.1.3 2003/06/03 07:04:48 itojun Exp $ */
/* $NetBSD: strtoul.c,v 1.2 2003/06/03 07:33:52 itojun Exp $ */
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)strtoul.c 8.1 (Berkeley) 6/4/93";

View File

@ -1,4 +1,4 @@
/* $NetBSD: writev.c,v 1.1.1.3 2003/06/03 07:04:48 itojun Exp $ */
/* $NetBSD: writev.c,v 1.2 2003/06/03 07:33:52 itojun Exp $ */
#ifndef LINT
static const char rcsid[] = "Id: writev.c,v 8.5.18.1 2003/06/02 06:08:28 marka Exp";

View File

@ -1,7 +1,7 @@
/* $NetBSD: bsafe_link.c,v 1.5 2002/06/20 11:43:02 itojun Exp $ */
/* $NetBSD: bsafe_link.c,v 1.6 2003/06/03 07:33:53 itojun Exp $ */
#if defined(BSAFE) || defined(DNSSAFE)
static const char rcsid[] = "Header: /proj/cvs/isc/bind8/src/lib/dst/bsafe_link.c,v 1.15 2001/09/25 04:50:28 marka Exp";
static const char rcsid[] = "Header: /proj/cvs/isc/bind8/src/lib/dst/bsafe_link.c,v 1.16 2002/12/03 05:26:49 marka Exp";
/*
* Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc.
@ -1115,6 +1115,8 @@ T_realloc(POINTER block, unsigned int len)
}
#else /* BSAFE NOT available */
#define dst_bsafe_init __dst_bsafe_init
int
dst_bsafe_init()
{

View File

@ -1,7 +1,7 @@
/* $NetBSD: cylink_link.c,v 1.4 2002/06/20 11:43:02 itojun Exp $ */
/* $NetBSD: cylink_link.c,v 1.5 2003/06/03 07:33:53 itojun Exp $ */
#ifdef CYLINK_DSS
static const char rcsid[] = "Header: /proj/cvs/isc/bind8/src/lib/dst/cylink_link.c,v 1.9 2001/05/29 05:48:05 marka Exp";
static const char rcsid[] = "Header: /proj/cvs/isc/bind8/src/lib/dst/cylink_link.c,v 1.10 2002/12/03 05:26:49 marka Exp";
/*
* Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc.
@ -664,6 +664,8 @@ memcpyend(void *dest, const void *src, size_t n, size_t size) {
}
#else
#define dst_cylink_init __dst_cylink_init
int
dst_cylink_init()
{

View File

@ -1,7 +1,7 @@
/* $NetBSD: dst_api.c,v 1.5 2002/06/20 11:43:02 itojun Exp $ */
/* $NetBSD: dst_api.c,v 1.6 2003/06/03 07:33:53 itojun Exp $ */
#ifndef LINT
static const char rcsid[] = "Header: /proj/cvs/isc/bind8/src/lib/dst/dst_api.c,v 1.20 2001/07/26 01:20:08 marka Exp";
static const char rcsid[] = "Header: /proj/cvs/isc/bind8/src/lib/dst/dst_api.c,v 1.21 2002/06/28 06:58:19 marka Exp";
#endif
/*
@ -219,7 +219,6 @@ dst_compare_keys(const DST_KEY *key1, const DST_KEY *key2)
* Then data is hashed (SIG_MODE_UPDATE). Finally the signature
* itself is created (SIG_MODE_FINAL). This function can be called
* once with INIT, UPDATE and FINAL modes all set, or it can be
* called separately with a different mode set for each step. The
* UPDATE step can be repeated.
* Parameters
@ -459,7 +458,7 @@ dst_s_write_private_key(const DST_KEY *key)
* filename of the key file to be read.
* Returns
* NULL If the key does not exist or no name is supplied.
* NON-NULL Initalized key structure if the key exists.
* NON-NULL Initialized key structure if the key exists.
*/
static DST_KEY *

View File

@ -1,8 +1,8 @@
/* $NetBSD: hmac_link.c,v 1.3 2002/06/20 11:43:02 itojun Exp $ */
/* $NetBSD: hmac_link.c,v 1.4 2003/06/03 07:33:54 itojun Exp $ */
#ifdef HMAC_MD5
#ifndef LINT
static const char rcsid[] = "Header: /proj/cvs/isc/bind8/src/lib/dst/hmac_link.c,v 1.9 2001/05/29 05:48:10 marka Exp";
static const char rcsid[] = "Header: /proj/cvs/isc/bind8/src/lib/dst/hmac_link.c,v 1.10 2002/12/03 05:26:49 marka Exp";
#endif
/*
* Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc.
@ -483,15 +483,10 @@ dst_hmac_md5_init()
}
#else
#define dst_hmac_md5_init __dst_hmac_md5_init
int
dst_hmac_md5_init(){
return (0);
}
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: dns_gr.c,v 1.2 2002/06/20 11:43:03 itojun Exp $ */
/* $NetBSD: dns_gr.c,v 1.3 2003/06/03 07:33:55 itojun Exp $ */
/*
* Copyright (c) 1996-1999 by Internet Software Consortium.
@ -18,7 +18,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "Id: dns_gr.c,v 1.20 2001/05/29 05:48:27 marka Exp";
static const char rcsid[] = "Id: dns_gr.c,v 1.21 2002/07/08 06:26:09 marka Exp";
#endif
/*
@ -228,7 +228,7 @@ get_hes_group(struct irs_gr *this, const char *name, const char *type) {
goto cleanup;
*cp++ = '\0';
errno = -1;
errno = 0;
t = strtoul(cp, NULL, 10);
if (errno == ERANGE)
goto cleanup;

View File

@ -1,4 +1,4 @@
/* $NetBSD: dns_ho.c,v 1.5 2002/07/04 23:30:39 itojun Exp $ */
/* $NetBSD: dns_ho.c,v 1.6 2003/06/03 07:33:55 itojun Exp $ */
/*
* Copyright (c) 1985, 1988, 1993
@ -54,7 +54,7 @@
/* BIND Id: gethnamaddr.c,v 8.15 1996/05/22 04:56:30 vixie Exp $ */
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "Id: dns_ho.c,v 1.39 2002/06/27 03:56:32 marka Exp";
static const char rcsid[] = "Id: dns_ho.c,v 1.42.6.1 2003/06/02 09:24:40 marka Exp";
#endif /* LIBC_SCCS and not lint */
/* Imports. */
@ -97,7 +97,7 @@ static const char rcsid[] = "Id: dns_ho.c,v 1.39 2002/06/27 03:56:32 marka Exp";
#define MAXALIASES 35
#define MAXADDRS 35
#define MAXPACKET (1024*64)
#define MAXPACKET (65535) /* Maximum TCP message size */
#define BOUNDS_CHECK(ptr, count) \
if ((ptr) + (count) > eom) { \
@ -174,15 +174,6 @@ static struct hostent * gethostans(struct irs_ho *this,
const struct addrinfo *pai);
static int add_hostent(struct pvt *pvt, char *bp, char **hap,
struct addrinfo *ai);
static const u_char * ar_head(const u_char *, int, const u_char *,
const u_char *, struct pvt *,
int (*)(const char *));
static struct addrinfo * a6_expand(const u_char *, const u_char *, int,
const u_char *, const u_char *,
const struct in6_addr *, int,
const struct addrinfo *,
struct pvt *, int (*)(const char *), int *);
static const char *dname_subst(const char *, const char *, const char *);
static int init(struct irs_ho *this);
/* Exports. */
@ -259,21 +250,19 @@ ho_byname2(struct irs_ho *this, const char *name, int af)
char tmp[NS_MAXDNAME];
const char *cp;
struct addrinfo ai;
struct dns_res_target *q, *q2, *p;
struct dns_res_target *q, *p;
int querystate = RESQRY_FAIL;
if (init(this) == -1)
return (NULL);
q = memget(sizeof(*q));
q2 = memget(sizeof(*q2));
if (q == NULL || q2 == NULL) {
if (q == NULL) {
RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
errno = ENOMEM;
goto cleanup;
}
memset(q, 0, sizeof(q));
memset(q2, 0, sizeof(q2));
switch (af) {
case AF_INET:
@ -287,21 +276,10 @@ ho_byname2(struct irs_ho *this, const char *name, int af)
case AF_INET6:
size = IN6ADDRSZ;
q->qclass = C_IN;
q->qtype = ns_t_a6;
q->qtype = T_AAAA;
q->answer = q->qbuf.buf;
q->anslen = sizeof(q->qbuf);
q->next = q2;
#ifdef RES_USE_A6
if ((pvt->res->options & RES_USE_A6) == 0)
q->action = RESTGT_IGNORE;
else
#endif
q->action = RESTGT_DOALWAYS;
q2->qclass = C_IN;
q2->qtype = T_AAAA;
q2->answer = q2->qbuf.buf;
q2->anslen = sizeof(q2->qbuf);
q2->action = RESTGT_AFTERFAILURE;
q->action = RESTGT_DOALWAYS;
break;
default:
RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
@ -351,8 +329,6 @@ ho_byname2(struct irs_ho *this, const char *name, int af)
cleanup:
if (q != NULL)
memput(q, sizeof(*q));
if (q2 != NULL)
memput(q2, sizeof(*q2));
return(hp);
}
@ -449,7 +425,12 @@ ho_byaddr(struct irs_ho *this, const void *addr, int len, int af)
abort();
qp += i;
}
#ifdef HAVE_STRLCAT
strlcat(q->qname, res_get_nibblesuffix(pvt->res),
sizeof(q->qname));
#else
strcpy(qp, res_get_nibblesuffix(pvt->res));
#endif
}
if (q2->action != RESTGT_IGNORE) {
qp = q2->qname;
@ -461,7 +442,12 @@ ho_byaddr(struct irs_ho *this, const void *addr, int len, int af)
abort();
qp += i;
}
#ifdef HAVE_STRLCAT
strlcat(q->qname, res_get_nibblesuffix2(pvt->res),
sizeof(q->qname));
#else
strcpy(qp, res_get_nibblesuffix2(pvt->res));
#endif
}
break;
default:
@ -571,7 +557,7 @@ ho_addrinfo(struct irs_ho *this, const char *name, const struct addrinfo *pai)
int n;
char tmp[NS_MAXDNAME];
const char *cp;
struct dns_res_target *q, *q2, *q3, *p;
struct dns_res_target *q, *q2, *p;
struct addrinfo sentinel, *cur;
int querystate = RESQRY_FAIL;
@ -583,42 +569,28 @@ ho_addrinfo(struct irs_ho *this, const char *name, const struct addrinfo *pai)
q = memget(sizeof(*q));
q2 = memget(sizeof(*q2));
q3 = memget(sizeof(*q3));
if (q == NULL || q2 == NULL || q3 == NULL) {
if (q == NULL || q2 == NULL) {
RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
errno = ENOMEM;
goto cleanup;
}
memset(q, 0, sizeof(q2));
memset(q2, 0, sizeof(q2));
memset(q3, 0, sizeof(q3));
switch (pai->ai_family) {
case AF_UNSPEC:
/* prefer IPv6 */
q->qclass = C_IN;
q->qtype = ns_t_a6;
q->qtype = T_AAAA;
q->answer = q->qbuf.buf;
q->anslen = sizeof(q->qbuf);
q->next = q2;
#ifdef RES_USE_A6
if ((pvt->res->options & RES_USE_A6) == 0)
q->action = RESTGT_IGNORE;
else
#endif
q->action = RESTGT_DOALWAYS;
q->action = RESTGT_DOALWAYS;
q2->qclass = C_IN;
q2->qtype = T_AAAA;
q2->qtype = T_A;
q2->answer = q2->qbuf.buf;
q2->anslen = sizeof(q2->qbuf);
q2->next = q3;
/* try AAAA only when A6 query fails */
q2->action = RESTGT_AFTERFAILURE;
q3->qclass = C_IN;
q3->qtype = T_A;
q3->answer = q3->qbuf.buf;
q3->anslen = sizeof(q3->qbuf);
q3->action = RESTGT_DOALWAYS;
q2->action = RESTGT_DOALWAYS;
break;
case AF_INET:
q->qclass = C_IN;
@ -629,21 +601,10 @@ ho_addrinfo(struct irs_ho *this, const char *name, const struct addrinfo *pai)
break;
case AF_INET6:
q->qclass = C_IN;
q->qtype = ns_t_a6;
q->qtype = T_AAAA;
q->answer = q->qbuf.buf;
q->anslen = sizeof(q->qbuf);
q->next = q2;
#ifdef RES_USE_A6
if ((pvt->res->options & RES_USE_A6) == 0)
q->action = RESTGT_IGNORE;
else
#endif
q->action = RESTGT_DOALWAYS;
q2->qclass = C_IN;
q2->qtype = T_AAAA;
q2->answer = q2->qbuf.buf;
q2->anslen = sizeof(q2->qbuf);
q2->action = RESTGT_AFTERFAILURE;
q->action = RESTGT_DOALWAYS;
break;
default:
RES_SET_H_ERRNO(pvt->res, NO_RECOVERY); /* better error? */
@ -696,375 +657,9 @@ ho_addrinfo(struct irs_ho *this, const char *name, const struct addrinfo *pai)
memput(q, sizeof(*q));
if (q2 != NULL)
memput(q2, sizeof(*q2));
if (q3 != NULL)
memput(q3, sizeof(*q3));
return(sentinel.ai_next);
}
static const u_char *
ar_head(cp, count, msg, eom, pvt, name_ok)
const u_char *cp, *msg, *eom;
int count;
struct pvt *pvt;
int (*name_ok)(const char *);
{
int n;
char buf[1024]; /* XXX */
while (count-- > 0 && cp < eom) {
n = dn_expand(msg, eom, cp, buf, sizeof(buf));
if (n < 0 || !maybe_ok(pvt->res, buf, name_ok))
goto end;
cp += n; /* name */
if (cp + 3 * INT16SZ + INT32SZ >= eom)
goto end;
cp += INT16SZ; /* type */
cp += INT16SZ + INT32SZ; /* class, TTL */
n = ns_get16(cp);
cp += n + INT16SZ; /* len */
}
return(cp);
end:
return(eom); /* XXX */
}
/* XXX: too many arguments */
static struct addrinfo *
a6_expand(const u_char *ansbuf, const u_char *a6p,
int a6len, const u_char *arp, const u_char *eom,
const struct in6_addr *in6, int plen, const struct addrinfo *pai,
struct pvt *pvt, int (*name_ok)(const char *), int *errorp)
{
struct in6_addr a;
int n, pbyte, plen1, pbyte1, error = 0;
const u_char *cp;
struct addrinfo sentinel, *cur;
char pname[1024], buf[1024]; /* XXX */
*errorp = NETDB_SUCCESS;
memset(&sentinel, 0, sizeof(sentinel));
cur = &sentinel;
/*
* Validate A6 parameters.
*/
if (a6len == 0) { /* an A6 record must contain at least 1 byte. */
error = NO_RECOVERY;
goto bad;
}
/* prefix length check. */
if ((plen1 = *a6p) > 128) {
error = NO_RECOVERY;
goto bad;
}
if (plen1 > plen) {
/*
* New length must not be greater than old one.
* Ignore the record as specified in RFC 2874
* Section 3.1.2.
*/
return(NULL); /* just ignore. */
}
/* boundary check for new plen and prefix addr */
pbyte1 = (plen1 & ~7) / 8;
if ((int)sizeof(struct in6_addr) - pbyte1 > a6len - 1) {
error = NO_RECOVERY;
goto bad;
}
/*
* merge the new prefix portion.
* <--- plen(bits) --->
* <--- pbyte ---><-b->
* 000000000000000pppppxxxxxxxxxxx(= in6, 0: unknown, x: known, p: pad)
* PP++++++++(+ should be merged. P: padding, must be 0)
* <-- plen1-->
* <-pbyte1->
* ^a6p+1
* The result should be:
* 0000000000PP++++++++xxxxxxxxxxx(= a)
*/
pbyte = (plen & ~7) / 8;
a = *in6;
if (pbyte > pbyte1) {
/* N.B. the case of "pbyte1 == 128" is implicitly excluded. */
int b = plen % 8; /* = the length of "pp..." above */
u_char c_hi, c_lo;
memcpy(&a.s6_addr[pbyte1], a6p + 1, pbyte - pbyte1);
if (b > 0) {
c_hi = a6p[pbyte - pbyte1 + 1];
c_lo = in6->s6_addr[pbyte];
a.s6_addr[pbyte] =
(c_hi & (0xff << (8 - b))) |
((0x00ff >> b) & c_lo);
}
}
#if 0 /* for debug */
if ((pvt->res->options & RES_DEBUG) != 0) {
u_char ntopbuf[INET6_ADDRSTRLEN];
inet_ntop(AF_INET6, &a, ntopbuf, sizeof(ntopbuf));
printf("a6_expand: %s\\%d\n", ntopbuf, plen1);
}
#endif
if (plen1 == 0) {
/* Here is the end of A6 chain. make addrinfo, then return. */
return(addr2addrinfo(pai, (const char *)&a));
}
/*
* Expand the new prefix name. Since the prefix name must not be
* compressed (RFC 2874 Section 3.1.1), we could use ns_name_ntop()
* here if it had a stricter boundary check.
*/
cp = a6p + 1 + (sizeof(*in6) - pbyte1);
n = dn_expand(ansbuf, eom, cp, pname, sizeof(pname));
if (n < 0 || !maybe_ok(pvt->res, pname, name_ok)) {
error = NO_RECOVERY;
goto bad;
}
if (cp + n != a6p + a6len) { /* length mismatch */
error = NO_RECOVERY;
goto bad;
}
/*
* we need (more) additional section records, but no one is
* available, which possibly means a malformed answer.
*/
if (arp == NULL) {
error = NO_RECOVERY; /* we can't resolve the chain. */
goto bad;
}
/*
* Loop thru the rest of the buffer, searching for the next A6 record
* that has the same owner name as the prefix name. If found, then
* recursively call this function to expand the whole A6 chain.
*/
plen = plen1;
for (cp = arp; cp != NULL && cp < eom; cp += n) {
int class, type;
n = dn_expand(ansbuf, eom, cp, buf, sizeof(buf));
if (n < 0 || !maybe_ok(pvt->res, buf, name_ok)) {
error = NO_RECOVERY;
goto bad;
}
cp += n; /* name */
if (cp + 3 * INT16SZ + INT32SZ > eom) {
error = NO_RECOVERY;
goto bad;
}
type = ns_get16(cp);
cp += INT16SZ; /* type */
class = ns_get16(cp);
cp += INT16SZ + INT32SZ; /* class, TTL */
n = ns_get16(cp);
cp += INT16SZ; /* len */
if (cp + n > eom) {
error = NO_RECOVERY;
goto bad;
}
if (class != C_IN || type != ns_t_a6) {
/* we are only interested in A6 records. skip others */
continue;
}
if (ns_samename(buf, pname) != 1) {
continue;
}
/* Proceed to the next record in the chain. */
cur->ai_next = a6_expand(ansbuf, cp, n, cp + n, eom,
(const struct in6_addr *)&a,
plen, pai, pvt, name_ok, &error);
if (error != NETDB_SUCCESS)
goto bad;
while (cur && cur->ai_next)
cur = cur->ai_next;
}
return(sentinel.ai_next);
bad:
*errorp = error;
if (sentinel.ai_next)
freeaddrinfo(sentinel.ai_next);
return(NULL);
}
static const char *
dname_subst(const char *qname0, const char *owner0, const char *target) {
char owner[MAXDNAME];
static char qname[MAXDNAME];
const char blabelhead[] = "\\[x"; /* we can assume hex strings */
int qlen, olen;
int bufsiz = sizeof(qname);
/* make local copies, which are canonicalized. */
if (ns_makecanon(qname0, qname, sizeof(qname)) < 0 ||
ns_makecanon(owner0, owner, sizeof(owner)) < 0)
return(NULL);
qlen = strlen(qname);
olen = strlen(owner);
/* from now on, do not refer to qname0 nor owner0. */
/*
* check if QNAME is a subdomain of OWNER.
* XXX: currently, we only handle the following two cases:
* (A) none of the labels are bitlabels, or
* (B) both of the head labels are bitlabels (and the following
* labels are NOT bitlabels).
* If we pass the check, then subtract the remaining part from QNAME.
* ex. (A) qname=www.foo.com,owner=foo.com => new qname=www.
* (B) qname=\[x3ffe0501/32].foo.com,owner=\[x3ffe/16].foo.com
* => new qname=\[x0501/16].
*/
if (ns_samedomain(qname, owner)) { /* check (A) */
/* at this point, qlen must not be smaller than olen */
qname[qlen - olen] = 0;
bufsiz -= (qlen - olen);
} else { /* check (B) */
char *parent0, *parent1;
/* the following 3 have enough size to store 1 bitlabel */
u_char qlabel[64], olabel[64], newlabel[64];
int qlabellen, olabellen;
if (strncmp(qname, blabelhead, 3) != 0 ||
strncmp(owner, blabelhead, 3) != 0)
return(NULL);
/*
* Both two begin with bitlabels. The succeeding parts
* must exact match.
*/
if ((parent0 = strchr(qname, '.')) == NULL ||
(parent1 = strchr(owner, '.')) == NULL)
return(NULL);
/* ns_samename allows names to begin with '.' */
if (ns_samename(parent0, parent1) != 1)
return(NULL);
/* cut the upper domain parts off. */
*(parent0 + 1) = 0;
*(parent1 + 1) = 0;
/* convert the textual form into binary one. */
if (ns_name_pton(qname, qlabel, sizeof(qlabel)) < 0 ||
ns_name_pton(owner, olabel, sizeof(olabel)) < 0)
return(NULL);
if ((qlabellen = *(qlabel + 1)) == 0)
qlabellen = 256;
if ((olabellen = *(olabel + 1)) == 0)
olabellen = 256;
if (olabellen > qlabellen)
return(NULL); /* owner does not contain qname. */
else {
int qplen = (qlabellen + 7) / 8;
int oplen = (olabellen + 7) / 8;
int sft = olabellen % 8;
int nllen, n;
u_char *qp, *op, *np;
/* skip ELT and Count. */
qp = qlabel + 2;
op = olabel + 2;
/* check if olabel is a "subdomain" of qlabel. */
if (memcmp(qp, op, oplen - 1) != 0)
return(NULL);
if (sft > 0) {
/* compare trailing bits (between 1 and 7) */
if ((qp[qplen - 1] & (0xff << sft)) !=
op[qplen - 1])
return(NULL);
}
/* OK, get remaining bits from qlabel. */
np = newlabel;
if (olabellen == qlabellen) {
/*
* Two names (including bitlabels) are exactly
* same. Discard the whole names.
* XXX: ns_samename() above should exclude
* this case...
*/
qname[0] = 0;
goto maketarget;
}
*np++ = 0x41; /* XXX hardcoding */
*np++ = nllen = (qlabellen - olabellen);
if (sft == 0) {
/*
* No alignment issue. can just use memcpy.
* Note that the "else" part below contains
* this case. We separate the two cases just
* for efficiency.
* We assume that ns_name_pton above ensures
* QP does not contain trailing garbages.
*/
memcpy(np, qp + oplen, qplen - oplen);
np += qplen - oplen;
*np = 0;
} else {
/*
* copy the lower (8-SFT) bits of QP to the
* upper (8-SFT) bits of NP, then copy the
* upper SFT bits of QP+1 to the lower SFT bits
* of NP, and so on...
* if QP is xxxyyyyy zzzwww..., then
* NP would be yyyyyzzz ...
* Again, we assume QP does not contain
* trailing garbages.
*/
qp += (oplen - 1);
while (nllen > 0) {
*np = (*qp << sft) & 0xff;
if ((nllen -= (8 - sft)) <= 0)
break; /* done */
qp++;
*np |= ((*qp >> sft) & 0xff);
np++;
nllen -= sft;
}
*++np = 0;
}
/*
* make a new bitlabel with the remaining bits.
* Note that there's no buffer boundary issue, since
* qlabel, olabel, and newlabel all have the same size.
* ns_name_ntop() must not return 0, since we have
* a non-empty bitlabel.
*/
if ((n = ns_name_ntop(newlabel, qname, sizeof(qname)))
<= 0)
return(NULL);
bufsiz -= n;
if (qname[n - 1] != '.') { /* XXX no trailing dot */
qname[n - 1] = '.';
qname[n] = 0;
bufsiz--;
}
}
}
maketarget:
/*
* Finally, append the remaining part (maybe empty) to the new target.
*/
if (bufsiz < (int)strlen(target)) /* bufsiz takes care of the \0. */
return(NULL);
strcat(qname, target);
return((const char *)qname);
}
static void
ho_res_set(struct irs_ho *this, struct __res_state *res,
void (*free_res)(void *)) {
@ -1100,7 +695,6 @@ gethostans(struct irs_ho *this,
char *bp, *ep, **ap, **hap;
char tbuf[MAXDNAME+1];
struct addrinfo sentinel, *cur, ai;
const u_char *arp = NULL;
if (pai == NULL) abort();
if (ret_aip != NULL)
@ -1111,7 +705,6 @@ gethostans(struct irs_ho *this,
tname = qname;
eom = ansbuf + anslen;
switch (qtype) {
case ns_t_a6:
case T_A:
case T_AAAA:
case T_ANY: /* use T_ANY only for T_A/T_AAAA lookup */
@ -1156,8 +749,7 @@ gethostans(struct irs_ho *this,
RES_SET_H_ERRNO(pvt->res, NO_RECOVERY);
return (NULL);
}
if (qtype == T_A || qtype == T_AAAA ||
qtype == ns_t_a6 || qtype == T_ANY) {
if (qtype == T_A || qtype == T_AAAA || qtype == T_ANY) {
/* res_nsend() has already verified that the query name is the
* same as the one we sent; this just gets the expanded name
* (i.e., with the succeeding search-domain tacked on).
@ -1201,8 +793,8 @@ gethostans(struct irs_ho *this,
continue;
}
eor = cp + n;
if ((qtype == T_A || qtype == T_AAAA || qtype == ns_t_a6 ||
qtype == T_ANY) && type == T_CNAME) {
if ((qtype == T_A || qtype == T_AAAA || qtype == T_ANY) &&
type == T_CNAME) {
if (haveanswer) {
int level = LOG_CRIT;
#ifdef LOG_SECURITY
@ -1230,58 +822,16 @@ gethostans(struct irs_ho *this,
had_error++;
continue;
}
#ifdef HAVE_STRLCPY
strlcpy(bp, tbuf, ep - bp);
#else
strcpy(bp, tbuf);
#endif
pvt->host.h_name = bp;
hname = bp;
bp += n;
continue;
}
if (type == ns_t_dname) {
const char *t0, *t;
/*
* just replace the query target; do not update the
* alias list. (Or should we?)
*/
t0 = (qtype == T_PTR) ? tname : hname;
n = dn_expand(ansbuf, eor, cp, tbuf, sizeof(tbuf));
if (n < 0 || !maybe_dnok(pvt->res, tbuf)) {
had_error++;
continue;
}
#ifdef RES_USE_DNAME
if ((pvt ->res->options & RES_USE_DNAME) == 0) {
cp += n;
continue;
}
#endif
if ((t = dname_subst(t0, bp, tbuf)) == NULL) {
cp += n;
continue;
}
#if 0 /* for debug */
if ((pvt->res->options & RES_DEBUG) != 0) {
printf("DNAME owner=%s, target=%s, next=%s\n",
bp, tbuf, t);
}
#endif
cp += n;
n = strlen(t) + 1; /* for the \0 */
if (n > (ep - bp)) {
had_error++;
continue;
}
strcpy(bp, t);
if (qtype == T_PTR)
tname = bp;
else
hname = bp;
bp += n;
continue;
}
if (qtype == T_PTR && type == T_CNAME) {
n = dn_expand(ansbuf, eor, cp, tbuf, sizeof tbuf);
if (n < 0 || !maybe_dnok(pvt->res, tbuf)) {
@ -1308,14 +858,17 @@ gethostans(struct irs_ho *this,
had_error++;
continue;
}
#ifdef HAVE_STRLCPY
strlcpy(bp, tbuf, ep - bp);
#else
strcpy(bp, tbuf);
#endif
tname = bp;
bp += n;
continue;
}
if (qtype == T_ANY) {
if (!(type == T_A || type == T_AAAA ||
type == ns_t_a6)) {
if (!(type == T_A || type == T_AAAA)) {
cp += n;
continue;
}
@ -1354,66 +907,6 @@ gethostans(struct irs_ho *this,
bp += n;
}
break;
case ns_t_a6: {
struct in6_addr in6;
struct addrinfo ai;
#ifdef RES_USE_A6
if ((pvt->res->options & RES_USE_A6) == 0) {
cp += n;
continue;
}
#endif
if (ns_samename(hname, bp) != 1) {
cp += n;
continue;
}
/*
* search for the top of the additional section.
* once found, keep it for the case where we have
* more than one A6 record.
* XXX: however, we may not need this part.
*/
if (arp == NULL && arcount > 0) {
int nscount = ntohs(hp->nscount);
arp = ar_head(cp + n, nscount + ancount - 1,
ansbuf, eom, pvt, name_ok);
}
/* recursively collect the whole A6 chain */
ai = *pai; /* XXX: we can't override constant pai */
ai.ai_family = AF_INET6;
memset(&in6, 0, sizeof(in6)); /* just for safety */
cur->ai_next = a6_expand(ansbuf, cp, n, arp, eom,
&in6, 128,
(const struct addrinfo *)&ai,
pvt, name_ok, &error);
if (error != NETDB_SUCCESS) {
#ifdef DEBUG
/* in this case, cur->ai_next must be NULL. */
if (cur->ai_next != NULL)
abort();
#endif
had_error++;
continue;
}
/*
* We don't bother even if cur->ai_next is NULL unless
* the expansion failed by a fatal error. The list
* can be NULL if the given A6 is incomplete, but we
* may have another complete A6 chain in this answer.
* See the last paragraph of RFC 2874 Section 3.1.4.
*/
if (cur->ai_next == NULL) {
cp += n;
continue; /* no error, no answer */
}
goto convertinfo;
} /* FALLTHROUGH */
case T_A:
case T_AAAA:
if (ns_samename(hname, bp) != 1) {
@ -1438,7 +931,6 @@ gethostans(struct irs_ho *this,
if (cur->ai_next == NULL)
had_error++;
convertinfo: /* convert addrinfo into hostent form */
if (!haveanswer) {
int nn;
@ -1479,7 +971,7 @@ gethostans(struct irs_ho *this,
continue;
if (hap < &pvt->h_addr_ptrs[MAXADDRS-1])
hap++;
*hap = NULL;
bp += m;
}
@ -1506,7 +998,11 @@ gethostans(struct irs_ho *this,
n = strlen(qname) + 1; /* for the \0 */
if (n > (ep - bp) || n >= MAXHOSTNAMELEN)
goto no_recovery;
#ifdef HAVE_STRLCPY
strlcpy(bp, qname, ep - bp);
#else
strcpy(bp, qname);
#endif
pvt->host.h_name = bp;
bp += n;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: dns_nw.c,v 1.4 2002/06/28 06:20:55 itojun Exp $ */
/* $NetBSD: dns_nw.c,v 1.5 2003/06/03 07:33:55 itojun Exp $ */
/*
* Copyright (c) 1996-1999 by Internet Software Consortium.
@ -18,7 +18,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "Id: dns_nw.c,v 1.23 2002/06/26 07:42:06 marka Exp";
static const char rcsid[] = "Id: dns_nw.c,v 1.25 2002/07/18 02:07:43 marka Exp";
#endif /* LIBC_SCCS and not lint */
/* Imports. */
@ -351,7 +351,12 @@ get1101answer(struct irs_nw *this,
RES_SET_H_ERRNO(pvt->res, NO_RECOVERY);
return (NULL);
}
#ifdef HAVE_STRLCPY
strlcpy(bp, name, ep - bp);
pvt->net.n_name = bp;
#else
pvt->net.n_name = strcpy(bp, name);
#endif
bp += n;
}
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: gen_gr.c,v 1.3 2002/06/20 11:43:04 itojun Exp $ */
/* $NetBSD: gen_gr.c,v 1.4 2003/06/03 07:33:56 itojun Exp $ */
/*
* Copyright (c) 1996-1999 by Internet Software Consortium.
@ -18,7 +18,7 @@
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "Id: gen_gr.c,v 1.25 2001/06/07 02:12:26 marka Exp";
static const char rcsid[] = "Id: gen_gr.c,v 1.26 2002/07/18 02:07:44 marka Exp";
#endif
/* Imports */
@ -326,7 +326,7 @@ gr_res_set(struct irs_gr *this, struct __res_state *res,
static void
grmerge(struct irs_gr *this, const struct group *src, int preserve) {
struct pvt *pvt = (struct pvt *)this->private;
char *cp, **m, **p, *oldmembuf;
char *cp, **m, **p, *oldmembuf, *ep;
int n, ndst, nnew;
size_t used;
@ -381,6 +381,7 @@ grmerge(struct irs_gr *this, const struct group *src, int preserve) {
/* No harm done, no work done. */
return;
}
ep = cp + used + n;
if (used != 0)
memcpy(cp, pvt->membuf, used);
oldmembuf = pvt->membuf;
@ -402,7 +403,11 @@ grmerge(struct irs_gr *this, const struct group *src, int preserve) {
if (isnew(pvt->group.gr_mem, *m)) {
*p++ = cp;
*p = NULL;
#ifdef HAVE_STRLCPY
strlcpy(cp, *m, ep - cp);
#else
strcpy(cp, *m);
#endif
cp += strlen(cp) + 1;
}
if (preserve) {
@ -412,10 +417,18 @@ grmerge(struct irs_gr *this, const struct group *src, int preserve) {
(pvt->group.gr_passwd - oldmembuf);
} else {
pvt->group.gr_name = cp;
#ifdef HAVE_STRLCPY
strlcpy(cp, src->gr_name, ep - cp);
#else
strcpy(cp, src->gr_name);
#endif
cp += strlen(src->gr_name) + 1;
pvt->group.gr_passwd = cp;
#ifdef HAVE_STRLCPY
strlcpy(cp, src->gr_passwd, ep - cp);
#else
strcpy(cp, src->gr_passwd);
#endif
cp += strlen(src->gr_passwd) + 1;
}
if (oldmembuf != NULL)

View File

@ -1,4 +1,4 @@
/* $NetBSD: getaddrinfo.c,v 1.4 2002/07/04 23:30:40 itojun Exp $ */
/* $NetBSD: getaddrinfo.c,v 1.5 2003/06/03 07:33:56 itojun Exp $ */
/* $KAME: getaddrinfo.c,v 1.14 2001/01/06 09:41:15 jinmei Exp $ */
@ -103,17 +103,12 @@
#include <stdarg.h>
#include <irs.h>
#include <isc/assertions.h>
#include "port_after.h"
#include "irs_data.h"
/*
* if we enable it, we will see duplicated addrinfo entries on reply if both
* AAAA and A6 records are found. disable it for default installation.
*/
#undef T_A6
#define SUCCESS 0
#define ANY 0
#define YES 1
@ -194,7 +189,8 @@ static int get_portmatch __P((const struct addrinfo *, const char *));
static int get_port __P((const struct addrinfo *, const char *, int));
static const struct afd *find_afd __P((int));
static int addrconfig __P((int));
static u_int32_t ip6_str2scopeid __P((char *, struct sockaddr_in6 *));
static int ip6_str2scopeid __P((char *, struct sockaddr_in6 *,
u_int32_t *scopeidp));
static struct net_data *init __P((void));
struct addrinfo *hostent2addrinfo __P((struct hostent *,
@ -598,7 +594,7 @@ explore_fqdn(pai, hostname, servname, res)
char tmp[NS_MAXDNAME];
const char *cp;
*res = NULL;
INSIST(res != NULL && *res == NULL);
/*
* if the servname does not match socktype/protocol, ignore it.
@ -857,13 +853,13 @@ explore_numeric_scope(pai, hostname, servname, res)
error = explore_numeric(pai, addr, servname, res);
if (error == 0) {
u_int32_t scopeid;
u_int32_t scopeid = 0;
for (cur = *res; cur; cur = cur->ai_next) {
if (cur->ai_family != AF_INET6)
continue;
sin6 = (struct sockaddr_in6 *)(void *)cur->ai_addr;
if ((scopeid = ip6_str2scopeid(scope, sin6)) == -1) {
if (!ip6_str2scopeid(scope, sin6, &scopeid)) {
free(hostname2);
return(EAI_NONAME); /* XXX: is return OK? */
}
@ -993,7 +989,17 @@ get_port(const struct addrinfo *ai, const char *servname, int matchonly) {
allownumeric = 1;
break;
case ANY:
allownumeric = 0;
switch (ai->ai_family) {
case AF_INET:
#ifdef AF_INET6
case AF_INET6:
#endif
allownumeric = 1;
break;
default:
allownumeric = 0;
break;
}
break;
default:
return EAI_SOCKTYPE;
@ -1078,19 +1084,18 @@ addrconfig(af)
}
/* convert a string to a scope identifier. XXX: IPv6 specific */
static u_int32_t
ip6_str2scopeid(scope, sin6)
char *scope;
struct sockaddr_in6 *sin6;
static int
ip6_str2scopeid(char *scope, struct sockaddr_in6 *sin6,
u_int32_t *scopeidp)
{
u_int32_t scopeid;
u_long lscopeid;
struct in6_addr *a6 = &sin6->sin6_addr;
char *ep;
/* empty scopeid portion is invalid */
if (*scope == '\0')
return -1;
return (0);
#ifdef USE_IFNAMELINKID
if (IN6_IS_ADDR_LINKLOCAL(a6) || IN6_IS_ADDR_MC_LINKLOCAL(a6)) {
@ -1101,8 +1106,8 @@ ip6_str2scopeid(scope, sin6)
*/
scopeid = if_nametoindex(scope);
if (scopeid == 0)
goto trynumeric;
return(scopeid);
*scopeidp = scopeid;
return (1);
}
#endif
@ -1118,11 +1123,12 @@ ip6_str2scopeid(scope, sin6)
trynumeric:
errno = 0;
lscopeid = strtoul(scope, &ep, 10);
scopeid = lscopeid & 0xffffffffUL;
if (errno == 0 && ep && *ep == '\0' && scopeid == lscopeid)
return scopeid;
else
return -1;
scopeid = lscopeid & 0xffffffff;
if (errno == 0 && ep && *ep == '\0' && scopeid == lscopeid) {
*scopeidp = scopeid;
return (1);
} else
return (0);
}
struct addrinfo *

View File

@ -1,4 +1,4 @@
/* $NetBSD: gethostent.c,v 1.4 2002/06/20 11:43:04 itojun Exp $ */
/* $NetBSD: gethostent.c,v 1.5 2003/06/03 07:33:57 itojun Exp $ */
/*
* Copyright (c) 1996-1999 by Internet Software Consortium.
@ -18,7 +18,7 @@
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "Id: gethostent.c,v 1.32 2002/05/27 06:50:55 marka Exp";
static const char rcsid[] = "Id: gethostent.c,v 1.32.10.1 2003/06/02 07:53:31 marka Exp";
#endif
/* Imports */
@ -484,7 +484,7 @@ freehostent(struct hostent *he) {
#define LIFREQ lifreq
#endif
static int
static void
scan_interfaces6(int *have_v4, int *have_v6) {
struct LIFCONF lifc;
struct LIFREQ lifreq;
@ -494,12 +494,9 @@ scan_interfaces6(int *have_v4, int *have_v6) {
static unsigned int bufsiz = 4095;
int s, cpsize, n;
/* Set to zero. Used as loop terminators below. */
*have_v4 = *have_v6 = 0;
/* Get interface list from system. */
if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) == -1)
goto err_ret;
goto cleanup;
/*
* Grow buffer until large enough to contain all interface
@ -508,7 +505,7 @@ scan_interfaces6(int *have_v4, int *have_v6) {
for (;;) {
buf = memget(bufsiz);
if (buf == NULL)
goto err_ret;
goto cleanup;
#ifdef SETFAMILYFLAGS
lifc.lifc_family = AF_UNSPEC; /* request all families */
lifc.lifc_flags = 0;
@ -528,10 +525,10 @@ scan_interfaces6(int *have_v4, int *have_v6) {
break;
}
if ((n == -1) && errno != EINVAL)
goto err_ret;
goto cleanup;
if (bufsiz > 1000000)
goto err_ret;
goto cleanup;
memput(buf, bufsiz);
bufsiz += 4096;
@ -602,16 +599,35 @@ scan_interfaces6(int *have_v4, int *have_v6) {
memput(buf, bufsiz);
close(s);
/* printf("scan interface -> 4=%d 6=%d\n", *have_v4, *have_v6); */
return (0);
err_ret:
return;
cleanup:
if (buf != NULL)
memput(buf, bufsiz);
if (s != -1)
close(s);
/* printf("scan interface -> 4=%d 6=%d\n", *have_v4, *have_v6); */
return (-1);
return;
}
#endif
#ifdef __linux
static void
scan_linux6(int *have_v6) {
FILE *proc = NULL;
char address[33];
char name[IF_NAMESIZE+1];
int ifindex, prefix, flag3, flag4;
proc = fopen("/proc/net/if_inet6", "r");
if (proc == NULL)
return;
if (fscanf(proc, "%32[a-f0-9] %x %x %x %x %16s\n",
address, &ifindex, &prefix, &flag3, &flag4, name) == 6)
*have_v6 = 1;
fclose(proc);
return;
}
#endif
static int
@ -628,17 +644,21 @@ scan_interfaces(int *have_v4, int *have_v6) {
int s, n;
size_t cpsize;
/* Set to zero. Used as loop terminators below. */
*have_v4 = *have_v6 = 0;
#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR) && \
!defined(IRIX_EMUL_IOCTL_SIOCGIFCONF)
/*
* Try to scan the interfaces using IPv6 ioctls().
*/
if (!scan_interfaces6(have_v4, have_v6))
scan_interfaces6(have_v4, have_v6);
if (*have_v4 != 0 && *have_v6 != 0)
return (0);
#endif
/* Set to zero. Used as loop terminators below. */
*have_v4 = *have_v6 = 0;
#ifdef __linux
scan_linux6(have_v6);
#endif
/* Get interface list from system. */
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1)

View File

@ -1,4 +1,4 @@
/* $NetBSD: getnameinfo.c,v 1.4 2002/06/28 06:40:52 itojun Exp $ */
/* $NetBSD: getnameinfo.c,v 1.5 2003/06/03 07:33:58 itojun Exp $ */
/*
* Issues to be discussed:
@ -46,6 +46,7 @@
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <netdb.h>
#include <resolv.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: getnetgrent.c,v 1.2 2002/06/20 11:43:04 itojun Exp $ */
/* $NetBSD: getnetgrent.c,v 1.3 2003/06/03 07:33:59 itojun Exp $ */
/*
* Copyright (c) 1996,1999 by Internet Software Consortium.
@ -18,7 +18,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "Id: getnetgrent.c,v 1.15 2001/05/29 05:48:49 marka Exp";
static const char rcsid[] = "Id: getnetgrent.c,v 1.16.6.1 2003/06/02 06:06:58 marka Exp";
#endif /* LIBC_SCCS and not lint */
/* Imports */
@ -49,8 +49,11 @@ static struct net_data *init(void);
/* Public */
#ifndef SETNETGRENT_ARGS
#define SETNETGRENT_ARGS const char *netgroup
#endif
void
setnetgrent(const char *netgroup) {
setnetgrent(SETNETGRENT_ARGS) {
struct net_data *net_data = init();
setnetgrent_p(netgroup, net_data);
@ -63,19 +66,31 @@ endnetgrent(void) {
endnetgrent_p(net_data);
}
#ifndef INNETGR_ARGS
#define INNETGR_ARGS const char *netgroup, const char *host, \
const char *user, const char *domain
#endif
int
innetgr(const char *netgroup, const char *host,
const char *user, const char *domain) {
innetgr(INNETGR_ARGS) {
struct net_data *net_data = init();
return (innetgr_p(netgroup, host, user, domain, net_data));
}
int
getnetgrent(const char **host, const char **user, const char **domain) {
getnetgrent(char **host, char **user, char **domain) {
struct net_data *net_data = init();
const char *ch, *cu, *cd;
int ret;
return (getnetgrent_p(host, user, domain, net_data));
ret = getnetgrent_p(&ch, &cu, &cd, net_data);
if (ret != 1)
return (ret);
DE_CONST(ch, *host);
DE_CONST(cu, *user);
DE_CONST(cd, *domain);
return (ret);
}
/* Shared private. */

View File

@ -1,4 +1,4 @@
/* $NetBSD: getnetgrent_r.c,v 1.2 2002/06/20 11:43:04 itojun Exp $ */
/* $NetBSD: getnetgrent_r.c,v 1.3 2003/06/03 07:33:59 itojun Exp $ */
/*
* Copyright (c) 1998-1999 by Internet Software Consortium.
@ -18,7 +18,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "Id: getnetgrent_r.c,v 8.6 2001/11/01 08:02:12 marka Exp";
static const char rcsid[] = "Id: getnetgrent_r.c,v 8.6.10.1 2003/06/02 06:06:58 marka Exp";
#endif /* LIBC_SCCS and not lint */
#include <port_before.h>
@ -43,9 +43,15 @@ copy_protoent(char **, char **, char **, const char *, const char *,
NGR_R_RETURN
innetgr_r(const char *netgroup, const char *host, const char *user,
const char *domain) {
const char *domain) {
char *ng, *ho, *us, *dom;
return (innetgr(netgroup, host, user, domain));
DE_CONST(netgroup, ng);
DE_CONST(host, ho);
DE_CONST(user, us);
DE_CONST(domain, dom);
return (innetgr(ng, ho, us, dom));
}
/*
@ -56,7 +62,7 @@ innetgr_r(const char *netgroup, const char *host, const char *user,
NGR_R_RETURN
getnetgrent_r(char **machinep, char **userp, char **domainp, NGR_R_ARGS) {
const char *mp, *up, *dp;
char *mp, *up, *dp;
int res = getnetgrent(&mp, &up, &dp);
if (res != 1)

View File

@ -1,7 +1,7 @@
/* $NetBSD: hesiod.c,v 1.3 2002/06/20 11:43:04 itojun Exp $ */
/* $NetBSD: hesiod.c,v 1.4 2003/06/03 07:33:59 itojun Exp $ */
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "Id: hesiod.c,v 1.22 2001/05/29 05:48:55 marka Exp";
static const char rcsid[] = "Id: hesiod.c,v 1.23 2002/07/18 02:07:45 marka Exp";
#endif
/*
@ -100,8 +100,13 @@ hesiod_init(void **context) {
errno = ENOMEM;
goto cleanup;
}
#ifdef HAVE_STRLCPY
strlcpy(ctx->LHS, DEF_LHS, strlen(DEF_LHS) + 1);
strlcpy(ctx->RHS, DEF_RHS, strlen(DEF_RHS) + 1);
#else
strcpy(ctx->LHS, DEF_LHS);
strcpy(ctx->RHS, DEF_RHS);
#endif
#else
goto cleanup;
#endif
@ -111,18 +116,31 @@ hesiod_init(void **context) {
* variable.
*/
if ((cp = getenv("HES_DOMAIN")) != NULL) {
size_t RHSlen = strlen(cp) + 2;
if (ctx->RHS)
free(ctx->RHS);
ctx->RHS = malloc(strlen(cp)+2);
ctx->RHS = malloc(RHSlen);
if (!ctx->RHS) {
errno = ENOMEM;
goto cleanup;
}
if (cp[0] == '.')
if (cp[0] == '.') {
#ifdef HAVE_STRLCPY
strlcpy(ctx->RHS, cp, RHSlen);
#else
strcpy(ctx->RHS, cp);
else {
#endif
} else {
#ifdef HAVE_STRLCPY
strlcpy(ctx->RHS, ".", RHSlen);
#else
strcpy(ctx->RHS, ".");
#endif
#ifdef HAVE_STRLCAT
strlcat(ctx->RHS, cp, RHSlen);
#else
strcat(ctx->RHS, cp);
#endif
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: irp_p.h,v 1.3 2002/06/20 11:43:05 itojun Exp $ */
/* $NetBSD: irp_p.h,v 1.4 2003/06/03 07:34:00 itojun Exp $ */
/*
* Copyright (c) 1996 by Internet Software Consortium.
@ -18,7 +18,7 @@
*/
/*
* Id: irp_p.h,v 8.2 2001/08/10 02:40:52 marka Exp
* Id: irp_p.h,v 8.2.10.1 2003/06/02 05:55:14 marka Exp
*/
#ifndef _IRP_P_H_INCLUDED
@ -55,8 +55,6 @@ char *irs_irp_read_body(struct irp_p *pvt, size_t *size);
int irs_irp_get_full_response(struct irp_p *pvt, int *code,
char *text, size_t textlen,
char **body, size_t *bodylen);
int irs_irp_send_command(struct irp_p *pvt, const char *fmt, ...) ISC_FORMAT_PRINTF(2, 3);
extern int irp_log_errors;

View File

@ -1,4 +1,4 @@
/* $NetBSD: irs_data.c,v 1.5 2002/06/20 11:43:05 itojun Exp $ */
/* $NetBSD: irs_data.c,v 1.6 2003/06/03 07:34:00 itojun Exp $ */
/*
* Copyright (c) 1996,1999 by Internet Software Consortium.
@ -18,7 +18,7 @@
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "Id: irs_data.c,v 1.19 2001/08/20 07:08:41 marka Exp";
static const char rcsid[] = "Id: irs_data.c,v 1.20.2.1 2003/06/02 10:09:48 marka Exp";
#endif
#include "port_before.h"
@ -40,6 +40,7 @@ static const char rcsid[] = "Id: irs_data.c,v 1.19 2001/08/20 07:08:41 marka Exp
#endif
#include <irs.h>
#include <stdlib.h>
#include "port_after.h"
@ -98,6 +99,14 @@ net_data_destroy(void *p) {
(*net_data->ng->close)(net_data->ng);
net_data->ng = NULL;
}
if (net_data->ho_data != NULL) {
free(net_data->ho_data);
net_data->ho_data = NULL;
}
if (net_data->nw_data != NULL) {
free(net_data->nw_data);
net_data->nw_data = NULL;
}
(*net_data->irs->close)(net_data->irs);
memput(net_data, sizeof *net_data);
@ -144,19 +153,27 @@ net_data_create(const char *conf_file) {
return (NULL);
memset(net_data, 0, sizeof (struct net_data));
if ((net_data->irs = irs_gen_acc("", conf_file)) == NULL)
if ((net_data->irs = irs_gen_acc("", conf_file)) == NULL) {
memput(net_data, sizeof (struct net_data));
return (NULL);
}
#ifndef DO_PTHREADS
(*net_data->irs->res_set)(net_data->irs, &_res, NULL);
#endif
net_data->res = (*net_data->irs->res_get)(net_data->irs);
if (net_data->res == NULL)
if (net_data->res == NULL) {
(*net_data->irs->close)(net_data->irs);
memput(net_data, sizeof (struct net_data));
return (NULL);
}
if ((net_data->res->options & RES_INIT) == 0 &&
res_ninit(net_data->res) == -1)
res_ninit(net_data->res) == -1) {
(*net_data->irs->close)(net_data->irs);
memput(net_data, sizeof (struct net_data));
return (NULL);
}
return (net_data);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: nis_gr.c,v 1.2 2002/06/20 11:43:05 itojun Exp $ */
/* $NetBSD: nis_gr.c,v 1.3 2003/06/03 07:34:01 itojun Exp $ */
/*
* Copyright (c) 1989, 1993, 1995
@ -51,7 +51,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "Id: nis_gr.c,v 1.21 2001/05/29 05:49:12 marka Exp";
static const char rcsid[] = "Id: nis_gr.c,v 1.22 2002/07/08 06:26:11 marka Exp";
/* from getgrent.c 8.2 (Berkeley) 3/21/94"; */
/* from BSDI Id: getgrent.c,v 2.8 1996/05/28 18:15:14 bostic Exp $ */
#endif /* LIBC_SCCS and not lint */
@ -288,7 +288,7 @@ makegroupent(struct irs_gr *this) {
goto cleanup;
*cp++ = '\0';
errno = -1;
errno = 0;
t = strtoul(cp, NULL, 10);
if (errno == ERANGE)
goto cleanup;

View File

@ -1,4 +1,4 @@
/* $NetBSD: nis_ho.c,v 1.2 2002/06/20 11:43:05 itojun Exp $ */
/* $NetBSD: nis_ho.c,v 1.3 2003/06/03 07:34:01 itojun Exp $ */
/*
* Copyright (c) 1996,1999 by Internet Software Consortium.
@ -18,7 +18,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "Id: nis_ho.c,v 1.18 2001/06/18 14:44:00 marka Exp";
static const char rcsid[] = "Id: nis_ho.c,v 1.18.10.1 2003/06/02 05:50:57 marka Exp";
#endif /* LIBC_SCCS and not lint */
/* Imports */
@ -89,6 +89,9 @@ static const u_char mapped[] = { 0,0, 0,0, 0,0, 0,0, 0,0, 0xff,0xff };
static const u_char tunnelled[] = { 0,0, 0,0, 0,0, 0,0, 0,0, 0,0 };
static /*const*/ char hosts_byname[] = "hosts.byname";
static /*const*/ char hosts_byaddr[] = "hosts.byaddr";
static /*const*/ char ipnode_byname[] = "ipnode.byname";
static /*const*/ char ipnode_byaddr[] = "ipnode.byaddr";
static /*const*/ char yp_multi[] = "YP_MULTI_";
/* Forwards */
@ -188,9 +191,32 @@ ho_byname2(struct irs_ho *this, const char *name, int af) {
return (NULL);
nisfree(pvt, do_val);
DE_CONST(name, tmp);
r = yp_match(pvt->nis_domain, hosts_byname, tmp,
strcpy(pvt->hostbuf, yp_multi);
strncat(pvt->hostbuf, name, sizeof(pvt->hostbuf) - sizeof(yp_multi));
pvt->hostbuf[sizeof(pvt->hostbuf) - 1] = '\0';
for (r = sizeof(yp_multi) - 1; pvt->hostbuf[r] != '\0'; r++)
if (isupper((unsigned char)pvt->hostbuf[r]))
tolower(pvt->hostbuf[r]);
tmp = pvt->hostbuf;
r = yp_match(pvt->nis_domain, ipnode_byname, tmp,
strlen(tmp), &pvt->curval_data, &pvt->curval_len);
if (r != 0) {
tmp = pvt->hostbuf + sizeof(yp_multi) - 1;
r = yp_match(pvt->nis_domain, ipnode_byname, tmp,
strlen(tmp), &pvt->curval_data, &pvt->curval_len);
}
if (r != 0) {
tmp = pvt->hostbuf;
r = yp_match(pvt->nis_domain, hosts_byname, tmp,
strlen(tmp), &pvt->curval_data, &pvt->curval_len);
}
if (r != 0) {
tmp = pvt->hostbuf + sizeof(yp_multi) - 1;
r = yp_match(pvt->nis_domain, hosts_byname, tmp,
strlen(tmp), &pvt->curval_data, &pvt->curval_len);
}
if (r != 0) {
RES_SET_H_ERRNO(pvt->res, HOST_NOT_FOUND);
return (NULL);
@ -222,8 +248,11 @@ ho_byaddr(struct irs_ho *this, const void *addr, int len, int af) {
return (NULL);
}
nisfree(pvt, do_val);
r = yp_match(pvt->nis_domain, hosts_byaddr, tmp, strlen(tmp),
r = yp_match(pvt->nis_domain, ipnode_byaddr, tmp, strlen(tmp),
&pvt->curval_data, &pvt->curval_len);
if (r != 0)
r = yp_match(pvt->nis_domain, hosts_byaddr, tmp, strlen(tmp),
&pvt->curval_data, &pvt->curval_len);
if (r != 0) {
RES_SET_H_ERRNO(pvt->res, HOST_NOT_FOUND);
return (NULL);
@ -384,12 +413,35 @@ ho_addrinfo(struct irs_ho *this, const char *name, const struct addrinfo *pai)
/* Private */
/*
ipnodes:
::1 localhost
127.0.0.1 localhost
1.2.3.4 FOO bar
1.2.6.4 FOO bar
1.2.6.5 host
ipnodes.byname:
YP_MULTI_localhost ::1,127.0.0.1 localhost
YP_MULTI_foo 1.2.3.4,1.2.6.4 FOO bar
YP_MULTI_bar 1.2.3.4,1.2.6.4 FOO bar
host 1.2.6.5 host
hosts.byname:
localhost 127.0.0.1 localhost
host 1.2.6.5 host
YP_MULTI_foo 1.2.3.4,1.2.6.4 FOO bar
YP_MULTI_bar 1.2.3.4,1.2.6.4 FOO bar
*/
static struct hostent *
makehostent(struct irs_ho *this) {
struct pvt *pvt = (struct pvt *)this->private;
static const char spaces[] = " \t";
char *cp, **q, *p;
int af, len;
char *cp, **q, *p, *comma, *ap;
int af = 0, len = 0;
int multi = 0;
int addr = 0;
p = pvt->curval_data;
if ((cp = strpbrk(p, "#\n")) != NULL)
@ -397,25 +449,40 @@ makehostent(struct irs_ho *this) {
if (!(cp = strpbrk(p, spaces)))
return (NULL);
*cp++ = '\0';
if ((pvt->res->options & RES_USE_INET6) &&
inet_pton(AF_INET6, p, pvt->host_addr) > 0) {
af = AF_INET6;
len = IN6ADDRSZ;
} else if (inet_pton(AF_INET, p, pvt->host_addr) > 0) {
if (pvt->res->options & RES_USE_INET6) {
map_v4v6_address((char*)pvt->host_addr,
(char*)pvt->host_addr);
ap = pvt->hostbuf;
do {
if ((comma = strchr(p, ',')) != NULL) {
*comma++ = '\0';
multi = 1;
}
if ((ap + IN6ADDRSZ) > (pvt->hostbuf + sizeof(pvt->hostbuf)))
break;
if ((pvt->res->options & RES_USE_INET6) &&
inet_pton(AF_INET6, p, ap) > 0) {
af = AF_INET6;
len = IN6ADDRSZ;
} else if (inet_pton(AF_INET, p, pvt->host_addr) > 0) {
if (pvt->res->options & RES_USE_INET6) {
map_v4v6_address((char*)pvt->host_addr, ap);
af = AF_INET6;
len = IN6ADDRSZ;
} else {
af = AF_INET;
len = INADDRSZ;
}
} else {
af = AF_INET;
len = INADDRSZ;
if (!multi)
return (NULL);
continue;
}
} else {
if (addr < MAXADDRS) {
pvt->h_addr_ptrs[addr++] = ap;
pvt->h_addr_ptrs[addr] = NULL;
ap += len;
}
} while ((p = comma) != NULL);
if (ap == pvt->hostbuf)
return (NULL);
}
pvt->h_addr_ptrs[0] = (char *)pvt->host_addr;
pvt->h_addr_ptrs[1] = NULL;
pvt->host.h_addr_list = pvt->h_addr_ptrs;
pvt->host.h_length = len;
pvt->host.h_addrtype = af;

View File

@ -1,7 +1,7 @@
/* $NetBSD: ctl_clnt.c,v 1.4 2002/06/20 11:43:06 itojun Exp $ */
/* $NetBSD: ctl_clnt.c,v 1.5 2003/06/03 07:34:02 itojun Exp $ */
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "Id: ctl_clnt.c,v 8.17 2001/06/06 00:33:35 marka Exp";
static const char rcsid[] = "Id: ctl_clnt.c,v 8.18 2002/07/08 05:10:23 marka Exp";
#endif /* not lint */
/*

View File

@ -1,7 +1,7 @@
/* $NetBSD: ctl_srvr.c,v 1.4 2002/06/20 11:43:07 itojun Exp $ */
/* $NetBSD: ctl_srvr.c,v 1.5 2003/06/03 07:34:03 itojun Exp $ */
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "Id: ctl_srvr.c,v 8.25 2001/05/29 05:49:27 marka Exp";
static const char rcsid[] = "Id: ctl_srvr.c,v 8.26 2002/07/08 05:10:25 marka Exp";
#endif /* not lint */
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: ev_files.c,v 1.3 2002/06/20 11:43:07 itojun Exp $ */
/* $NetBSD: ev_files.c,v 1.4 2003/06/03 07:34:03 itojun Exp $ */
/*
* Copyright (c) 1995-1999 by Internet Software Consortium
@ -22,7 +22,7 @@
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "Id: ev_files.c,v 1.21 2001/11/01 05:35:46 marka Exp";
static const char rcsid[] = "Id: ev_files.c,v 1.22 2002/07/08 05:50:07 marka Exp";
#endif
#include "port_before.h"

View File

@ -1,4 +1,4 @@
/* $NetBSD: ev_timers.c,v 1.6 2002/07/04 23:30:40 itojun Exp $ */
/* $NetBSD: ev_timers.c,v 1.7 2003/06/03 07:34:04 itojun Exp $ */
/*
* Copyright (c) 1995-1999 by Internet Software Consortium
@ -22,7 +22,7 @@
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "Id: ev_timers.c,v 1.32 2001/11/01 05:35:47 marka Exp";
static const char rcsid[] = "Id: ev_timers.c,v 1.33 2002/07/08 05:50:09 marka Exp";
#endif
/* Import. */

View File

@ -1,4 +1,4 @@
/* $NetBSD: ev_waits.c,v 1.3 2001/01/27 07:22:04 itojun Exp $ */
/* $NetBSD: ev_waits.c,v 1.4 2003/06/03 07:34:04 itojun Exp $ */
/*
* Copyright (c) 1996-1999 by Internet Software Consortium
@ -22,7 +22,7 @@
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "Id: ev_waits.c,v 8.11 2000/07/20 18:17:52 vixie Exp";
static const char rcsid[] = "Id: ev_waits.c,v 8.12 2002/07/08 05:50:10 marka Exp";
#endif
#include "port_before.h"

View File

@ -1,4 +1,4 @@
/* $NetBSD: eventlib.c,v 1.5 2002/07/04 23:30:40 itojun Exp $ */
/* $NetBSD: eventlib.c,v 1.6 2003/06/03 07:34:05 itojun Exp $ */
/*
* Copyright (c) 1995-1999 by Internet Software Consortium
@ -22,7 +22,7 @@
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "Id: eventlib.c,v 1.46 2001/11/01 05:35:48 marka Exp";
static const char rcsid[] = "Id: eventlib.c,v 1.48 2002/07/17 07:37:34 marka Exp";
#endif
#include "port_before.h"
@ -298,7 +298,7 @@ evGetNext(evContext opaqueCtx, evEvent *opaqueEv, int options) {
(u_long)ctx->rdLast.fds_bits[0],
(u_long)ctx->wrLast.fds_bits[0],
(u_long)ctx->exLast.fds_bits[0],
tp ? (long)tp->tv_sec : -1,
tp ? (long)tp->tv_sec : -1L,
tp ? tp->tv_nsec : -1);
/* XXX should predict system's earliness and adjust. */

View File

@ -1,4 +1,4 @@
/* $NetBSD: eventlib_p.h,v 1.4 2002/06/20 11:43:07 itojun Exp $ */
/* $NetBSD: eventlib_p.h,v 1.5 2003/06/03 07:34:05 itojun Exp $ */
/*
* Copyright (c) 1995-1999 by Internet Software Consortium
@ -20,7 +20,7 @@
/* eventlib_p.h - private interfaces for eventlib
* vix 09sep95 [initial]
*
* Id: eventlib_p.h,v 1.30 2001/11/01 05:35:50 marka Exp
* Id: eventlib_p.h,v 1.31 2003/04/03 05:37:56 marka Exp
*/
#ifndef _EVENTLIB_P_H
@ -201,7 +201,7 @@ typedef struct {
/* eventlib.c */
#define evPrintf __evPrintf
void evPrintf(const evContext_p *ctx, int level, const char *fmt, ...)
__attribute__((__format__(__printf__, 3, 4)));
ISC_FORMAT_PRINTF(3, 4);
/* ev_timers.c */
#define evCreateTimers __evCreateTimers

View File

@ -1,4 +1,4 @@
/* $NetBSD: logging.c,v 1.3 2002/06/20 11:43:07 itojun Exp $ */
/* $NetBSD: logging.c,v 1.4 2003/06/03 07:34:06 itojun Exp $ */
/*
* Copyright (c) 1996-1999 by Internet Software Consortium.
@ -18,7 +18,7 @@
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "Id: logging.c,v 8.31 2001/06/18 14:44:03 marka Exp";
static const char rcsid[] = "Id: logging.c,v 8.32 2003/01/02 00:35:42 marka Exp";
#endif /* not lint */
#include "port_before.h"
@ -284,6 +284,10 @@ log_vwrite(log_context lc, int category, int level, const char *format,
log_channel chan;
struct timeval tv;
struct tm *local_tm;
#ifdef HAVE_TIME_R
struct tm tm_tmp;
#endif
time_t tt;
const char *category_name;
const char *level_str;
char time_buf[256];
@ -315,10 +319,11 @@ log_vwrite(log_context lc, int category, int level, const char *format,
if (gettimeofday(&tv, NULL) < 0) {
syslog(LOG_INFO, "gettimeofday failed in log_vwrite()");
} else {
tt = tv.tv_sec;
#ifdef HAVE_TIME_R
localtime_r((time_t *)&tv.tv_sec, &local_tm);
local_tm = localtime_r(&tt, &tm_tmp);
#else
local_tm = localtime((time_t *)&tv.tv_sec);
local_tm = localtime(&tt);
#endif
if (local_tm != NULL) {
sprintf(time_buf, "%02d-%s-%4d %02d:%02d:%02d.%03ld ",

View File

@ -1,4 +1,4 @@
/* $NetBSD: ns_name.c,v 1.8 2002/11/17 14:09:53 itojun Exp $ */
/* $NetBSD: ns_name.c,v 1.9 2003/06/03 07:34:06 itojun Exp $ */
/*
* Copyright (c) 1996,1999 by Internet Software Consortium.
@ -18,7 +18,7 @@
*/
#ifndef lint
static const char rcsid[] = "Id: ns_name.c,v 8.18.4.1 2002/11/14 13:32:08 marka Exp";
static const char rcsid[] = "Id: ns_name.c,v 8.20 2003/04/03 06:00:07 marka Exp";
#endif
#include "port_before.h"

View File

@ -1,4 +1,4 @@
/* $NetBSD: ns_parse.c,v 1.4 2002/06/20 11:43:08 itojun Exp $ */
/* $NetBSD: ns_parse.c,v 1.5 2003/06/03 07:34:07 itojun Exp $ */
/*
* Copyright (c) 1996,1999 by Internet Software Consortium.
@ -18,7 +18,7 @@
*/
#ifndef lint
static const char rcsid[] = "Id: ns_parse.c,v 8.17 2001/06/20 02:50:49 marka Exp";
static const char rcsid[] = "Id: ns_parse.c,v 8.18 2003/04/03 06:10:10 marka Exp";
#endif
/* Import. */

View File

@ -1,4 +1,4 @@
/* $NetBSD: ns_print.c,v 1.4 2002/06/20 11:43:08 itojun Exp $ */
/* $NetBSD: ns_print.c,v 1.5 2003/06/03 07:34:07 itojun Exp $ */
/*
* Copyright (c) 1996-1999 by Internet Software Consortium.
@ -18,7 +18,7 @@
*/
#ifndef lint
static const char rcsid[] = "Id: ns_print.c,v 8.24 2001/06/18 06:40:45 marka Exp";
static const char rcsid[] = "Id: ns_print.c,v 8.26 2003/02/24 23:56:35 vixie Exp";
#endif
/* Import. */
@ -33,6 +33,7 @@ static const char rcsid[] = "Id: ns_print.c,v 8.24 2001/06/18 06:40:45 marka Exp
#include <arpa/inet.h>
#include <isc/assertions.h>
#include <isc/dst.h>
#include <errno.h>
#include <resolv.h>
#include <string.h>
@ -60,10 +61,6 @@ static int addstr(const char *src, size_t len,
static int addtab(size_t len, size_t target, int spaced,
char **buf, size_t *buflen);
/* Proto. */
u_int16_t dst_s_dns_key_id(const u_char *, const int);
/* Macros. */
#define T(x) \
@ -642,9 +639,10 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
len = SPRINTF((tmp, "%u %u %u ", mode, err, keysize));
T(addstr(tmp, len, &buf, &buflen));
/* needs to dump key, print otherdata length & other data */
/* XXX need to dump key, print otherdata length & other data */
break;
}
case ns_t_tsig: {
/* BEW - need to complete this */
int n;
@ -692,13 +690,13 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
break;
}
}
case ns_t_opt: {
len = SPRINTF((tmp, "%u bytes", class));
T(addstr(tmp, len, &buf, &buflen));
break;
}
}
default:
comment = "unknown RR type";

View File

@ -1,4 +1,4 @@
/* $NetBSD: ns_samedomain.c,v 1.3 2002/11/17 14:09:53 itojun Exp $ */
/* $NetBSD: ns_samedomain.c,v 1.4 2003/06/03 07:34:08 itojun Exp $ */
/*
* Copyright (c) 1995,1999 by Internet Software Consortium.
@ -18,7 +18,7 @@
*/
#ifndef lint
static const char rcsid[] = "Id: ns_samedomain.c,v 8.9.6.2 2002/11/14 22:36:46 marka Exp";
static const char rcsid[] = "Id: ns_samedomain.c,v 8.10.8.1 2003/06/02 05:05:05 marka Exp";
#endif
#include "port_before.h"
@ -127,12 +127,12 @@ ns_samedomain(const char *a, const char *b) {
*/
escaped = 0;
for (i = diff - 2; i >= 0; i--)
if (a[i] == '\\')
if (a[i] == '\\') {
if (escaped)
escaped = 0;
else
escaped = 1;
else
} else
break;
if (escaped)
return (0);
@ -168,14 +168,14 @@ int
ns_makecanon(const char *src, char *dst, size_t dstsize) {
size_t n = strlen(src);
if (n + sizeof "." + 1 > dstsize) {
if (n + sizeof "." > dstsize) { /* Note: sizeof == 2 */
errno = EMSGSIZE;
return (-1);
}
strcpy(dst, src);
while (n > 0 && dst[n - 1] == '.') /* Ends in "." */
if (n > 1 && dst[n - 2] == '\\' && /* Ends in "\." */
(n < 2 || dst[n - 3] != '\\')) /* But not "\\." */
while (n >= 1 && dst[n - 1] == '.') /* Ends in "." */
if (n >= 2 && dst[n - 2] == '\\' && /* Ends in "\." */
(n < 3 || dst[n - 3] != '\\')) /* But not "\\." */
break;
else
dst[--n] = '\0';

View File

@ -1,4 +1,4 @@
/* $NetBSD: ns_sign.c,v 1.3 2002/06/20 11:43:08 itojun Exp $ */
/* $NetBSD: ns_sign.c,v 1.4 2003/06/03 07:34:09 itojun Exp $ */
/*
* Copyright (c) 1999 by Internet Software Consortium, Inc.
@ -18,7 +18,7 @@
*/
#ifndef lint
static const char rcsid[] = "Id: ns_sign.c,v 8.11 2002/04/30 03:43:55 marka Exp";
static const char rcsid[] = "Id: ns_sign.c,v 8.12 2002/10/01 06:48:37 marka Exp";
#endif
/* Import. */
@ -43,6 +43,7 @@ static const char rcsid[] = "Id: ns_sign.c,v 8.11 2002/04/30 03:43:55 marka Exp"
#include <unistd.h>
#include <isc/dst.h>
#include <isc/assertions.h>
#include "port_after.h"
@ -92,22 +93,30 @@ ns_sign2(u_char *msg, int *msglen, int msgsize, int error, void *k,
DST_KEY *key = (DST_KEY *)k;
u_char *cp = msg + *msglen, *eob = msg + msgsize;
u_char *lenp;
u_char *name, *alg;
u_char *alg;
int n;
time_t timesigned;
u_char name[NS_MAXCDNAME];
dst_init();
if (msg == NULL || msglen == NULL || sig == NULL || siglen == NULL)
return (-1);
/* Name. */
if (key != NULL && error != ns_r_badsig && error != ns_r_badkey)
n = dn_comp(key->dk_key_name, cp, eob - cp, dnptrs, lastdnptr);
else
n = dn_comp("", cp, eob - cp, NULL, NULL);
if (key != NULL && error != ns_r_badsig && error != ns_r_badkey) {
n = ns_name_pton(key->dk_key_name, name, sizeof name);
if (n != -1)
n = ns_name_pack(name, cp, eob - cp,
(const u_char **)dnptrs,
(const u_char **)lastdnptr);
} else {
n = ns_name_pton("", name, sizeof name);
if (n != -1)
n = ns_name_pack(name, cp, eob - cp, NULL, NULL);
}
if (n < 0)
return (NS_TSIG_ERROR_NO_SPACE);
name = cp;
cp += n;
/* Type, class, ttl, length (not filled in yet). */
@ -144,7 +153,7 @@ ns_sign2(u_char *msg, int *msglen, int msgsize, int error, void *k,
/* Compute the signature. */
if (key != NULL && error != ns_r_badsig && error != ns_r_badkey) {
void *ctx;
u_char buf[MAXDNAME], *cp2;
u_char buf[NS_MAXCDNAME], *cp2;
int n;
dst_sign_data(SIG_MODE_INIT, key, &ctx, NULL, 0, NULL, 0);
@ -164,6 +173,7 @@ ns_sign2(u_char *msg, int *msglen, int msgsize, int error, void *k,
/* Digest the key name. */
n = ns_name_ntol(name, buf, sizeof(buf));
INSIST(n > 0);
dst_sign_data(SIG_MODE_UPDATE, key, &ctx, buf, n, NULL, 0);
/* Digest the class and TTL. */
@ -175,6 +185,7 @@ ns_sign2(u_char *msg, int *msglen, int msgsize, int error, void *k,
/* Digest the algorithm. */
n = ns_name_ntol(alg, buf, sizeof(buf));
INSIST(n > 0);
dst_sign_data(SIG_MODE_UPDATE, key, &ctx, buf, n, NULL, 0);
/* Digest the time signed, fudge, error, and other data */

View File

@ -1,4 +1,4 @@
/* $NetBSD: res_comp.c,v 1.1.1.2 2003/06/03 07:05:02 itojun Exp $ */
/* $NetBSD: res_comp.c,v 1.2 2003/06/03 07:34:10 itojun Exp $ */
/*
* Copyright (c) 1985, 1993

View File

@ -1,4 +1,4 @@
/* $NetBSD: res_debug.c,v 1.5 2002/06/20 11:43:08 itojun Exp $ */
/* $NetBSD: res_debug.c,v 1.6 2003/06/03 07:34:10 itojun Exp $ */
/*
* Copyright (c) 1985
@ -97,7 +97,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93";
static const char rcsid[] = "Id: res_debug.c,v 8.46 2002/05/21 01:57:45 marka Exp";
static const char rcsid[] = "Id: res_debug.c,v 8.49 2003/01/30 23:32:35 marka Exp";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
@ -617,9 +617,6 @@ p_option(u_long option) {
#ifdef RES_USE_EDNS0 /* KAME extension */
case RES_USE_EDNS0: return "edns0";
#endif
#ifdef RES_USE_A6
case RES_USE_A6: return "a6";
#endif
#ifdef RES_USE_DNAME
case RES_USE_DNAME: return "dname";
#endif
@ -656,6 +653,31 @@ p_rcode(int rcode) {
return (sym_ntos(__p_rcode_syms, rcode, (int *)0));
}
/*
* Return a string for a res_sockaddr_union.
*/
const char *
p_sockun(union res_sockaddr_union u, char *buf, size_t size) {
char ret[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:123.123.123.123"];
switch (u.sin.sin_family) {
case AF_INET:
inet_ntop(AF_INET, &u.sin.sin_addr, ret, sizeof ret);
break;
case AF_INET6:
inet_ntop(AF_INET6, &u.sin6.sin6_addr, ret, sizeof ret);
break;
default:
sprintf(ret, "[af%d]", u.sin.sin_family);
break;
}
if (size > 0) {
strncpy(buf, ret, size - 1);
buf[size - 1] = '0';
}
return (buf);
}
/*
* routines to convert between on-the-wire RR format and zone file format.
* Does not contain conversion to/from decimal degrees; divide or multiply
@ -1103,8 +1125,9 @@ res_nametoclass(const char *buf, int *successp) {
if (strncasecmp(buf, "CLASS", 5) != 0 ||
!isdigit((unsigned char)buf[5]))
goto done;
errno = 0;
result = strtoul(buf + 5, &endptr, 10);
if (*endptr == '\0' && result <= 0xffff)
if (errno == 0 && *endptr == '\0' && result <= 0xffff)
success = 1;
done:
if (successp)
@ -1125,8 +1148,9 @@ res_nametotype(const char *buf, int *successp) {
if (strncasecmp(buf, "type", 4) != 0 ||
!isdigit((unsigned char)buf[4]))
goto done;
errno = 0;
result = strtoul(buf + 4, &endptr, 10);
if (*endptr == '\0' && result <= 0xffff)
if (errno == 0 && *endptr == '\0' && result <= 0xffff)
success = 1;
done:
if (successp)

View File

@ -1,7 +1,7 @@
/* $NetBSD: res_findzonecut.c,v 1.4 2002/06/20 11:43:08 itojun Exp $ */
/* $NetBSD: res_findzonecut.c,v 1.5 2003/06/03 07:34:11 itojun Exp $ */
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "Id: res_findzonecut.c,v 8.16 2002/04/12 06:27:46 marka Exp";
static const char rcsid[] = "Id: res_findzonecut.c,v 8.17.6.2 2003/06/02 09:24:40 marka Exp";
#endif /* not lint */
/*
@ -51,19 +51,21 @@ static const char rcsid[] = "Id: res_findzonecut.c,v 8.16 2002/04/12 06:27:46 ma
typedef struct rr_a {
LINK(struct rr_a) link;
union res_sockaddr_union addr;
union res_sockaddr_union addr;
} rr_a;
typedef LIST(rr_a) rrset_a;
typedef struct rr_ns {
LINK(struct rr_ns) link;
const char * name;
int have_v4;
int have_v6;
unsigned int flags;
rrset_a addrs;
} rr_ns;
typedef LIST(rr_ns) rrset_ns;
#define RR_NS_HAVE_V4 0x01
#define RR_NS_HAVE_V6 0x02
/* Forward. */
static int satisfy(res_state, const char *, rrset_ns *,
@ -151,7 +153,8 @@ static void res_dprintf(const char *, ...) ISC_FORMAT_PRINTF(1, 2);
int
res_findzonecut(res_state statp, const char *dname, ns_class class, int opts,
char *zname, size_t zsize, struct in_addr *addrs, int naddrs) {
char *zname, size_t zsize, struct in_addr *addrs, int naddrs)
{
int result, i;
union res_sockaddr_union *u;
@ -269,7 +272,7 @@ get_soa(res_state statp, const char *dname, ns_class class, int opts,
rrset_ns *nsrrsp)
{
char tname[NS_MAXDNAME];
u_char resp[NS_PACKETSZ];
u_char *resp = NULL;
int n, i, ancount, nscount;
ns_sect sect;
ns_msg msg;
@ -281,9 +284,13 @@ get_soa(res_state statp, const char *dname, ns_class class, int opts,
/* First canonicalize dname (exactly one unescaped trailing "."). */
if (ns_makecanon(dname, tname, sizeof tname) < 0)
return (-1);
goto cleanup;
dname = tname;
resp = malloc(NS_MAXMSG);
if (resp == NULL)
goto cleanup;
/* Now grovel the subdomains, hunting for an SOA answer or auth. */
for (;;) {
/* Leading or inter-label '.' are skipped here. */
@ -295,7 +302,7 @@ get_soa(res_state statp, const char *dname, ns_class class, int opts,
if (n < 0) {
DPRINTF(("get_soa: do_query('%s', %s) failed (%d)",
dname, p_class(class), n));
return (-1);
goto cleanup;
}
if (n > 0) {
DPRINTF(("get_soa: CNAME or DNAME found"));
@ -320,7 +327,7 @@ get_soa(res_state statp, const char *dname, ns_class class, int opts,
if (ns_parserr(&msg, sect, i, &rr) < 0) {
DPRINTF(("get_soa: ns_parserr(%s, %d) failed",
p_section(sect, ns_o_query), i));
return (-1);
goto cleanup;
}
if (ns_rr_type(rr) == ns_t_cname ||
ns_rr_type(rr) == ns_t_dname)
@ -332,19 +339,23 @@ get_soa(res_state statp, const char *dname, ns_class class, int opts,
switch (sect) {
case ns_s_an:
if (ns_samedomain(dname, t) == 0) {
DPRINTF(("get_soa: ns_samedomain('%s', '%s') == 0",
dname, t));
DPRINTF(
("get_soa: ns_samedomain('%s', '%s') == 0",
dname, t)
);
errno = EPROTOTYPE;
return (-1);
goto cleanup;
}
break;
case ns_s_ns:
if (ns_samename(dname, t) == 1 ||
ns_samedomain(dname, t) == 0) {
DPRINTF(("get_soa: ns_samename() || !ns_samedomain('%s', '%s')",
dname, t));
DPRINTF(
("get_soa: ns_samename() || !ns_samedomain('%s', '%s')",
dname, t)
);
errno = EPROTOTYPE;
return (-1);
goto cleanup;
}
break;
default:
@ -354,21 +365,23 @@ get_soa(res_state statp, const char *dname, ns_class class, int opts,
DPRINTF(("get_soa: zname(%d) too small (%d)",
zsize, strlen(t) + 1));
errno = EMSGSIZE;
return (-1);
goto cleanup;
}
strcpy(zname, t);
rdata = ns_rr_rdata(rr);
rdlen = ns_rr_rdlen(rr);
if (ns_name_uncompress(resp, ns_msg_end(msg), rdata,
mname, msize) < 0) {
DPRINTF(("get_soa: ns_name_uncompress failed"));
return (-1);
DPRINTF(("get_soa: ns_name_uncompress failed")
);
goto cleanup;
}
if (save_ns(statp, &msg, ns_s_ns,
zname, class, opts, nsrrsp) < 0) {
DPRINTF(("get_soa: save_ns failed"));
return (-1);
goto cleanup;
}
free(resp);
return (0);
}
@ -381,13 +394,16 @@ get_soa(res_state statp, const char *dname, ns_class class, int opts,
if (*dname == '\\')
if (*++dname == '\0') {
errno = EMSGSIZE;
return (-1);
goto cleanup;
}
dname++;
}
}
DPRINTF(("get_soa: out of labels"));
errno = EDESTADDRREQ;
cleanup:
if (resp != NULL)
free(resp);
return (-1);
}
@ -395,15 +411,20 @@ static int
get_ns(res_state statp, const char *zname, ns_class class, int opts,
rrset_ns *nsrrsp)
{
u_char resp[NS_PACKETSZ];
u_char *resp;
ns_msg msg;
int n;
resp = malloc(NS_MAXMSG);
if (resp == NULL)
return (-1);
/* Go and get the NS RRs for this zone. */
n = do_query(statp, zname, class, ns_t_ns, resp, &msg);
if (n != 0) {
DPRINTF(("get_ns: do_query('%s', %s) failed (%d)",
zname, p_class(class), n));
free(resp);
return (-1);
}
@ -411,31 +432,38 @@ get_ns(res_state statp, const char *zname, ns_class class, int opts,
if (save_ns(statp, &msg, ns_s_an, zname, class, opts, nsrrsp) < 0) {
DPRINTF(("get_ns save_ns('%s', %s) failed",
zname, p_class(class)));
free(resp);
return (-1);
}
free(resp);
return (0);
}
static int
get_glue(res_state statp, ns_class class, int opts, rrset_ns *nsrrsp) {
rr_ns *nsrr, *nsrr_n;
u_char *resp;
resp = malloc(NS_MAXMSG);
if (resp == NULL)
return(-1);
/* Go and get the A RRs for each empty NS RR on our list. */
for (nsrr = HEAD(*nsrrsp); nsrr != NULL; nsrr = nsrr_n) {
u_char resp[NS_PACKETSZ];
ns_msg msg;
int n;
nsrr_n = NEXT(nsrr, link);
if (!nsrr->have_v4) {
if ((nsrr->flags & RR_NS_HAVE_V4) == 0) {
n = do_query(statp, nsrr->name, class, ns_t_a,
resp, &msg);
if (n < 0) {
DPRINTF(("get_glue: do_query('%s', %s') failed",
nsrr->name, p_class(class)));
return (-1);
DPRINTF(
("get_glue: do_query('%s', %s') failed",
nsrr->name, p_class(class)));
goto cleanup;
}
if (n > 0) {
DPRINTF((
@ -446,17 +474,18 @@ get_glue(res_state statp, ns_class class, int opts, rrset_ns *nsrrsp) {
opts, nsrr) < 0) {
DPRINTF(("get_glue: save_r('%s', %s) failed",
nsrr->name, p_class(class)));
return (-1);
goto cleanup;
}
}
if (!nsrr->have_v6) {
if ((nsrr->flags & RR_NS_HAVE_V6) == 0) {
n = do_query(statp, nsrr->name, class, ns_t_aaaa,
resp, &msg);
if (n < 0) {
DPRINTF(("get_glue: do_query('%s', %s') failed",
nsrr->name, p_class(class)));
return (-1);
DPRINTF(
("get_glue: do_query('%s', %s') failed",
nsrr->name, p_class(class)));
goto cleanup;
}
if (n > 0) {
DPRINTF((
@ -467,7 +496,7 @@ get_glue(res_state statp, ns_class class, int opts, rrset_ns *nsrrsp) {
opts, nsrr) < 0) {
DPRINTF(("get_glue: save_r('%s', %s) failed",
nsrr->name, p_class(class)));
return (-1);
goto cleanup;
}
}
@ -478,7 +507,12 @@ get_glue(res_state statp, ns_class class, int opts, rrset_ns *nsrrsp) {
free_nsrr(nsrrsp, nsrr);
}
}
free(resp);
return (0);
cleanup:
free(resp);
return (-1);
}
static int
@ -516,7 +550,8 @@ save_ns(res_state statp, ns_msg *msg, ns_sect sect,
if (ns_name_uncompress(ns_msg_base(*msg),
ns_msg_end(*msg), rdata,
tname, sizeof tname) < 0) {
DPRINTF(("save_ns: ns_name_uncompress failed"));
DPRINTF(("save_ns: ns_name_uncompress failed")
);
free(nsrr);
return (-1);
}
@ -528,8 +563,7 @@ save_ns(res_state statp, ns_msg *msg, ns_sect sect,
}
INIT_LINK(nsrr, link);
INIT_LIST(nsrr->addrs);
nsrr->have_v4 = 0;
nsrr->have_v6 = 0;
nsrr->flags = 0;
APPEND(*nsrrsp, nsrr, link);
}
if (save_a(statp, msg, ns_s_ar,
@ -558,7 +592,8 @@ save_a(res_state statp, ns_msg *msg, ns_sect sect,
p_section(sect, ns_o_query), i));
return (-1);
}
if ((ns_rr_type(rr) != ns_t_a && ns_rr_type(rr) != ns_t_aaaa) ||
if ((ns_rr_type(rr) != ns_t_a &&
ns_rr_type(rr) != ns_t_aaaa) ||
ns_rr_class(rr) != class ||
ns_samename(ns_rr_name(rr), owner) != 1 ||
ns_rr_rdlen(rr) != NS_INADDRSZ)
@ -583,7 +618,7 @@ save_a(res_state statp, ns_msg *msg, ns_sect sect,
memcpy(&arr->addr.sin.sin_addr, ns_rr_rdata(rr),
NS_INADDRSZ);
arr->addr.sin.sin_port = htons(NAMESERVER_PORT);
nsrr->have_v4 = 1;
nsrr->flags |= RR_NS_HAVE_V4;
break;
case ns_t_aaaa:
arr->addr.sin6.sin6_family = AF_INET6;
@ -592,7 +627,7 @@ save_a(res_state statp, ns_msg *msg, ns_sect sect,
#endif
memcpy(&arr->addr.sin6.sin6_addr, ns_rr_rdata(rr), 16);
arr->addr.sin.sin_port = htons(NAMESERVER_PORT);
nsrr->have_v6 = 1;
nsrr->flags |= RR_NS_HAVE_V6;
break;
default:
abort();
@ -648,7 +683,7 @@ do_query(res_state statp, const char *dname, ns_class class, ns_type qtype,
DPRINTF(("do_query: res_nmkquery failed"));
return (-1);
}
n = res_nsend(statp, req, n, resp, NS_PACKETSZ);
n = res_nsend(statp, req, n, resp, NS_MAXMSG);
if (n < 0) {
DPRINTF(("do_query: res_nsend failed"));
return (-1);

View File

@ -1,4 +1,4 @@
/* $NetBSD: res_init.c,v 1.4 2002/06/20 11:43:08 itojun Exp $ */
/* $NetBSD: res_init.c,v 1.5 2003/06/03 07:34:11 itojun Exp $ */
/*
* Copyright (c) 1985, 1989, 1993
@ -72,7 +72,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93";
static const char rcsid[] = "Id: res_init.c,v 8.29 2002/05/31 06:05:31 marka Exp";
static const char rcsid[] = "Id: res_init.c,v 8.32 2003/04/03 06:31:10 marka Exp";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
@ -163,6 +163,7 @@ __res_vinit(res_state statp, int preinit) {
char *net;
#endif
int dots;
union res_sockaddr_union u[2];
if (!preinit) {
statp->retrans = RES_TIMEOUT;
@ -174,17 +175,32 @@ __res_vinit(res_state statp, int preinit) {
if ((statp->options & RES_INIT) != 0)
res_ndestroy(statp);
memset(u, 0, sizeof(u));
#ifdef USELOOPBACK
statp->nsaddr.sin_addr = inet_makeaddr(IN_LOOPBACKNET, 1);
u[nserv].sin.sin_addr = inet_makeaddr(IN_LOOPBACKNET, 1);
#else
statp->nsaddr.sin_addr.s_addr = INADDR_ANY;
u[nserv].sin.sin_addr.s_addr = INADDR_ANY;
#endif
statp->nsaddr.sin_family = AF_INET;
statp->nsaddr.sin_port = htons(NAMESERVER_PORT);
u[nserv].sin.sin_family = AF_INET;
u[nserv].sin.sin_port = htons(NAMESERVER_PORT);
#ifdef HAVE_SA_LEN
statp->nsaddr.sin_len = sizeof(struct sockaddr_in);
u[nserv].sin.sin_len = sizeof(struct sockaddr_in);
#endif
statp->nscount = 1;
nserv++;
#ifdef HAS_INET6_STRUCTS
#ifdef USELOOPBACK
u[nserv].sin6.sin6_addr = in6addr_loopback;
#else
u[nserv].sin6.sin6_addr = in6addr_any;
#endif
u[nserv].sin6.sin6_family = AF_INET6;
u[nserv].sin6.sin6_port = htons(NAMESERVER_PORT);
#ifdef HAVE_SA_LEN
u[nserv].sin6.sin6_len = sizeof(struct sockaddr_in6);
#endif
nserv++;
#endif
statp->nscount = 0;
statp->ndots = 1;
statp->pfcode = 0;
statp->_vcsock = -1;
@ -198,11 +214,11 @@ __res_vinit(res_state statp, int preinit) {
statp->_u._ext.ext->nsaddrs[0].sin = statp->nsaddr;
strcpy(statp->_u._ext.ext->nsuffix, "ip6.arpa");
strcpy(statp->_u._ext.ext->nsuffix2, "ip6.int");
strcpy(statp->_u._ext.ext->bsuffix, "ip6.arpa");
}
#ifdef RESOLVSORT
statp->nsort = 0;
#endif
res_setservers(statp, u, nserv);
/* Allow user to override the local domain definition */
if ((cp = getenv("LOCALDOMAIN")) != NULL) {
@ -244,6 +260,7 @@ __res_vinit(res_state statp, int preinit) {
(line[sizeof(name) - 1] == ' ' || \
line[sizeof(name) - 1] == '\t'))
nserv = 0;
if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) {
/* read the config file */
while (fgets(buf, sizeof(buf), fp) != NULL) {
@ -509,9 +526,6 @@ res_setoptions(res_state statp, const char *options, const char *source)
statp->options |= RES_USE_EDNS0;
}
#endif
else if (!strncmp(cp, "a6", sizeof("a6") - 1)) {
statp->options |= RES_USE_A6;
}
else if (!strncmp(cp, "dname", sizeof("dname") - 1)) {
statp->options |= RES_USE_DNAME;
}
@ -531,14 +545,6 @@ res_setoptions(res_state statp, const char *options, const char *source)
strncpy(ext->nsuffix2, cp, i);
ext->nsuffix2[i] = '\0';
}
else if (!strncmp(cp, "bitstring:", sizeof("bitstring:") - 1)) {
if (ext == NULL)
goto skip;
cp += sizeof("bitstring:") - 1;
i = MIN(strcspn(cp, " \t"), sizeof(ext->bsuffix) - 1);
strncpy(ext->bsuffix, cp, i);
ext->bsuffix[i] = '\0';
}
else if (!strncmp(cp, "v6revmode:", sizeof("v6revmode:") - 1)) {
cp += sizeof("v6revmode:") - 1;
/* "nibble" and "bitstring" used to be valid */
@ -630,13 +636,6 @@ res_get_nibblesuffix2(res_state statp) {
return ("ip6.int");
}
const char *
res_get_bitstringsuffix(res_state statp) {
if (statp->_u._ext.ext)
return (statp->_u._ext.ext->bsuffix);
return ("ip6.arpa");
}
void
res_setservers(res_state statp, const union res_sockaddr_union *set, int cnt) {
int i, nserv;

View File

@ -1,4 +1,4 @@
/* $NetBSD: res_mkquery.c,v 1.2 2002/06/20 11:43:08 itojun Exp $ */
/* $NetBSD: res_mkquery.c,v 1.3 2003/06/03 07:34:12 itojun Exp $ */
/*
* Copyright (c) 1985, 1993
@ -72,7 +72,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_mkquery.c 8.1 (Berkeley) 6/4/93";
static const char rcsid[] = "Id: res_mkquery.c,v 8.14 2001/09/24 13:50:27 marka Exp";
static const char rcsid[] = "Id: res_mkquery.c,v 8.15.8.1 2003/06/02 05:59:57 marka Exp";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
@ -107,7 +107,7 @@ res_nmkquery(res_state statp,
int buflen) /* size of buffer */
{
register HEADER *hp;
register u_char *cp;
register u_char *cp, *ep;
register int n;
u_char *dnptrs[20], **dpp, **lastdnptr;
@ -130,7 +130,7 @@ res_nmkquery(res_state statp,
hp->rd = (statp->options & RES_RECURSE) != 0;
hp->rcode = NOERROR;
cp = buf + HFIXEDSZ;
buflen -= HFIXEDSZ;
ep = buf + buflen;
dpp = dnptrs;
*dpp++ = buf;
*dpp++ = NULL;
@ -141,15 +141,15 @@ res_nmkquery(res_state statp,
switch (op) {
case QUERY: /*FALLTHROUGH*/
case NS_NOTIFY_OP:
if ((buflen -= QFIXEDSZ) < 0)
if (ep - cp < QFIXEDSZ)
return (-1);
if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0)
if ((n = dn_comp(dname, cp, ep - cp - QFIXEDSZ, dnptrs,
lastdnptr)) < 0)
return (-1);
cp += n;
buflen -= n;
__putshort(type, cp);
ns_put16(type, cp);
cp += INT16SZ;
__putshort(class, cp);
ns_put16(class, cp);
cp += INT16SZ;
hp->qdcount = htons(1);
if (op == QUERY || data == NULL)
@ -157,19 +157,20 @@ res_nmkquery(res_state statp,
/*
* Make an additional record for completion domain.
*/
buflen -= RRFIXEDSZ;
n = dn_comp((const char *)data, cp, buflen, dnptrs, lastdnptr);
if ((ep - cp) < RRFIXEDSZ)
return (-1);
n = dn_comp((const char *)data, cp, ep - cp - RRFIXEDSZ,
dnptrs, lastdnptr);
if (n < 0)
return (-1);
cp += n;
buflen -= n;
__putshort(T_NULL, cp);
ns_put16(T_NULL, cp);
cp += INT16SZ;
__putshort(class, cp);
ns_put16(class, cp);
cp += INT16SZ;
__putlong(0, cp);
ns_put32(0, cp);
cp += INT32SZ;
__putshort(0, cp);
ns_put16(0, cp);
cp += INT16SZ;
hp->arcount = htons(1);
break;
@ -178,16 +179,16 @@ res_nmkquery(res_state statp,
/*
* Initialize answer section
*/
if (buflen < 1 + RRFIXEDSZ + datalen)
if (ep - cp < 1 + RRFIXEDSZ + datalen)
return (-1);
*cp++ = '\0'; /* no domain name */
__putshort(type, cp);
ns_put16(type, cp);
cp += INT16SZ;
__putshort(class, cp);
ns_put16(class, cp);
cp += INT16SZ;
__putlong(0, cp);
ns_put32(0, cp);
cp += INT32SZ;
__putshort(datalen, cp);
ns_put16(datalen, cp);
cp += INT16SZ;
if (datalen) {
memcpy(cp, data, datalen);
@ -209,15 +210,14 @@ res_nmkquery(res_state statp,
#endif
int
res_nopt(statp, n0, buf, buflen, anslen)
res_state statp;
int n0;
u_char *buf; /* buffer to put query */
int buflen; /* size of buffer */
int anslen; /* answer buffer length */
res_nopt(res_state statp,
int n0, /* current offset in buffer */
u_char *buf, /* buffer to put query */
int buflen, /* size of buffer */
int anslen) /* UDP answer buffer size */
{
register HEADER *hp;
register u_char *cp;
register u_char *cp, *ep;
u_int16_t flags = 0;
#ifdef DEBUG
@ -227,17 +227,16 @@ res_nopt(statp, n0, buf, buflen, anslen)
hp = (HEADER *) buf;
cp = buf + n0;
buflen -= n0;
ep = buf + buflen;
if (buflen < 1 + RRFIXEDSZ)
return -1;
if ((ep - cp) < 1 + RRFIXEDSZ)
return (-1);
*cp++ = 0; /* "." */
buflen--;
__putshort(T_OPT, cp); /* TYPE */
ns_put16(T_OPT, cp); /* TYPE */
cp += INT16SZ;
__putshort(anslen & 0xffff, cp); /* CLASS = UDP payload size */
ns_put16(anslen & 0xffff, cp); /* CLASS = UDP payload size */
cp += INT16SZ;
*cp++ = NOERROR; /* extended RCODE */
*cp++ = 0; /* EDNS version */
@ -248,13 +247,12 @@ res_nopt(statp, n0, buf, buflen, anslen)
#endif
flags |= NS_OPT_DNSSEC_OK;
}
__putshort(flags, cp);
ns_put16(flags, cp);
cp += INT16SZ;
__putshort(0, cp); /* RDLEN */
ns_put16(0, cp); /* RDLEN */
cp += INT16SZ;
hp->arcount = htons(ntohs(hp->arcount) + 1);
buflen -= RRFIXEDSZ;
return cp - buf;
return (cp - buf);
}
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: res_mkupdate.c,v 1.3 2002/06/20 11:43:08 itojun Exp $ */
/* $NetBSD: res_mkupdate.c,v 1.4 2003/06/03 07:34:12 itojun Exp $ */
/*
* Copyright (c) 1996-1999 by Internet Software Consortium.
@ -23,7 +23,7 @@
*/
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "Id: res_mkupdate.c,v 1.26 2001/05/29 05:49:47 marka Exp";
static const char rcsid[] = "Id: res_mkupdate.c,v 1.27.8.1 2003/06/02 04:56:28 marka Exp";
#endif /* not lint */
#include "port_before.h"
@ -304,7 +304,7 @@ res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) {
if (!getword_str(buf2, sizeof buf2, &startp, endp))
return (-1);
n = dn_comp(buf2, cp, buflen, dnptrs, lastdnptr);
n = dn_comp(buf2, cp, buflen, NULL, NULL);
if (n < 0)
return (-1);
cp += n;
@ -484,8 +484,10 @@ res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) {
char *ulendp;
u_int32_t ottl;
errno = 0;
ottl = strtoul(buf2, &ulendp, 10);
if (ulendp != NULL && *ulendp != '\0')
if (errno != 0 ||
(ulendp != NULL && *ulendp != '\0'))
return (-1);
ShrinkBuffer(INT32SZ);
PUTLONG(ottl, cp);
@ -574,7 +576,7 @@ res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) {
/* next name */
if (!getword_str(buf2, sizeof buf2, &startp, endp))
return (-1);
n = dn_comp(buf2, cp, buflen, dnptrs, lastdnptr);
n = dn_comp(buf2, cp, buflen, NULL, NULL);
if (n < 0)
return (-1);
cp += n;
@ -638,6 +640,62 @@ res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) {
memcpy(cp, &in6a, NS_IN6ADDRSZ);
cp += NS_IN6ADDRSZ;
break;
case ns_t_naptr:
/* Order Preference Flags Service Replacement Regexp */
/* Order */
n = getnum_str(&startp, endp);
if (n < 0 || n > 65535)
return (-1);
ShrinkBuffer(INT16SZ);
PUTSHORT(n, cp);
/* Preference */
n = getnum_str(&startp, endp);
if (n < 0 || n > 65535)
return (-1);
ShrinkBuffer(INT16SZ);
PUTSHORT(n, cp);
/* Flags */
if ((n = getstr_str(buf2, sizeof buf2,
&startp, endp)) < 0) {
return (-1);
}
if (n > 255)
return (-1);
ShrinkBuffer(n+1);
*cp++ = n;
memcpy(cp, buf2, n);
cp += n;
/* Service Classes */
if ((n = getstr_str(buf2, sizeof buf2,
&startp, endp)) < 0) {
return (-1);
}
if (n > 255)
return (-1);
ShrinkBuffer(n+1);
*cp++ = n;
memcpy(cp, buf2, n);
cp += n;
/* Pattern */
if ((n = getstr_str(buf2, sizeof buf2,
&startp, endp)) < 0) {
return (-1);
}
if (n > 255)
return (-1);
ShrinkBuffer(n+1);
*cp++ = n;
memcpy(cp, buf2, n);
cp += n;
/* Replacement */
if (!getword_str(buf2, sizeof buf2, &startp, endp))
return (-1);
n = dn_comp(buf2, cp, buflen, NULL, NULL);
if (n < 0)
return (-1);
cp += n;
ShrinkBuffer(n);
break;
default:
return (-1);
} /*switch*/
@ -809,7 +867,7 @@ gethexnum_str(u_char **startpp, u_char *endp) {
}
/*
* Get a whitespace delimited base 16 number from a string (not file) into buf
* Get a whitespace delimited base 10 number from a string (not file) into buf
* update the start pointer to point after the number in the string.
*/
static int

View File

@ -1,4 +1,4 @@
/* $NetBSD: res_private.h,v 1.1.1.2 2003/06/03 07:05:04 itojun Exp $ */
/* $NetBSD: res_private.h,v 1.2 2003/06/03 07:34:13 itojun Exp $ */
#ifndef res_private_h
#define res_private_h

View File

@ -1,4 +1,4 @@
/* $NetBSD: res_query.c,v 1.3 2002/06/20 11:43:08 itojun Exp $ */
/* $NetBSD: res_query.c,v 1.4 2003/06/03 07:34:13 itojun Exp $ */
/*
* Copyright (c) 1988, 1993
@ -72,7 +72,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93";
static const char rcsid[] = "Id: res_query.c,v 8.23 2001/09/24 13:50:29 marka Exp";
static const char rcsid[] = "Id: res_query.c,v 8.24 2003/01/31 15:25:58 vixie Exp";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
@ -169,8 +169,11 @@ again:
if (hp->rcode != NOERROR || ntohs(hp->ancount) == 0) {
#ifdef DEBUG
if (statp->options & RES_DEBUG)
printf(";; rcode = %d, ancount=%d\n", hp->rcode,
ntohs(hp->ancount));
printf(";; rcode = (%s), counts = an:%d ns:%d ar:%d\n",
p_rcode(hp->rcode),
ntohs(hp->ancount),
ntohs(hp->nscount),
ntohs(hp->arcount));
#endif
switch (hp->rcode) {
case NXDOMAIN:

View File

@ -1,4 +1,4 @@
/* $NetBSD: res_send.c,v 1.6 2002/07/04 23:30:40 itojun Exp $ */
/* $NetBSD: res_send.c,v 1.7 2003/06/03 07:34:14 itojun Exp $ */
/*
* Copyright (c) 1985, 1989, 1993
@ -72,7 +72,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_send.c 8.1 (Berkeley) 6/4/93";
static const char rcsid[] = "Id: res_send.c,v 8.49 2002/03/29 21:50:51 marka Exp";
static const char rcsid[] = "Id: res_send.c,v 8.51.2.1 2003/06/02 05:59:57 marka Exp";
#endif /* LIBC_SCCS and not lint */
/*
@ -391,6 +391,8 @@ res_nsend(res_state statp,
int nsaplen;
nsap = get_nsaddr(statp, ns);
nsaplen = get_salen(nsap);
statp->_flags &= ~RES_F_LASTMASK;
statp->_flags |= (ns << RES_F_LASTSHIFT);
same_ns:
if (statp->qhook) {
int done = 0, loops = 0;
@ -628,7 +630,7 @@ send_vc(res_state statp,
/*
* Send length & message
*/
putshort((u_short)buflen, (u_char*)&len);
ns_put16((u_short)buflen, (u_char*)&len);
iov[0] = evConsIovec(&len, INT16SZ);
DE_CONST(buf, tmp);
iov[1] = evConsIovec(tmp, buflen);

View File

@ -1,7 +1,7 @@
/* $NetBSD: res_update.c,v 1.5 2002/06/20 11:43:08 itojun Exp $ */
/* $NetBSD: res_update.c,v 1.6 2003/06/03 07:34:14 itojun Exp $ */
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "Id: res_update.c,v 1.34 2002/04/12 06:28:52 marka Exp";
static const char rcsid[] = "Id: res_update.c,v 1.35.8.2 2003/06/02 09:24:40 marka Exp";
#endif /* not lint */
/*
@ -94,12 +94,18 @@ static void res_dprintf(const char *, ...) ISC_FORMAT_PRINTF(1, 2);
int
res_nupdate(res_state statp, ns_updrec *rrecp_in, ns_tsig_key *key) {
ns_updrec *rrecp;
u_char answer[PACKETSZ], packet[2*PACKETSZ];
u_char answer[PACKETSZ];
u_char *packet;
struct zonegrp *zptr, tgrp;
LIST(struct zonegrp) zgrps;
int nzones = 0, nscount = 0, n;
union res_sockaddr_union nsaddrs[MAXNS];
packet = malloc(NS_MAXMSG);
if (packet == NULL) {
DPRINTF(("malloc failed"));
return (0);
}
/* Thread all of the updates onto a list of groups. */
INIT_LIST(zgrps);
memset(&tgrp, 0, sizeof (tgrp));
@ -152,7 +158,7 @@ res_nupdate(res_state statp, ns_updrec *rrecp_in, ns_tsig_key *key) {
/* Marshall the update message. */
n = res_nmkupdate(statp, HEAD(zptr->z_rrlist),
packet, sizeof packet);
packet, NS_MAXMSG);
DPRINTF(("res_mkupdate -> %d", n));
if (n < 0)
goto done;
@ -190,6 +196,7 @@ res_nupdate(res_state statp, ns_updrec *rrecp_in, ns_tsig_key *key) {
if (nscount != 0)
res_setservers(statp, nsaddrs, nscount);
free(packet);
return (nzones);
}

4
dist/bind/man/dig.1 vendored
View File

@ -1,6 +1,6 @@
.\" $NetBSD: dig.1,v 1.9 2003/04/13 16:35:02 wiz Exp $
.\" $NetBSD: dig.1,v 1.10 2003/06/03 07:34:15 itojun Exp $
.\"
.\" Id: dig.1,v 8.9 2002/06/18 01:53:43 marka Exp
.\" Id: dig.1,v 8.11 2003/04/03 05:52:34 marka Exp
.\"
.\" ++Copyright++ 1993
.\" -

View File

@ -1,4 +1,4 @@
.\" $NetBSD: named-xfer.8,v 1.7 2002/12/21 12:28:14 wiz Exp $
.\" $NetBSD: named-xfer.8,v 1.8 2003/06/03 07:34:16 itojun Exp $
.\"
.\" ++Copyright++ 1985
.\" -
@ -89,7 +89,11 @@
.Op Fl i Ar ixfr_file
.Op Fl t Ar trace_file
.Op Fl p Ar port#
.Op Fl C Ar class
.Op Fl S
.Op Fl q
.Op Fl x Ar src_address
.Op Fl T Ar tsig_file
.Ar nameserver
.Op Sy axfr | ixfr
.Sh DESCRIPTION
@ -146,6 +150,9 @@ as returned by
.Xr getservbyname 3
for the service
.Dq Li domain .
.It Fl C Ar class
Defines which class to use.
Defaults to 'IN'.
.It Fl S
Perform a restricted transfer of only the SOA, NS records and glue A records
for the zone. The SOA record will not be loaded by
@ -156,6 +163,26 @@ determine when to verify the NS records. See the
directive in
.Xr named 8
for more information.
.It Fl q
Tells named-xfer to be quiet.
.It Fl x Ar src_address
Specifies the source address to use for this query.
.It Fl T Ar tsig_file
Specifies a file to transfer TSIG information to named-xfer.
Multiple entries of the following format:
.Pp
.Bl -hang -width "IP address" -compact
.It IP address
When connecting to this address use this TSIG key.
.It key name
.It algorithm
157 (HMAC-MD5) is the only algorithm supported.
.It key data
base64
.El
.Pp
named-xfer expects this file to be temporary in nature and
will explicitly delete this file after its use.
.El
.Pp
Additional arguments are taken as name server addresses in so-called

View File

@ -1,4 +1,4 @@
.\" $NetBSD: named.conf.5,v 1.12 2003/04/06 19:39:46 wiz Exp $
.\" $NetBSD: named.conf.5,v 1.13 2003/06/03 07:34:16 itojun Exp $
.\"
.\" Copyright (c) 1999-2000 by Internet Software Consortium
.\"
@ -769,6 +769,7 @@ options {
[ sortlist { \fIaddress_match_list\fR }; ]
[ rrset-order { \fIorder_spec\fR ; [ \fIorder_spec\fR ; ... ] }; ]
[ preferred-glue ( A | AAAA ); ]
[ edns-udp-size \fInumber\fR; ]
};
.Ed
.Ss Definition and Usage
@ -1554,6 +1555,16 @@ in the answer to a priming query.
This can be achieved by setting
.Ic preferred-glue A;
which will add A records before other types in the additional section.
.Ss EDNS
Some firewalls fail to pass EDNS/UDP messages that are larger than
certain size, 512 or the UDP reassembly buffer.
To allow EDNS to
work across such firewalls it is necessary to advertise a EDNS
buffer size that is small enough to not trigger failures.
.Ic edns-udp-size
can be use to adjust the advertised size.
Values less than 512 will be increased to 512 and values greater than
4096 will be truncated to 4096.
.Ss Tuning
.Bl -tag -width 0n
.It Ic lame-ttl