Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-6]: src/lib/libc/net Pull up revision 1.26 (requested by itojun...
details: https://anonhg.NetBSD.org/src/rev/c70f79fa48af
branches: netbsd-1-6
changeset: 529355:c70f79fa48af
user: lukem <lukem%NetBSD.org@localhost>
date: Fri Nov 15 00:50:19 2002 +0000
description:
Pull up revision 1.26 (requested by itojun in ticket #990):
pull in changes in http://www.isc.org/products/BIND/patches/bind4910.diff
- better error check on __dn_skipname
- more strict reverse lookup handling
diffstat:
lib/libc/net/getnetnamadr.c | 50 ++++++++++++++++++++++++++++----------------
1 files changed, 32 insertions(+), 18 deletions(-)
diffs (102 lines):
diff -r 2133096ffff0 -r c70f79fa48af lib/libc/net/getnetnamadr.c
--- a/lib/libc/net/getnetnamadr.c Fri Nov 15 00:48:43 2002 +0000
+++ b/lib/libc/net/getnetnamadr.c Fri Nov 15 00:50:19 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: getnetnamadr.c,v 1.20.4.4 2002/11/15 00:46:09 lukem Exp $ */
+/* $NetBSD: getnetnamadr.c,v 1.20.4.5 2002/11/15 00:50:19 lukem Exp $ */
/* Copyright (c) 1993 Carlos Leandro and Rui Salgueiro
* Dep. Matematica Universidade de Coimbra, Portugal, Europe
@@ -47,7 +47,7 @@
static char sccsid_[] = "from getnetnamadr.c 1.4 (Coimbra) 93/06/03";
static char rcsid[] = "Id: getnetnamadr.c,v 8.8 1997/06/01 20:34:37 vixie Exp ";
#else
-__RCSID("$NetBSD: getnetnamadr.c,v 1.20.4.4 2002/11/15 00:46:09 lukem Exp $");
+__RCSID("$NetBSD: getnetnamadr.c,v 1.20.4.5 2002/11/15 00:50:19 lukem Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -137,7 +137,7 @@
int type, class, ancount, qdcount, haveanswer, i, nchar;
char aux1[MAXDNAME], aux2[MAXDNAME], ans[MAXDNAME];
char *in, *st, *pauxt, *bp, **ap;
- char *paux1 = &aux1[0], *paux2 = &aux2[0], flag = 0, *ep;
+ char *paux1 = &aux1[0], *paux2 = &aux2[0], *ep;
static char netbuf[PACKETSZ];
_DIAGASSERT(answer != NULL);
@@ -170,8 +170,14 @@
h_errno = TRY_AGAIN;
return (NULL);
}
- while (qdcount-- > 0)
- cp += __dn_skipname(cp, eom) + QFIXEDSZ;
+ while (qdcount-- > 0) {
+ n = __dn_skipname(cp, eom);
+ if (n < 0 || (cp + n + QFIXEDSZ) > eom) {
+ h_errno = NO_RECOVERY;
+ return(NULL);
+ }
+ cp += n + QFIXEDSZ;
+ }
ap = net_aliases;
*ap = NULL;
net_entry.n_aliases = net_aliases;
@@ -182,7 +188,7 @@
break;
cp += n;
ans[0] = '\0';
- (void)strlcpy(&ans[0], bp, sizeof(ans));
+ (void)strlcpy(ans, bp, sizeof(ans));
GETSHORT(type, cp);
GETSHORT(class, cp);
cp += INT32SZ; /* TTL */
@@ -209,28 +215,36 @@
net_entry.n_net = 0L;
break;
case BYNAME:
- in = *net_entry.n_aliases;
- net_entry.n_name = &ans[0];
+ ap = net_entry.n_aliases;
+ next_alias:
+ in = *ap++;
+ if (in == NULL) {
+ h_errno = HOST_NOT_FOUND;
+ return (NULL);
+ }
+ net_entry.n_name = ans;
aux2[0] = '\0';
for (i = 0; i < 4; i++) {
for (st = in, nchar = 0;
- *st != '.';
+ isdigit((unsigned char)*st);
st++, nchar++)
;
- if (nchar != 1 || *in != '0' || flag) {
- flag = 1;
- (void)strlcpy(paux1,
- (i==0) ? in : in-1,
- (size_t)((i==0) ? nchar+1 : nchar+2));
- pauxt = paux2;
- paux2 = strcat(paux1, paux2);
- paux1 = pauxt;
- }
+ if (*st != '.' || nchar == 0 || nchar > 3)
+ goto next_alias;
+ if (i != 0)
+ nchar++;
+ (void)strlcpy(paux1, in, (size_t)nchar);
+ paux1[nchar] = '\0';
+ pauxt = paux2;
+ paux2 = strcat(paux1, paux2);
+ paux1 = pauxt;
in = ++st;
}
net_entry.n_net = inet_network(paux2);
break;
}
+ if (strcasecmp(in, "IN-ADDR.ARPA") != 0)
+ goto next_alias;
net_entry.n_aliases++;
return (&net_entry);
}
Home |
Main Index |
Thread Index |
Old Index