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.43 (requested by lukem ...
details: https://anonhg.NetBSD.org/src/rev/8b4047ea9f46
branches: netbsd-1-6
changeset: 528634:8b4047ea9f46
user: lukem <lukem%NetBSD.org@localhost>
date: Mon Jul 29 15:22:28 2002 +0000
description:
Pull up revision 1.43 (requested by lukem as a prerequisite for ticket #569):
be picky about string manipulation in reverse lookups
diffstat:
lib/libc/net/gethnamaddr.c | 27 ++++++++++++++-------------
1 files changed, 14 insertions(+), 13 deletions(-)
diffs (68 lines):
diff -r 12f129cca42a -r 8b4047ea9f46 lib/libc/net/gethnamaddr.c
--- a/lib/libc/net/gethnamaddr.c Mon Jul 29 15:00:57 2002 +0000
+++ b/lib/libc/net/gethnamaddr.c Mon Jul 29 15:22:28 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gethnamaddr.c,v 1.42.2.3 2002/06/26 11:15:53 lukem Exp $ */
+/* $NetBSD: gethnamaddr.c,v 1.42.2.4 2002/07/29 15:22:28 lukem Exp $ */
/*
* ++Copyright++ 1985, 1988, 1993
@@ -61,7 +61,7 @@
static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93";
static char rcsid[] = "Id: gethnamaddr.c,v 8.21 1997/06/01 20:34:37 vixie Exp ";
#else
-__RCSID("$NetBSD: gethnamaddr.c,v 1.42.2.3 2002/06/26 11:15:53 lukem Exp $");
+__RCSID("$NetBSD: gethnamaddr.c,v 1.42.2.4 2002/07/29 15:22:28 lukem Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -1056,7 +1056,6 @@
hp = ap[j];
ap[j] = ap[j+1];
ap[j+1] = hp;
-
} else
break;
}
@@ -1175,7 +1174,7 @@
querybuf buf;
struct hostent *hp;
const unsigned char *uaddr;
- int len, af;
+ int len, af, advance;
_DIAGASSERT(rv != NULL);
@@ -1185,21 +1184,23 @@
switch (af) {
case AF_INET:
- (void)sprintf(qbuf, "%u.%u.%u.%u.in-addr.arpa",
- (uaddr[3] & 0xff),
- (uaddr[2] & 0xff),
- (uaddr[1] & 0xff),
- (uaddr[0] & 0xff));
+ (void)snprintf(qbuf, sizeof(qbuf), "%u.%u.%u.%u.in-addr.arpa",
+ (uaddr[3] & 0xff), (uaddr[2] & 0xff),
+ (uaddr[1] & 0xff), (uaddr[0] & 0xff));
break;
case AF_INET6:
qp = qbuf;
for (n = IN6ADDRSZ - 1; n >= 0; n--) {
- qp += sprintf(qp, "%x.%x.",
- uaddr[n] & 0xf,
- ((unsigned int)uaddr[n] >> 4) & 0xf);
+ advance = sprintf(qp, "%x.%x.", uaddr[n] & 0xf,
+ ((unsigned int)uaddr[n] >> 4) & 0xf);
+ if (advance > 0 &&
+ qp + advance < qbuf + sizeof(qbuf) - 1)
+ qp += advance;
+ else
+ return NS_NOTFOUND;
}
- strcpy(qp, "ip6.int");
+ strlcat(qbuf, "ip6.int", sizeof(qbuf));
break;
default:
abort();
Home |
Main Index |
Thread Index |
Old Index