Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/dist/bind sync with audit result from kame.
details: https://anonhg.NetBSD.org/src/rev/868c2f41b166
branches: trunk
changeset: 533600:868c2f41b166
user: itojun <itojun%NetBSD.org@localhost>
date: Thu Jul 04 23:30:39 2002 +0000
description:
sync with audit result from kame.
- sprintf() can return negative value on error, so p += sprintf(p, blah)
is unsafe
- signed/unsigned mixup
- wrong assumption: sizeof(time_t) <= sizeof(int)
- need to init errno to 0 before strtoul()
diffstat:
dist/bind/bin/nsupdate/nsupdate.c | 6 ++++--
dist/bind/lib/irs/dns_ho.c | 14 ++++++++++----
dist/bind/lib/irs/getaddrinfo.c | 23 ++++++++++++++---------
dist/bind/lib/isc/ev_timers.c | 14 +++++++-------
dist/bind/lib/isc/eventlib.c | 6 +++---
dist/bind/lib/nameser/ns_name.c | 29 ++++++++++++++++++++++-------
dist/bind/lib/resolv/res_send.c | 5 ++++-
7 files changed, 64 insertions(+), 33 deletions(-)
diffs (281 lines):
diff -r 91be3fecf7c4 -r 868c2f41b166 dist/bind/bin/nsupdate/nsupdate.c
--- a/dist/bind/bin/nsupdate/nsupdate.c Thu Jul 04 23:24:43 2002 +0000
+++ b/dist/bind/bin/nsupdate/nsupdate.c Thu Jul 04 23:30:39 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nsupdate.c,v 1.4 2002/06/20 11:43:01 itojun Exp $ */
+/* $NetBSD: nsupdate.c,v 1.5 2002/07/04 23:30:39 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";
@@ -400,7 +400,9 @@
(void) getword_str(buf2, sizeof buf2, &startp, endp);
if (isdigit(buf2[0])) { /* ttl */
- u_long tmp_ttl = strtoul(buf2, 0, 10);
+ u_long tmp_ttl;
+ errno = 0;
+ tmp_ttl = strtoul(buf2, 0, 10);
if ((errno == ERANGE && tmp_ttl == ULONG_MAX) ||
tmp_ttl > UINT32_MAX) {
fprintf(stderr, "oversized ttl: %s\n", buf2);
diff -r 91be3fecf7c4 -r 868c2f41b166 dist/bind/lib/irs/dns_ho.c
--- a/dist/bind/lib/irs/dns_ho.c Thu Jul 04 23:24:43 2002 +0000
+++ b/dist/bind/lib/irs/dns_ho.c Thu Jul 04 23:30:39 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dns_ho.c,v 1.4 2002/06/28 06:11:53 itojun Exp $ */
+/* $NetBSD: dns_ho.c,v 1.5 2002/07/04 23:30:39 itojun Exp $ */
/*
* Copyright (c) 1985, 1988, 1993
@@ -365,7 +365,7 @@
struct hostent *hp = NULL;
struct addrinfo ai;
struct dns_res_target *q, *q2, *p;
- int n, size;
+ int n, size, i;
int querystate = RESQRY_FAIL;
if (init(this) == -1)
@@ -442,18 +442,24 @@
if (q->action != RESTGT_IGNORE) {
qp = q->qname;
for (n = IN6ADDRSZ - 1; n >= 0; n--) {
- qp += SPRINTF((qp, "%x.%x.",
+ i = SPRINTF((qp, "%x.%x.",
uaddr[n] & 0xf,
(uaddr[n] >> 4) & 0xf));
+ if (i < 0)
+ abort();
+ qp += i;
}
strcpy(qp, res_get_nibblesuffix(pvt->res));
}
if (q2->action != RESTGT_IGNORE) {
qp = q2->qname;
for (n = IN6ADDRSZ - 1; n >= 0; n--) {
- qp += SPRINTF((qp, "%x.%x.",
+ i = SPRINTF((qp, "%x.%x.",
uaddr[n] & 0xf,
(uaddr[n] >> 4) & 0xf));
+ if (i < 0)
+ abort();
+ qp += i;
}
strcpy(qp, res_get_nibblesuffix2(pvt->res));
}
diff -r 91be3fecf7c4 -r 868c2f41b166 dist/bind/lib/irs/getaddrinfo.c
--- a/dist/bind/lib/irs/getaddrinfo.c Thu Jul 04 23:24:43 2002 +0000
+++ b/dist/bind/lib/irs/getaddrinfo.c Thu Jul 04 23:30:39 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: getaddrinfo.c,v 1.3 2002/06/28 06:21:29 itojun Exp $ */
+/* $NetBSD: getaddrinfo.c,v 1.4 2002/07/04 23:30:40 itojun Exp $ */
/* $KAME: getaddrinfo.c,v 1.14 2001/01/06 09:41:15 jinmei Exp $ */
@@ -194,7 +194,7 @@
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 int ip6_str2scopeid __P((char *, struct sockaddr_in6 *));
+static u_int32_t ip6_str2scopeid __P((char *, struct sockaddr_in6 *));
static struct net_data *init __P((void));
struct addrinfo *hostent2addrinfo __P((struct hostent *,
@@ -299,8 +299,9 @@
if (*p == '\0')
return NO;
ep = NULL;
+ errno = 0;
(void)strtoul(p, &ep, 10);
- if (ep && *ep == '\0')
+ if (errno == 0 && ep && *ep == '\0')
return YES;
else
return NO;
@@ -856,7 +857,7 @@
error = explore_numeric(pai, addr, servname, res);
if (error == 0) {
- int scopeid;
+ u_int32_t scopeid;
for (cur = *res; cur; cur = cur->ai_next) {
if (cur->ai_family != AF_INET6)
@@ -1001,9 +1002,10 @@
if (str_isnumber(servname)) {
if (!allownumeric)
return EAI_SERVICE;
- port = htons(atoi(servname));
+ port = atoi(servname);
if (port < 0 || port > 65535)
return EAI_SERVICE;
+ port = htons(port);
} else {
switch (ai->ai_socktype) {
case SOCK_DGRAM:
@@ -1076,12 +1078,13 @@
}
/* convert a string to a scope identifier. XXX: IPv6 specific */
-static int
+static u_int32_t
ip6_str2scopeid(scope, sin6)
char *scope;
struct sockaddr_in6 *sin6;
{
- int scopeid;
+ u_int32_t scopeid;
+ u_long lscopeid;
struct in6_addr *a6 = &sin6->sin6_addr;
char *ep;
@@ -1113,8 +1116,10 @@
/* try to convert to a numeric id as a last resort */
trynumeric:
- scopeid = (int)strtoul(scope, &ep, 10);
- if (*ep == '\0')
+ errno = 0;
+ lscopeid = strtoul(scope, &ep, 10);
+ scopeid = lscopeid & 0xffffffffUL;
+ if (errno == 0 && ep && *ep == '\0' && scopeid == lscopeid)
return scopeid;
else
return -1;
diff -r 91be3fecf7c4 -r 868c2f41b166 dist/bind/lib/isc/ev_timers.c
--- a/dist/bind/lib/isc/ev_timers.c Thu Jul 04 23:24:43 2002 +0000
+++ b/dist/bind/lib/isc/ev_timers.c Thu Jul 04 23:30:39 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ev_timers.c,v 1.5 2002/06/20 11:43:07 itojun Exp $ */
+/* $NetBSD: ev_timers.c,v 1.6 2002/07/04 23:30:40 itojun Exp $ */
/*
* Copyright (c) 1995-1999 by Internet Software Consortium
@@ -154,10 +154,10 @@
evTimer *id;
evPrintf(ctx, 1,
-"evSetTimer(ctx %p, func %p, uap %p, due %d.%09ld, inter %d.%09ld)\n",
+"evSetTimer(ctx %p, func %p, uap %p, due %ld.%09ld, inter %ld.%09ld)\n",
ctx, func, uap,
- (int)due.tv_sec, due.tv_nsec,
- (int)inter.tv_sec, inter.tv_nsec);
+ (long)due.tv_sec, due.tv_nsec,
+ (long)inter.tv_sec, inter.tv_nsec);
/* due={0,0} is a magic cookie meaning "now." */
if (due.tv_sec == 0 && due.tv_nsec == 0L)
@@ -381,10 +381,10 @@
cur = what;
evPrintf(ctx, 7,
- " func %p, uap %p, due %d.%09ld, inter %d.%09ld\n",
+ " func %p, uap %p, due %ld.%09ld, inter %ld.%09ld\n",
cur->func, cur->uap,
- (int)cur->due.tv_sec, cur->due.tv_nsec,
- (int)cur->inter.tv_sec, cur->inter.tv_nsec);
+ (long)cur->due.tv_sec, cur->due.tv_nsec,
+ (long)cur->inter.tv_sec, cur->inter.tv_nsec);
}
static void
diff -r 91be3fecf7c4 -r 868c2f41b166 dist/bind/lib/isc/eventlib.c
--- a/dist/bind/lib/isc/eventlib.c Thu Jul 04 23:24:43 2002 +0000
+++ b/dist/bind/lib/isc/eventlib.c Thu Jul 04 23:30:39 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: eventlib.c,v 1.4 2002/06/20 11:43:07 itojun Exp $ */
+/* $NetBSD: eventlib.c,v 1.5 2002/07/04 23:30:40 itojun Exp $ */
/*
* Copyright (c) 1995-1999 by Internet Software Consortium
@@ -293,12 +293,12 @@
}
evPrintf(ctx, 4,
- "pselect(%d, 0x%lx, 0x%lx, 0x%lx, %d.%09ld)\n",
+ "pselect(%d, 0x%lx, 0x%lx, 0x%lx, %ld.%09ld)\n",
ctx->fdMax+1,
(u_long)ctx->rdLast.fds_bits[0],
(u_long)ctx->wrLast.fds_bits[0],
(u_long)ctx->exLast.fds_bits[0],
- tp ? (int)tp->tv_sec : -1,
+ tp ? (long)tp->tv_sec : -1,
tp ? tp->tv_nsec : -1);
/* XXX should predict system's earliness and adjust. */
diff -r 91be3fecf7c4 -r 868c2f41b166 dist/bind/lib/nameser/ns_name.c
--- a/dist/bind/lib/nameser/ns_name.c Thu Jul 04 23:24:43 2002 +0000
+++ b/dist/bind/lib/nameser/ns_name.c Thu Jul 04 23:30:39 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ns_name.c,v 1.4 2002/06/20 11:43:08 itojun Exp $ */
+/* $NetBSD: ns_name.c,v 1.5 2002/07/04 23:30:40 itojun Exp $ */
/*
* Copyright (c) 1996,1999 by Internet Software Consortium.
@@ -790,7 +790,7 @@
{
const char *cp = *cpp;
char *beg = dn, tc;
- int b, blen, plen;
+ int b, blen, plen, i;
if ((blen = (*cp & 0xff)) == 0)
blen = 256;
@@ -800,18 +800,33 @@
return(-1);
cp++;
- dn += SPRINTF((dn, "\\[x"));
+ i = SPRINTF((dn, "\\[x"));
+ if (i < 0)
+ return (-1);
+ dn += i;
for (b = blen; b > 7; b -= 8, cp++)
- dn += SPRINTF((dn, "%02x", *cp & 0xff));
+ i = SPRINTF((dn, "%02x", *cp & 0xff));
+ if (i < 0)
+ return (-1);
+ dn += i;
if (b > 4) {
tc = *cp++;
- dn += SPRINTF((dn, "%02x", tc & (0xff << (8 - b))));
+ i = SPRINTF((dn, "%02x", tc & (0xff << (8 - b))));
+ if (i < 0)
+ return (-1);
+ dn += i;
} else if (b > 0) {
tc = *cp++;
- dn += SPRINTF((dn, "%1x",
+ i = SPRINTF((dn, "%1x",
((tc >> 4) & 0x0f) & (0x0f << (4 - b))));
+ if (i < 0)
+ return (-1);
+ dn += i;
}
- dn += SPRINTF((dn, "/%d]", blen));
+ i = SPRINTF((dn, "/%d]", blen));
+ if (i < 0)
+ return (-1);
+ dn += i;
*cpp = cp;
return(dn - beg);
diff -r 91be3fecf7c4 -r 868c2f41b166 dist/bind/lib/resolv/res_send.c
--- a/dist/bind/lib/resolv/res_send.c Thu Jul 04 23:24:43 2002 +0000
+++ b/dist/bind/lib/resolv/res_send.c Thu Jul 04 23:30:39 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: res_send.c,v 1.5 2002/06/20 11:43:08 itojun Exp $ */
+/* $NetBSD: res_send.c,v 1.6 2002/07/04 23:30:40 itojun Exp $ */
/*
* Copyright (c) 1985, 1989, 1993
@@ -173,6 +173,9 @@
srv6 = (struct sockaddr_in6 *)get_nsaddr(statp, ns);
if (srv6->sin6_family == in6p->sin6_family &&
srv6->sin6_port == in6p->sin6_port &&
+#ifdef HAVE_SIN6_SCOPE_ID
+ srv6->sin6_scope_id == in6p->sin6_scope_id &&
+#endif
(IN6_IS_ADDR_UNSPECIFIED(&srv6->sin6_addr) ||
IN6_ARE_ADDR_EQUAL(&srv6->sin6_addr, &in6p->sin6_addr)))
return (1);
Home |
Main Index |
Thread Index |
Old Index