svn commit: r270838 - in stable/10: include include/arpa lib/libc/include lib/libc/include/isc lib/libc/inet lib/libc/isc lib/libc/nameser lib/libc/resolv

Hajimu UMEMOTO ume at FreeBSD.org
Sat Aug 30 10:16:30 UTC 2014


Author: ume
Date: Sat Aug 30 10:16:25 2014
New Revision: 270838
URL: http://svnweb.freebsd.org/changeset/base/270838

Log:
  MFC r269867:
  Update our stub resolver to final version of libbind
  (libbind-6.0).
  
  Obtained from:  ISC

Modified:
  stable/10/include/arpa/inet.h
  stable/10/include/arpa/nameser.h
  stable/10/include/arpa/nameser_compat.h
  stable/10/include/res_update.h
  stable/10/include/resolv.h
  stable/10/lib/libc/include/isc/eventlib.h
  stable/10/lib/libc/include/isc/list.h
  stable/10/lib/libc/include/port_before.h
  stable/10/lib/libc/inet/inet_addr.c
  stable/10/lib/libc/inet/inet_cidr_ntop.c
  stable/10/lib/libc/inet/inet_cidr_pton.c
  stable/10/lib/libc/inet/inet_net_ntop.c
  stable/10/lib/libc/inet/inet_net_pton.c
  stable/10/lib/libc/inet/inet_neta.c
  stable/10/lib/libc/inet/inet_ntoa.c
  stable/10/lib/libc/inet/inet_ntop.c
  stable/10/lib/libc/inet/inet_pton.c
  stable/10/lib/libc/inet/nsap_addr.c
  stable/10/lib/libc/isc/ev_streams.c
  stable/10/lib/libc/isc/ev_timers.c
  stable/10/lib/libc/isc/eventlib_p.h
  stable/10/lib/libc/nameser/Symbol.map
  stable/10/lib/libc/nameser/ns_name.c
  stable/10/lib/libc/nameser/ns_netint.c
  stable/10/lib/libc/nameser/ns_parse.c
  stable/10/lib/libc/nameser/ns_print.c
  stable/10/lib/libc/nameser/ns_samedomain.c
  stable/10/lib/libc/nameser/ns_ttl.c
  stable/10/lib/libc/resolv/Makefile.inc
  stable/10/lib/libc/resolv/Symbol.map
  stable/10/lib/libc/resolv/herror.c
  stable/10/lib/libc/resolv/res_comp.c
  stable/10/lib/libc/resolv/res_data.c
  stable/10/lib/libc/resolv/res_debug.c
  stable/10/lib/libc/resolv/res_findzonecut.c
  stable/10/lib/libc/resolv/res_init.c
  stable/10/lib/libc/resolv/res_mkquery.c
  stable/10/lib/libc/resolv/res_mkupdate.c
  stable/10/lib/libc/resolv/res_query.c
  stable/10/lib/libc/resolv/res_send.c
  stable/10/lib/libc/resolv/res_update.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/include/arpa/inet.h
==============================================================================
--- stable/10/include/arpa/inet.h	Sat Aug 30 09:55:38 2014	(r270837)
+++ stable/10/include/arpa/inet.h	Sat Aug 30 10:16:25 2014	(r270838)
@@ -51,7 +51,7 @@
 
 /*%
  *	@(#)inet.h	8.1 (Berkeley) 6/2/93
- *	$Id: inet.h,v 1.2.18.1 2005/04/27 05:00:50 sra Exp $
+ *	$Id: inet.h,v 1.3 2005/04/27 04:56:16 sra Exp $
  * $FreeBSD$
  */
 

Modified: stable/10/include/arpa/nameser.h
==============================================================================
--- stable/10/include/arpa/nameser.h	Sat Aug 30 09:55:38 2014	(r270837)
+++ stable/10/include/arpa/nameser.h	Sat Aug 30 10:16:25 2014	(r270838)
@@ -1,7 +1,24 @@
 /*
+ * Portions Copyright (C) 2004, 2005, 2008, 2009  Internet Systems Consortium, Inc. ("ISC")
+ * Portions Copyright (C) 1996-2003  Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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.
+ */
+
+/*
  * Copyright (c) 1983, 1989, 1993
  *    The Regents of the University of California.  All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -13,7 +30,7 @@
  * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -28,24 +45,7 @@
  */
 
 /*
- * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
- * 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 ISC DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC 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.
- */
-
-/*
- *	$Id: nameser.h,v 1.7.18.2 2008/04/03 23:15:15 marka Exp $
+ *	$Id: nameser.h,v 1.16 2009/03/03 01:52:48 each Exp $
  * $FreeBSD$
  */
 
@@ -68,15 +68,18 @@
  * contains a new enough lib/nameser/ to support the feature you need.
  */
 
-#define __NAMESER	19991006	/*%< New interface version stamp. */
+#define __NAMESER	20090302	/*%< New interface version stamp. */
 /*
  * Define constants based on RFC0883, RFC1034, RFC 1035
  */
 #define NS_PACKETSZ	512	/*%< default UDP packet size */
-#define NS_MAXDNAME	1025	/*%< maximum domain name */
+#define NS_MAXDNAME	1025	/*%< maximum domain name (presentation format)*/
 #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_MAXLABELS	128	/*%< theoretical max #/labels per domain name */
+#define NS_MAXNNAME	256	/*%< maximum uncompressed (binary) domain name*/
+#define	NS_MAXPADDR	(sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")
 #define NS_HFIXEDSZ	12	/*%< #/bytes of fixed data in header */
 #define NS_QFIXEDSZ	4	/*%< #/bytes of fixed data in query */
 #define NS_RRFIXEDSZ	10	/*%< #/bytes of fixed data in r record */
