summaryrefslogtreecommitdiffstats
path: root/contrib/bind/lib/inet
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1999-11-30 02:43:11 +0000
committerpeter <peter@FreeBSD.org>1999-11-30 02:43:11 +0000
commit4ef23ce6957fc75fc005885496d605fed48213e1 (patch)
tree7828b08c74ef918938b1b853c98f0cb41edac52c /contrib/bind/lib/inet
parent67e0f3ce71726dc4058c2f80a813341a59244dbd (diff)
downloadFreeBSD-src-4ef23ce6957fc75fc005885496d605fed48213e1.zip
FreeBSD-src-4ef23ce6957fc75fc005885496d605fed48213e1.tar.gz
Import bind v8.2.2.p5, minus the crypto for the time being. The bind
package does have BXA export approval, but the licensing strings on the dnssafe code are a bit unpleasant. The crypto is easy to restore and bind will run without it - just without full dnssec support. Obtained from: The Internet Software Consortium (www.isc.org)
Diffstat (limited to 'contrib/bind/lib/inet')
-rw-r--r--contrib/bind/lib/inet/Makefile29
-rw-r--r--contrib/bind/lib/inet/inet_addr.c78
-rw-r--r--contrib/bind/lib/inet/inet_cidr_ntop.c129
-rw-r--r--contrib/bind/lib/inet/inet_cidr_pton.c153
-rw-r--r--contrib/bind/lib/inet/inet_lnaof.c2
-rw-r--r--contrib/bind/lib/inet/inet_makeaddr.c2
-rw-r--r--contrib/bind/lib/inet/inet_net_ntop.c7
-rw-r--r--contrib/bind/lib/inet/inet_net_pton.c41
-rw-r--r--contrib/bind/lib/inet/inet_neta.c4
-rw-r--r--contrib/bind/lib/inet/inet_netof.c2
-rw-r--r--contrib/bind/lib/inet/inet_network.c15
-rw-r--r--contrib/bind/lib/inet/inet_ntoa.c6
-rw-r--r--contrib/bind/lib/inet/inet_ntop.c7
-rw-r--r--contrib/bind/lib/inet/inet_pton.c9
-rw-r--r--contrib/bind/lib/inet/nsap_addr.c4
15 files changed, 412 insertions, 76 deletions
diff --git a/contrib/bind/lib/inet/Makefile b/contrib/bind/lib/inet/Makefile
index 80bff87..04c4c1f 100644
--- a/contrib/bind/lib/inet/Makefile
+++ b/contrib/bind/lib/inet/Makefile
@@ -1,4 +1,4 @@
-# Copyright (c) 1996 by Internet Software Consortium
+# Copyright (c) 1996,1999 by Internet Software Consortium
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@@ -13,7 +13,7 @@
# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
# SOFTWARE.
-# $Id: Makefile,v 8.8 1997/05/21 19:32:07 halley Exp $
+# $Id: Makefile,v 8.16 1999/03/03 08:07:16 vixie Exp $
# these are only appropriate for BSD 4.4 or derivatives, and are used in
# development. normal builds will be done in the top level directory and
@@ -31,36 +31,53 @@ TOP= ../..
INCL = ${TOP}/include
PORTINCL = ${TOP}/port/${SYSTYPE}/include
LIBBIND = ${TOP}/lib/libbind.${A}
+LIBBINDR = ../${TOP}/lib/libbind_r.${A}
CFLAGS= ${CDEBUG} -I${PORTINCL} -I${INCL}
LD_LIBFLAGS= -x -r
-AR= ar cruv
+AR= ar cru
RANLIB= ranlib
INSTALL= install
+INSTALL_EXEC=
+INSTALL_LIB=-o bin -g bin
+THREADED= threaded
SRCS= nsap_addr.c inet_addr.c inet_ntop.c inet_pton.c \
inet_ntoa.c inet_neta.c inet_net_ntop.c inet_net_pton.c \
+ inet_cidr_ntop.c inet_cidr_pton.c \
inet_lnaof.c inet_makeaddr.c inet_netof.c inet_network.c
OBJS= nsap_addr.${O} inet_addr.${O} inet_ntop.${O} inet_pton.${O} \
inet_ntoa.${O} inet_neta.${O} inet_net_ntop.${O} inet_net_pton.${O} \
+ inet_cidr_ntop.${O} inet_cidr_pton.${O} \
inet_lnaof.${O} inet_makeaddr.${O} inet_netof.${O} inet_network.${O}
-
all: ${LIBBIND}
${LIBBIND}: ${OBJS}
+ ( cd ${THREADED} ; \
+ ${AR} ${LIBBINDR} ${ARPREF} ${OBJS} ${ARSUFF} ; \
+ ${RANLIB} ${LIBBINDR} )
${AR} ${LIBBIND} ${ARPREF} ${OBJS} ${ARSUFF}
${RANLIB} ${LIBBIND}
.c.${O}:
- ${CC} ${CPPFLAGS} ${CFLAGS} -c $*.c
- -${LDS} ${LD} ${LD_LIBFLAGS} $*.${O} && ${LDS} mv a.out $*.${O}
+ if test ! -d ${THREADED} ; then mkdir ${THREADED} ; fi
+ ${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} ${REENTRANT} -c $*.c \
+ -o ${THREADED}/$*.${O}
+ -${LDS} ${LD} ${LD_LIBFLAGS} ${THREADED}/$*.${O} -o a.out && \
+ ${LDS} mv a.out ${THREADED}/$*.${O}
+ ${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} -c $*.c
+ -${LDS} ${LD} ${LD_LIBFLAGS} $*.${O} -o a.out && \
+ ${LDS} mv a.out $*.${O}
distclean: clean
clean: FRC
rm -f .depend a.out core ${LIB} tags
rm -f *.${O} *.BAK *.CKP *~
+ rm -f ${THREADED}/*.${O}
+ -rmdir ${THREADED}
+
depend: FRC
mkdep -I${INCL} -I${PORTINCL} ${CPPFLAGS} ${SRCS}
diff --git a/contrib/bind/lib/inet/inet_addr.c b/contrib/bind/lib/inet/inet_addr.c
index 1d3943b..3b54aa8 100644
--- a/contrib/bind/lib/inet/inet_addr.c
+++ b/contrib/bind/lib/inet/inet_addr.c
@@ -1,6 +1,4 @@
/*
- * ++Copyright++ 1983, 1990, 1993
- * -
* Copyright (c) 1983, 1990, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -31,7 +29,9 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- * -
+ */
+
+/*
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
*
* Permission to use, copy, modify, and distribute this software for any
@@ -49,33 +49,48 @@
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
- * -
- * --Copyright--
+ */
+
+/*
+ * Portions Copyright (c) 1996-1999 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93";
-static char rcsid[] = "$Id: inet_addr.c,v 8.7 1996/11/18 09:09:07 vixie Exp $";
+static const char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93";
+static const char rcsid[] = "$Id: inet_addr.c,v 8.11 1999/10/13 16:39:25 vixie Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
+
#include <sys/types.h>
#include <sys/param.h>
+
#include <netinet/in.h>
#include <arpa/inet.h>
+
#include <ctype.h>
-#include "port_after.h"
-/* these are compatibility routines, not needed on recent BSD releases */
+#include "port_after.h"
/*
* Ascii internet address interpretation routine.
* The value returned is in network order.
*/
u_long
-inet_addr(cp)
- register const char *cp;
-{
+inet_addr(const char *cp) {
struct in_addr val;
if (inet_aton(cp, &val))
@@ -91,15 +106,13 @@ inet_addr(cp)
* cannot distinguish between failure and a local broadcast address.
*/
int
-inet_aton(cp, addr)
- register const char *cp;
- struct in_addr *addr;
-{
- register u_long val;
- register int base, n;
- register char c;
- u_int parts[4];
- register u_int *pp = parts;
+inet_aton(const char *cp, struct in_addr *addr) {
+ u_long val;
+ int base, n;
+ char c;
+ u_int8_t parts[4];
+ u_int8_t *pp = parts;
+ int digit;
c = *cp;
for (;;) {
@@ -110,22 +123,28 @@ inet_aton(cp, addr)
*/
if (!isdigit(c))
return (0);
- val = 0; base = 10;
+ val = 0; base = 10; digit = 0;
if (c == '0') {
c = *++cp;
if (c == 'x' || c == 'X')
base = 16, c = *++cp;
- else
+ else {
base = 8;
+ digit = 1 ;
+ }
}
for (;;) {
if (isascii(c) && isdigit(c)) {
+ if (base == 8 && (c == '8' || c == '9'))
+ return (0);
val = (val * base) + (c - '0');
c = *++cp;
+ digit = 1;
} else if (base == 16 && isascii(c) && isxdigit(c)) {
val = (val << 4) |
(c + 10 - (islower(c) ? 'a' : 'A'));
c = *++cp;
+ digit = 1;
} else
break;
}
@@ -136,7 +155,7 @@ inet_aton(cp, addr)
* a.b.c (with c treated as 16 bits)
* a.b (with b treated as 24 bits)
*/
- if (pp >= parts + 3)
+ if (pp >= parts + 3 || val > 0xff)
return (0);
*pp++ = val;
c = *++cp;
@@ -149,15 +168,16 @@ inet_aton(cp, addr)
if (c != '\0' && (!isascii(c) || !isspace(c)))
return (0);
/*
+ * Did we get a valid digit?
+ */
+ if (!digit)
+ return (0);
+ /*
* Concoct the address according to
* the number of parts specified.
*/
n = pp - parts + 1;
switch (n) {
-
- case 0:
- return (0); /* initial nondigit */
-
case 1: /* a -- 32 bits */
break;
@@ -179,7 +199,7 @@ inet_aton(cp, addr)
val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
break;
}
- if (addr)
+ if (addr != NULL)
addr->s_addr = htonl(val);
return (1);
}
diff --git a/contrib/bind/lib/inet/inet_cidr_ntop.c b/contrib/bind/lib/inet/inet_cidr_ntop.c
new file mode 100644
index 0000000..08352ab
--- /dev/null
+++ b/contrib/bind/lib/inet/inet_cidr_ntop.c
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 1998,1999 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static const char rcsid[] = "$Id: inet_cidr_ntop.c,v 8.4 1999/10/07 20:44:02 vixie Exp $";
+#endif
+
+#include "port_before.h"
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "port_after.h"
+
+#ifdef SPRINTF_CHAR
+# define SPRINTF(x) strlen(sprintf/**/x)
+#else
+# define SPRINTF(x) ((size_t)sprintf x)
+#endif
+
+static char * inet_cidr_ntop_ipv4 __P((const u_char *src, int bits,
+ char *dst, size_t size));
+
+/*
+ * char *
+ * inet_cidr_ntop(af, src, bits, dst, size)
+ * convert network address from network to presentation format.
+ * "src"'s size is determined from its "af".
+ * return:
+ * pointer to dst, or NULL if an error occurred (check errno).
+ * note:
+ * 192.5.5.1/28 has a nonzero host part, which means it isn't a network
+ * as called for by inet_net_ntop() but it can be a host address with
+ * an included netmask.
+ * author:
+ * Paul Vixie (ISC), October 1998
+ */
+char *
+inet_cidr_ntop(int af, const void *src, int bits, char *dst, size_t size) {
+ switch (af) {
+ case AF_INET:
+ return (inet_cidr_ntop_ipv4(src, bits, dst, size));
+ default:
+ errno = EAFNOSUPPORT;
+ return (NULL);
+ }
+}
+
+/*
+ * static char *
+ * inet_cidr_ntop_ipv4(src, bits, dst, size)
+ * convert IPv4 network address from network to presentation format.
+ * "src"'s size is determined from its "af".
+ * return:
+ * pointer to dst, or NULL if an error occurred (check errno).
+ * note:
+ * network byte order assumed. this means 192.5.5.240/28 has
+ * 0b11110000 in its fourth octet.
+ * author:
+ * Paul Vixie (ISC), October 1998
+ */
+static char *
+inet_cidr_ntop_ipv4(const u_char *src, int bits, char *dst, size_t size) {
+ char *odst = dst;
+ char *t;
+ size_t len = 4;
+ int b, tb;
+
+ if ((bits < -1) || (bits > 32)) {
+ errno = EINVAL;
+ return (NULL);
+ }
+
+ /* Find number of significant bytes in address. */
+ if (bits == -1)
+ len = 3;
+ else
+ for (len = 0,b = 1 ; b < 4; b++)
+ if (*(src + b))
+ len = b;
+
+ /* Format whole octets plus nonzero trailing octets. */
+ tb = (bits <= 0) ? 1 : (bits - 1);
+ for (b = 0; b <= (tb / 8) || (b <= len); b++) {
+ if (size < sizeof "255.")
+ goto emsgsize;
+ t = dst;
+ dst += SPRINTF((dst, "%u", *src++));
+ if (b + 1 <= (tb / 8) || (b + 1 <= len)) {
+ *dst++ = '.';
+ *dst = '\0';
+ }
+ size -= (size_t)(dst - t);
+ }
+
+ if (bits != -1) {
+ /* Format CIDR /width. */
+ if (size < sizeof "/32")
+ goto emsgsize;
+ dst += SPRINTF((dst, "/%u", bits));
+ }
+
+ return (odst);
+
+ emsgsize:
+ errno = EMSGSIZE;
+ return (NULL);
+}
diff --git a/contrib/bind/lib/inet/inet_cidr_pton.c b/contrib/bind/lib/inet/inet_cidr_pton.c
new file mode 100644
index 0000000..4fae2c6
--- /dev/null
+++ b/contrib/bind/lib/inet/inet_cidr_pton.c
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 1998,1999 by Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
+ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
+ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static const char rcsid[] = "$Id: inet_cidr_pton.c,v 8.3 1999/01/08 19:23:41 vixie Exp $";
+#endif
+
+#include "port_before.h"
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <isc/assertions.h>
+#include <ctype.h>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "port_after.h"
+
+#ifdef SPRINTF_CHAR
+# define SPRINTF(x) strlen(sprintf/**/x)
+#else
+# define SPRINTF(x) ((size_t)sprintf x)
+#endif
+
+static int inet_cidr_pton_ipv4 __P((const char *src, u_char *dst,
+ int *bits));
+
+/*
+ * int
+ * inet_cidr_pton(af, src, dst, *bits)
+ * convert network address from presentation to network format.
+ * accepts inet_pton()'s input for this "af" plus trailing "/CIDR".
+ * "dst" is assumed large enough for its "af". "bits" is set to the
+ * /CIDR prefix length, which can have defaults (like /32 for IPv4).
+ * return:
+ * -1 if an error occurred (inspect errno; ENOENT means bad format).
+ * 0 if successful conversion occurred.
+ * note:
+ * 192.5.5.1/28 has a nonzero host part, which means it isn't a network
+ * as called for by inet_net_pton() but it can be a host address with
+ * an included netmask.
+ * author:
+ * Paul Vixie (ISC), October 1998
+ */
+int
+inet_cidr_pton(int af, const char *src, void *dst, int *bits) {
+ switch (af) {
+ case AF_INET:
+ return (inet_cidr_pton_ipv4(src, dst, bits));
+ default:
+ errno = EAFNOSUPPORT;
+ return (-1);
+ }
+}
+
+static int
+inet_cidr_pton_ipv4(const char *src, u_char *dst, int *pbits) {
+ static const char digits[] = "0123456789";
+ const u_char *odst = dst;
+ int n, ch, tmp, bits;
+ size_t size = 4;
+
+ /* Get the mantissa. */
+ while (ch = *src++, (isascii(ch) && isdigit(ch))) {
+ tmp = 0;
+ do {
+ n = strchr(digits, ch) - digits;
+ INSIST(n >= 0 && n <= 9);
+ tmp *= 10;
+ tmp += n;
+ if (tmp > 255)
+ goto enoent;
+ } while ((ch = *src++) != '\0' && isascii(ch) && isdigit(ch));
+ if (size-- == 0)
+ goto emsgsize;
+ *dst++ = (u_char) tmp;
+ if (ch == '\0' || ch == '/')
+ break;
+ if (ch != '.')
+ goto enoent;
+ }
+
+ /* Get the prefix length if any. */
+ bits = -1;
+ if (ch == '/' && isascii(src[0]) && isdigit(src[0]) && dst > odst) {
+ /* CIDR width specifier. Nothing can follow it. */
+ ch = *src++; /* Skip over the /. */
+ bits = 0;
+ do {
+ n = strchr(digits, ch) - digits;
+ INSIST(n >= 0 && n <= 9);
+ bits *= 10;
+ bits += n;
+ } while ((ch = *src++) != '\0' && isascii(ch) && isdigit(ch));
+ if (ch != '\0')
+ goto enoent;
+ if (bits > 32)
+ goto emsgsize;
+ }
+
+ /* Firey death and destruction unless we prefetched EOS. */
+ if (ch != '\0')
+ goto enoent;
+
+ /* Prefix length can default to /32 only if all four octets spec'd. */
+ if (bits == -1)
+ if (dst - odst == 4)
+ bits = 32;
+ else
+ goto enoent;
+
+ /* If nothing was written to the destination, we found no address. */
+ if (dst == odst)
+ goto enoent;
+
+ /* If prefix length overspecifies mantissa, life is bad. */
+ if ((bits / 8) > (dst - odst))
+ goto enoent;
+
+ /* Extend address to four octets. */
+ while (size-- > 0)
+ *dst++ = 0;
+
+ *pbits = bits;
+ return (0);
+
+ enoent:
+ errno = ENOENT;
+ return (-1);
+
+ emsgsize:
+ errno = EMSGSIZE;
+ return (-1);
+}
diff --git a/contrib/bind/lib/inet/inet_lnaof.c b/contrib/bind/lib/inet/inet_lnaof.c
index 9562024..97b80cf 100644
--- a/contrib/bind/lib/inet/inet_lnaof.c
+++ b/contrib/bind/lib/inet/inet_lnaof.c
@@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)inet_lnaof.c 8.1 (Berkeley) 6/4/93";
+static const char sccsid[] = "@(#)inet_lnaof.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
diff --git a/contrib/bind/lib/inet/inet_makeaddr.c b/contrib/bind/lib/inet/inet_makeaddr.c
index 8a4b082..49ea023 100644
--- a/contrib/bind/lib/inet/inet_makeaddr.c
+++ b/contrib/bind/lib/inet/inet_makeaddr.c
@@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)inet_makeaddr.c 8.1 (Berkeley) 6/4/93";
+static const char sccsid[] = "@(#)inet_makeaddr.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
diff --git a/contrib/bind/lib/inet/inet_net_ntop.c b/contrib/bind/lib/inet/inet_net_ntop.c
index 7f6526f..4e2f91f 100644
--- a/contrib/bind/lib/inet/inet_net_ntop.c
+++ b/contrib/bind/lib/inet/inet_net_ntop.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996 by Internet Software Consortium.
+ * Copyright (c) 1996,1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: inet_net_ntop.c,v 1.4 1996/11/18 09:09:08 vixie Exp $";
+static const char rcsid[] = "$Id: inet_net_ntop.c,v 1.6 1999/01/08 19:23:42 vixie Exp $";
#endif
#include "port_before.h"
@@ -78,7 +78,7 @@ inet_net_ntop(af, src, bits, dst, size)
* pointer to dst, or NULL if an error occurred (check errno).
* note:
* network byte order assumed. this means 192.5.5.240/28 has
- * 0x11110000 in its fourth octet.
+ * 0b11110000 in its fourth octet.
* author:
* Paul Vixie (ISC), July 1996
*/
@@ -102,6 +102,7 @@ inet_net_ntop_ipv4(src, bits, dst, size)
if (size < sizeof "0")
goto emsgsize;
*dst++ = '0';
+ size--;
*dst = '\0';
}
diff --git a/contrib/bind/lib/inet/inet_net_pton.c b/contrib/bind/lib/inet/inet_net_pton.c
index 5f381c5..4d265b2 100644
--- a/contrib/bind/lib/inet/inet_net_pton.c
+++ b/contrib/bind/lib/inet/inet_net_pton.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996 by Internet Software Consortium.
+ * Copyright (c) 1996,1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: inet_net_pton.c,v 1.8 1996/11/21 10:28:12 vixie Exp $";
+static const char rcsid[] = "$Id: inet_net_pton.c,v 1.11 1999/01/08 19:23:44 vixie Exp $";
#endif
#include "port_before.h"
@@ -26,7 +26,7 @@ static const char rcsid[] = "$Id: inet_net_pton.c,v 1.8 1996/11/21 10:28:12 vixi
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <assert.h>
+#include <isc/assertions.h>
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
@@ -85,7 +85,7 @@ inet_net_pton(af, src, dst, size)
* not an IPv4 network specification.
* note:
* network byte order assumed. this means 192.5.5.240/28 has
- * 0x11110000 in its fourth octet.
+ * 0b11110000 in its fourth octet.
* author:
* Paul Vixie (ISC), June 1996
*/
@@ -107,31 +107,36 @@ inet_net_pton_ipv4(src, dst, size)
/* Hexadecimal: Eat nybble string. */
if (size <= 0)
goto emsgsize;
- *dst = 0, dirty = 0;
+ dirty = 0;
src++; /* skip x or X. */
- while ((ch = *src++) != '\0' &&
- isascii(ch) && isxdigit(ch)) {
+ while ((ch = *src++) != '\0' && isascii(ch) && isxdigit(ch)) {
if (isupper(ch))
ch = tolower(ch);
n = strchr(xdigits, ch) - xdigits;
- assert(n >= 0 && n <= 15);
- *dst |= n;
- if (!dirty++)
- *dst <<= 4;
- else if (size-- > 0)
- *++dst = 0, dirty = 0;
+ INSIST(n >= 0 && n <= 15);
+ if (dirty == 0)
+ tmp = n;
else
+ tmp = (tmp << 4) | n;
+ if (++dirty == 2) {
+ if (size-- <= 0)
+ goto emsgsize;
+ *dst++ = (u_char) tmp;
+ dirty = 0;
+ }
+ }
+ if (dirty) { /* Odd trailing nybble? */
+ if (size-- <= 0)
goto emsgsize;
+ *dst++ = (u_char) (tmp << 4);
}
- if (dirty)
- size--;
} else if (isascii(ch) && isdigit(ch)) {
/* Decimal: eat dotted digit string. */
for (;;) {
tmp = 0;
do {
n = strchr(digits, ch) - digits;
- assert(n >= 0 && n <= 9);
+ INSIST(n >= 0 && n <= 9);
tmp *= 10;
tmp += n;
if (tmp > 255)
@@ -159,7 +164,7 @@ inet_net_pton_ipv4(src, dst, size)
bits = 0;
do {
n = strchr(digits, ch) - digits;
- assert(n >= 0 && n <= 9);
+ INSIST(n >= 0 && n <= 9);
bits *= 10;
bits += n;
} while ((ch = *src++) != '\0' && isascii(ch) && isdigit(ch));
@@ -167,8 +172,6 @@ inet_net_pton_ipv4(src, dst, size)
goto enoent;
if (bits > 32)
goto emsgsize;
- if (bits > 32)
- goto emsgsize;
}
/* Firey death and destruction unless we prefetched EOS. */
diff --git a/contrib/bind/lib/inet/inet_neta.c b/contrib/bind/lib/inet/inet_neta.c
index 96c24f3..8665a9a 100644
--- a/contrib/bind/lib/inet/inet_neta.c
+++ b/contrib/bind/lib/inet/inet_neta.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996 by Internet Software Consortium.
+ * Copyright (c) 1996,1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: inet_neta.c,v 1.5 1997/09/26 17:56:01 halley Exp $";
+static const char rcsid[] = "$Id: inet_neta.c,v 1.6 1999/01/08 19:23:45 vixie Exp $";
#endif
#include "port_before.h"
diff --git a/contrib/bind/lib/inet/inet_netof.c b/contrib/bind/lib/inet/inet_netof.c
index 54b700c..e887530 100644
--- a/contrib/bind/lib/inet/inet_netof.c
+++ b/contrib/bind/lib/inet/inet_netof.c
@@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)inet_netof.c 8.1 (Berkeley) 6/4/93";
+static const char sccsid[] = "@(#)inet_netof.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
diff --git a/contrib/bind/lib/inet/inet_network.c b/contrib/bind/lib/inet/inet_network.c
index 485b0b9..d26369c 100644
--- a/contrib/bind/lib/inet/inet_network.c
+++ b/contrib/bind/lib/inet/inet_network.c
@@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)inet_network.c 8.1 (Berkeley) 6/4/93";
+static const char sccsid[] = "@(#)inet_network.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
@@ -56,28 +56,35 @@ inet_network(cp)
register u_long val, base, n, i;
register char c;
u_long parts[4], *pp = parts;
+ int digit;
again:
- val = 0; base = 10;
+ val = 0; base = 10; digit = 0;
if (*cp == '0')
- base = 8, cp++;
+ digit = 1, base = 8, cp++;
if (*cp == 'x' || *cp == 'X')
base = 16, cp++;
while ((c = *cp) != 0) {
if (isdigit(c)) {
+ if (base == 8 && (c == '8' || c == '9'))
+ return (INADDR_NONE);
val = (val * base) + (c - '0');
cp++;
+ digit = 1;
continue;
}
if (base == 16 && isxdigit(c)) {
val = (val << 4) + (c + 10 - (islower(c) ? 'a' : 'A'));
cp++;
+ digit = 1;
continue;
}
break;
}
+ if (!digit)
+ return (INADDR_NONE);
if (*cp == '.') {
- if (pp >= parts + 4)
+ if (pp >= parts + 4 || val > 0xff)
return (INADDR_NONE);
*pp++ = val, cp++;
goto again;
diff --git a/contrib/bind/lib/inet/inet_ntoa.c b/contrib/bind/lib/inet/inet_ntoa.c
index 6d1ec29..aaedcb6 100644
--- a/contrib/bind/lib/inet/inet_ntoa.c
+++ b/contrib/bind/lib/inet/inet_ntoa.c
@@ -32,8 +32,8 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)inet_ntoa.c 8.1 (Berkeley) 6/4/93";
-static char rcsid[] = "$Id: inet_ntoa.c,v 1.5 1997/09/26 17:56:01 halley Exp $";
+static const char sccsid[] = "@(#)inet_ntoa.c 8.1 (Berkeley) 6/4/93";
+static const char rcsid[] = "$Id: inet_ntoa.c,v 1.7 1999/05/14 18:16:55 vixie Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
@@ -52,7 +52,7 @@ static char rcsid[] = "$Id: inet_ntoa.c,v 1.5 1997/09/26 17:56:01 halley Exp $";
* Convert network-format internet address
* to base 256 d.d.d.d representation.
*/
-char *
+/*const*/ char *
inet_ntoa(struct in_addr in) {
static char ret[18];
diff --git a/contrib/bind/lib/inet/inet_ntop.c b/contrib/bind/lib/inet/inet_ntop.c
index f575fce..0b85e70 100644
--- a/contrib/bind/lib/inet/inet_ntop.c
+++ b/contrib/bind/lib/inet/inet_ntop.c
@@ -1,4 +1,5 @@
-/* Copyright (c) 1996 by Internet Software Consortium.
+/*
+ * Copyright (c) 1996-1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -15,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$Id: inet_ntop.c,v 1.4 1996/11/18 09:09:10 vixie Exp $";
+static const char rcsid[] = "$Id: inet_ntop.c,v 1.8 1999/10/13 16:39:28 vixie Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
@@ -77,7 +78,7 @@ inet_ntop(af, src, dst, size)
/* const char *
* inet_ntop4(src, dst, size)
- * format an IPv4 address, more or less like inet_ntoa()
+ * format an IPv4 address
* return:
* `dst' (as a const)
* notes:
diff --git a/contrib/bind/lib/inet/inet_pton.c b/contrib/bind/lib/inet/inet_pton.c
index 021e840..0a2927d 100644
--- a/contrib/bind/lib/inet/inet_pton.c
+++ b/contrib/bind/lib/inet/inet_pton.c
@@ -1,4 +1,5 @@
-/* Copyright (c) 1996 by Internet Software Consortium.
+/*
+ * Copyright (c) 1996,1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -15,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$Id: inet_pton.c,v 1.4 1996/11/18 09:09:11 vixie Exp $";
+static const char rcsid[] = "$Id: inet_pton.c,v 1.7 1999/10/13 16:39:28 vixie Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
@@ -171,6 +172,8 @@ inet_pton6(src, dst)
return (0);
colonp = tp;
continue;
+ } else if (*src == '\0') {
+ return (0);
}
if (tp + NS_INT16SZ > endp)
return (0);
@@ -202,6 +205,8 @@ inet_pton6(src, dst)
const int n = tp - colonp;
int i;
+ if (tp == endp)
+ return (0);
for (i = 1; i <= n; i++) {
endp[- i] = colonp[n - i];
colonp[n - i] = 0;
diff --git a/contrib/bind/lib/inet/nsap_addr.c b/contrib/bind/lib/inet/nsap_addr.c
index e8dec96..b28acec 100644
--- a/contrib/bind/lib/inet/nsap_addr.c
+++ b/contrib/bind/lib/inet/nsap_addr.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 1998 by Internet Software Consortium.
+ * Copyright (c) 1996-1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$Id: nsap_addr.c,v 8.8 1998/02/13 01:11:12 halley Exp $";
+static const char rcsid[] = "$Id: nsap_addr.c,v 8.10 1999/10/13 16:39:28 vixie Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
OpenPOWER on IntegriCloud