@@ -103,6 +106,18 @@ typedef enum __ns_sect {
 } ns_sect;
 
 /*%
+ * Network name (compressed or not) type.  Equivilent to a pointer when used
+ * in a function prototype.  Can be const'd.
+ */
+typedef u_char ns_nname[NS_MAXNNAME];
+typedef const u_char *ns_nname_ct;
+typedef u_char *ns_nname_t;
+
+struct ns_namemap { ns_nname_ct base; int len; };
+typedef struct ns_namemap *ns_namemap_t;
+typedef const struct ns_namemap *ns_namemap_ct;
+
+/*%
  * This is a message handle.  It is caller allocated and has no dynamic data.
  * This structure is intended to be opaque to all but ns_parse.c, thus the
  * leading _'s on the member names.  Use the accessor functions, not the _'s.
@@ -116,6 +131,17 @@ typedef struct __ns_msg {
 	const u_char	*_msg_ptr;
 } ns_msg;
 
+/*
+ * This is a newmsg handle, used when constructing new messages with
+ * ns_newmsg_init, et al.
+ */
+struct ns_newmsg {
+	ns_msg		msg;
+	const u_char	*dnptrs[25];
+	const u_char	**lastdnptr;
+};
+typedef struct ns_newmsg ns_newmsg;
+
 /* Private data structure - do not use from outside library. */
 struct _ns_flagdata {  int mask, shift;  };
 extern struct _ns_flagdata _ns_flagdata[];
@@ -140,8 +166,23 @@ typedef	struct __ns_rr {
 	const u_char *	rdata;
 } ns_rr;
 
+/*
+ * Same thing, but using uncompressed network binary names, and real C types.
+ */
+typedef	struct __ns_rr2 {
+	ns_nname	nname;
+	size_t		nnamel;
+	int		type;
+	int		rr_class;
+	u_int		ttl;
+	int		rdlength;
+	const u_char *	rdata;
+} ns_rr2;
+
 /* Accessor macros - this is part of the public interface. */
 #define ns_rr_name(rr)	(((rr).name[0] != '\0') ? (rr).name : ".")
+#define ns_rr_nname(rr)	((const ns_nname_t)(rr).nname)
+#define ns_rr_nnamel(rr) ((rr).nnamel + 0)
 #define ns_rr_type(rr)	((ns_type)((rr).type + 0))
 #define ns_rr_class(rr)	((ns_class)((rr).rr_class + 0))
 #define ns_rr_ttl(rr)	((rr).ttl + 0)
@@ -216,9 +257,9 @@ typedef enum __ns_update_operation {
  * This structure is used for TSIG authenticated messages
  */
 struct ns_tsig_key {
-        char name[NS_MAXDNAME], alg[NS_MAXDNAME];
-        unsigned char *data;
-        int len;
+	char name[NS_MAXDNAME], alg[NS_MAXDNAME];
+	unsigned char *data;
+	int len;
 };
 typedef struct ns_tsig_key ns_tsig_key;
 
@@ -274,7 +315,7 @@ typedef enum __ns_type {
 	ns_t_key = 25,		/*%< Security key. */
 	ns_t_px = 26,		/*%< X.400 mail mapping. */
 	ns_t_gpos = 27,		/*%< Geographical position (withdrawn). */
-	ns_t_aaaa = 28,		/*%< Ip6 Address. */
+	ns_t_aaaa = 28,		/*%< IPv6 Address. */
 	ns_t_loc = 29,		/*%< Location Information. */
 	ns_t_nxt = 30,		/*%< Next domain (security). */
 	ns_t_eid = 31,		/*%< Endpoint identifier. */
@@ -284,11 +325,22 @@ typedef enum __ns_type {
 	ns_t_naptr = 35,	/*%< Naming Authority PoinTeR */
 	ns_t_kx = 36,		/*%< Key Exchange */
 	ns_t_cert = 37,		/*%< Certification record */
-	ns_t_a6 = 38,		/*%< IPv6 address (deprecates AAAA) */
-	ns_t_dname = 39,	/*%< Non-terminal DNAME (for IPv6) */
+	ns_t_a6 = 38,		/*%< IPv6 address (experimental) */
+	ns_t_dname = 39,	/*%< Non-terminal DNAME */
 	ns_t_sink = 40,		/*%< Kitchen sink (experimentatl) */
 	ns_t_opt = 41,		/*%< EDNS0 option (meta-RR) */
 	ns_t_apl = 42,		/*%< Address prefix list (RFC3123) */
+	ns_t_ds = 43,		/*%< Delegation Signer */
+	ns_t_sshfp = 44,	/*%< SSH Fingerprint */
+	ns_t_ipseckey = 45,	/*%< IPSEC Key */
+	ns_t_rrsig = 46,	/*%< RRset Signature */
+	ns_t_nsec = 47,		/*%< Negative security */
+	ns_t_dnskey = 48,	/*%< DNS Key */
+	ns_t_dhcid = 49,	/*%< Dynamic host configuratin identifier */
+	ns_t_nsec3 = 50,	/*%< Negative security type 3 */
+	ns_t_nsec3param = 51,	/*%< Negative security type 3 parameters */
+	ns_t_hip = 55,		/*%< Host Identity Protocol */
+	ns_t_spf = 99,		/*%< Sender Policy Framework */
 	ns_t_tkey = 249,	/*%< Transaction key */
 	ns_t_tsig = 250,	/*%< Transaction signature. */
 	ns_t_ixfr = 251,	/*%< Incremental zone transfer. */
@@ -297,6 +349,7 @@ typedef enum __ns_type {
 	ns_t_maila = 254,	/*%< Transfer mail agent records. */
 	ns_t_any = 255,		/*%< Wildcard match. */
 	ns_t_zxfr = 256,	/*%< BIND-specific, nonstandard. */
+	ns_t_dlv = 32769,	/*%< DNSSEC look-aside validatation. */
 	ns_t_max = 65536
 } ns_type;
 
@@ -475,6 +528,7 @@ typedef enum __ns_cert_types {
 #define ns_initparse		__ns_initparse
 #define ns_skiprr		__ns_skiprr
 #define ns_parserr		__ns_parserr
+#define ns_parserr2		__ns_parserr2
 #define	ns_sprintrr		__ns_sprintrr
 #define	ns_sprintrrf		__ns_sprintrrf
 #define	ns_format_ttl		__ns_format_ttl
@@ -485,12 +539,19 @@ typedef enum __ns_cert_types {
 #define	ns_name_ntol		__ns_name_ntol
 #define	ns_name_ntop		__ns_name_ntop
 #define	ns_name_pton		__ns_name_pton
+#define	ns_name_pton2		__ns_name_pton2
 #define	ns_name_unpack		__ns_name_unpack
+#define	ns_name_unpack2		__ns_name_unpack2
 #define	ns_name_pack		__ns_name_pack
 #define	ns_name_compress	__ns_name_compress
 #define	ns_name_uncompress	__ns_name_uncompress
 #define	ns_name_skip		__ns_name_skip
 #define	ns_name_rollback	__ns_name_rollback
+#define	ns_name_length		__ns_name_length
+#define	ns_name_eq		__ns_name_eq
+#define	ns_name_owned		__ns_name_owned
+#define	ns_name_map		__ns_name_map
+#define	ns_name_labels		__ns_name_labels
 #if 0
 #define	ns_sign			__ns_sign
 #define	ns_sign2		__ns_sign2
@@ -508,6 +569,16 @@ typedef enum __ns_cert_types {
 #endif
 #define	ns_makecanon		__ns_makecanon
 #define	ns_samename		__ns_samename
+#define	ns_newmsg_init		__ns_newmsg_init
+#define	ns_newmsg_copy		__ns_newmsg_copy
+#define	ns_newmsg_id		__ns_newmsg_id
+#define	ns_newmsg_flag		__ns_newmsg_flag
+#define	ns_newmsg_q		__ns_newmsg_q
+#define	ns_newmsg_rr		__ns_newmsg_rr
+#define	ns_newmsg_done		__ns_newmsg_done
+#define	ns_rdata_unpack		__ns_rdata_unpack
+#define	ns_rdata_equal		__ns_rdata_equal
+#define	ns_rdata_refers		__ns_rdata_refers
 
 __BEGIN_DECLS
 int		ns_msg_getflag(ns_msg, int);
@@ -518,6 +589,7 @@ void		ns_put32(u_long, u_char *);
 int		ns_initparse(const u_char *, int, ns_msg *);
 int		ns_skiprr(const u_char *, const u_char *, ns_sect, int);
 int		ns_parserr(ns_msg *, ns_sect, int, ns_rr *);
+int		ns_parserr2(ns_msg *, ns_sect, int, ns_rr2 *);
 int		ns_sprintrr(const ns_msg *, const ns_rr *,
 			    const char *, const char *, char *, size_t);
 int		ns_sprintrrf(const u_char *, size_t, const char *,
@@ -532,8 +604,12 @@ u_int32_t	ns_datetosecs(const char *cp, 
 int		ns_name_ntol(const u_char *, u_char *, size_t);
 int		ns_name_ntop(const u_char *, char *, size_t);
 int		ns_name_pton(const char *, u_char *, size_t);
+int		ns_name_pton2(const char *, u_char *, size_t, size_t *);
 int		ns_name_unpack(const u_char *, const u_char *,
 			       const u_char *, u_char *, size_t);
+int		ns_name_unpack2(const u_char *, const u_char *,
+				const u_char *, u_char *, size_t,
+				size_t *);
 int		ns_name_pack(const u_char *, u_char *, int,
 			     const u_char **, const u_char **);
 int		ns_name_uncompress(const u_char *, const u_char *,
@@ -543,6 +619,11 @@ int		ns_name_compress(const char *, u_ch
 int		ns_name_skip(const u_char **, const u_char *);
 void		ns_name_rollback(const u_char *, const u_char **,
 				 const u_char **);
+ssize_t		ns_name_length(ns_nname_ct, size_t);
+int		ns_name_eq(ns_nname_ct, size_t, ns_nname_ct, size_t);
+int		ns_name_owned(ns_namemap_ct, int, ns_namemap_ct, int);
+int		ns_name_map(ns_nname_ct, size_t, ns_namemap_t, int);
+int		ns_name_labels(ns_nname_ct, size_t);
 #if 0
 int		ns_sign(u_char *, int *, int, int, void *,
 			const u_char *, int, u_char *, int *, time_t);
@@ -570,6 +651,25 @@ int		ns_subdomain(const char *, const ch
 #endif
 int		ns_makecanon(const char *, char *, size_t);
 int		ns_samename(const char *, const char *);
+int		ns_newmsg_init(u_char *buffer, size_t bufsiz, ns_newmsg *);
+int		ns_newmsg_copy(ns_newmsg *, ns_msg *);
+void		ns_newmsg_id(ns_newmsg *handle, u_int16_t id);
+void		ns_newmsg_flag(ns_newmsg *handle, ns_flag flag, u_int value);
+int		ns_newmsg_q(ns_newmsg *handle, ns_nname_ct qname,
+			    ns_type qtype, ns_class qclass);
+int		ns_newmsg_rr(ns_newmsg *handle, ns_sect sect,
+			     ns_nname_ct name, ns_type type,
+			     ns_class rr_class, u_int32_t ttl,
+			     u_int16_t rdlen, const u_char *rdata);
+size_t		ns_newmsg_done(ns_newmsg *handle);
+ssize_t		ns_rdata_unpack(const u_char *, const u_char *, ns_type,
+				const u_char *, size_t, u_char *, size_t);
+int		ns_rdata_equal(ns_type,
+			       const u_char *, size_t,
+			       const u_char *, size_t);
+int		ns_rdata_refers(ns_type,
+				const u_char *, size_t,
+				const u_char *);
 __END_DECLS
 
 #ifdef BIND_4_COMPAT

Modified: stable/10/include/arpa/nameser_compat.h
==============================================================================
--- stable/10/include/arpa/nameser_compat.h	Sat Aug 30 09:55:38 2014	(r270837)
+++ stable/10/include/arpa/nameser_compat.h	Sat Aug 30 10:16:25 2014	(r270838)
@@ -28,7 +28,7 @@
 
 /*%
  *      from nameser.h	8.1 (Berkeley) 6/2/93
- *	$Id: nameser_compat.h,v 1.5.18.3 2006/05/19 02:36:00 marka Exp $
+ *	$Id: nameser_compat.h,v 1.8 2006/05/19 02:33:40 marka Exp $
  * $FreeBSD$
  */
 

Modified: stable/10/include/res_update.h
==============================================================================
--- stable/10/include/res_update.h	Sat Aug 30 09:55:38 2014	(r270837)
+++ stable/10/include/res_update.h	Sat Aug 30 10:16:25 2014	(r270838)
@@ -16,7 +16,7 @@
  */
 
 /*
- *	$Id: res_update.h,v 1.2.18.1 2005/04/27 05:00:49 sra Exp $
+ *	$Id: res_update.h,v 1.3 2005/04/27 04:56:15 sra Exp $
  * $FreeBSD$
  */
 

Modified: stable/10/include/resolv.h
==============================================================================
--- stable/10/include/resolv.h	Sat Aug 30 09:55:38 2014	(r270837)
+++ stable/10/include/resolv.h	Sat Aug 30 10:16:25 2014	(r270838)
@@ -1,7 +1,24 @@
 /*
+ * Portions Copyright (C) 2004, 2005, 2008, 2009  Internet Systems Consortium, Inc. ("ISC")
+ * Portions Copyright (C) 1995-2003  Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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.
+ */
+
+/*
  * Copyright (c) 1983, 1987, 1989
  *    The Regents of the University of California.  All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -13,7 +30,7 @@
  * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -27,26 +44,9 @@
  * SUCH DAMAGE.
  */
 
-/*
- * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
- * 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 ISC DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC 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.
- */
-
 /*%
  *	@(#)resolv.h	8.1 (Berkeley) 6/2/93
- *	$Id: resolv.h,v 1.19.18.4 2008/04/03 23:15:15 marka Exp $
+ *	$Id: resolv.h,v 1.30 2009/03/03 01:52:48 each Exp $
  * $FreeBSD$
  */
 
@@ -68,7 +68,7 @@
  * is new enough to contain a certain feature.
  */
 
-#define	__RES	20030124
+#define	__RES	20090302
 
 /*%
  * This used to be defined in res_query.c, now it's in herror.c.
@@ -179,7 +179,7 @@ struct __res_state {
 	u_int	_pad;			/*%< make _u 64 bit aligned */
 	union {
 		/* On an 32-bit arch this means 512b total. */
-		char	pad[72 - 4*sizeof (int) - 2*sizeof (void *)];
+		char	pad[72 - 4*sizeof (int) - 3*sizeof (void *)];
 		struct {
 			u_int16_t		nscount;
 			u_int16_t		nstimes[MAXNS];	/*%< ms. */
@@ -187,6 +187,7 @@ struct __res_state {
 			struct __res_state_ext *ext;	/*%< extension for IPv6 */
 		} _ext;
 	} _u;
+	u_char	*_rnd;			/*%< PRIVATE: random state */
 };
 
 typedef struct __res_state *res_state;
@@ -320,7 +321,7 @@ __END_DECLS
 #if !defined(SHARED_LIBBIND) || defined(LIB)
 /*
  * If libbind is a shared object (well, DLL anyway)
- * these externs break the linker when resolv.h is 
+ * these externs break the linker when resolv.h is
  * included by a lib client (like named)
  * Make them go away if a client is including this
  *
@@ -378,7 +379,9 @@ extern const struct res_sym __p_rcode_sy
 #define res_nisourserver	__res_nisourserver
 #define res_ownok		__res_ownok
 #define res_queriesmatch	__res_queriesmatch
+#define res_rndinit		__res_rndinit
 #define res_randomid		__res_randomid
+#define res_nrandomid		__res_nrandomid
 #define sym_ntop		__sym_ntop
 #define sym_ntos		__sym_ntos
 #define sym_ston		__sym_ston
@@ -441,7 +444,9 @@ int		dn_count_labels(const char *);
 int		dn_comp(const char *, u_char *, int, u_char **, u_char **);
 int		dn_expand(const u_char *, const u_char *, const u_char *,
 			  char *, int);
+void		res_rndinit(res_state);
 u_int		res_randomid(void);
+u_int		res_nrandomid(res_state);
 int		res_nameinquery(const char *, int, int, const u_char *,
 				const u_char *);
 int		res_queriesmatch(const u_char *, const u_char *,

Modified: stable/10/lib/libc/include/isc/eventlib.h
==============================================================================
--- stable/10/lib/libc/include/isc/eventlib.h	Sat Aug 30 09:55:38 2014	(r270837)
+++ stable/10/lib/libc/include/isc/eventlib.h	Sat Aug 30 10:16:25 2014	(r270838)
@@ -1,24 +1,24 @@
 /*
- * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 1995-1999 by Internet Software Consortium
+ * Copyright (C) 2004, 2005, 2008  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 1995-1999, 2001, 2003  Internet Software Consortium.
  *
- * Permission to use, copy, modify, and distribute this software for any
+ * Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC 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.
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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.
  */
 
 /* eventlib.h - exported interfaces for eventlib
  * vix 09sep95 [initial]
  *
- * $Id: eventlib.h,v 1.3.18.3 2008/01/23 02:12:01 marka Exp $
+ * $Id: eventlib.h,v 1.7 2008/11/14 02:36:51 marka Exp $
  */
 
 #ifndef _EVENTLIB_H

Modified: stable/10/lib/libc/include/isc/list.h
==============================================================================
--- stable/10/lib/libc/include/isc/list.h	Sat Aug 30 09:55:38 2014	(r270837)
+++ stable/10/lib/libc/include/isc/list.h	Sat Aug 30 10:16:25 2014	(r270838)
@@ -38,7 +38,8 @@
 	} while (0)
 #define INIT_LINK(elt, link) \
 	INIT_LINK_TYPE(elt, link, void)
-#define LINKED(elt, link) ((void *)((elt)->link.prev) != (void *)(-1))
+#define LINKED(elt, link) ((void *)((elt)->link.prev) != (void *)(-1) && \
+			   (void *)((elt)->link.next) != (void *)(-1))
 
 #define HEAD(list) ((list).head)
 #define TAIL(list) ((list).tail)

Modified: stable/10/lib/libc/include/port_before.h
==============================================================================
--- stable/10/lib/libc/include/port_before.h	Sat Aug 30 09:55:38 2014	(r270837)
+++ stable/10/lib/libc/include/port_before.h	Sat Aug 30 10:16:25 2014	(r270838)
@@ -6,6 +6,7 @@
 #define _LIBC		1
 #define DO_PTHREADS	1
 #define USE_KQUEUE	1
+#define HAVE_MD5	1
 
 #define ISC_SOCKLEN_T	socklen_t
 #define ISC_FORMAT_PRINTF(fmt, args) \

Modified: stable/10/lib/libc/inet/inet_addr.c
==============================================================================
--- stable/10/lib/libc/inet/inet_addr.c	Sat Aug 30 09:55:38 2014	(r270837)
+++ stable/10/lib/libc/inet/inet_addr.c	Sat Aug 30 10:16:25 2014	(r270838)
@@ -66,7 +66,7 @@
 
 #if defined(LIBC_SCCS) && !defined(lint)
 static const char sccsid[] = "@(#)inet_addr.c	8.1 (Berkeley) 6/17/93";
-static const char rcsid[] = "$Id: inet_addr.c,v 1.4.18.1 2005/04/27 05:00:52 sra Exp $";
+static const char rcsid[] = "$Id: inet_addr.c,v 1.5 2005/04/27 04:56:19 sra Exp $";
 #endif /* LIBC_SCCS and not lint */
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");

Modified: stable/10/lib/libc/inet/inet_cidr_ntop.c
==============================================================================
--- stable/10/lib/libc/inet/inet_cidr_ntop.c	Sat Aug 30 09:55:38 2014	(r270837)
+++ stable/10/lib/libc/inet/inet_cidr_ntop.c	Sat Aug 30 10:16:25 2014	(r270838)
@@ -16,8 +16,10 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: inet_cidr_ntop.c,v 1.4.18.3 2006/10/11 02:32:47 marka Exp $";
+static const char rcsid[] = "$Id: inet_cidr_ntop.c,v 1.7 2006/10/11 02:18:18 marka Exp $";
 #endif
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
 
 #include "port_before.h"
 

Modified: stable/10/lib/libc/inet/inet_cidr_pton.c
==============================================================================
--- stable/10/lib/libc/inet/inet_cidr_pton.c	Sat Aug 30 09:55:38 2014	(r270837)
+++ stable/10/lib/libc/inet/inet_cidr_pton.c	Sat Aug 30 10:16:25 2014	(r270838)
@@ -16,7 +16,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: inet_cidr_pton.c,v 1.5.18.1 2005/04/27 05:00:53 sra Exp $";
+static const char rcsid[] = "$Id: inet_cidr_pton.c,v 1.6 2005/04/27 04:56:19 sra Exp $";
 #endif
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");

Modified: stable/10/lib/libc/inet/inet_net_ntop.c
==============================================================================
--- stable/10/lib/libc/inet/inet_net_ntop.c	Sat Aug 30 09:55:38 2014	(r270837)
+++ stable/10/lib/libc/inet/inet_net_ntop.c	Sat Aug 30 10:16:25 2014	(r270838)
@@ -16,7 +16,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: inet_net_ntop.c,v 1.3.18.2 2006/06/20 02:51:32 marka Exp $";
+static const char rcsid[] = "$Id: inet_net_ntop.c,v 1.5 2006/06/20 02:50:14 marka Exp $";
 #endif
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");

Modified: stable/10/lib/libc/inet/inet_net_pton.c
==============================================================================
--- stable/10/lib/libc/inet/inet_net_pton.c	Sat Aug 30 09:55:38 2014	(r270837)
+++ stable/10/lib/libc/inet/inet_net_pton.c	Sat Aug 30 10:16:25 2014	(r270838)
@@ -1,22 +1,22 @@
 /*
- * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 1996,1999 by Internet Software Consortium.
+ * Copyright (C) 2004, 2005, 2008  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 1996, 1998, 1999, 2001, 2003  Internet Software Consortium.
  *
- * Permission to use, copy, modify, and distribute this software for any
+ * Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC 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.
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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_net_pton.c,v 1.7.18.2 2008/08/26 04:42:43 marka Exp $";
+static const char rcsid[] = "$Id: inet_net_pton.c,v 1.10 2008/11/14 02:36:51 marka Exp $";
 #endif
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");

Modified: stable/10/lib/libc/inet/inet_neta.c
==============================================================================
--- stable/10/lib/libc/inet/inet_neta.c	Sat Aug 30 09:55:38 2014	(r270837)
+++ stable/10/lib/libc/inet/inet_neta.c	Sat Aug 30 10:16:25 2014	(r270838)
@@ -16,7 +16,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: inet_neta.c,v 1.2.18.1 2005/04/27 05:00:53 sra Exp $";
+static const char rcsid[] = "$Id: inet_neta.c,v 1.3 2005/04/27 04:56:20 sra Exp $";
 #endif
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");

Modified: stable/10/lib/libc/inet/inet_ntoa.c
==============================================================================
--- stable/10/lib/libc/inet/inet_ntoa.c	Sat Aug 30 09:55:38 2014	(r270837)
+++ stable/10/lib/libc/inet/inet_ntoa.c	Sat Aug 30 10:16:25 2014	(r270838)
@@ -29,7 +29,7 @@
 
 #if defined(LIBC_SCCS) && !defined(lint)
 static const char sccsid[] = "@(#)inet_ntoa.c	8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: inet_ntoa.c,v 1.1.352.1 2005/04/27 05:00:54 sra Exp $";
+static const char rcsid[] = "$Id: inet_ntoa.c,v 1.2 2005/04/27 04:56:21 sra Exp $";
 #endif /* LIBC_SCCS and not lint */
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");

Modified: stable/10/lib/libc/inet/inet_ntop.c
==============================================================================
--- stable/10/lib/libc/inet/inet_ntop.c	Sat Aug 30 09:55:38 2014	(r270837)
+++ stable/10/lib/libc/inet/inet_ntop.c	Sat Aug 30 10:16:25 2014	(r270838)
@@ -16,7 +16,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: inet_ntop.c,v 1.3.18.2 2005/11/03 23:02:22 marka Exp $";
+static const char rcsid[] = "$Id: inet_ntop.c,v 1.5 2005/11/03 22:59:52 marka Exp $";
 #endif /* LIBC_SCCS and not lint */
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");

Modified: stable/10/lib/libc/inet/inet_pton.c
==============================================================================
--- stable/10/lib/libc/inet/inet_pton.c	Sat Aug 30 09:55:38 2014	(r270837)
+++ stable/10/lib/libc/inet/inet_pton.c	Sat Aug 30 10:16:25 2014	(r270838)
@@ -16,7 +16,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: inet_pton.c,v 1.3.18.2 2005/07/28 07:38:07 marka Exp $";
+static const char rcsid[] = "$Id: inet_pton.c,v 1.5 2005/07/28 06:51:47 marka Exp $";
 #endif /* LIBC_SCCS and not lint */
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");

Modified: stable/10/lib/libc/inet/nsap_addr.c
==============================================================================
--- stable/10/lib/libc/inet/nsap_addr.c	Sat Aug 30 09:55:38 2014	(r270837)
+++ stable/10/lib/libc/inet/nsap_addr.c	Sat Aug 30 10:16:25 2014	(r270838)
@@ -16,7 +16,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: nsap_addr.c,v 1.3.18.2 2005/07/28 07:38:08 marka Exp $";
+static const char rcsid[] = "$Id: nsap_addr.c,v 1.5 2005/07/28 06:51:48 marka Exp $";
 #endif /* LIBC_SCCS and not lint */
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");

Modified: stable/10/lib/libc/isc/ev_streams.c
==============================================================================
--- stable/10/lib/libc/isc/ev_streams.c	Sat Aug 30 09:55:38 2014	(r270837)
+++ stable/10/lib/libc/isc/ev_streams.c	Sat Aug 30 10:16:25 2014	(r270838)
@@ -20,7 +20,7 @@
  */
 
 #if !defined(LINT) && !defined(CODECENTER)
-static const char rcsid[] = "$Id: ev_streams.c,v 1.4.18.1 2005/04/27 05:01:06 sra Exp $";
+static const char rcsid[] = "$Id: ev_streams.c,v 1.5 2005/04/27 04:56:36 sra Exp $";
 #endif
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");

Modified: stable/10/lib/libc/isc/ev_timers.c
==============================================================================
--- stable/10/lib/libc/isc/ev_timers.c	Sat Aug 30 09:55:38 2014	(r270837)
+++ stable/10/lib/libc/isc/ev_timers.c	Sat Aug 30 10:16:25 2014	(r270838)
@@ -20,7 +20,7 @@
  */
 
 #if !defined(LINT) && !defined(CODECENTER)
-static const char rcsid[] = "$Id: ev_timers.c,v 1.5.18.1 2005/04/27 05:01:06 sra Exp $";
+static const char rcsid[] = "$Id: ev_timers.c,v 1.6 2005/04/27 04:56:36 sra Exp $";
 #endif
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");

Modified: stable/10/lib/libc/isc/eventlib_p.h
==============================================================================
--- stable/10/lib/libc/isc/eventlib_p.h	Sat Aug 30 09:55:38 2014	(r270837)
+++ stable/10/lib/libc/isc/eventlib_p.h	Sat Aug 30 10:16:25 2014	(r270838)
@@ -19,7 +19,7 @@
  * \brief private interfaces for eventlib
  * \author vix 09sep95 [initial]
  *
- * $Id: eventlib_p.h,v 1.5.18.4 2006/03/10 00:20:08 marka Exp $
+ * $Id: eventlib_p.h,v 1.9 2006/03/09 23:57:56 marka Exp $
  * $FreeBSD$
  */
 

Modified: stable/10/lib/libc/nameser/Symbol.map
==============================================================================
--- stable/10/lib/libc/nameser/Symbol.map	Sat Aug 30 09:55:38 2014	(r270837)
+++ stable/10/lib/libc/nameser/Symbol.map	Sat Aug 30 10:16:25 2014	(r270838)
@@ -29,3 +29,24 @@ FBSD_1.0 {
 	__ns_format_ttl;
 	__ns_parse_ttl;
 };
+
+FBSD_1.4 {
+	__ns_parserr2;
+	__ns_name_pton2;
+	__ns_name_unpack2;
+	__ns_name_length;
+	__ns_name_eq;
+	__ns_name_owned;
+	__ns_name_map;
+	__ns_name_labels;
+	__ns_newmsg_init;
+	__ns_newmsg_copy;
+	__ns_newmsg_id;
+	__ns_newmsg_flag;
+	__ns_newmsg_q;
+	__ns_newmsg_rr;
+	__ns_newmsg_done;
+	__ns_rdata_unpack;
+	__ns_rdata_equal;
+	__ns_rdata_refers;
+};

Modified: stable/10/lib/libc/nameser/ns_name.c
==============================================================================
--- stable/10/lib/libc/nameser/ns_name.c	Sat Aug 30 09:55:38 2014	(r270837)
+++ stable/10/lib/libc/nameser/ns_name.c	Sat Aug 30 10:16:25 2014	(r270838)
@@ -16,8 +16,10 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: ns_name.c,v 1.8.18.2 2005/04/27 05:01:08 sra Exp $";
+static const char rcsid[] = "$Id: ns_name.c,v 1.11 2009/01/23 19:59:16 each Exp $";
 #endif
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
 
 #include "port_before.h"
 
@@ -121,7 +123,7 @@ ns_name_ntop(const u_char *src, char *ds
 		}
 		if ((l = labellen(cp - 1)) < 0) {
 			errno = EMSGSIZE; /*%< XXX */
-			return(-1);
+			return (-1);
 		}
 		if (dn + l >= eom) {
 			errno = EMSGSIZE;
@@ -133,12 +135,12 @@ ns_name_ntop(const u_char *src, char *ds
 			if (n != DNS_LABELTYPE_BITSTRING) {
 				/* XXX: labellen should reject this case */
 				errno = EINVAL;
-				return(-1);
+				return (-1);
 			}
 			if ((m = decode_bitstring(&cp, dn, eom)) < 0)
 			{
 				errno = EMSGSIZE;
-				return(-1);
+				return (-1);
 			}
 			dn += m; 
 			continue;
@@ -197,10 +199,25 @@ ns_name_ntop(const u_char *src, char *ds
  * notes:
  *\li	Enforces label and domain length limits.
  */
+int
+ns_name_pton(const char *src, u_char *dst, size_t dstsiz) {
+	return (ns_name_pton2(src, dst, dstsiz, NULL));
+}
 
+/*
+ * ns_name_pton2(src, dst, dstsiz, *dstlen)
+ *	Convert a ascii string into an encoded domain name as per RFC1035.
+ * return:
+ *	-1 if it fails
+ *	1 if string was fully qualified
+ *	0 is string was not fully qualified
+ * side effects:
+ *	fills in *dstlen (if non-NULL)
+ * notes:
+ *	Enforces label and domain length limits.
+ */
 int
-ns_name_pton(const char *src, u_char *dst, size_t dstsiz)
-{
+ns_name_pton2(const char *src, u_char *dst, size_t dstsiz, size_t *dstlen) {
 	u_char *label, *bp, *eom;
 	int c, n, escaped, e = 0;
 	char *cp;
@@ -215,13 +232,13 @@ ns_name_pton(const char *src, u_char *ds
 			if (c == '[') { /*%< start a bit string label */
 				if ((cp = strchr(src, ']')) == NULL) {
 					errno = EINVAL; /*%< ??? */
-					return(-1);
+					return (-1);
 				}
 				if ((e = encode_bitsring(&src, cp + 2,
 							 &label, &bp, eom))
 				    != 0) {
 					errno = e;
-					return(-1);
+					return (-1);
 				}
 				escaped = 0;
 				label = bp++;
@@ -229,7 +246,7 @@ ns_name_pton(const char *src, u_char *ds
 					goto done;
 				else if (c != '.') {
 					errno = EINVAL;
-					return(-1);
+					return	(-1);
 				}
 				continue;
 			}
@@ -281,6 +298,8 @@ ns_name_pton(const char *src, u_char *ds
 					errno = EMSGSIZE;
 					return (-1);
 				}
+				if (dstlen != NULL)
+					*dstlen = (bp - dst);
 				return (1);
 			}
 			if (c == 0 || *src == '.') {
@@ -318,6 +337,8 @@ ns_name_pton(const char *src, u_char *ds
 		errno = EMSGSIZE;
 		return (-1);
 	}
+	if (dstlen != NULL)
+		*dstlen = (bp - dst);
 	return (0);
 }
 
@@ -365,7 +386,7 @@ ns_name_ntol(const u_char *src, u_char *
 		}
 		for ((void)NULL; l > 0; l--) {
 			c = *cp++;
-			if (isupper(c))
+			if (isascii(c) && isupper(c))
 				*dn++ = tolower(c);
 			else
 				*dn++ = c;
@@ -385,6 +406,21 @@ int
 ns_name_unpack(const u_char *msg, const u_char *eom, const u_char *src,
 	       u_char *dst, size_t dstsiz)
 {
+	return (ns_name_unpack2(msg, eom, src, dst, dstsiz, NULL));
+}
+
+/*
+ * ns_name_unpack2(msg, eom, src, dst, dstsiz, *dstlen)
+ *	Unpack a domain name from a message, source may be compressed.
+ * return:
+ *	-1 if it fails, or consumed octets if it succeeds.
+ * side effect:
+ *	fills in *dstlen (if non-NULL).
+ */
+int
+ns_name_unpack2(const u_char *msg, const u_char *eom, const u_char *src,
+		u_char *dst, size_t dstsiz, size_t *dstlen)
+{
 	const u_char *srcp, *dstlim;
 	u_char *dstp;
 	int n, len, checked, l;
@@ -407,7 +443,7 @@ ns_name_unpack(const u_char *msg, const 
 			/* Limit checks. */
 			if ((l = labellen(srcp - 1)) < 0) {
 				errno = EMSGSIZE;
-				return(-1);
+				return (-1);
 			}
 			if (dstp + l + 1 >= dstlim || srcp + l >= eom) {
 				errno = EMSGSIZE;
@@ -449,7 +485,9 @@ ns_name_unpack(const u_char *msg, const 
 			return (-1);			/*%< flag error */
 		}
 	}
-	*dstp = '\0';
+	*dstp++ = 0;
+	if (dstlen != NULL)
+		*dstlen = dstp - dst;
 	if (len < 0)
 		len = srcp - src;
 	return (len);
@@ -508,7 +546,7 @@ ns_name_pack(const u_char *src, u_char *
 		}
 		if ((l0 = labellen(srcp)) < 0) {
 			errno = EINVAL;
-			return(-1);
+			return (-1);
 		}
 		l += l0 + 1;
 		if (l > MAXCDNAME) {
@@ -655,7 +693,7 @@ ns_name_skip(const u_char **ptrptr, cons
 		case NS_TYPE_ELT: /*%< EDNS0 extended label */
 			if ((l = labellen(cp - 1)) < 0) {
 				errno = EMSGSIZE; /*%< XXX */
-				return(-1);
+				return (-1);
 			}
 			cp += l;
 			continue;
@@ -676,6 +714,150 @@ ns_name_skip(const u_char **ptrptr, cons
 	return (0);
 }
 
+/* Find the number of octets an nname takes up, including the root label.
+ * (This is basically ns_name_skip() without compression-pointer support.)
+ * ((NOTE: can only return zero if passed-in namesiz argument is zero.))
+ */
+ssize_t
+ns_name_length(ns_nname_ct nname, size_t namesiz) {
+	ns_nname_ct orig = nname;
+	u_int n;
+
+	while (namesiz-- > 0 && (n = *nname++) != 0) {
+		if ((n & NS_CMPRSFLGS) != 0) {
+			errno = EISDIR;
+			return (-1);
+		}
+		if (n > namesiz) {
+			errno = EMSGSIZE;
+			return (-1);
+		}
+		nname += n;
+		namesiz -= n;
+	}
+	return (nname - orig);
+}
+
+/* Compare two nname's for equality.  Return -1 on error (setting errno).
+ */
+int
+ns_name_eq(ns_nname_ct a, size_t as, ns_nname_ct b, size_t bs) {
+	ns_nname_ct ae = a + as, be = b + bs;
+	int ac, bc;
+
+	while (ac = *a, bc = *b, ac != 0 && bc != 0) {
+		if ((ac & NS_CMPRSFLGS) != 0 || (bc & NS_CMPRSFLGS) != 0) {
+			errno = EISDIR;
+			return (-1);
+		}
+		if (a + ac >= ae || b + bc >= be) {
+			errno = EMSGSIZE;
+			return (-1);
+		}
+		if (ac != bc || strncasecmp((const char *) ++a,
+					    (const char *) ++b, ac) != 0)
+			return (0);
+		a += ac, b += bc;
+	}
+	return (ac == 0 && bc == 0);
+}
+
+/* Is domain "A" owned by (at or below) domain "B"?
+ */
+int
+ns_name_owned(ns_namemap_ct a, int an, ns_namemap_ct b, int bn) {
+	/* If A is shorter, it cannot be owned by B. */
+	if (an < bn)
+		return (0);
+
+	/* If they are unequal before the length of the shorter, A cannot... */
+	while (bn > 0) {
+		if (a->len != b->len ||
+		    strncasecmp((const char *) a->base,
+				(const char *) b->base, a->len) != 0)
+			return (0);
+		a++, an--;
+		b++, bn--;
+	}
+
+	/* A might be longer or not, but either way, B owns it. */
+	return (1);
+}
+
+/* Build an array of <base,len> tuples from an nname, top-down order.
+ * Return the number of tuples (labels) thus discovered.
+ */
+int
+ns_name_map(ns_nname_ct nname, size_t namelen, ns_namemap_t map, int mapsize) {
+	u_int n;
+	int l;
+
+	n = *nname++;
+	namelen--;
+
+	/* Root zone? */
+	if (n == 0) {
+		/* Extra data follows name? */
+		if (namelen > 0) {
+			errno = EMSGSIZE;
+			return (-1);
+		}
+		return (0);
+	}
+
+	/* Compression pointer? */
+	if ((n & NS_CMPRSFLGS) != 0) {
+		errno = EISDIR;
+		return (-1);
+	}
+
+	/* Label too long? */
+	if (n > namelen) {
+		errno = EMSGSIZE;
+		return (-1);
+	}
+

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-all mailing list