]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
1471. [bug] libbind: updated to BIND 8.4.0.
authorMark Andrews <marka@isc.org>
Tue, 3 Jun 2003 04:39:35 +0000 (04:39 +0000)
committerMark Andrews <marka@isc.org>
Tue, 3 Jun 2003 04:39:35 +0000 (04:39 +0000)
58 files changed:
CHANGES
lib/bind/bsd/strtoul.c
lib/bind/bsd/writev.c
lib/bind/config.h.in
lib/bind/configure.in
lib/bind/dst/hmac_link.c
lib/bind/include/arpa/nameser.h
lib/bind/include/arpa/nameser_compat.h
lib/bind/include/hesiod.h
lib/bind/include/irp.h
lib/bind/include/irs.h
lib/bind/include/isc/ctl.h
lib/bind/include/isc/dst.h
lib/bind/include/isc/eventlib.h
lib/bind/include/isc/irpmarshall.h
lib/bind/include/isc/logging.h
lib/bind/include/isc/misc.h
lib/bind/include/isc/tree.h
lib/bind/include/netdb.h
lib/bind/include/resolv.h
lib/bind/irs/dns_gr.c
lib/bind/irs/dns_ho.c
lib/bind/irs/dns_nw.c
lib/bind/irs/gen_gr.c
lib/bind/irs/getaddrinfo.c
lib/bind/irs/gethostent.c
lib/bind/irs/getnameinfo.c
lib/bind/irs/getnetgrent.c
lib/bind/irs/getnetgrent_r.c
lib/bind/irs/hesiod.c
lib/bind/irs/irp_p.h
lib/bind/irs/irs_data.c
lib/bind/irs/nis_gr.c
lib/bind/irs/nis_ho.c
lib/bind/isc/ctl_clnt.c
lib/bind/isc/ctl_srvr.c
lib/bind/isc/ev_files.c
lib/bind/isc/ev_timers.c
lib/bind/isc/ev_waits.c
lib/bind/isc/eventlib.c
lib/bind/isc/eventlib_p.h
lib/bind/isc/logging.c
lib/bind/nameser/ns_name.c
lib/bind/nameser/ns_parse.c
lib/bind/nameser/ns_print.c
lib/bind/nameser/ns_samedomain.c
lib/bind/nameser/ns_sign.c
lib/bind/port_after.h.in
lib/bind/resolv/res_comp.c
lib/bind/resolv/res_debug.c
lib/bind/resolv/res_findzonecut.c
lib/bind/resolv/res_init.c
lib/bind/resolv/res_mkquery.c
lib/bind/resolv/res_mkupdate.c
lib/bind/resolv/res_private.h
lib/bind/resolv/res_query.c
lib/bind/resolv/res_send.c
lib/bind/resolv/res_update.c

diff --git a/CHANGES b/CHANGES
index 95942d4d67190d034fec0bb94486891913db6e37..2cd1b5d0b4e8ac1f8281cad637f328bc5c1d93d8 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,5 @@
+1471.  [bug]           libbind: updated to BIND 8.4.0.
+
 1470.  [bug]           Incorrect length passed to snprintf. [RT #5966]
 
 1469.  [func]          Log end of outgoing zone transfer at same level
index ab3d5a479e9e8297a4514df623411cd18fa30bec..87bf1662183fdb40e5cbedaa9afc7db31fd038eb 100644 (file)
@@ -1,6 +1,6 @@
 #if defined(LIBC_SCCS) && !defined(lint)
 static const char sccsid[] = "@(#)strtoul.c    8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: strtoul.c,v 1.1 2001/03/29 06:30:36 marka Exp $";
+static const char rcsid[] = "$Id: strtoul.c,v 1.2 2003/06/03 04:39:27 marka Exp $";
 #endif /* LIBC_SCCS and not lint */
 
 /*
@@ -70,7 +70,7 @@ strtoul(const char *nptr, char **endptr, int base) {
         * See strtol for comments as to the logic used.
         */
        do {
-               c = *s++;
+               c = *(unsigned char *)s++;
        } while (isspace(c));
        if (c == '-') {
                neg = 1;
@@ -87,7 +87,7 @@ strtoul(const char *nptr, char **endptr, int base) {
                base = c == '0' ? 8 : 10;
        cutoff = (u_long)ULONG_MAX / (u_long)base;
        cutlim = (u_long)ULONG_MAX % (u_long)base;
-       for (acc = 0, any = 0;; c = *s++) {
+       for (acc = 0, any = 0;; c = *(unsigned char*)s++) {
                if (isdigit(c))
                        c -= '0';
                else if (isalpha(c))
index 37392880faea230a8ee896e38fc7f782db3b6078..5e12302b09dd512ab2cda90f5f8ff716bf702beb 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef LINT
-static const char rcsid[] = "$Id: writev.c,v 1.1 2001/03/29 06:30:37 marka Exp $";
+static const char rcsid[] = "$Id: writev.c,v 1.2 2003/06/03 04:39:27 marka Exp $";
 #endif
 
 #include "port_before.h"
@@ -31,6 +31,7 @@ __writev(int fd, struct iovec *iov, int iovlen)
        if (statbuf.st_mode & S_IFSOCK) {
                struct msghdr   mesg;           
 
+               memset(&mesg, 0, sizeof(mesg));
                mesg.msg_name = 0;
                mesg.msg_namelen = 0;
                mesg.msg_iov = iov;
index c1c9399b91193d99f04f48e2f1264271ab9e296f..46de822b7eecfd149bc930fc16790ba331f36fcb 100644 (file)
@@ -42,3 +42,4 @@ struct __sFILE;
 extern __inline int __sputaux(int _c, struct __sFILE *_p);
 #endif
 #undef BROKEN_IN6ADDR_INIT_MACROS
+#undef HAVE_STRLCAT
index 25c8287344e5473b60d16760345fff01dbdc404d..7f471425e350a07b9c2a081bdf754711cbb5533a 100644 (file)
@@ -13,7 +13,7 @@
 # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-AC_REVISION($Revision: 1.86 $)
+AC_REVISION($Revision: 1.87 $)
 
 AC_INIT(resolv/herror.c)
 AC_PREREQ(2.13)
@@ -518,6 +518,8 @@ else
        thread_dir=nothreads
 fi
 
+AC_CHECK_FUNC(strlcat, AC_DEFINE(HAVE_STRLCAT))
+
 AC_SUBST(ALWAYS_DEFINES)
 AC_SUBST(DO_PTHREADS)
 AC_SUBST(WANT_IRS_THREADSGR_OBJS)
@@ -2214,6 +2216,72 @@ SERV_R_SET_RETURN="#define SERV_R_SET_RETURN void"
 AC_SUBST(SERV_R_SET_RESULT)
 AC_SUBST(SERV_R_SET_RETURN)
 
+AC_TRY_COMPILE(
+[
+#undef _REENTRANT
+#define _REENTRANT
+#undef __USE_MISC
+#define __USE_MISC
+#include <unistd.h>
+#include <netdb.h>
+int innetgr(const char *netgroup, const char *host, const char *user, const char *domain);
+]
+,,
+[
+INNETGR_ARGS="#undef INNETGR_ARGS"
+]
+,
+AC_TRY_COMPILE(
+[
+#undef _REENTRANT
+#define _REENTRANT
+#undef __USE_MISC
+#define __USE_MISC
+#include <unistd.h>
+#include <netdb.h>
+int innetgr(char *netgroup, char *host, char *user, char *domain);
+]
+,,
+[
+INNETGR_ARGS="#define INNETGR_ARGS char *netgroup, char *host, char *user, char *domain"
+]
+,
+))
+
+AC_TRY_COMPILE(
+[
+#undef _REENTRANT
+#define _REENTRANT
+#undef __USE_MISC
+#define __USE_MISC
+#include <unistd.h>
+#include <netdb.h>
+void setnetgrent(const char *);
+]
+,,
+[
+SETNETGRENT_ARGS="#undef SETNETGRENT_ARGS"
+]
+,
+AC_TRY_COMPILE(
+[
+#undef _REENTRANT
+#define _REENTRANT
+#undef __USE_MISC
+#define __USE_MISC
+#include <unistd.h>
+#include <netdb.h>
+void setnetgrent(char *);
+]
+,,
+[
+SETNETGRENT_ARGS="#define SETNETGRENT_ARGS char *netgroup"
+]
+,
+))
+AC_SUBST(SETNETGRENT_ARGS)
+AC_SUBST(INNETGR_ARGS)
+
 #
 # Random remaining OS-specific issues involving compiler warnings.
 # XXXDCL print messages to indicate some compensation is being done?
index cc19d02736365198961c8c552d96b1af9a4f6a61..4f042b44a812e350e5e30c767fce90515cd4e74c 100644 (file)
@@ -1,6 +1,6 @@
 #ifdef HMAC_MD5
 #ifndef LINT
-static const char rcsid[] = "$Header: /u0/home/explorer/proj/ISC/git-conversion/cvsroot/bind9/lib/bind/dst/Attic/hmac_link.c,v 1.2 2001/04/03 00:28:14 bwelling Exp $";
+static const char rcsid[] = "$Header: /u0/home/explorer/proj/ISC/git-conversion/cvsroot/bind9/lib/bind/dst/Attic/hmac_link.c,v 1.3 2003/06/03 04:39:27 marka Exp $";
 #endif
 /*
  * Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc.
@@ -459,15 +459,10 @@ dst_hmac_md5_init()
 }
 
 #else 
+#define        dst_hmac_md5_init       __dst_hmac_md5_init
+
 int
 dst_hmac_md5_init(){
        return (0);
 }
 #endif
-
-
-
-
-
-
-
index e876c44790d3e0ae191e2575c32dd3dd9f4ad9f8..e8c0d867bc26b0ff0e3394ead27940aec8fecc7c 100644 (file)
@@ -49,7 +49,7 @@
  */
 
 /*
- *     $Id: nameser.h,v 1.5 2002/06/28 05:41:56 marka Exp $
+ *     $Id: nameser.h,v 1.6 2003/06/03 04:39:28 marka Exp $
  */
 
 #ifndef _ARPA_NAMESER_H_
@@ -78,8 +78,9 @@
 /*
  * Define constants based on RFC 883, RFC 1034, RFC 1035
  */
-#define NS_PACKETSZ    512     /* maximum packet size */
+#define NS_PACKETSZ    512     /* default UDP packet size */
 #define NS_MAXDNAME    1025    /* maximum domain name */
+#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_HFIXEDSZ    12      /* #/bytes of fixed data in header */
@@ -294,6 +295,7 @@ typedef enum __ns_type {
        ns_t_dname = 39,        /* Non-terminal DNAME (for IPv6) */
        ns_t_sink = 40,         /* Kitchen sink (experimentatl) */
        ns_t_opt = 41,          /* EDNS0 option (meta-RR) */
+       ns_t_apl = 42,          /* Address prefix list (RFC 3123) */
        ns_t_tkey = 249,        /* Transaction key */
        ns_t_tsig = 250,        /* Transaction signature. */
        ns_t_ixfr = 251,        /* Incremental zone transfer. */
@@ -398,7 +400,7 @@ typedef enum __ns_cert_types {
 
 /* Signatures */
 #define        NS_MD5RSA_MIN_BITS       512    /* Size of a mod or exp in bits */
-#define        NS_MD5RSA_MAX_BITS      2552
+#define        NS_MD5RSA_MAX_BITS      4096
        /* Total of binary mod and exp */
 #define        NS_MD5RSA_MAX_BYTES     ((NS_MD5RSA_MAX_BITS+7/8)*2+3)
        /* Max length of text sig block */
index 19cd5f0fe0035f4d134e34ae3c98160b8c1c9e22..28b43d12e8879a809c26c4550c510cd09d5adb7d 100644 (file)
@@ -32,7 +32,7 @@
 
 /*
  *      from nameser.h 8.1 (Berkeley) 6/2/93
- *     $Id: nameser_compat.h,v 1.3 2002/05/20 04:29:29 marka Exp $
+ *     $Id: nameser_compat.h,v 1.4 2003/06/03 04:39:29 marka Exp $
  */
 
 #ifndef _ARPA_NAMESER_COMPAT_
@@ -138,6 +138,7 @@ typedef struct {
 #define RRFIXEDSZ      NS_RRFIXEDSZ
 #define        INT32SZ         NS_INT32SZ
 #define        INT16SZ         NS_INT16SZ
+#define        INT8SZ          NS_INT8SZ
 #define        INADDRSZ        NS_INADDRSZ
 #define        IN6ADDRSZ       NS_IN6ADDRSZ
 #define        INDIR_MASK      NS_CMPRSFLGS
index b49f5e3de65c84f6638ea602519ce3a5076a6b64..1ca33cd43281a0d771642777a31e48fd99d84c57 100644 (file)
  */
 
 /*
- * $Id: hesiod.h,v 1.1 2001/03/29 06:31:33 marka Exp $
+ * $Id: hesiod.h,v 1.2 2003/06/03 04:39:28 marka Exp $
  */
 
 #ifndef _HESIOD_H_INCLUDED
 #define _HESIOD_H_INCLUDED
 
-int            hesiod_init __P((void **context));
-void           hesiod_end __P((void *context));
-char *         hesiod_to_bind __P((void *context, const char *name,
-                                   const char *type));
-char **                hesiod_resolve __P((void *context, const char *name,
-                                   const char *type));
-void           hesiod_free_list __P((void *context, char **list));
-struct __res_state * __hesiod_res_get __P((void *context));
-void           __hesiod_res_set __P((void *context, struct __res_state *,
+int            hesiod_init __P((void **));
+void           hesiod_end __P((void *));
+char *         hesiod_to_bind __P((void *, const char *, const char *));
+char **                hesiod_resolve __P((void *, const char *, const char *));
+void           hesiod_free_list __P((void *, char **));
+struct __res_state * __hesiod_res_get __P((void *));
+void           __hesiod_res_set __P((void *, struct __res_state *,
                                      void (*)(void *)));
 
 #endif /*_HESIOD_H_INCLUDED*/
index e56cfbc688a24e4e7a335600d1ac86a909f45987..6234a6d43be7ea6ef821b2de6a949559c7c3eab6 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 /*
- * $Id: irp.h,v 1.1 2001/03/29 06:31:34 marka Exp $
+ * $Id: irp.h,v 1.2 2003/06/03 04:39:28 marka Exp $
  */
 
 #ifndef _IRP_H_INCLUDED
 
 struct irp_p;
 
-char   *irs_irp_read_body(struct irp_p *pvt, size_t *size);
-int    irs_irp_read_response(struct irp_p *pvt, char *text, size_t len);
-void   irs_irp_disconnect(struct irp_p *pvt);
-int    irs_irp_connect(struct irp_p *pvt);
-int    irs_irp_is_connected(struct irp_p *pvt);
-int    irs_irp_connection_setup(struct irp_p *cxndata, int *warned);
-int    irs_irp_send_command(struct irp_p *pvt, const char *fmt, ...);
-int    irs_irp_get_full_response(struct irp_p *pvt, int *code, char *text,
-                                 size_t textlen, char **body,
-                                 size_t *bodylen);
-int    irs_irp_read_line(struct irp_p *pvt, char *buffer, int len);
+char   *irs_irp_read_body(struct irp_p *, size_t *);
+int    irs_irp_read_response(struct irp_p *, char *, size_t);
+void   irs_irp_disconnect(struct irp_p *);
+int    irs_irp_connect(struct irp_p *);
+int    irs_irp_is_connected(struct irp_p *);
+int    irs_irp_connection_setup(struct irp_p *, int *);
+#ifdef __GNUC__
+int    irs_irp_send_command(struct irp_p *, const char *, ...)
+                            __attribute__((__format__(__printf__, 2, 3)));
+#else
+int    irs_irp_send_command(struct irp_p *, const char *, ...);
+#endif
+int    irs_irp_get_full_response(struct irp_p *, int *, char *, size_t,
+                                 char **, size_t *);
+int    irs_irp_read_line(struct irp_p *, char *, int);
 
 #endif
index d7fc7b4d5fd8db88d9eb6b18d168b990ab694cea..f417e3acbd9b3ff694d87d0f4e68b857979b16e0 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 /*
- * $Id: irs.h,v 1.2 2001/06/22 05:10:58 marka Exp $
+ * $Id: irs.h,v 1.3 2003/06/03 04:39:28 marka Exp $
  */
 
 #ifndef _IRS_H_INCLUDED
@@ -198,18 +198,58 @@ struct nwent {
 #define        irs_dns_acc     __irs_dns_acc
 #define        irs_nis_acc     __irs_nis_acc
 #define        irs_irp_acc     __irs_irp_acc
+#define        irs_destroy     __irs_destroy
+#define        irs_dns_gr      __irs_dns_gr
+#define        irs_dns_ho      __irs_dns_ho
+#define        irs_dns_nw      __irs_dns_nw
+#define        irs_dns_pr      __irs_dns_pr
+#define        irs_dns_pw      __irs_dns_pw
+#define        irs_dns_sv      __irs_dns_sv
+#define        irs_gen_gr      __irs_gen_gr
+#define        irs_gen_ho      __irs_gen_ho
+#define        irs_gen_ng      __irs_gen_ng
+#define        irs_gen_nw      __irs_gen_nw
+#define        irs_gen_pr      __irs_gen_pr
+#define        irs_gen_pw      __irs_gen_pw
+#define        irs_gen_sv      __irs_gen_sv
+#define        irs_irp_get_full_response       __irs_irp_get_full_response
+#define        irs_irp_gr      __irs_irp_gr
+#define        irs_irp_ho      __irs_irp_ho
+#define        irs_irp_is_connected    __irs_irp_is_connected
+#define        irs_irp_ng      __irs_irp_ng
+#define        irs_irp_nw      __irs_irp_nw
+#define        irs_irp_pr      __irs_irp_pr
+#define        irs_irp_pw      __irs_irp_pw
+#define        irs_irp_read_line       __irs_irp_read_line
+#define        irs_irp_sv      __irs_irp_sv
+#define        irs_lcl_gr      __irs_lcl_gr
+#define        irs_lcl_ho      __irs_lcl_ho
+#define        irs_lcl_ng      __irs_lcl_ng
+#define        irs_lcl_nw      __irs_lcl_nw
+#define        irs_lcl_pr      __irs_lcl_pr
+#define        irs_lcl_pw      __irs_lcl_pw
+#define        irs_lcl_sv      __irs_lcl_sv
+#define        irs_nis_gr      __irs_nis_gr
+#define        irs_nis_ho      __irs_nis_ho
+#define        irs_nis_ng      __irs_nis_ng
+#define        irs_nis_nw      __irs_nis_nw
+#define        irs_nis_pr      __irs_nis_pr
+#define        irs_nis_pw      __irs_nis_pw
+#define        irs_nis_sv      __irs_nis_sv
+#define        net_data_create __net_data_create
+#define        net_data_destroy        __net_data_destroy
+#define        net_data_minimize       __net_data_minimize
 
 /*
  * Externs.
  */
-extern struct irs_acc *        irs_gen_acc __P((const char *options, 
-                                        const char *conf_file));
-extern struct irs_acc *        irs_lcl_acc __P((const char *options));
-extern struct irs_acc *        irs_dns_acc __P((const char *options));
-extern struct irs_acc *        irs_nis_acc __P((const char *options));
-extern struct irs_acc *        irs_irp_acc __P((const char *options));
+extern struct irs_acc *        irs_gen_acc __P((const char *, const char *));
+extern struct irs_acc *        irs_lcl_acc __P((const char *));
+extern struct irs_acc *        irs_dns_acc __P((const char *));
+extern struct irs_acc *        irs_nis_acc __P((const char *));
+extern struct irs_acc *        irs_irp_acc __P((const char *));
 
-extern void            irs_destroy(void);
+extern void            irs_destroy __P((void));
 
 /*
  * These forward declarations are for the semi-private functions in
@@ -228,102 +268,78 @@ struct net_data;                 /* forward */
  * the default interface will use net_data_create by default.  Servers will
  * probably want net_data_init (one call per client)
  */
-struct net_data *net_data_create(const char *conf_file);
-struct net_data *net_data_init(const char *conf_file);
-void           net_data_destroy(void *p);
+struct net_data *net_data_create __P((const char *));
+struct net_data *net_data_init __P((const char *));
+void           net_data_destroy __P((void *));
        
-extern struct group    *getgrent_p __P((struct net_data *net_data));
-extern struct group    *getgrnam_p __P((const char *name,
-                                       struct net_data *net_data));
-extern struct group    *getgrgid_p __P((gid_t gid,
-                                       struct net_data *net_data));
-extern int             setgroupent_p __P((int stayopen,
-                                          struct net_data *net_data));
-extern void            endgrent_p __P((struct net_data *net_data));
-extern int             getgrouplist_p __P((const char *name,
-                                           gid_t basegid,
-                                           gid_t *groups,
-                                           int *ngroups,
-                                           struct net_data *net_data));
+extern struct group    *getgrent_p __P((struct net_data *));
+extern struct group    *getgrnam_p __P((const char *, struct net_data *));
+extern struct group    *getgrgid_p __P((gid_t, struct net_data *));
+extern int             setgroupent_p __P((int, struct net_data *));
+extern void            endgrent_p __P((struct net_data *));
+extern int             getgrouplist_p __P((const char *, gid_t, gid_t *, int *,
+                                           struct net_data *));
 
 #ifdef SETGRENT_VOID
-extern void            setgrent_p __P((struct net_data *net_data));
+extern void            setgrent_p __P((struct net_data *));
 #else
-extern int             setgrent_p __P((struct net_data *net_data));
+extern int             setgrent_p __P((struct net_data *));
 #endif
 
-extern struct hostent  *gethostbyname_p __P((const char *name,
-                                             struct net_data *net_data));
-extern struct hostent  *gethostbyname2_p __P((const char *name, int af,
-                                              struct net_data *net_data));
-extern struct hostent  *gethostbyaddr_p __P((const char *addr, int len,
-                                             int af,
-                                             struct net_data *net_data));
-extern struct hostent  *gethostent_p __P((struct net_data *net_data));
-extern void            sethostent_p __P((int stayopen,
-                                         struct net_data *net_data));
-extern void            endhostent_p __P((struct net_data *net_data));
-extern struct hostent  *getipnodebyname_p __P((const char *name, int af,
-                                              int flags, int *errp,
-                                              struct net_data *net_data));
-extern struct hostent  *getipnodebyaddr_p __P((const void *addr, size_t len,
-                                             int af, int *errp,
-                                             struct net_data *net_data));
+extern struct hostent  *gethostbyname_p __P((const char *,
+                                             struct net_data *));
+extern struct hostent  *gethostbyname2_p __P((const char *, int,
+                                              struct net_data *));
+extern struct hostent  *gethostbyaddr_p __P((const char *, int, int,
+                                             struct net_data *));
+extern struct hostent  *gethostent_p __P((struct net_data *));
+extern void            sethostent_p __P((int, struct net_data *));
+extern void            endhostent_p __P((struct net_data *));
+extern struct hostent  *getipnodebyname_p __P((const char *, int, int, int *,
+                                              struct net_data *));
+extern struct hostent  *getipnodebyaddr_p __P((const void *, size_t,
+                                             int, int *, struct net_data *));
 
-extern struct netent   *getnetent_p __P((struct net_data *net_data));
-extern struct netent   *getnetbyname_p __P((const char *name,
-                                            struct net_data *net_data));
-extern struct netent   *getnetbyaddr_p __P((unsigned long net, int type,
-                                            struct net_data *net_data));
-extern void            setnetent_p __P((int stayopen,
-                                        struct net_data *net_data));
-extern void            endnetent_p __P((struct net_data *net_data));
+extern struct netent   *getnetent_p __P((struct net_data *));
+extern struct netent   *getnetbyname_p __P((const char *, struct net_data *));
+extern struct netent   *getnetbyaddr_p __P((unsigned long, int,
+                                            struct net_data *));
+extern void            setnetent_p __P((int, struct net_data *));
+extern void            endnetent_p __P((struct net_data *));
 
-extern void            setnetgrent_p __P((const char *netgroup,
-                                          struct net_data *net_data));
-extern void            endnetgrent_p __P((struct net_data *net_data));
-extern int             innetgr_p __P((const char *netgroup,
-                                      const char *host,
-                                      const char *user,
-                                      const char *domain,
-                                      struct net_data *net_data));
-extern int             getnetgrent_p __P((const char **host, const char **user,
-                                          const char **domain,
-                                          struct net_data *net_data));
+extern void            setnetgrent_p __P((const char *, struct net_data *));
+extern void            endnetgrent_p __P((struct net_data *));
+extern int             innetgr_p __P((const char *, const char *, const char *,
+                                      const char *, struct net_data *));
+extern int             getnetgrent_p __P((const char **, const char **,
+                                          const char **, struct net_data *));
 
-extern struct protoent  *getprotoent_p __P((struct net_data *net_data));
-extern struct protoent  *getprotobyname_p __P((const char *name,
-                                              struct net_data *net_data));
-extern struct protoent *getprotobynumber_p __P((int proto,
-                                                struct net_data *net_data));
-extern void            setprotoent_p __P((int stayopen,
-                                          struct net_data *net_data));
-extern void            endprotoent_p __P((struct net_data *net_data));
+extern struct protoent  *getprotoent_p __P((struct net_data *));
+extern struct protoent  *getprotobyname_p __P((const char *,
+                                              struct net_data *));
+extern struct protoent *getprotobynumber_p __P((int, struct net_data *));
+extern void            setprotoent_p __P((int, struct net_data *));
+extern void            endprotoent_p __P((struct net_data *));
 
 
-extern struct passwd   *getpwent_p __P((struct net_data *net_data));
-extern struct passwd   *getpwnam_p __P((const char *name,
-                                        struct net_data *net_data));
-extern struct passwd   *getpwuid_p __P((uid_t uid,
-                                        struct net_data *net_data));
-extern int             setpassent_p __P((int stayopen,
-                                         struct net_data *net_data));
-extern void            endpwent_p __P((struct net_data *net_data));
+extern struct passwd   *getpwent_p __P((struct net_data *));
+extern struct passwd   *getpwnam_p __P((const char *, struct net_data *));
+extern struct passwd   *getpwuid_p __P((uid_t, struct net_data *));
+extern int             setpassent_p __P((int, struct net_data *));
+extern void            endpwent_p __P((struct net_data *));
 
 #ifdef SETPWENT_VOID
-extern void            setpwent_p __P((struct net_data *net_data));
+extern void            setpwent_p __P((struct net_data *));
 #else
-extern int             setpwent_p __P((struct net_data *net_data));
+extern int             setpwent_p __P((struct net_data *));
 #endif
 
-extern struct servent  *getservent_p __P((struct net_data *net_data));
-extern struct servent  *getservbyname_p __P((const char *name,
-                                             const char *proto,
-                                             struct net_data *net_data));
-extern struct servent  *getservbyport_p __P((int port, const char *proto,
-                                             struct net_data *net_data));
-extern void            setservent_p __P((int stayopen,
-                                         struct net_data *net_data));
-extern void            endservent_p __P((struct net_data *net_data));
+extern struct servent  *getservent_p __P((struct net_data *));
+extern struct servent  *getservbyname_p __P((const char *, const char *,
+                                             struct net_data *));
+extern struct servent  *getservbyport_p __P((int, const char *,
+                                             struct net_data *));
+extern void            setservent_p __P((int, struct net_data *));
+extern void            endservent_p __P((struct net_data *));
 
 #endif /*_IRS_H_INCLUDED*/
index cc7ae0d8011f149e5998003473218f93cd340474..c2b8a3177611a5f97248a8db8d26b78773204716 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 /*
- * $Id: ctl.h,v 1.2 2001/11/01 04:21:13 marka Exp $
+ * $Id: ctl.h,v 1.3 2003/06/03 04:39:29 marka Exp $
  */
 
 #include <sys/types.h>
@@ -42,11 +42,11 @@ struct ctl_verb;
 
 enum ctl_severity { ctl_debug, ctl_warning, ctl_error };
 
-typedef void (*ctl_logfunc)(enum ctl_severity, const char *fmt, ...);
+typedef void (*ctl_logfunc)(enum ctl_severity, const char *, ...);
 
 typedef void (*ctl_verbfunc)(struct ctl_sctx *, struct ctl_sess *,
-                            const struct ctl_verb *, const char *rest,
-                            u_int respflags, const void *respctx, void *uctx);
+                            const struct ctl_verb *, const char *,
+                            u_int, const void *, void *);
 
 typedef void (*ctl_srvrdone)(struct ctl_sctx *, struct ctl_sess *, void *);
 
index 4509f272500ba99b09aaa4a48fd946705af22bd8..fe9229725a919daa5243d6f5ee46244711ba3cbb 100644 (file)
@@ -12,72 +12,114 @@ typedef struct dst_key {
 } DST_KEY;
 #endif /* HAS_DST_KEY */
 
+/*
+ * do not taint namespace
+ */
+#define        dst_bsafe_init          __dst_bsafe_init
+#define        dst_buffer_to_key       __dst_buffer_to_key
+#define        dst_check_algorithm     __dst_check_algorithm
+#define        dst_compare_keys        __dst_compare_keys
+#define        dst_cylink_init         __dst_cylink_init
+#define        dst_dnskey_to_key       __dst_dnskey_to_key
+#define        dst_eay_dss_init        __dst_eay_dss_init
+#define        dst_free_key            __dst_free_key
+#define        dst_generate_key        __dst_generate_key
+#define        dst_hmac_md5_init       __dst_hmac_md5_init
+#define        dst_init                __dst_init
+#define        dst_key_to_buffer       __dst_key_to_buffer
+#define        dst_key_to_dnskey       __dst_key_to_dnskey
+#define        dst_read_key            __dst_read_key
+#define        dst_rsaref_init         __dst_rsaref_init
+#define        dst_s_build_filename    __dst_s_build_filename
+#define        dst_s_calculate_bits    __dst_s_calculate_bits
+#define        dst_s_conv_bignum_b64_to_u8     __dst_s_conv_bignum_b64_to_u8
+#define        dst_s_conv_bignum_u8_to_b64     __dst_s_conv_bignum_u8_to_b64
+#define        dst_s_dns_key_id        __dst_s_dns_key_id
+#define        dst_s_dump              __dst_s_dump
+#define        dst_s_filename_length   __dst_s_filename_length
+#define        dst_s_fopen             __dst_s_fopen
+#define        dst_s_get_int16         __dst_s_get_int16
+#define        dst_s_get_int32         __dst_s_get_int32
+#define        dst_s_id_calc           __dst_s_id_calc
+#define        dst_s_put_int16         __dst_s_put_int16
+#define        dst_s_put_int32         __dst_s_put_int32
+#define        dst_s_quick_random      __dst_s_quick_random
+#define        dst_s_quick_random_set  __dst_s_quick_random_set
+#define        dst_s_random            __dst_s_random
+#define        dst_s_semi_random       __dst_s_semi_random
+#define        dst_s_verify_str        __dst_s_verify_str
+#define        dst_sig_size            __dst_sig_size
+#define        dst_sign_data           __dst_sign_data
+#define        dst_verify_data         __dst_verify_data
+#define        dst_write_key           __dst_write_key
+
 /* 
  * DST Crypto API defintions 
  */
 void     dst_init(void);
 int      dst_check_algorithm(const int);
 
-int dst_sign_data(const int mode,       /* specifies INIT/UPDATE/FINAL/ALL */
-                 DST_KEY *in_key,       /* the key to use */
-                 void **context,        /* pointer to state structure */
-                 const u_char *data,    /* data to be signed */
-                 const int len,         /* length of input data */
-                 u_char *signature,     /* buffer to write signature to */
-                 const int sig_len);    /* size of output buffer */
+int dst_sign_data(const int,           /* specifies INIT/UPDATE/FINAL/ALL */
+                 DST_KEY *,            /* the key to use */
+                 void **,              /* pointer to state structure */
+                 const u_char *,       /* data to be signed */
+                 const int,            /* length of input data */
+                 u_char *,             /* buffer to write signature to */
+                 const int);           /* size of output buffer */
+
+int dst_verify_data(const int,         /* specifies INIT/UPDATE/FINAL/ALL */
+                   DST_KEY *,          /* the key to use */
+                   void **,            /* pointer to state structure */
+                   const u_char *,     /* data to be verified */
+                   const int,          /* length of input data */
+                   const u_char *,     /* buffer containing signature */
+                   const int);         /* length of signature */
 
-int dst_verify_data(const int mode,     /* specifies INIT/UPDATE/FINAL/ALL */
-                   DST_KEY *in_key,     /* the key to use */
-                   void **context,      /* pointer to state structure */
-                   const u_char *data,  /* data to be verified */
-                   const int len,       /* length of input data */
-                   const u_char *signature,/* buffer containing signature */
-                   const int sig_len);  /* length of signature */
 
+DST_KEY *dst_read_key(const char *,    /* name of key */
+                     const u_int16_t,  /* key tag identifier */
+                     const int,        /* key algorithm */
+                     const int);       /* Private/PublicKey wanted*/
 
-DST_KEY *dst_read_key(const char *in_name,   /* name of key */
-                     const u_int16_t in_id, /* key tag identifier */
-                     const int in_alg,      /* key algorithm */
-                     const int key_type);   /* Private/PublicKey wanted*/
+int      dst_write_key(const DST_KEY *,        /* key to write out */
+                      const int);      /* Public/Private */
 
-int      dst_write_key(const DST_KEY *key,  /* key to write out */
-                      const int key_type); /* Public/Private */
+DST_KEY *dst_dnskey_to_key(const char *,       /* KEY record name */
+                          const u_char *,      /* KEY RDATA */
+                          const int);          /* size of input buffer*/
 
-DST_KEY *dst_dnskey_to_key(const char *in_name,        /* KEY record name */
-                          const u_char *key,   /* KEY RDATA */
-                          const int len);      /* size of input buffer*/
 
+int      dst_key_to_dnskey(const DST_KEY *,    /* key to translate */
+                          u_char *,            /* output buffer */
+                          const int);          /* size of out_storage*/
 
-int      dst_key_to_dnskey(const DST_KEY *key, /* key to translate */
-                          u_char *out_storage, /* output buffer */
-                          const int out_len);  /* size of out_storage*/
 
+DST_KEY *dst_buffer_to_key(const char *,       /* name of the key */
+                          const int,           /* algorithm */
+                          const int,           /* dns flags */
+                          const int,           /* dns protocol */
+                          const u_char *,      /* key in dns wire fmt */
+                          const int);          /* size of key */
 
-DST_KEY *dst_buffer_to_key(const char *key_name,  /* name of the key */
-                          const int alg,         /* algorithm */
-                          const int flags,       /* dns flags */
-                          const int protocol,    /* dns protocol */
-                          const u_char *key_buf, /* key in dns wire fmt */
-                          const int key_len);    /* size of key */
 
+int     dst_key_to_buffer(DST_KEY *, u_char *, int);
 
-int     dst_key_to_buffer(DST_KEY *key, u_char *out_buff, int buf_len);
+DST_KEY *dst_generate_key(const char *,        /* name of new key */
+                         const int,            /* key algorithm to generate */
+                         const int,            /* size of new key */
+                         const int,            /* alg dependent parameter*/
+                         const int,            /* key DNS flags */
+                         const int);           /* key DNS protocol */
 
-DST_KEY *dst_generate_key(const char *name,    /* name of new key */
-                         const int alg,       /* key algorithm to generate */
-                         const int bits,      /* size of new key */
-                         const int exp,       /* alg dependent parameter*/
-                         const int flags,     /* key DNS flags */
-                         const int protocol); /* key DNS protocol */
+DST_KEY *dst_free_key(DST_KEY *);
+int      dst_compare_keys(const DST_KEY *, const DST_KEY *);
 
-DST_KEY *dst_free_key(DST_KEY *f_key);
-int      dst_compare_keys(const DST_KEY *key1, const DST_KEY *key2);
+int    dst_sig_size(DST_KEY *);
 
-int    dst_sig_size(DST_KEY *key);
 
 /* support for dns key tags/ids */
-u_int16_t dst_s_dns_key_id(const u_char *dns_key_rdata, const int rdata_len);
-u_int16_t dst_s_id_calc(const u_char *key_data, const int key_len);
+u_int16_t dst_s_dns_key_id(const u_char *, const int);
+u_int16_t dst_s_id_calc(const u_char *, const int);
 
 /* Used by callers as well as by the library.  */
 #define RAW_KEY_SIZE    8192        /* large enough to store any key */
index 4a3dc4b9f8659d5909d2171eb79abc35dd02d2c7..c0d99a22b26e02990e9aedfba4d689eaa5f46de3 100644 (file)
@@ -18,7 +18,7 @@
 /* eventlib.h - exported interfaces for eventlib
  * vix 09sep95 [initial]
  *
- * $Id: eventlib.h,v 1.1 2001/03/29 06:31:36 marka Exp $
+ * $Id: eventlib.h,v 1.2 2003/06/03 04:39:30 marka Exp $
  */
 
 #ifndef _EVENTLIB_H
@@ -50,14 +50,13 @@ typedef struct { void *opaque; } evEvent;
 #define        evInitID(id) ((id)->opaque = NULL)
 #define        evTestID(id) ((id).opaque != NULL)
 
-typedef void (*evConnFunc)__P((evContext ctx, void *uap, int fd,
-                              const void *la, int lalen,
-                              const void *ra, int ralen));
-typedef void (*evFileFunc)__P((evContext ctx, void *uap, int fd, int evmask));
-typedef        void (*evStreamFunc)__P((evContext ctx, void *uap, int fd, int bytes));
-typedef void (*evTimerFunc)__P((evContext ctx, void *uap,
-                               struct timespec due, struct timespec inter));
-typedef        void (*evWaitFunc)__P((evContext ctx, void *uap, const void *tag));
+typedef void (*evConnFunc)__P((evContext, void *, int, const void *, int,
+                              const void *, int));
+typedef void (*evFileFunc)__P((evContext, void *, int, int));
+typedef        void (*evStreamFunc)__P((evContext, void *, int, int));
+typedef void (*evTimerFunc)__P((evContext, void *,
+                               struct timespec, struct timespec));
+typedef        void (*evWaitFunc)__P((evContext, void *, const void *));
 
 typedef        struct { unsigned char mask[256/8]; } evByteMask;
 #define        EV_BYTEMASK_BYTE(b) ((b) / 8)
@@ -87,14 +86,14 @@ typedef     struct { unsigned char mask[256/8]; } evByteMask;
 #define evMainLoop     __evMainLoop
 #define evHighestFD    __evHighestFD
 
-int  evCreate __P((evContext *ctx));
-void evSetDebug __P((evContext ctx, int lev, FILE *out));
-int  evDestroy __P((evContext ctx));
-int  evGetNext __P((evContext ctx, evEvent *ev, int options));
-int  evDispatch __P((evContext ctx, evEvent ev));
-void evDrop __P((evContext ctx, evEvent ev));
-int  evMainLoop __P((evContext ctx));
-int  evHighestFD __P((evContext ctx));
+int  evCreate __P((evContext *));
+void evSetDebug __P((evContext, int, FILE *));
+int  evDestroy __P((evContext));
+int  evGetNext __P((evContext, evEvent *, int));
+int  evDispatch __P((evContext, evEvent));
+void evDrop __P((evContext, evEvent));
+int  evMainLoop __P((evContext));
+int  evHighestFD __P((evContext));
 
 /* ev_connects.c */
 #define evListen       __evListen
@@ -104,11 +103,10 @@ int  evHighestFD __P((evContext ctx));
 #define evUnhold       __evUnhold
 #define evTryAccept    __evTryAccept
 
-int evListen __P((evContext ctx, int fd, int maxconn,
-                 evConnFunc func, void *uap, evConnID *id));
-int evConnect __P((evContext ctx, int fd, const void *ra, int ralen,
-                  evConnFunc func, void *uap, evConnID *id));
-int evCancelConn __P((evContext ctx, evConnID id));
+int evListen __P((evContext, int, int, evConnFunc, void *, evConnID *));
+int evConnect __P((evContext, int, const void *, int,
+                  evConnFunc, void *, evConnID *));
+int evCancelConn __P((evContext, evConnID));
 int evHold __P((evContext, evConnID));
 int evUnhold __P((evContext, evConnID));
 int evTryAccept __P((evContext, evConnID, int *));
@@ -117,9 +115,8 @@ int evTryAccept __P((evContext, evConnID, int *));
 #define evSelectFD     __evSelectFD
 #define evDeselectFD   __evDeselectFD
 
-int evSelectFD __P((evContext ctx, int fd, int eventmask,
-                   evFileFunc func, void *uap, evFileID *id));
-int evDeselectFD __P((evContext ctx, evFileID id));
+int evSelectFD __P((evContext, int, int, evFileFunc, void *, evFileID *));
+int evDeselectFD __P((evContext, evFileID));
 
 /* ev_streams.c */
 #define evConsIovec    __evConsIovec
@@ -129,14 +126,14 @@ int evDeselectFD __P((evContext ctx, evFileID id));
 #define evUntimeRW     __evUntimeRW
 #define        evCancelRW      __evCancelRW
 
-struct iovec evConsIovec __P((void *buf, size_t cnt));
-int evWrite __P((evContext ctx, int fd, const struct iovec *iov, int cnt,
-                evStreamFunc func, void *uap, evStreamID *id));
-int evRead __P((evContext ctx, int fd, const struct iovec *iov, int cnt,
-               evStreamFunc func, void *uap, evStreamID *id));
-int evTimeRW __P((evContext ctx, evStreamID id, evTimerID timer));
-int evUntimeRW __P((evContext ctx, evStreamID id));
-int evCancelRW __P((evContext ctx, evStreamID id));
+struct iovec evConsIovec __P((void *, size_t));
+int evWrite __P((evContext, int, const struct iovec *, int,
+                evStreamFunc func, void *, evStreamID *));
+int evRead __P((evContext, int, const struct iovec *, int,
+               evStreamFunc func, void *, evStreamID *));
+int evTimeRW __P((evContext, evStreamID, evTimerID timer));
+int evUntimeRW __P((evContext, evStreamID));
+int evCancelRW __P((evContext, evStreamID));
 
 /* ev_timers.c */
 #define evConsTime     __evConsTime
@@ -157,17 +154,16 @@ int evCancelRW __P((evContext ctx, evStreamID id));
 #define evTouchIdleTimer       __evTouchIdleTimer
 
 struct timespec evConsTime __P((time_t sec, long nsec));
-struct timespec evAddTime __P((struct timespec add1, struct timespec add2));
-struct timespec evSubTime __P((struct timespec minu, struct timespec subtra));
+struct timespec evAddTime __P((struct timespec, struct timespec));
+struct timespec evSubTime __P((struct timespec, struct timespec));
 struct timespec evNowTime __P((void));
 struct timespec evLastEventTime __P((evContext));
 struct timespec evTimeSpec __P((struct timeval));
 struct timeval evTimeVal __P((struct timespec));
-int evCmpTime __P((struct timespec a, struct timespec b));
-int evSetTimer __P((evContext ctx, evTimerFunc func, void *uap,
-                   struct timespec due, struct timespec inter,
-                   evTimerID *id));
-int evClearTimer __P((evContext ctx, evTimerID id));
+int evCmpTime __P((struct timespec, struct timespec));
+int evSetTimer __P((evContext, evTimerFunc, void *, struct timespec,
+                   struct timespec, evTimerID *));
+int evClearTimer __P((evContext, evTimerID));
 int evResetTimer __P((evContext, evTimerID, evTimerFunc, void *,
                      struct timespec, struct timespec));
 int evSetIdleTimer __P((evContext, evTimerFunc, void *, struct timespec,
@@ -183,10 +179,9 @@ int evTouchIdleTimer __P((evContext, evTimerID));
 #define evUnwait       __evUnwait
 #define evDefer                __evDefer
 
-int evWaitFor __P((evContext ctx, const void *tag, evWaitFunc func, void *uap,
-                  evWaitID *id));
-int evDo __P((evContext ctx, const void *tag));
-int evUnwait __P((evContext ctx, evWaitID id));
+int evWaitFor __P((evContext, const void *, evWaitFunc, void *, evWaitID *));
+int evDo __P((evContext, const void *));
+int evUnwait __P((evContext, evWaitID));
 int evDefer __P((evContext, evWaitFunc, void *));
 
 #ifdef __EVENTLIB_P_DEFINED
index d851ecacd488a6d3486790e3f56fd9567a6f3ddf..4746fd51d1f8e2355ad4ae59b36bc8bf95c93718 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 /*
- * $Id: irpmarshall.h,v 1.1 2001/03/29 06:31:36 marka Exp $
+ * $Id: irpmarshall.h,v 1.2 2003/06/03 04:39:30 marka Exp $
  */
 
 #ifndef _IRPMARSHALL_H_INCLUDED
                       (x == AF_INET6 ? "AF_INET6" : "UNKNOWN"))
 
 /* See comment below on usage */
-int irp_marshall_pw(const struct passwd *pw, char **buffer, size_t *len);
-int irp_unmarshall_pw(struct passwd *pw, char *buffer);
-int irp_marshall_gr(const struct group *gr, char **buffer, size_t *len);
-int irp_unmarshall_gr(struct group *gr, char *buffer);
-int irp_marshall_sv(const struct servent *sv, char **buffer, size_t *len);
-int irp_unmarshall_sv(struct servent *sv, char *buffer);
-int irp_marshall_pr(struct protoent *pr, char **buffer, size_t *len);
-int irp_unmarshall_pr(struct protoent *pr, char *buffer);
-int irp_marshall_ho(struct hostent *ho, char **buffer, size_t *len);
-int irp_unmarshall_ho(struct hostent *ho, char *buffer);
-int irp_marshall_ng(const char *host, const char *user, const char *domain,
-                   char **buffer, size_t *len);
-int irp_unmarshall_ng(const char **host, const char **user,
-                     const char **domain, char *buffer);
-int irp_marshall_nw(struct nwent *ne, char **buffer, size_t *len);
-int irp_unmarshall_nw(struct nwent *ne, char *buffer);
-int irp_marshall_ne(struct netent *ne, char **buffer, size_t *len);
-int irp_unmarshall_ne(struct netent *ne, char *buffer);
+int irp_marshall_pw(const struct passwd *, char **, size_t *);
+int irp_unmarshall_pw(struct passwd *, char *);
+int irp_marshall_gr(const struct group *, char **, size_t *);
+int irp_unmarshall_gr(struct group *, char *);
+int irp_marshall_sv(const struct servent *, char **, size_t *);
+int irp_unmarshall_sv(struct servent *, char *);
+int irp_marshall_pr(struct protoent *, char **, size_t *);
+int irp_unmarshall_pr(struct protoent *, char *);
+int irp_marshall_ho(struct hostent *, char **, size_t *);
+int irp_unmarshall_ho(struct hostent *, char *);
+int irp_marshall_ng(const char *, const char *, const char *,
+                   char **, size_t *);
+int irp_unmarshall_ng(const char **, const char **, const char **, char *);
+int irp_marshall_nw(struct nwent *, char **, size_t *);
+int irp_unmarshall_nw(struct nwent *, char *);
+int irp_marshall_ne(struct netent *, char **, size_t *);
+int irp_unmarshall_ne(struct netent *, char *);
 
 /*
  * Functions to marshall and unmarshall various system data structures. We
index 6d6976f1a8ee479ef4a41a13b7612b1c4f4ae884..dc491dc095f8bd90086bec647610d079f9aa89bc 100644 (file)
@@ -80,12 +80,15 @@ FILE *                      log_get_stream(log_channel);
 char *                 log_get_filename(log_channel);
 int                    log_check_channel(log_context, int, log_channel);
 int                    log_check(log_context, int, int);
-void                   log_vwrite(log_context, int, int, const char *, 
-                                  va_list args);
 #ifdef __GNUC__
+void                   log_vwrite(log_context, int, int, const char *, 
+                                  va_list args)
+                               __attribute__((__format__(__printf__, 4, 0)));
 void                   log_write(log_context, int, int, const char *, ...)
                                __attribute__((__format__(__printf__, 4, 5)));
 #else
+void                   log_vwrite(log_context, int, int, const char *, 
+                                  va_list args);
 void                   log_write(log_context, int, int, const char *, ...);
 #endif
 int                    log_new_context(int, char **, log_context *);
index b75121d4d2ecef21614ef1dec4d4b89607924251..e9b177fda9410235f165e575c270b6155ccc07d1 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 /*
- * $Id: misc.h,v 1.2 2001/06/21 08:26:05 marka Exp $
+ * $Id: misc.h,v 1.3 2003/06/03 04:39:30 marka Exp $
  */
 
 #ifndef _ISC_MISC_H
@@ -27,7 +27,7 @@
 #define        bitncmp         __bitncmp
 /*#define isc_movefile __isc_movefile */
 
-extern int             bitncmp(const void *l, const void *r, int n);
+extern int             bitncmp(const void *, const void *, int);
 extern int             isc_movefile(const char *, const char *);
 
 extern int             isc_gethexstring(unsigned char *, size_t, int, FILE *,
index f383489e17ef5c2287b97f0bcb4a97cfb36e6974..80df6cfa12299df031bb6b04796f8effb0d5d12c 100644 (file)
@@ -3,7 +3,7 @@
  * vix 22jan93 [revisited; uses RCS, ANSI, POSIX; has bug fixes]
  * vix 27jun86 [broken out of tree.c]
  *
- * $Id: tree.h,v 1.1 2001/03/29 06:31:37 marka Exp $
+ * $Id: tree.h,v 1.2 2003/06/03 04:39:30 marka Exp $
  */
 
 
@@ -28,6 +28,16 @@ typedef      void *tree_t;
 typedef        char *tree_t;
 #endif
 
+/*
+ * Do not taint namespace
+ */
+#define        tree_add        __tree_add
+#define        tree_delete     __tree_delete
+#define        tree_init       __tree_init
+#define        tree_mung       __tree_mung
+#define        tree_srch       __tree_srch
+#define        tree_trav       __tree_trav
+
 
 typedef        struct tree_s {
                tree_t          data;
index d992ad7b7b9c0d57e4b1d6a7a871fc708e3f7ede..7ef4c47cbef81babecf8a99e1a0c38f446da1075 100644 (file)
@@ -86,7 +86,7 @@
 
 /*
  *      @(#)netdb.h    8.1 (Berkeley) 6/2/93
- *     $Id: netdb.h,v 1.12 2001/07/23 00:48:51 marka Exp $
+ *     $Id: netdb.h,v 1.13 2003/06/03 04:39:28 marka Exp $
  */
 
 #ifndef _NETDB_H_
@@ -192,7 +192,6 @@ struct      addrinfo {
 /*
  * Error return codes from getaddrinfo()
  */
-
 #define        EAI_ADDRFAMILY   1      /* address family for hostname not supported */
 #define        EAI_AGAIN        2      /* temporary failure in name resolution */
 #define        EAI_BADFLAGS     3      /* invalid value for ai_flags */
index 9579a2f01031443cb9d07704ff07751f647a4cc1..be1c644ff49903a463f9c9d9608c41270e888778 100644 (file)
@@ -50,7 +50,7 @@
 
 /*
  *     @(#)resolv.h    8.1 (Berkeley) 6/2/93
- *     $Id: resolv.h,v 1.17 2002/06/28 05:46:10 marka Exp $
+ *     $Id: resolv.h,v 1.18 2003/06/03 04:39:28 marka Exp $
  */
 
 #ifndef _RESOLV_H_
@@ -75,7 +75,7 @@
  * is new enough to contain a certain feature.
  */
 
-#define        __RES   19991006
+#define        __RES   20030124
 
 /*
  * This used to be defined in res_query.c, now it's in herror.c.
@@ -105,7 +105,7 @@ __END_DECLS
 /*
  * Resolver configuration file.
  * Normally not present, but may contain the address of the
- * inital name server(s) to query and the domain search list.
+ * initial name server(s) to query and the domain search list.
  */
 
 #ifndef _PATH_RESCONF
@@ -115,19 +115,13 @@ __END_DECLS
 typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error }
        res_sendhookact;
 
-typedef res_sendhookact (*res_send_qhook)__P((struct sockaddr * const *ns,
-                                             const u_char **query,
-                                             int *querylen,
-                                             u_char *ans,
-                                             int anssiz,
-                                             int *resplen));
+typedef res_sendhookact (*res_send_qhook)__P((struct sockaddr * const *,
+                                             const u_char **, int *,
+                                             u_char *, int, int *));
 
-typedef res_sendhookact (*res_send_rhook)__P((const struct sockaddr *ns,
-                                             const u_char *query,
-                                             int querylen,
-                                             u_char *ans,
-                                             int anssiz,
-                                             int *resplen));
+typedef res_sendhookact (*res_send_rhook)__P((const struct sockaddr *,
+                                             const u_char *, int, u_char *,
+                                             int, int *));
 
 struct res_sym {
        int             number;    /* Identifying number, like T_MX */
@@ -154,7 +148,7 @@ struct res_sym {
 struct __res_state_ext;
 
 struct __res_state {
-       int     retrans;                /* retransmition time interval */
+       int     retrans;                /* retransmission time interval */
        int     retry;                  /* number of times to retransmit */
 #ifdef sun
        u_int   options;                /* option flags - see below. */
@@ -219,6 +213,10 @@ union res_sockaddr_union {
 #define        RES_F_VC        0x00000001      /* socket is TCP */
 #define        RES_F_CONN      0x00000002      /* socket is connected */
 #define        RES_F_EDNS0ERR  0x00000004      /* EDNS0 caused errors */
+#define        RES_F__UNUSED   0x00000008      /* (unused) */
+#define        RES_F_LASTMASK  0x000000F0      /* ordinal server of last res_nsend */
+#define        RES_F_LASTSHIFT 4               /* bit position of LASTMASK "flag" */
+#define        RES_GETLAST(res) (((res)._flags & RES_F_LASTMASK) >> RES_F_LASTSHIFT)
 
 /* res_findzonecut2() options */
 #define        RES_EXHAUSTIVE  0x00000001      /* always do all queries */
@@ -246,13 +244,10 @@ union res_sockaddr_union {
 #define        RES_NOCHECKNAME 0x00008000      /* do not check names for sanity. */
 #define        RES_KEEPTSIG    0x00010000      /* do not strip TSIG records */
 #define        RES_BLAST       0x00020000      /* blast all recursive servers */
-#define RES_NO_NIBBLE  0x00040000      /* disable IPv6 nibble mode reverse */
-#define RES_NO_BITSTRING 0x00080000    /* disable IPv6 bitstring mode reverse */
 #define RES_NOTLDQUERY 0x00100000      /* don't unqualified name as a tld */
 #define RES_USE_DNSSEC 0x00200000      /* use DNSSEC using OK bit in OPT */
 /* KAME extensions: use higher bit to avoid conflict with ISC use */
 #define RES_USE_DNAME  0x10000000      /* use DNAME */
-#define RES_USE_A6     0x20000000      /* use A6 */
 #define RES_USE_EDNS0  0x40000000      /* use EDNS0 if configured */
 #define RES_NO_NIBBLE2 0x80000000      /* disable alternate nibble lookup */
 
@@ -361,6 +356,7 @@ extern const struct res_sym __p_rcode_syms[];
 #define p_time                 __p_time
 #define p_type                 __p_type
 #define p_rcode                        __p_rcode
+#define p_sockun               __p_sockun
 #define putlong                        __putlong
 #define putshort               __putshort
 #define res_dnok               __res_dnok
@@ -392,6 +388,18 @@ extern const struct res_sym __p_rcode_syms[];
 #define        res_nametotype          __res_nametotype
 #define        res_setservers          __res_setservers
 #define        res_getservers          __res_getservers
+#define        res_buildprotolist      __res_buildprotolist
+#define        res_destroyprotolist    __res_destroyprotolist
+#define        res_destroyservicelist  __res_destroyservicelist
+#define        res_get_nibblesuffix    __res_get_nibblesuffix
+#define        res_get_nibblesuffix2   __res_get_nibblesuffix2
+#define        res_ourserver_p         __res_ourserver_p
+#define        res_protocolname        __res_protocolname
+#define        res_protocolnumber      __res_protocolnumber
+#define        res_send_setqhook       __res_send_setqhook
+#define        res_send_setrhook       __res_send_setrhook
+#define        res_servicename         __res_servicename
+#define        res_servicenumber       __res_servicenumber
 __BEGIN_DECLS
 int            res_hnok __P((const char *));
 int            res_ownok __P((const char *));
@@ -402,25 +410,26 @@ const char *      sym_ntos __P((const struct res_sym *, int, int *));
 const char *   sym_ntop __P((const struct res_sym *, int, int *));
 int            b64_ntop __P((u_char const *, size_t, char *, size_t));
 int            b64_pton __P((char const *, u_char *, size_t));
-int            loc_aton __P((const char *ascii, u_char *binary));
-const char *   loc_ntoa __P((const u_char *binary, char *ascii));
+int            loc_aton __P((const char *, u_char *));
+const char *   loc_ntoa __P((const u_char *, char *));
 int            dn_skipname __P((const u_char *, const u_char *));
 void           putlong __P((u_int32_t, u_char *));
 void           putshort __P((u_int16_t, u_char *));
 #ifndef __ultrix__
-u_int16_t      _getshort __P((const u_char *src));
-u_int32_t      _getlong __P((const u_char *src));
+u_int16_t      _getshort __P((const u_char *));
+u_int32_t      _getlong __P((const u_char *));
 #endif
 const char *   p_class __P((int));
 const char *   p_time __P((u_int32_t));
 const char *   p_type __P((int));
 const char *   p_rcode __P((int));
+const char *   p_sockun __P((union res_sockaddr_union, char *, size_t));
 const u_char * p_cdnname __P((const u_char *, const u_char *, int, FILE *));
 const u_char * p_cdname __P((const u_char *, const u_char *, FILE *));
-const u_char * p_fqnname __P((const u_char *cp, const u_char *msg,
+const u_char * p_fqnname __P((const u_char *, const u_char *,
                               int, char *, int));
 const u_char * p_fqname __P((const u_char *, const u_char *, FILE *));
-const char *   p_option __P((u_long option));
+const char *   p_option __P((u_long));
 char *         p_secstodate __P((u_long));
 int            dn_count_labels __P((const char *));
 int            dn_comp __P((const char *, u_char *, int,
@@ -428,11 +437,11 @@ int               dn_comp __P((const char *, u_char *, int,
 int            dn_expand __P((const u_char *, const u_char *, const u_char *,
                               char *, int));
 u_int          res_randomid __P((void));
-int            res_nameinquery __P((const char *, int, int,
-                                    const u_char *, const u_char *));
+int            res_nameinquery __P((const char *, int, int, const u_char *,
+                                    const u_char *));
 int            res_queriesmatch __P((const u_char *, const u_char *,
                                      const u_char *, const u_char *));
-const char *   p_section __P((int section, int opcode));
+const char *   p_section __P((int, int));
 /* Things involving a resolver context. */
 int            res_ninit __P((res_state));
 int            res_nisourserver __P((const res_state,
@@ -441,16 +450,15 @@ void              fp_resstat __P((const res_state, FILE *));
 void           res_pquery __P((const res_state, const u_char *, int, FILE *));
 const char *   res_hostalias __P((const res_state, const char *,
                                   char *, size_t));
-int            res_nquery __P((res_state,
-                               const char *, int, int, u_char *, int));
-int            res_nsearch __P((res_state, const char *, int,
-                                int, u_char *, int));
-int            res_nquerydomain __P((res_state,
-                                     const char *, const char *, int, int,
-                                     u_char *, int));
-int            res_nmkquery __P((res_state,
-                                 int, const char *, int, int, const u_char *,
-                                 int, const u_char *, u_char *, int));
+int            res_nquery __P((res_state, const char *, int, int,
+                               u_char *, int));
+int            res_nsearch __P((res_state, const char *, int, int, u_char *,
+                                int));
+int            res_nquerydomain __P((res_state, const char *, const char *,
+                                     int, int, u_char *, int));
+int            res_nmkquery __P((res_state, int, const char *, int, int,
+                                 const u_char *, int, const u_char *,
+                                 u_char *, int));
 int            res_nsend __P((res_state, const u_char *, int, u_char *, int));
 int            res_nsendsigned __P((res_state, const u_char *, int,
                                     ns_tsig_key *, u_char *, int));
@@ -461,20 +469,19 @@ int               res_findzonecut2 __P((res_state, const char *, ns_class, int,
                                      union res_sockaddr_union *, int));
 void           res_nclose __P((res_state));
 int            res_nopt __P((res_state, int, u_char *, int, int));
-void           res_send_setqhook __P((res_send_qhook hook));
-void           res_send_setrhook __P((res_send_rhook hook));
+void           res_send_setqhook __P((res_send_qhook));
+void           res_send_setrhook __P((res_send_rhook));
 int            __res_vinit __P((res_state, int));
 void           res_destroyservicelist __P((void));
-const char *   res_servicename __P((u_int16_t port, const char *proto));
-const char *   res_protocolname __P((int num));
+const char *   res_servicename __P((u_int16_t, const char *));
+const char *   res_protocolname __P((int));
 void           res_destroyprotolist __P((void));
 void           res_buildprotolist __P((void));
 const char *   res_get_nibblesuffix __P((res_state));
 const char *   res_get_nibblesuffix2 __P((res_state));
-const char *   res_get_bitstringsuffix __P((res_state));
 void           res_ndestroy __P((res_state));
-u_int16_t      res_nametoclass __P((const char *buf, int *success));
-u_int16_t      res_nametotype __P((const char *buf, int *success));
+u_int16_t      res_nametoclass __P((const char *, int *));
+u_int16_t      res_nametotype __P((const char *, int *));
 void           res_setservers __P((res_state,
                                    const union res_sockaddr_union *, int));
 int            res_getservers __P((res_state,
index a47ba1e41251b81c873007021decce471378fd46..d0190e72e4107b23e32d5d55e16abf387e938b85 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: dns_gr.c,v 1.1 2001/03/29 06:31:42 marka Exp $";
+static const char rcsid[] = "$Id: dns_gr.c,v 1.2 2003/06/03 04:39:30 marka Exp $";
 #endif
 
 /*
@@ -226,7 +226,7 @@ get_hes_group(struct irs_gr *this, const char *name, const char *type) {
                goto cleanup;
        *cp++ = '\0';
 
-       errno = -1;
+       errno = 0;
        t = strtoul(cp, NULL, 10);
        if (errno == ERANGE)
                goto cleanup;
index bb7b512bcdc2e6298afca2185db8ed8f9e2cc72b..79c3bddb4d64f51fdb890cab7680be60ae70766d 100644 (file)
@@ -52,7 +52,7 @@
 /* BIND Id: gethnamaddr.c,v 8.15 1996/05/22 04:56:30 vixie Exp $ */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: dns_ho.c,v 1.11 2002/06/28 06:12:42 marka Exp $";
+static const char rcsid[] = "$Id: dns_ho.c,v 1.12 2003/06/03 04:39:30 marka Exp $";
 #endif /* LIBC_SCCS and not lint */
 
 /* Imports. */
@@ -95,7 +95,7 @@ static const char rcsid[] = "$Id: dns_ho.c,v 1.11 2002/06/28 06:12:42 marka Exp
 #define        MAXALIASES      35
 #define        MAXADDRS        35
 
-#define MAXPACKET (1024*64)
+#define MAXPACKET (65535)      /* Maximum TCP message size */
 
 #define BOUNDS_CHECK(ptr, count) \
        if ((ptr) + (count) > eom) { \
@@ -172,15 +172,6 @@ static struct hostent *    gethostans(struct irs_ho *this,
                                   const struct addrinfo *pai);
 static int add_hostent(struct pvt *pvt, char *bp, char **hap,
                       struct addrinfo *ai);
-static const u_char * ar_head(const u_char *, int, const u_char *,
-                             const u_char *, struct pvt *,
-                             int (*)(const char *));
-static struct addrinfo * a6_expand(const u_char *, const u_char *, int,
-                                  const u_char *, const u_char *,
-                                  const struct in6_addr *, int,
-                                  const struct addrinfo *,
-                                  struct pvt *, int (*)(const char *), int *);
-static const char *dname_subst(const char *, const char *, const char *);
 static int             init(struct irs_ho *this);
 
 /* Exports. */
@@ -257,21 +248,19 @@ ho_byname2(struct irs_ho *this, const char *name, int af)
        char tmp[NS_MAXDNAME];
        const char *cp;
        struct addrinfo ai;
-       struct dns_res_target *q, *q2, *p;
+       struct dns_res_target *q, *p;
        int querystate = RESQRY_FAIL;
 
        if (init(this) == -1)
                return (NULL);
 
        q = memget(sizeof(*q));
-       q2 = memget(sizeof(*q2));
-       if (q == NULL || q2 == NULL) {
+       if (q == NULL) {
                RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
                errno = ENOMEM;
                goto cleanup;
        }
        memset(q, 0, sizeof(q));
-       memset(q2, 0, sizeof(q2));
 
        switch (af) {
        case AF_INET:
@@ -285,21 +274,10 @@ ho_byname2(struct irs_ho *this, const char *name, int af)
        case AF_INET6:
                size = IN6ADDRSZ;
                q->qclass = C_IN;
-               q->qtype = ns_t_a6;
+               q->qtype = T_AAAA;
                q->answer = q->qbuf.buf;
                q->anslen = sizeof(q->qbuf);
-               q->next = q2;
-#ifdef RES_USE_A6
-               if ((pvt->res->options & RES_USE_A6) == 0)
-                       q->action = RESTGT_IGNORE;
-               else
-#endif
-                       q->action = RESTGT_DOALWAYS;
-               q2->qclass = C_IN;
-               q2->qtype = T_AAAA;
-               q2->answer = q2->qbuf.buf;
-               q2->anslen = sizeof(q2->qbuf);
-               q2->action = RESTGT_AFTERFAILURE;
+               q->action = RESTGT_DOALWAYS;
                break;
        default:
                RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
@@ -349,8 +327,6 @@ ho_byname2(struct irs_ho *this, const char *name, int af)
  cleanup:
        if (q != NULL)
                memput(q, sizeof(*q));
-       if (q2 != NULL)
-               memput(q2, sizeof(*q2));
        return(hp);
 }
 
@@ -363,7 +339,7 @@ ho_byaddr(struct irs_ho *this, const void *addr, int len, int af)
        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)
@@ -440,20 +416,36 @@ ho_byaddr(struct irs_ho *this, const void *addr, int len, int af)
                if (q->action != RESTGT_IGNORE) {
                        qp = q->qname;
                        for (n = IN6ADDRSZ - 1; n >= 0; n--) {
-                               qp += SPRINTF((qp, "%x.%x.",
+                               = SPRINTF((qp, "%x.%x.",
                                               uaddr[n] & 0xf,
                                               (uaddr[n] >> 4) & 0xf));
+                               if (i < 0)
+                                       abort();
+                               qp += i;
                        }
+#ifdef HAVE_STRLCAT
+                       strlcat(q->qname, res_get_nibblesuffix(pvt->res),
+                           sizeof(q->qname));
+#else
                        strcpy(qp, res_get_nibblesuffix(pvt->res));
+#endif
                }
                if (q2->action != RESTGT_IGNORE) {
                        qp = q2->qname;
                        for (n = IN6ADDRSZ - 1; n >= 0; n--) {
-                               qp += SPRINTF((qp, "%x.%x.",
+                               = SPRINTF((qp, "%x.%x.",
                                               uaddr[n] & 0xf,
                                               (uaddr[n] >> 4) & 0xf));
+                               if (i < 0)
+                                       abort();
+                               qp += i;
                        }
+#ifdef HAVE_STRLCAT
+                       strlcat(q->qname, res_get_nibblesuffix2(pvt->res),
+                           sizeof(q->qname));
+#else
                        strcpy(qp, res_get_nibblesuffix2(pvt->res));
+#endif
                }
                break;
        default:
@@ -563,7 +555,7 @@ ho_addrinfo(struct irs_ho *this, const char *name, const struct addrinfo *pai)
        int n;
        char tmp[NS_MAXDNAME];
        const char *cp;
-       struct dns_res_target *q, *q2, *q3, *p;
+       struct dns_res_target *q, *q2, *p;
        struct addrinfo sentinel, *cur;
        int querystate = RESQRY_FAIL;
 
@@ -575,42 +567,28 @@ ho_addrinfo(struct irs_ho *this, const char *name, const struct addrinfo *pai)
 
        q = memget(sizeof(*q));
        q2 = memget(sizeof(*q2));
-       q3 = memget(sizeof(*q3));
-       if (q == NULL || q2 == NULL || q3 == NULL) {
+       if (q == NULL || q2 == NULL) {
                RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
                errno = ENOMEM;
                goto cleanup;
        }
        memset(q, 0, sizeof(q2));
        memset(q2, 0, sizeof(q2));
-       memset(q3, 0, sizeof(q3));
 
        switch (pai->ai_family) {
        case AF_UNSPEC:
                /* prefer IPv6 */
                q->qclass = C_IN;
-               q->qtype = ns_t_a6;
+               q->qtype = T_AAAA;
                q->answer = q->qbuf.buf;
                q->anslen = sizeof(q->qbuf);
                q->next = q2;
-#ifdef RES_USE_A6
-               if ((pvt->res->options & RES_USE_A6) == 0)
-                       q->action = RESTGT_IGNORE;
-               else
-#endif
-                       q->action = RESTGT_DOALWAYS;
+               q->action = RESTGT_DOALWAYS;
                q2->qclass = C_IN;
-               q2->qtype = T_AAAA;
+               q2->qtype = T_A;
                q2->answer = q2->qbuf.buf;
                q2->anslen = sizeof(q2->qbuf);
-               q2->next = q3;
-               /* try AAAA only when A6 query fails */
-               q2->action = RESTGT_AFTERFAILURE;
-               q3->qclass = C_IN;
-               q3->qtype = T_A;
-               q3->answer = q3->qbuf.buf;
-               q3->anslen = sizeof(q3->qbuf);
-               q3->action = RESTGT_DOALWAYS;
+               q2->action = RESTGT_DOALWAYS;
                break;
        case AF_INET:
                q->qclass = C_IN;
@@ -621,21 +599,10 @@ ho_addrinfo(struct irs_ho *this, const char *name, const struct addrinfo *pai)
                break;
        case AF_INET6:
                q->qclass = C_IN;
-               q->qtype = ns_t_a6;
+               q->qtype = T_AAAA;
                q->answer = q->qbuf.buf;
                q->anslen = sizeof(q->qbuf);
-               q->next = q2;
-#ifdef RES_USE_A6
-               if ((pvt->res->options & RES_USE_A6) == 0)
-                       q->action = RESTGT_IGNORE;
-               else
-#endif
-                       q->action = RESTGT_DOALWAYS;
-               q2->qclass = C_IN;
-               q2->qtype = T_AAAA;
-               q2->answer = q2->qbuf.buf;
-               q2->anslen = sizeof(q2->qbuf);
-               q2->action = RESTGT_AFTERFAILURE;
+               q->action = RESTGT_DOALWAYS;
                break;
        default:
                RES_SET_H_ERRNO(pvt->res, NO_RECOVERY); /* better error? */
@@ -688,375 +655,9 @@ ho_addrinfo(struct irs_ho *this, const char *name, const struct addrinfo *pai)
                memput(q, sizeof(*q));
        if (q2 != NULL)
                memput(q2, sizeof(*q2));
-       if (q3 != NULL)
-               memput(q3, sizeof(*q3));
        return(sentinel.ai_next);
 }
 
-static const u_char *
-ar_head(cp, count, msg, eom, pvt, name_ok)
-       const u_char *cp, *msg, *eom;
-       int count;
-       struct pvt *pvt;
-       int (*name_ok)(const char *);
-{
-       int n;
-       char buf[1024]; /* XXX */
-
-       while (count-- > 0 && cp < eom) {
-               n = dn_expand(msg, eom, cp, buf, sizeof(buf));
-               if (n < 0 || !maybe_ok(pvt->res, buf, name_ok))
-                       goto end;
-               cp += n;                        /* name */
-               if (cp + 3 * INT16SZ + INT32SZ >= eom)
-                       goto end;
-               cp += INT16SZ;                  /* type */
-               cp += INT16SZ + INT32SZ;        /* class, TTL */
-               n = ns_get16(cp);
-               cp += n + INT16SZ;              /* len */
-       }
-       return(cp);
-
-  end:
-       return(eom);            /* XXX */
-}
-
-/* XXX: too many arguments */
-static struct addrinfo *
-a6_expand(const u_char *ansbuf, const u_char *a6p,
-         int a6len, const u_char *arp, const u_char *eom,
-         const struct in6_addr *in6, int plen, const struct addrinfo *pai,
-         struct pvt *pvt, int (*name_ok)(const char *), int *errorp)
-{
-       struct in6_addr a;
-       int n, pbyte, plen1, pbyte1, error = 0;
-       const u_char *cp;
-       struct addrinfo sentinel, *cur;
-       char pname[1024], buf[1024]; /* XXX */
-
-       *errorp = NETDB_SUCCESS;
-       memset(&sentinel, 0, sizeof(sentinel));
-       cur = &sentinel;
-
-       /*
-        * Validate A6 parameters.
-        */
-       if (a6len == 0) { /* an A6 record must contain at least 1 byte. */
-               error = NO_RECOVERY;
-               goto bad;
-       }
-       /* prefix length check. */
-       if ((plen1 = *a6p) > 128) {
-               error = NO_RECOVERY;
-               goto bad;
-       }
-       if (plen1 > plen) {
-               /*
-                * New length must not be greater than old one.
-                * Ignore the record as specified in RFC 2874
-                * Section 3.1.2.
-                */
-               return(NULL); /* just ignore. */
-       }
-       /* boundary check for new plen and prefix addr */
-       pbyte1 = (plen1 & ~7) / 8;
-       if ((int)sizeof(struct in6_addr) - pbyte1 > a6len - 1) {
-               error = NO_RECOVERY;
-               goto bad;
-       }
-
-       /*
-        * merge the new prefix portion.
-        * <--- plen(bits) --->
-        * <--- pbyte ---><-b->
-        * 000000000000000pppppxxxxxxxxxxx(= in6, 0: unknown, x: known, p: pad)
-        *           PP++++++++(+ should be merged. P: padding, must be 0)
-        * <-- plen1-->
-        * <-pbyte1->
-        *           ^a6p+1
-        * The result should be:
-        * 0000000000PP++++++++xxxxxxxxxxx(= a)
-        */
-       pbyte = (plen & ~7) / 8;
-       a = *in6;
-       if (pbyte > pbyte1) {
-               /* N.B. the case of "pbyte1 == 128" is implicitly excluded. */
-               int b = plen % 8; /* = the length of "pp..." above */
-               u_char c_hi, c_lo;
-
-               memcpy(&a.s6_addr[pbyte1], a6p + 1, pbyte - pbyte1);
-               if (b > 0) {
-                       c_hi = a6p[pbyte - pbyte1 + 1];
-                       c_lo = in6->s6_addr[pbyte];
-                       a.s6_addr[pbyte] =
-                               (c_hi & (0xff << (8 - b))) |
-                               ((0x00ff >> b) & c_lo);
-               }
-       }
-
-#if 0                          /* for debug */
-       if ((pvt->res->options & RES_DEBUG) != 0) {
-               u_char ntopbuf[INET6_ADDRSTRLEN];
-
-               inet_ntop(AF_INET6, &a, ntopbuf, sizeof(ntopbuf));
-               printf("a6_expand: %s\\%d\n", ntopbuf, plen1);
-       }
-#endif
-
-       if (plen1 == 0) {
-               /* Here is the end of A6 chain. make addrinfo, then return. */
-               return(addr2addrinfo(pai, (const char *)&a));
-       }
-
-       /*
-        * Expand the new prefix name. Since the prefix name must not be
-        * compressed (RFC 2874 Section 3.1.1), we could use ns_name_ntop()
-        * here if it had a stricter boundary check.
-        */
-       cp = a6p + 1 + (sizeof(*in6) - pbyte1);
-       n = dn_expand(ansbuf, eom, cp, pname, sizeof(pname));
-       if (n < 0 || !maybe_ok(pvt->res, pname, name_ok)) {
-               error = NO_RECOVERY;
-               goto bad;
-       }
-       if (cp + n != a6p + a6len) { /* length mismatch */
-               error = NO_RECOVERY;
-               goto bad;
-       }
-
-       /*
-        * we need (more) additional section records, but no one is
-        * available, which possibly means a malformed answer.
-        */
-       if (arp == NULL) {
-               error = NO_RECOVERY; /* we can't resolve the chain. */
-               goto bad;
-       }
-
-       /*
-        * Loop thru the rest of the buffer, searching for the next A6 record
-        * that has the same owner name as the prefix name. If found, then
-        * recursively call this function to expand the whole A6 chain.
-        */
-       plen = plen1;
-       for (cp = arp; cp != NULL && cp < eom; cp += n) {
-               int class, type;
-
-               n = dn_expand(ansbuf, eom, cp, buf, sizeof(buf));
-               if (n < 0 || !maybe_ok(pvt->res, buf, name_ok)) {
-                       error = NO_RECOVERY;
-                       goto bad;
-               }
-               cp += n;                        /* name */
-               if (cp + 3 * INT16SZ + INT32SZ > eom) {
-                       error = NO_RECOVERY;
-                       goto bad;
-               }
-               type = ns_get16(cp);
-               cp += INT16SZ;                  /* type */
-               class = ns_get16(cp);
-               cp += INT16SZ + INT32SZ;        /* class, TTL */
-               n = ns_get16(cp);
-               cp += INT16SZ;                  /* len */
-               if (cp + n > eom) {
-                       error = NO_RECOVERY;
-                       goto bad;
-               }
-               if (class != C_IN || type != ns_t_a6) {
-                       /* we are only interested in A6 records. skip others */
-                       continue;
-               }
-
-               if (ns_samename(buf, pname) != 1) {
-                       continue;
-               }
-
-               /* Proceed to the next record in the chain. */
-               cur->ai_next = a6_expand(ansbuf, cp, n, cp + n, eom,
-                                        (const struct in6_addr *)&a,
-                                        plen, pai, pvt, name_ok, &error);
-               if (error != NETDB_SUCCESS)
-                       goto bad;
-               while (cur && cur->ai_next)
-                       cur = cur->ai_next;
-       }
-
-       return(sentinel.ai_next);
-
-  bad:
-       *errorp = error;
-       if (sentinel.ai_next)
-               freeaddrinfo(sentinel.ai_next);
-       return(NULL);
-}
-
-static const char *
-dname_subst(const char *qname0, const char *owner0, const char *target) {
-       char owner[MAXDNAME];
-       static char qname[MAXDNAME];
-       const char blabelhead[] = "\\[x"; /* we can assume hex strings */
-       int qlen, olen;
-       int bufsiz = sizeof(qname);
-
-       /* make local copies, which are canonicalized. */
-       if (ns_makecanon(qname0, qname, sizeof(qname)) < 0 ||
-           ns_makecanon(owner0, owner, sizeof(owner)) < 0)
-               return(NULL);
-       qlen = strlen(qname);
-       olen = strlen(owner);
-       /* from now on, do not refer to qname0 nor owner0. */
-
-       /*
-        * check if QNAME is a subdomain of OWNER.
-        * XXX: currently, we only handle the following two cases:
-        *      (A) none of the labels are bitlabels, or
-        *      (B) both of the head labels are bitlabels (and the following
-        *          labels are NOT bitlabels).
-        * If we pass the check, then subtract the remaining part from QNAME.
-        * ex. (A) qname=www.foo.com,owner=foo.com => new qname=www.
-        *     (B) qname=\[x3ffe0501/32].foo.com,owner=\[x3ffe/16].foo.com
-        *                                  => new qname=\[x0501/16].
-        */
-       if (ns_samedomain(qname, owner)) { /* check (A) */
-               /* at this point, qlen must not be smaller than olen */
-               qname[qlen - olen] = 0;
-               bufsiz -= (qlen - olen);
-       } else {                /* check (B) */
-               char *parent0, *parent1;
-               /* the following 3 have enough size to store 1 bitlabel */
-               u_char qlabel[64], olabel[64], newlabel[64];
-               int qlabellen, olabellen;
-
-               if (strncmp(qname, blabelhead, 3) != 0 ||
-                   strncmp(owner, blabelhead, 3) != 0)
-                       return(NULL);
-               /*
-                * Both two begin with bitlabels. The succeeding parts
-                * must exact match.
-                */
-               if ((parent0 = strchr(qname, '.')) == NULL ||
-                   (parent1 = strchr(owner, '.')) == NULL)
-                       return(NULL);
-
-               /* ns_samename allows names to begin with '.' */
-               if (ns_samename(parent0, parent1) != 1)
-                       return(NULL);
-
-               /* cut the upper domain parts off. */
-               *(parent0 + 1) = 0;
-               *(parent1 + 1) = 0;
-               /* convert the textual form into binary one. */
-               if (ns_name_pton(qname, qlabel, sizeof(qlabel)) < 0 ||
-                   ns_name_pton(owner, olabel, sizeof(olabel)) < 0)
-                       return(NULL);
-               if ((qlabellen = *(qlabel + 1)) == 0)
-                       qlabellen = 256;
-               if ((olabellen = *(olabel + 1)) == 0)
-                       olabellen = 256;
-               if (olabellen > qlabellen)
-                       return(NULL); /* owner does not contain qname. */
-               else {
-                       int qplen = (qlabellen + 7) / 8;
-                       int oplen = (olabellen + 7) / 8;
-                       int sft = olabellen % 8;
-                       int nllen, n;
-                       u_char *qp, *op, *np;
-
-                       /* skip ELT and Count. */
-                       qp = qlabel + 2;
-                       op = olabel + 2;
-
-                       /* check if olabel is a "subdomain" of qlabel. */
-                       if (memcmp(qp, op, oplen - 1) != 0)
-                               return(NULL);
-                       if (sft > 0) {
-                               /* compare trailing bits (between 1 and 7) */
-                               if ((qp[qplen - 1] & (0xff << sft)) !=
-                                   op[qplen - 1])
-                                       return(NULL);
-                       }
-
-                       /* OK, get remaining bits from qlabel. */
-                       np = newlabel;
-                       if (olabellen == qlabellen) {
-                               /*
-                                * Two names (including bitlabels) are exactly
-                                * same. Discard the whole names.
-                                * XXX: ns_samename() above should exclude
-                                * this case...
-                                */
-                               qname[0] = 0;
-                               goto maketarget;
-                       }
-                       *np++ = 0x41; /* XXX hardcoding */
-                       *np++ = nllen = (qlabellen - olabellen);
-                       if (sft == 0) {
-                               /*
-                                * No alignment issue. can just use memcpy.
-                                * Note that the "else" part below contains
-                                * this case. We separate the two cases just
-                                * for efficiency.
-                                * We assume that ns_name_pton above ensures
-                                * QP does not contain trailing garbages.
-                                */
-                               memcpy(np, qp + oplen, qplen - oplen);
-                               np += qplen - oplen;
-                               *np = 0;
-                       } else {
-                               /*
-                                * copy the lower (8-SFT) bits of QP to the
-                                * upper (8-SFT) bits of NP, then copy the
-                                * upper SFT bits of QP+1 to the lower SFT bits
-                                * of NP, and so on...
-                                * if QP is       xxxyyyyy zzzwww..., then
-                                *    NP would be yyyyyzzz ...
-                                * Again, we assume QP does not contain
-                                * trailing garbages.
-                                */
-                               qp += (oplen - 1);
-                               while (nllen > 0) {
-                                       *np = (*qp << sft) & 0xff;
-                                       if ((nllen -= (8 - sft)) <= 0)
-                                               break; /* done */
-                                       qp++;
-                                       *np |= ((*qp >> sft) & 0xff);
-                                       np++;
-                                       nllen -= sft;
-                               }
-                               *++np = 0;
-                       }
-
-                       /*
-                        * make a new bitlabel with the remaining bits.
-                        * Note that there's no buffer boundary issue, since
-                        * qlabel, olabel, and newlabel all have the same size.
-                        * ns_name_ntop() must not return 0, since we have
-                        * a non-empty bitlabel.
-                        */
-                       if ((n = ns_name_ntop(newlabel, qname, sizeof(qname)))
-                            <= 0)
-                               return(NULL);
-                       bufsiz -= n;
-                       if (qname[n - 1] != '.') { /* XXX no trailing dot */
-                               qname[n - 1] = '.';
-                               qname[n] = 0;
-                               bufsiz--;
-                       }
-
-               }
-       }
-
-  maketarget:
-       /*
-        * Finally, append the remaining part (maybe empty) to the new target.
-        */
-       if (bufsiz < (int)strlen(target)) /* bufsiz takes care of the \0. */
-               return(NULL);
-       strcat(qname, target);
-
-       return((const char *)qname);
-}
-
 static void
 ho_res_set(struct irs_ho *this, struct __res_state *res,
                void (*free_res)(void *)) {
@@ -1092,7 +693,6 @@ gethostans(struct irs_ho *this,
        char *bp, *ep, **ap, **hap;
        char tbuf[MAXDNAME+1];
        struct addrinfo sentinel, *cur, ai;
-       const u_char *arp = NULL;
 
        if (pai == NULL) abort();
        if (ret_aip != NULL)
@@ -1103,7 +703,6 @@ gethostans(struct irs_ho *this,
        tname = qname;
        eom = ansbuf + anslen;
        switch (qtype) {
-       case ns_t_a6:
        case T_A:
        case T_AAAA:
        case T_ANY:     /* use T_ANY only for T_A/T_AAAA lookup */
@@ -1148,8 +747,7 @@ gethostans(struct irs_ho *this,
                RES_SET_H_ERRNO(pvt->res, NO_RECOVERY);
                return (NULL);
        }
-       if (qtype == T_A || qtype == T_AAAA ||
-           qtype == ns_t_a6 || qtype == T_ANY) {
+       if (qtype == T_A || qtype == T_AAAA || qtype == T_ANY) {
                /* res_nsend() has already verified that the query name is the
                 * same as the one we sent; this just gets the expanded name
                 * (i.e., with the succeeding search-domain tacked on).
@@ -1193,8 +791,8 @@ gethostans(struct irs_ho *this,
                        continue;
                }
                eor = cp + n;
-               if ((qtype == T_A || qtype == T_AAAA || qtype == ns_t_a6 ||
-                    qtype == T_ANY) && type == T_CNAME) {
+               if ((qtype == T_A || qtype == T_AAAA || qtype == T_ANY) &&
+                   type == T_CNAME) {
                        if (haveanswer) {
                                int level = LOG_CRIT;
 #ifdef LOG_SECURITY
@@ -1222,58 +820,16 @@ gethostans(struct irs_ho *this,
                                had_error++;
                                continue;
                        }
+#ifdef HAVE_STRLCPY
+                       strlcpy(bp, tbuf, ep - bp);
+#else
                        strcpy(bp, tbuf);
+#endif
                        pvt->host.h_name = bp;
                        hname = bp;
                        bp += n;
                        continue;
                }
-               if (type == ns_t_dname) {
-                       const char *t0, *t;
-
-                       /*
-                        * just replace the query target; do not update the
-                        * alias list. (Or should we?)
-                        */
-                       t0 = (qtype == T_PTR) ? tname : hname;
-
-                       n = dn_expand(ansbuf, eor, cp, tbuf, sizeof(tbuf));
-                       if (n < 0 || !maybe_dnok(pvt->res, tbuf)) {
-                               had_error++;
-                               continue;
-                       }
-#ifdef RES_USE_DNAME
-                       if ((pvt ->res->options & RES_USE_DNAME) == 0) {
-                               cp += n;
-                               continue;
-                       }
-#endif
-                       if ((t = dname_subst(t0, bp, tbuf)) == NULL) {
-                               cp += n;
-                               continue;
-                       }
-#if 0                          /* for debug */
-                       if ((pvt->res->options & RES_DEBUG) != 0) {
-                               printf("DNAME owner=%s, target=%s, next=%s\n",
-                                      bp, tbuf, t);
-                       }
-#endif
-                       cp += n;
-
-                       n = strlen(t) + 1; /* for the \0 */
-                       if (n > (ep - bp)) {
-                               had_error++;
-                               continue;
-                       }
-                       strcpy(bp, t);
-                       if (qtype == T_PTR)
-                               tname = bp;
-                       else
-                               hname = bp;
-                       bp += n;
-
-                       continue;
-               }
                if (qtype == T_PTR && type == T_CNAME) {
                        n = dn_expand(ansbuf, eor, cp, tbuf, sizeof tbuf);
                        if (n < 0 || !maybe_dnok(pvt->res, tbuf)) {
@@ -1300,14 +856,17 @@ gethostans(struct irs_ho *this,
                                had_error++;
                                continue;
                        }
+#ifdef HAVE_STRLCPY
+                       strlcpy(bp, tbuf, ep - bp);
+#else
                        strcpy(bp, tbuf);
+#endif
                        tname = bp;
                        bp += n;
                        continue;
                }
                if (qtype == T_ANY) {
-                       if (!(type == T_A || type == T_AAAA ||
-                             type == ns_t_a6)) {
+                       if (!(type == T_A || type == T_AAAA)) {
                                cp += n;
                                continue;
                        }
@@ -1346,66 +905,6 @@ gethostans(struct irs_ho *this,
                                bp += n;
                        }
                        break;
-               case ns_t_a6: {
-                       struct in6_addr in6;
-                       struct addrinfo ai;
-
-#ifdef RES_USE_A6
-                       if ((pvt->res->options & RES_USE_A6) == 0) {
-                               cp += n;
-                               continue;
-                       }
-#endif
-
-                       if (ns_samename(hname, bp) != 1) {
-                               cp += n;
-                               continue;
-                       }
-
-                       /*
-                        * search for the top of the additional section.
-                        * once found, keep it for the case where we have
-                        * more than one A6 record.
-                        * XXX: however, we may not need this part.
-                        */
-                       if (arp == NULL && arcount > 0) {
-                               int nscount = ntohs(hp->nscount);
-
-                               arp = ar_head(cp + n, nscount + ancount - 1,
-                                             ansbuf, eom, pvt, name_ok);
-                       }
-
-                       /* recursively collect the whole A6 chain */
-                       ai = *pai; /* XXX: we can't override constant pai */
-                       ai.ai_family = AF_INET6;
-                       memset(&in6, 0, sizeof(in6)); /* just for safety */
-                       cur->ai_next = a6_expand(ansbuf, cp, n, arp, eom,
-                                                &in6, 128,
-                                                (const struct addrinfo *)&ai,
-                                                pvt, name_ok, &error);
-                       if (error != NETDB_SUCCESS) {
-#ifdef DEBUG
-                               /* in this case, cur->ai_next must be NULL. */
-                               if (cur->ai_next != NULL)
-                                       abort();
-#endif
-                               had_error++;
-                               continue;
-                       }
-
-                       /*
-                        * We don't bother even if cur->ai_next is NULL unless
-                        * the expansion failed by a fatal error. The list
-                        * can be NULL if the given A6 is incomplete, but we
-                        * may have another complete A6 chain in this answer.
-                        * See the last paragraph of RFC 2874 Section 3.1.4. 
-                        */
-                       if (cur->ai_next == NULL) {
-                               cp += n;
-                               continue; /* no error, no answer */
-                       }
-                       goto convertinfo;
-               } /* FALLTHROUGH */
                case T_A:
                case T_AAAA:
                        if (ns_samename(hname, bp) != 1) {
@@ -1430,7 +929,6 @@ gethostans(struct irs_ho *this,
                        if (cur->ai_next == NULL)
                                had_error++;
 
-                 convertinfo:  /* convert addrinfo into hostent form */
                        if (!haveanswer) {
                                int nn;
 
@@ -1471,7 +969,7 @@ gethostans(struct irs_ho *this,
                                                continue;
                                        if (hap < &pvt->h_addr_ptrs[MAXADDRS-1])
                                                hap++;
-
+                                       *hap = NULL;
                                        bp += m;
                                }
 
@@ -1498,7 +996,11 @@ gethostans(struct irs_ho *this,
                                n = strlen(qname) + 1;  /* for the \0 */
                                if (n > (ep - bp) || n >= MAXHOSTNAMELEN)
                                        goto no_recovery;
+#ifdef HAVE_STRLCPY
+                               strlcpy(bp, qname, ep - bp);
+#else
                                strcpy(bp, qname);
+#endif
                                pvt->host.h_name = bp;
                                bp += n;
                        }
index cb80d443c4d411dadba5b9ab6adc64b856766018..0d23473686f6b787c8981b7737c8458412d91608 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: dns_nw.c,v 1.6 2002/06/28 06:06:24 marka Exp $";
+static const char rcsid[] = "$Id: dns_nw.c,v 1.7 2003/06/03 04:39:30 marka Exp $";
 #endif /* LIBC_SCCS and not lint */
 
 /* Imports. */
@@ -349,7 +349,12 @@ get1101answer(struct irs_nw *this,
                                RES_SET_H_ERRNO(pvt->res, NO_RECOVERY);
                                return (NULL);
                        }
+#ifdef HAVE_STRLCPY
+                       strlcpy(bp, name, ep - bp);
+                       pvt->net.n_name = bp;
+#else
                        pvt->net.n_name = strcpy(bp, name);
+#endif
                        bp += n;
                }
                break;
@@ -522,37 +527,37 @@ get1101mask(struct irs_nw *this, struct nwent *nwent) {
 static int
 make1101inaddr(const u_char *net, int bits, char *name, int size) {
        int n, m;
+       char *ep;
+
+       ep = name + size;
 
        /* Zero fill any whole bytes left out of the prefix. */
        for (n = (32 - bits) / 8; n > 0; n--) {
-               if (size < (int)(sizeof "0."))
+               if (ep - name < (int)(sizeof "0."))
                        goto emsgsize;
                m = SPRINTF((name, "0."));
                name += m;
-               size -= m;
        }
 
        /* Format the partial byte, if any, within the prefix. */
        if ((n = bits % 8) != 0) {
-               if (size < (int)(sizeof "255."))
+               if (ep - name < (int)(sizeof "255."))
                        goto emsgsize;
                m = SPRINTF((name, "%u.",
                             net[bits / 8] & ~((1 << (8 - n)) - 1)));
                name += m;
-               size -= m;
        }
 
        /* Format the whole bytes within the prefix. */
        for (n = bits / 8; n > 0; n--) {
-               if (size < (int)(sizeof "255."))
+               if (ep - name < (int)(sizeof "255."))
                        goto emsgsize;
                m = SPRINTF((name, "%u.", net[n - 1]));
                name += m;
-               size -= m;
        }
 
        /* Add the static text. */
-       if (size < (int)(sizeof "in-addr.arpa"))
+       if (ep - name < (int)(sizeof "in-addr.arpa"))
                goto emsgsize;
        (void) SPRINTF((name, "in-addr.arpa"));
        return (0);
index cb1c926c86c41f9fd44a95cc8894165113c3336e..40891eb1a8dc329aeb338a062c7123a6cb578142 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #if !defined(LINT) && !defined(CODECENTER)
-static const char rcsid[] = "$Id: gen_gr.c,v 1.4 2001/06/07 02:14:52 marka Exp $";
+static const char rcsid[] = "$Id: gen_gr.c,v 1.5 2003/06/03 04:39:30 marka Exp $";
 #endif
 
 /* Imports */
@@ -324,7 +324,7 @@ gr_res_set(struct irs_gr *this, struct __res_state *res,
 static void
 grmerge(struct irs_gr *this, const struct group *src, int preserve) {
        struct pvt *pvt = (struct pvt *)this->private;
-       char *cp, **m, **p, *oldmembuf;
+       char *cp, **m, **p, *oldmembuf, *ep;
        int n, ndst, nnew;
        size_t used;
 
@@ -379,6 +379,7 @@ grmerge(struct irs_gr *this, const struct group *src, int preserve) {
                /* No harm done, no work done. */
                return;
        }
+       ep = cp + used + n;
        if (used != 0)
                memcpy(cp, pvt->membuf, used);
        oldmembuf = pvt->membuf;
@@ -400,7 +401,11 @@ grmerge(struct irs_gr *this, const struct group *src, int preserve) {
                if (isnew(pvt->group.gr_mem, *m)) {
                        *p++ = cp;
                        *p = NULL;
+#ifdef HAVE_STRLCPY
+                       strlcpy(cp, *m, ep - cp);
+#else
                        strcpy(cp, *m);
+#endif
                        cp += strlen(cp) + 1;
                }
        if (preserve) {
@@ -410,10 +415,18 @@ grmerge(struct irs_gr *this, const struct group *src, int preserve) {
                                       (pvt->group.gr_passwd - oldmembuf);
        } else {
                pvt->group.gr_name = cp;
+#ifdef HAVE_STRLCPY
+               strlcpy(cp, src->gr_name, ep - cp);
+#else
                strcpy(cp, src->gr_name);
+#endif
                cp += strlen(src->gr_name) + 1;
                pvt->group.gr_passwd = cp;
+#ifdef HAVE_STRLCPY
+               strlcpy(cp, src->gr_passwd, ep - cp);
+#else
                strcpy(cp, src->gr_passwd);
+#endif
                cp += strlen(src->gr_passwd) + 1;
        }
        if (oldmembuf != NULL)
index 243f10656c3c3452d869f9e12e43c8112c43ff3b..89db519fcfd705cd47be8ac0f859d1bd986f5dee 100644 (file)
 #include <stdarg.h>
 
 #include <irs.h>
+#include <isc/assertions.h>
 
 #include "port_after.h"
 
 #include "irs_data.h"
 
-/*
- * if we enable it, we will see duplicated addrinfo entries on reply if both
- * AAAA and A6 records are found.  disable it for default installation.
- */
-#undef T_A6
-
 #define SUCCESS 0
 #define ANY 0
 #define YES 1
@@ -192,7 +187,8 @@ static int get_portmatch __P((const struct addrinfo *, const char *));
 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 int ip6_str2scopeid __P((char *, struct sockaddr_in6 *,
+                               u_int32_t *scopeidp));
 static struct net_data *init __P((void));
 
 struct addrinfo *hostent2addrinfo __P((struct hostent *,
@@ -297,8 +293,9 @@ str_isnumber(p)
        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;
@@ -595,7 +592,7 @@ explore_fqdn(pai, hostname, servname, res)
        char tmp[NS_MAXDNAME];
        const char *cp;
 
-       result = NULL;
+       INSIST(res != NULL && *res == NULL);
 
        /*
         * if the servname does not match socktype/protocol, ignore it.
@@ -854,13 +851,13 @@ explore_numeric_scope(pai, hostname, servname, res)
 
        error = explore_numeric(pai, addr, servname, res);
        if (error == 0) {
-               int scopeid;
+               u_int32_t scopeid = 0;
 
                for (cur = *res; cur; cur = cur->ai_next) {
                        if (cur->ai_family != AF_INET6)
                                continue;
                        sin6 = (struct sockaddr_in6 *)(void *)cur->ai_addr;
-                       if ((scopeid = ip6_str2scopeid(scope, sin6)) == -1) {
+                       if (!ip6_str2scopeid(scope, sin6, &scopeid)) {
                                free(hostname2);
                                return(EAI_NONAME); /* XXX: is return OK? */
                        }
@@ -990,7 +987,17 @@ get_port(const struct addrinfo *ai, const char *servname, int matchonly) {
                allownumeric = 1;
                break;
        case ANY:
-               allownumeric = 0;
+               switch (ai->ai_family) {
+               case AF_INET:
+#ifdef AF_INET6
+               case AF_INET6:
+#endif
+                       allownumeric = 1;
+                       break;
+               default:
+                       allownumeric = 0;
+                       break;
+               }
                break;
        default:
                return EAI_SOCKTYPE;
@@ -999,9 +1006,10 @@ get_port(const struct addrinfo *ai, const char *servname, int matchonly) {
        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:
@@ -1075,17 +1083,17 @@ addrconfig(af)
 
 /* convert a string to a scope identifier. XXX: IPv6 specific */
 static int
-ip6_str2scopeid(scope, sin6)
-       char *scope;
-       struct sockaddr_in6 *sin6;
+ip6_str2scopeid(char *scope, struct sockaddr_in6 *sin6,
+               u_int32_t *scopeidp)
 {
-       int scopeid;
+       u_int32_t scopeid;
+       u_long lscopeid;
        struct in6_addr *a6 = &sin6->sin6_addr;
        char *ep;
-
+       
        /* empty scopeid portion is invalid */
        if (*scope == '\0')
-               return -1;
+               return (0);
 
 #ifdef USE_IFNAMELINKID
        if (IN6_IS_ADDR_LINKLOCAL(a6) || IN6_IS_ADDR_MC_LINKLOCAL(a6)) {
@@ -1096,8 +1104,8 @@ ip6_str2scopeid(scope, sin6)
                 */
                scopeid = if_nametoindex(scope);
                if (scopeid == 0)
-                       goto trynumeric;
-               return(scopeid);
+               *scopeidp = scopeid;
+               return (1);
        }
 #endif
 
@@ -1111,11 +1119,14 @@ ip6_str2scopeid(scope, sin6)
 
        /* try to convert to a numeric id as a last resort */
 trynumeric:
-       scopeid = (int)strtoul(scope, &ep, 10);
-       if (*ep == '\0')
-               return scopeid;
-       else
-               return -1;
+       errno = 0;
+       lscopeid = strtoul(scope, &ep, 10);
+       scopeid = lscopeid & 0xffffffff;
+       if (errno == 0 && ep && *ep == '\0' && scopeid == lscopeid) {
+               *scopeidp = scopeid;
+               return (1);
+       } else
+               return (0);
 }
 
 struct addrinfo *
index 3a137ea4877cd8290f62efdff7c8daaf824e71b9..014d6af44c5676bfa7d6e374209a772b4aea4b8d 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #if !defined(LINT) && !defined(CODECENTER)
-static const char rcsid[] = "$Id: gethostent.c,v 1.3 2002/05/27 07:54:35 marka Exp $";
+static const char rcsid[] = "$Id: gethostent.c,v 1.4 2003/06/03 04:39:30 marka Exp $";
 #endif
 
 /* Imports */
@@ -482,7 +482,7 @@ freehostent(struct hostent *he) {
 #define LIFREQ lifreq
 #endif
 
-static int
+static void
 scan_interfaces6(int *have_v4, int *have_v6) {
        struct LIFCONF lifc;
        struct LIFREQ lifreq;
@@ -492,12 +492,9 @@ scan_interfaces6(int *have_v4, int *have_v6) {
        static unsigned int bufsiz = 4095;
        int s, cpsize, n;
 
-       /* Set to zero.  Used as loop terminators below. */
-       *have_v4 = *have_v6 = 0;
-
        /* Get interface list from system. */
        if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) == -1)
-               goto err_ret;
+               goto cleanup;
 
        /*
         * Grow buffer until large enough to contain all interface
@@ -506,7 +503,7 @@ scan_interfaces6(int *have_v4, int *have_v6) {
        for (;;) {
                buf = memget(bufsiz);
                if (buf == NULL)
-                       goto err_ret;
+                       goto cleanup;
 #ifdef SETFAMILYFLAGS
                lifc.lifc_family = AF_UNSPEC;   /* request all families */
                lifc.lifc_flags = 0;
@@ -526,10 +523,10 @@ scan_interfaces6(int *have_v4, int *have_v6) {
                                break;
                }
                if ((n == -1) && errno != EINVAL)
-                       goto err_ret;
+                       goto cleanup;
 
                if (bufsiz > 1000000)
-                       goto err_ret;
+                       goto cleanup;
 
                memput(buf, bufsiz);
                bufsiz += 4096;
@@ -600,16 +597,42 @@ scan_interfaces6(int *have_v4, int *have_v6) {
                memput(buf, bufsiz);
        close(s);
        /* printf("scan interface -> 4=%d 6=%d\n", *have_v4, *have_v6); */
-       return (0);
err_ret:
+       return;
cleanup:
        if (buf != NULL)
                memput(buf, bufsiz);
        if (s != -1)
                close(s);
        /* printf("scan interface -> 4=%d 6=%d\n", *have_v4, *have_v6); */
-       return (-1);
+       return;
 }
+#endif
 
+#ifdef __linux
+#ifndef IF_NAMESIZE
+# ifdef IFNAMSIZ
+#  define IF_NAMESIZE  IFNAMSIZ
+# else
+#  define IF_NAMESIZE 16
+# endif
+#endif
+static void
+scan_linux6(int *have_v6) {
+       FILE *proc = NULL;
+       char address[33];
+       char name[IF_NAMESIZE+1];
+       int ifindex, prefix, flag3, flag4;
+       
+       proc = fopen("/proc/net/if_inet6", "r");
+       if (proc == NULL)
+               return;
+
+       if (fscanf(proc, "%32[a-f0-9] %x %x %x %x %16s\n",
+                  address, &ifindex, &prefix, &flag3, &flag4, name) == 6)
+               *have_v6 = 1;
+       fclose(proc);
+       return;
+}
 #endif
 
 static int
@@ -626,17 +649,21 @@ scan_interfaces(int *have_v4, int *have_v6) {
        int s, n;
        size_t cpsize;
 
+       /* Set to zero.  Used as loop terminators below. */
+       *have_v4 = *have_v6 = 0;
+
 #if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR) && \
     !defined(IRIX_EMUL_IOCTL_SIOCGIFCONF) 
        /*
         * Try to scan the interfaces using IPv6 ioctls().
         */
-       if (!scan_interfaces6(have_v4, have_v6))
+       scan_interfaces6(have_v4, have_v6);
+       if (*have_v4 != 0 && *have_v6 != 0)
                return (0);
 #endif
-
-       /* Set to zero.  Used as loop terminators below. */
-       *have_v4 = *have_v6 = 0;
+#ifdef __linux
+       scan_linux6(have_v6);
+#endif
 
        /* Get interface list from system. */
        if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
index 9b26c641ff675816d48d74fab00e816f105e6486..702b932bf39af06a2031079848474386c20b6a55 100644 (file)
@@ -44,6 +44,7 @@
 #include <netinet/in.h>
 #include <arpa/nameser.h>
 #include <arpa/inet.h>
+#include <net/if.h>
 
 #include <netdb.h>
 #include <resolv.h>
index 07f39a75083620fcf67d5c329956f6f9d6733903..201873464fbd39c0e51249e54b49c58f16a07c03 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: getnetgrent.c,v 1.1 2001/03/29 06:31:46 marka Exp $";
+static const char rcsid[] = "$Id: getnetgrent.c,v 1.2 2003/06/03 04:39:31 marka Exp $";
 #endif /* LIBC_SCCS and not lint */
 
 /* Imports */
@@ -47,8 +47,11 @@ static struct net_data *init(void);
 
 /* Public */
 
+#ifndef SETNETGRENT_ARGS
+#define SETNETGRENT_ARGS const char *netgroup
+#endif
 void
-setnetgrent(const char *netgroup) {
+setnetgrent(SETNETGRENT_ARGS) {
        struct net_data *net_data = init();
 
        setnetgrent_p(netgroup, net_data);
@@ -61,19 +64,31 @@ endnetgrent(void) {
        endnetgrent_p(net_data);
 }
 
+#ifndef INNETGR_ARGS
+#define INNETGR_ARGS const char *netgroup, const char *host, \
+                    const char *user, const char *domain
+#endif
 int
-innetgr(const char *netgroup, const char *host,
-       const char *user, const char *domain) {
+innetgr(INNETGR_ARGS) {
        struct net_data *net_data = init();
 
        return (innetgr_p(netgroup, host, user, domain, net_data));
 }
 
 int
-getnetgrent(const char **host, const char **user, const char **domain) {
+getnetgrent(char **host, char **user, char **domain) {
        struct net_data *net_data = init();
+       const char *ch, *cu, *cd;
+       int ret;
 
-       return (getnetgrent_p(host, user, domain, net_data));
+       ret = getnetgrent_p(&ch, &cu, &cd, net_data);
+       if (ret != 1)
+               return (ret);
+
+       DE_CONST(ch, *host);
+       DE_CONST(cu, *user);
+       DE_CONST(cd, *domain);
+       return (ret);
 }
 
 /* Shared private. */
index d3130e7589849601f54d555cf9f6330a390d0b0f..ef1de3602369b0d9201748678550195d8ff4de3d 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: getnetgrent_r.c,v 1.5 2001/07/04 04:51:05 marka Exp $";
+static const char rcsid[] = "$Id: getnetgrent_r.c,v 1.6 2003/06/03 04:39:31 marka Exp $";
 #endif /* LIBC_SCCS and not lint */
 
 #include <port_before.h>
@@ -40,9 +40,15 @@ copy_protoent(char **, char **, char **, const char *, const char *,
 
 NGR_R_RETURN
 innetgr_r(const char *netgroup, const char *host, const char *user,
-       const char *domain) {
+         const char *domain) {
+       char *ng, *ho, *us, *dom;
 
-       return (innetgr(netgroup, host, user, domain));
+       DE_CONST(netgroup, ng);
+       DE_CONST(host, ho);
+       DE_CONST(user, us);
+       DE_CONST(domain, dom);
+
+       return (innetgr(ng, ho, us, dom));
 }
 
 /*
@@ -53,7 +59,7 @@ innetgr_r(const char *netgroup, const char *host, const char *user,
 
 NGR_R_RETURN
 getnetgrent_r(char **machinep, char **userp, char **domainp, NGR_R_ARGS) {
-       const char *mp, *up, *dp;
+       char *mp, *up, *dp;
        int res = getnetgrent(&mp, &up, &dp);
 
        if (res != 1) 
index 242e875f13c42f00004e60eef8f6688de94596a0..71856e7bf24753e72342bf747f1db32580671949 100644 (file)
@@ -1,5 +1,5 @@
 #if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: hesiod.c,v 1.1 2001/03/29 06:31:48 marka Exp $";
+static const char rcsid[] = "$Id: hesiod.c,v 1.2 2003/06/03 04:39:31 marka Exp $";
 #endif
 
 /*
@@ -98,8 +98,13 @@ hesiod_init(void **context) {
                        errno = ENOMEM;
                        goto cleanup;
                }
+#ifdef HAVE_STRLCPY
+               strlcpy(ctx->LHS, DEF_LHS, strlen(DEF_LHS) + 1);
+               strlcpy(ctx->RHS, DEF_RHS, strlen(DEF_RHS) + 1);
+#else
                strcpy(ctx->LHS, DEF_LHS);
                strcpy(ctx->RHS, DEF_RHS);
+#endif
 #else
                goto cleanup;
 #endif
@@ -109,18 +114,31 @@ hesiod_init(void **context) {
         * variable.
         */
        if ((cp = getenv("HES_DOMAIN")) != NULL) {
+               size_t RHSlen = strlen(cp) + 2;
                if (ctx->RHS)
                        free(ctx->RHS);
-               ctx->RHS = malloc(strlen(cp)+2);
+               ctx->RHS = malloc(RHSlen);
                if (!ctx->RHS) {
                        errno = ENOMEM;
                        goto cleanup;
                }
-               if (cp[0] == '.')
+               if (cp[0] == '.') {
+#ifdef HAVE_STRLCPY
+                       strlcpy(ctx->RHS, cp, RHSlen);
+#else
                        strcpy(ctx->RHS, cp);
-               else {
+#endif
+               } else {
+#ifdef HAVE_STRLCPY
+                       strlcpy(ctx->RHS, ".", RHSlen);
+#else
                        strcpy(ctx->RHS, ".");
+#endif
+#ifdef HAVE_STRLCAT
+                       strlcat(ctx->RHS, cp, RHSlen);
+#else
                        strcat(ctx->RHS, cp);
+#endif
                }
        }
 
index 444cb0931a9c01499c3f9fd358146aef7bd32cbb..862ac151142c603ccf0f6fbb3b8a2ae66b89aaab 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 /*
- * $Id: irp_p.h,v 1.2 2001/11/01 04:21:15 marka Exp $
+ * $Id: irp_p.h,v 1.3 2003/06/03 04:39:31 marka Exp $
  */
 
 #ifndef _IRP_P_H_INCLUDED
@@ -53,8 +53,6 @@ char *irs_irp_read_body(struct irp_p *pvt, size_t *size);
 int irs_irp_get_full_response(struct irp_p *pvt, int *code,
                              char *text, size_t textlen,
                              char **body, size_t *bodylen);
-int irs_irp_send_command(struct irp_p *pvt, const char *fmt, ...) ISC_FORMAT_PRINTF(2, 3);
-
 
 extern int irp_log_errors;
 
index 46aa548da358660d76eeba018ca123222aab108b..a68569cadd79e43979eb71f55ffb7978f23c800d 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #if !defined(LINT) && !defined(CODECENTER)
-static const char rcsid[] = "$Id: irs_data.c,v 1.4 2001/11/01 04:03:40 marka Exp $";
+static const char rcsid[] = "$Id: irs_data.c,v 1.5 2003/06/03 04:39:31 marka Exp $";
 #endif
 
 #include "port_before.h"
@@ -38,6 +38,7 @@ static const char rcsid[] = "$Id: irs_data.c,v 1.4 2001/11/01 04:03:40 marka Exp
 #endif
 
 #include <irs.h>
+#include <stdlib.h>
 
 #include "port_after.h"
 
@@ -97,6 +98,14 @@ net_data_destroy(void *p) {
                (*net_data->ng->close)(net_data->ng);
                net_data->ng = NULL;
        }
+       if (net_data->ho_data != NULL) {
+               free(net_data->ho_data);
+               net_data->ho_data = NULL;
+       }
+       if (net_data->nw_data != NULL) {
+               free(net_data->nw_data);
+               net_data->nw_data = NULL;
+       }
 
        (*net_data->irs->close)(net_data->irs);
        memput(net_data, sizeof *net_data);
@@ -143,19 +152,27 @@ net_data_create(const char *conf_file) {
                return (NULL);
        memset(net_data, 0, sizeof (struct net_data));
 
-       if ((net_data->irs = irs_gen_acc("", conf_file)) == NULL)
+       if ((net_data->irs = irs_gen_acc("", conf_file)) == NULL) {
+               memput(net_data, sizeof (struct net_data));
                return (NULL);
+       }
 #ifndef DO_PTHREADS
        (*net_data->irs->res_set)(net_data->irs, &_res, NULL);
 #endif
 
        net_data->res = (*net_data->irs->res_get)(net_data->irs);
-       if (net_data->res == NULL)
+       if (net_data->res == NULL) {
+               (*net_data->irs->close)(net_data->irs);
+               memput(net_data, sizeof (struct net_data));
                return (NULL);
+       }
 
        if ((net_data->res->options & RES_INIT) == 0 &&
-           res_ninit(net_data->res) == -1)
+           res_ninit(net_data->res) == -1) {
+               (*net_data->irs->close)(net_data->irs);
+               memput(net_data, sizeof (struct net_data));
                return (NULL);
+       }
 
        return (net_data);
 }
index a617fd3ee070a7728a4a0c7fe578b0c078ad0eee..3ecc41b35aa3ee579a44035fd6f0540410297857 100644 (file)
@@ -49,7 +49,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: nis_gr.c,v 1.1 2001/03/29 06:31:51 marka Exp $";
+static const char rcsid[] = "$Id: nis_gr.c,v 1.2 2003/06/03 04:39:31 marka Exp $";
 /* from getgrent.c 8.2 (Berkeley) 3/21/94"; */
 /* from BSDI Id: getgrent.c,v 2.8 1996/05/28 18:15:14 bostic Exp $     */
 #endif /* LIBC_SCCS and not lint */
@@ -286,7 +286,7 @@ makegroupent(struct irs_gr *this) {
                goto cleanup;
        *cp++ = '\0';
 
-       errno = -1;
+       errno = 0;
        t = strtoul(cp, NULL, 10);
        if (errno == ERANGE)
                goto cleanup;
index 5d7c44c6ad78b69659cffab958e2a944d447e1ce..1a21b370c3c437dd2365507c7198c669a14e82eb 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: nis_ho.c,v 1.2 2001/04/04 05:32:23 marka Exp $";
+static const char rcsid[] = "$Id: nis_ho.c,v 1.3 2003/06/03 04:39:31 marka Exp $";
 #endif /* LIBC_SCCS and not lint */
 
 /* Imports */
@@ -87,6 +87,9 @@ static const u_char mapped[] = { 0,0, 0,0, 0,0, 0,0, 0,0, 0xff,0xff };
 static const u_char tunnelled[] = { 0,0, 0,0, 0,0, 0,0, 0,0, 0,0 };
 static /*const*/ char hosts_byname[] = "hosts.byname";
 static /*const*/ char hosts_byaddr[] = "hosts.byaddr";
+static /*const*/ char ipnode_byname[] = "ipnode.byname";
+static /*const*/ char ipnode_byaddr[] = "ipnode.byaddr";
+static /*const*/ char yp_multi[] = "YP_MULTI_";
 
 /* Forwards */
 
@@ -186,9 +189,32 @@ ho_byname2(struct irs_ho *this, const char *name, int af) {
                return (NULL);
 
        nisfree(pvt, do_val);
-       DE_CONST(name, tmp);
-       r = yp_match(pvt->nis_domain, hosts_byname, tmp,
+
+       strcpy(pvt->hostbuf, yp_multi);
+       strncat(pvt->hostbuf, name, sizeof(pvt->hostbuf) - sizeof(yp_multi));
+       pvt->hostbuf[sizeof(pvt->hostbuf) - 1] = '\0';
+       for (r = sizeof(yp_multi) - 1; pvt->hostbuf[r] != '\0'; r++)
+               if (isupper((unsigned char)pvt->hostbuf[r]))
+                       tolower(pvt->hostbuf[r]);
+
+       tmp = pvt->hostbuf;
+       r = yp_match(pvt->nis_domain, ipnode_byname, tmp,
                     strlen(tmp), &pvt->curval_data, &pvt->curval_len);
+       if (r != 0) {
+               tmp = pvt->hostbuf + sizeof(yp_multi) - 1;
+               r = yp_match(pvt->nis_domain, ipnode_byname, tmp,
+                            strlen(tmp), &pvt->curval_data, &pvt->curval_len);
+       }
+       if (r != 0) {
+               tmp = pvt->hostbuf;
+               r = yp_match(pvt->nis_domain, hosts_byname, tmp,
+                            strlen(tmp), &pvt->curval_data, &pvt->curval_len);
+       }
+       if (r != 0) {
+               tmp = pvt->hostbuf + sizeof(yp_multi) - 1;
+               r = yp_match(pvt->nis_domain, hosts_byname, tmp,
+                            strlen(tmp), &pvt->curval_data, &pvt->curval_len);
+       }
        if (r != 0) {
                RES_SET_H_ERRNO(pvt->res, HOST_NOT_FOUND);
                return (NULL);
@@ -220,8 +246,11 @@ ho_byaddr(struct irs_ho *this, const void *addr, int len, int af) {
                return (NULL);
        }
        nisfree(pvt, do_val);
-       r = yp_match(pvt->nis_domain, hosts_byaddr, tmp, strlen(tmp),
+       r = yp_match(pvt->nis_domain, ipnode_byaddr, tmp, strlen(tmp),
                     &pvt->curval_data, &pvt->curval_len);
+       if (r != 0)
+               r = yp_match(pvt->nis_domain, hosts_byaddr, tmp, strlen(tmp),
+                            &pvt->curval_data, &pvt->curval_len);
        if (r != 0) {
                RES_SET_H_ERRNO(pvt->res, HOST_NOT_FOUND);
                return (NULL);
@@ -382,12 +411,35 @@ ho_addrinfo(struct irs_ho *this, const char *name, const struct addrinfo *pai)
 
 /* Private */
 
+/*
+ipnodes:
+::1             localhost
+127.0.0.1       localhost
+1.2.3.4         FOO bar
+1.2.6.4         FOO bar
+1.2.6.5         host
+
+ipnodes.byname:
+YP_MULTI_localhost ::1,127.0.0.1        localhost
+YP_MULTI_foo 1.2.3.4,1.2.6.4    FOO bar
+YP_MULTI_bar 1.2.3.4,1.2.6.4    FOO bar
+host 1.2.6.5    host
+
+hosts.byname:
+localhost 127.0.0.1     localhost
+host 1.2.6.5    host
+YP_MULTI_foo 1.2.3.4,1.2.6.4    FOO bar
+YP_MULTI_bar 1.2.3.4,1.2.6.4    FOO bar
+*/
+
 static struct hostent *
 makehostent(struct irs_ho *this) {
        struct pvt *pvt = (struct pvt *)this->private;
        static const char spaces[] = " \t";
-       char *cp, **q, *p;
-       int af, len;
+       char *cp, **q, *p, *comma, *ap;
+       int af = 0, len = 0;
+       int multi = 0;
+       int addr = 0;
 
        p = pvt->curval_data;
        if ((cp = strpbrk(p, "#\n")) != NULL)
@@ -395,25 +447,40 @@ makehostent(struct irs_ho *this) {
        if (!(cp = strpbrk(p, spaces)))
                return (NULL);
        *cp++ = '\0';
-       if ((pvt->res->options & RES_USE_INET6) &&
-           inet_pton(AF_INET6, p, pvt->host_addr) > 0) {
-               af = AF_INET6;
-               len = IN6ADDRSZ;
-       } else if (inet_pton(AF_INET, p, pvt->host_addr) > 0) {
-               if (pvt->res->options & RES_USE_INET6) {
-                       map_v4v6_address((char*)pvt->host_addr,
-                                        (char*)pvt->host_addr);
+       ap = pvt->hostbuf;
+       do {
+               if ((comma = strchr(p, ',')) != NULL) {
+                       *comma++ = '\0';
+                       multi = 1;
+               }
+               if ((ap + IN6ADDRSZ) > (pvt->hostbuf + sizeof(pvt->hostbuf)))
+                       break;
+               if ((pvt->res->options & RES_USE_INET6) &&
+                   inet_pton(AF_INET6, p, ap) > 0) {
                        af = AF_INET6;
                        len = IN6ADDRSZ;
+               } else if (inet_pton(AF_INET, p, pvt->host_addr) > 0) {
+                       if (pvt->res->options & RES_USE_INET6) {
+                               map_v4v6_address((char*)pvt->host_addr, ap);
+                               af = AF_INET6;
+                               len = IN6ADDRSZ;
+                       } else {
+                               af = AF_INET;
+                               len = INADDRSZ;
+                       }
                } else {
-                       af = AF_INET;
-                       len = INADDRSZ;
+                       if (!multi)
+                               return (NULL);
+                       continue;
+               }
+               if (addr < MAXADDRS) {
+                       pvt->h_addr_ptrs[addr++] = ap;
+                       pvt->h_addr_ptrs[addr] = NULL;
+                       ap += len;
                }
-       } else {
+       } while ((p = comma) != NULL);
+       if (ap == pvt->hostbuf)
                return (NULL);
-       }
-       pvt->h_addr_ptrs[0] = (char *)pvt->host_addr;
-       pvt->h_addr_ptrs[1] = NULL;
        pvt->host.h_addr_list = pvt->h_addr_ptrs;
        pvt->host.h_length = len;
        pvt->host.h_addrtype = af;
index cfe0d7e0ee2a67f14996ca1300dd96c443da99d8..704fb5c18a45901a3f5fcf6753cf074e4a40130d 100644 (file)
@@ -1,5 +1,5 @@
 #if !defined(lint) && !defined(SABER)
-static const char rcsid[] = "$Id: ctl_clnt.c,v 1.4 2001/06/06 01:56:32 marka Exp $";
+static const char rcsid[] = "$Id: ctl_clnt.c,v 1.5 2003/06/03 04:39:32 marka Exp $";
 #endif /* not lint */
 
 /*
@@ -185,7 +185,7 @@ ctl_client(evContext lev, const struct sockaddr *cap, size_t cap_len,
        if (evConnect(lev, ctx->sock, (const struct sockaddr *)sap, sap_len,
                      conn_done, ctx, &ctx->coID) < 0) {
                (*ctx->logger)(ctl_error, "%s: evConnect(fd %d): %s",
-                              me, (void *)ctx->sock, strerror(errno));
+                              me, ctx->sock, strerror(errno));
  fatal:
                if (ctx != NULL) {
                        if (ctx->sock >= 0)
index 1d2f449e47639ae121cc8929b43a347d7ea855e9..835c0c55c5af5a42af449bc8922ed3191735958c 100644 (file)
@@ -1,5 +1,5 @@
 #if !defined(lint) && !defined(SABER)
-static const char rcsid[] = "$Id: ctl_srvr.c,v 1.3 2001/04/03 06:42:30 marka Exp $";
+static const char rcsid[] = "$Id: ctl_srvr.c,v 1.4 2003/06/03 04:39:32 marka Exp $";
 #endif /* not lint */
 
 /*
@@ -252,7 +252,7 @@ ctl_server(evContext lev, const struct sockaddr *sap, size_t sap_len,
                     &ctx->acID) < 0) {
                save_errno = errno;
                (*ctx->logger)(ctl_error, "%s: evListen(fd %d): %s",
-                              me, (void *)ctx->sock, strerror(errno));
+                              me, ctx->sock, strerror(errno));
                close(ctx->sock);
                memput(ctx, sizeof *ctx);
                errno = save_errno;
index 528026497030a8c634939bb5ec42b5ed7e596c9e..7890ed330b406107188a49eecdcb3efc12104c2a 100644 (file)
@@ -20,7 +20,7 @@
  */
 
 #if !defined(LINT) && !defined(CODECENTER)
-static const char rcsid[] = "$Id: ev_files.c,v 1.3 2001/07/02 02:02:27 marka Exp $";
+static const char rcsid[] = "$Id: ev_files.c,v 1.4 2003/06/03 04:39:32 marka Exp $";
 #endif
 
 #include "port_before.h"
@@ -54,7 +54,7 @@ evSelectFD(evContext opaqueCtx,
        int mode;
 
        evPrintf(ctx, 1,
-                "evSelectFD(ctx %#x, fd %d, mask 0x%x, func %#x, uap %#x)\n",
+                "evSelectFD(ctx %p, fd %d, mask 0x%x, func %p, uap %p)\n",
                 ctx, fd, eventmask, func, uap);
        if (eventmask == 0 || (eventmask & ~EV_MASK_ALL) != 0)
                EV_ERR(EINVAL);
index 0a59ad1e5b6f5ffe902771dbe0b9cce854fae7c4..000cfb75842db6b5401a1c10db9c438e2ed39a75 100644 (file)
@@ -20,7 +20,7 @@
  */
 
 #if !defined(LINT) && !defined(CODECENTER)
-static const char rcsid[] = "$Id: ev_timers.c,v 1.2 2001/06/27 03:55:46 marka Exp $";
+static const char rcsid[] = "$Id: ev_timers.c,v 1.3 2003/06/03 04:39:32 marka Exp $";
 #endif
 
 /* Import. */
@@ -152,10 +152,10 @@ evSetTimer(evContext opaqueCtx,
        evTimer *id;
 
        evPrintf(ctx, 1,
-"evSetTimer(ctx %#x, func %#x, uap %#x, due %d.%09ld, inter %d.%09ld)\n",
+"evSetTimer(ctx %p, func %p, uap %p, due %ld.%09ld, inter %ld.%09ld)\n",
                 ctx, func, uap,
-                due.tv_sec, due.tv_nsec,
-                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)
@@ -379,10 +379,10 @@ print_timer(void *what, void *uap) {
 
        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,
-                cur->due.tv_sec, cur->due.tv_nsec,
-                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
index d6b15fa6c81fc2a1d1af53c924cc83fd4bf8eb29..c77461edf8853027d3f6fe193df991b8fc405acd 100644 (file)
@@ -20,7 +20,7 @@
  */
 
 #if !defined(LINT) && !defined(CODECENTER)
-static const char rcsid[] = "$Id: ev_waits.c,v 1.1 2001/03/29 06:31:54 marka Exp $";
+static const char rcsid[] = "$Id: ev_waits.c,v 1.2 2003/06/03 04:39:32 marka Exp $";
 #endif
 
 #include "port_before.h"
@@ -190,14 +190,14 @@ print_waits(evContext_p *ctx) {
        evPrintf(ctx, 9, "wait waiting:\n");
        for (wl = ctx->waitLists; wl != NULL; wl = wl->next) {
                INSIST(wl->first != NULL);
-               evPrintf(ctx, 9, "  tag %#x:", wl->first->tag);
+               evPrintf(ctx, 9, "  tag %p:", wl->first->tag);
                for (this = wl->first; this != NULL; this = this->next)
-                       evPrintf(ctx, 9, " %#x", this);
+                       evPrintf(ctx, 9, " %p", this);
                evPrintf(ctx, 9, "\n");
        }
        evPrintf(ctx, 9, "wait done:");
        for (this = ctx->waitDone.first; this != NULL; this = this->next)
-               evPrintf(ctx, 9, " %#x", this);
+               evPrintf(ctx, 9, " %p", this);
        evPrintf(ctx, 9, "\n");
 }
 
index 96337e387f318b2bb3b86667afbc603a5d99aff4..8ba6038869c6da5b46b95572ea190f6ec8d6cb45 100644 (file)
@@ -20,7 +20,7 @@
  */
 
 #if !defined(LINT) && !defined(CODECENTER)
-static const char rcsid[] = "$Id: eventlib.c,v 1.2 2001/06/27 03:55:47 marka Exp $";
+static const char rcsid[] = "$Id: eventlib.c,v 1.3 2003/06/03 04:39:32 marka Exp $";
 #endif
 
 #include "port_before.h"
@@ -291,12 +291,12 @@ evGetNext(evContext opaqueCtx, evEvent *opaqueEv, int options) {
                        }
 
                        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 ? tp->tv_sec : -1,
+                                tp ? (long)tp->tv_sec : -1L,
                                 tp ? tp->tv_nsec : -1);
 
                        /* XXX should predict system's earliness and adjust. */
@@ -463,7 +463,7 @@ evDispatch(evContext opaqueCtx, evEvent opaqueEv) {
                evAccept *this = ev->u.accept.this;
 
                evPrintf(ctx, 5,
-                       "Dispatch.Accept: fd %d -> %d, func %#x, uap %#x\n",
+                       "Dispatch.Accept: fd %d -> %d, func %p, uap %p\n",
                         this->conn->fd, this->fd,
                         this->conn->func, this->conn->uap);
                errno = this->ioErrno;
@@ -480,7 +480,7 @@ evDispatch(evContext opaqueCtx, evEvent opaqueEv) {
                int eventmask = ev->u.file.eventmask;
 
                evPrintf(ctx, 5,
-                       "Dispatch.File: fd %d, mask 0x%x, func %#x, uap %#x\n",
+                       "Dispatch.File: fd %d, mask 0x%x, func %p, uap %p\n",
                         this->fd, this->eventmask, this->func, this->uap);
                (this->func)(opaqueCtx, this->uap, this->fd, eventmask);
 #ifdef EVENTLIB_TIME_CHECKS
@@ -492,7 +492,7 @@ evDispatch(evContext opaqueCtx, evEvent opaqueEv) {
                evStream *this = ev->u.stream.this;
 
                evPrintf(ctx, 5,
-                        "Dispatch.Stream: fd %d, func %#x, uap %#x\n",
+                        "Dispatch.Stream: fd %d, func %p, uap %p\n",
                         this->fd, this->func, this->uap);
                errno = this->ioErrno;
                (this->func)(opaqueCtx, this->uap, this->fd, this->ioDone);
@@ -504,7 +504,7 @@ evDispatch(evContext opaqueCtx, evEvent opaqueEv) {
            case Timer: {
                evTimer *this = ev->u.timer.this;
 
-               evPrintf(ctx, 5, "Dispatch.Timer: func %#x, uap %#x\n",
+               evPrintf(ctx, 5, "Dispatch.Timer: func %p, uap %p\n",
                         this->func, this->uap);
                (this->func)(opaqueCtx, this->uap, this->due, this->inter);
 #ifdef EVENTLIB_TIME_CHECKS
@@ -516,7 +516,7 @@ evDispatch(evContext opaqueCtx, evEvent opaqueEv) {
                evWait *this = ev->u.wait.this;
 
                evPrintf(ctx, 5,
-                        "Dispatch.Wait: tag %#x, func %#x, uap %#x\n",
+                        "Dispatch.Wait: tag %p, func %p, uap %p\n",
                         this->tag, this->func, this->uap);
                (this->func)(opaqueCtx, this->uap, this->tag);
 #ifdef EVENTLIB_TIME_CHECKS
index ea4b21c3b42c89200178ef3857722e434d94b117..0590fb032ce7be883f45f4f15f53eadc48c02f7f 100644 (file)
@@ -18,7 +18,7 @@
 /* eventlib_p.h - private interfaces for eventlib
  * vix 09sep95 [initial]
  *
- * $Id: eventlib_p.h,v 1.3 2001/07/03 06:49:54 marka Exp $
+ * $Id: eventlib_p.h,v 1.4 2003/06/03 04:39:32 marka Exp $
  */
 
 #ifndef _EVENTLIB_P_H
@@ -198,7 +198,8 @@ typedef struct {
 
 /* eventlib.c */
 #define evPrintf __evPrintf
-void evPrintf(const evContext_p *ctx, int level, const char *fmt, ...);
+void evPrintf(const evContext_p *ctx, int level, const char *fmt, ...)
+     ISC_FORMAT_PRINTF(3, 4);
 
 /* ev_timers.c */
 #define evCreateTimers __evCreateTimers
index cf1911410e4fc704c1c1fd867e625ada3657be80..3d86c70b224aad52252cb1fcbe48981a332ac0ab 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #if !defined(LINT) && !defined(CODECENTER)
-static const char rcsid[] = "$Id: logging.c,v 1.3 2001/06/21 08:26:15 marka Exp $";
+static const char rcsid[] = "$Id: logging.c,v 1.4 2003/06/03 04:39:32 marka Exp $";
 #endif /* not lint */
 
 #include "port_before.h"
@@ -282,6 +282,10 @@ log_vwrite(log_context lc, int category, int level, const char *format,
        log_channel chan;
        struct timeval tv;
        struct tm *local_tm;
+#ifdef HAVE_TIME_R
+       struct tm tm_tmp;
+#endif
+       time_t tt;
        const char *category_name;
        const char *level_str;
        char time_buf[256];
@@ -313,10 +317,11 @@ log_vwrite(log_context lc, int category, int level, const char *format,
        if (gettimeofday(&tv, NULL) < 0) {
                syslog(LOG_INFO, "gettimeofday failed in log_vwrite()");
        } else {
+               tt = tv.tv_sec;
 #ifdef HAVE_TIME_R
-               localtime_r((time_t *)&tv.tv_sec, &local_tm);
+               local_tm = localtime_r(&tt, &tm_tmp);
 #else
-               local_tm = localtime((time_t *)&tv.tv_sec);
+               local_tm = localtime(&tt);
 #endif
                if (local_tm != NULL) {
                        sprintf(time_buf, "%02d-%s-%4d %02d:%02d:%02d.%03ld ",
index c6a67422f3b3c173620220b4451237e9b8fb6c19..4d5c9fb291eadea6dd8824d213df1e36f20cc7f8 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: ns_name.c,v 1.6 2002/12/03 05:39:10 marka Exp $";
+static const char rcsid[] = "$Id: ns_name.c,v 1.7 2003/06/03 04:39:33 marka Exp $";
 #endif
 
 #include "port_before.h"
@@ -792,7 +792,7 @@ decode_bitstring(const char **cpp, char *dn, const char *eom)
 {
        const char *cp = *cpp;
        char *beg = dn, tc;
-       int b, blen, plen;
+       int b, blen, plen, i;
 
        if ((blen = (*cp & 0xff)) == 0)
                blen = 256;
@@ -802,18 +802,34 @@ decode_bitstring(const char **cpp, char *dn, const char *eom)
                return(-1);
 
        cp++;
-       dn += SPRINTF((dn, "\\[x"));
-       for (b = blen; b > 7; b -= 8, cp++)
-               dn += SPRINTF((dn, "%02x", *cp & 0xff));
+       i = SPRINTF((dn, "\\[x"));
+       if (i < 0)
+               return (-1);
+       dn += i;
+       for (b = blen; b > 7; b -= 8, cp++) {
+               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",
+               = 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);
index 6b591d145378c9580c35236f5c7c94c0b14cdf88..1ea881aedf221efff0f689485ff0db10b1ff7f3e 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: ns_parse.c,v 1.3 2001/06/21 08:26:18 marka Exp $";
+static const char rcsid[] = "$Id: ns_parse.c,v 1.4 2003/06/03 04:39:33 marka Exp $";
 #endif
 
 /* Import. */
@@ -132,9 +132,10 @@ ns_initparse(const u_char *msg, int msglen, ns_msg *handle) {
 int
 ns_parserr(ns_msg *handle, ns_sect section, int rrnum, ns_rr *rr) {
        int b;
+       int tmp;
 
        /* Make section right. */
-       if (section >= ns_s_max)
+       if ((tmp = section) < 0 || section >= ns_s_max)
                RETERR(ENODEV);
        if (section != handle->_sect)
                setsection(handle, section);
index 0eaf2b98e90c1852856f6af6ec338c48e59701fd..cdf8e311fcb5dd0110fc636cb04c541d8eb48330 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: ns_print.c,v 1.3 2001/06/21 08:26:19 marka Exp $";
+static const char rcsid[] = "$Id: ns_print.c,v 1.4 2003/06/03 04:39:33 marka Exp $";
 #endif
 
 /* Import. */
@@ -31,6 +31,7 @@ static const char rcsid[] = "$Id: ns_print.c,v 1.3 2001/06/21 08:26:19 marka Exp
 #include <arpa/inet.h>
 
 #include <isc/assertions.h>
+#include <isc/dst.h>
 #include <errno.h>
 #include <resolv.h>
 #include <string.h>
@@ -58,10 +59,6 @@ static int   addstr(const char *src, size_t len,
 static int     addtab(size_t len, size_t target, int spaced,
                       char **buf, size_t *buflen);
 
-/* Proto. */
-
-u_int16_t       dst_s_dns_key_id(const u_char *, const int);
-
 /* Macros. */
 
 #define        T(x) \
@@ -640,9 +637,10 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
                len = SPRINTF((tmp, "%u %u %u ", mode, err, keysize));
                T(addstr(tmp, len, &buf, &buflen));
 
-        /* needs to dump key, print otherdata length & other data */
+               /* XXX need to dump key, print otherdata length & other data */
                break;
            }
+
        case ns_t_tsig: {
                /* BEW - need to complete this */
                int n;
@@ -690,13 +688,13 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
                T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
                
                break;
-       }
+           }
 
        case ns_t_opt: {
                len = SPRINTF((tmp, "%u bytes", class));
                T(addstr(tmp, len, &buf, &buflen));
                break;
-       }
+           }
 
        default:
                comment = "unknown RR type";
index 24f5f2102c308a31e848384b3446e5541a9e94ac..9a71e19c45b79a24ca962f86e1fba270cdff3425 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: ns_samedomain.c,v 1.2 2001/11/27 22:53:55 marka Exp $";
+static const char rcsid[] = "$Id: ns_samedomain.c,v 1.3 2003/06/03 04:39:33 marka Exp $";
 #endif
 
 #include "port_before.h"
@@ -166,14 +166,14 @@ int
 ns_makecanon(const char *src, char *dst, size_t dstsize) {
        size_t n = strlen(src);
 
-       if (n + sizeof "." > dstsize) {
+       if (n + sizeof "." > dstsize) {                 /* Note: sizeof == 2 */
                errno = EMSGSIZE;
                return (-1);
        }
        strcpy(dst, src);
-       while (n > 0 && dst[n - 1] == '.')              /* Ends in "." */
-               if (n > 1 && dst[n - 2] == '\\' &&      /* Ends in "\." */
-                   (n < 2 || dst[n - 3] != '\\'))      /* But not "\\." */
+       while (n >= 1 && dst[n - 1] == '.')             /* Ends in "." */
+               if (n >= 2 && dst[n - 2] == '\\' &&     /* Ends in "\." */
+                   (n < 3 || dst[n - 3] != '\\'))      /* But not "\\." */
                        break;
                else
                        dst[--n] = '\0';
index 273d33cc9134b5a33758d8722ae83fa3cd718d7b..2622eba258f44537324a38556b8bdfbb6b40f81c 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: ns_sign.c,v 1.2 2002/05/06 06:29:41 marka Exp $";
+static const char rcsid[] = "$Id: ns_sign.c,v 1.3 2003/06/03 04:39:33 marka Exp $";
 #endif
 
 /* Import. */
@@ -41,6 +41,7 @@ static const char rcsid[] = "$Id: ns_sign.c,v 1.2 2002/05/06 06:29:41 marka Exp
 #include <unistd.h>
 
 #include <isc/dst.h>
+#include <isc/assertions.h>
 
 #include "port_after.h"
 
@@ -90,22 +91,30 @@ ns_sign2(u_char *msg, int *msglen, int msgsize, int error, void *k,
        DST_KEY *key = (DST_KEY *)k;
        u_char *cp = msg + *msglen, *eob = msg + msgsize;
        u_char *lenp;
-       u_char *name, *alg;
+       u_char *alg;
        int n;
        time_t timesigned;
+        u_char name[NS_MAXCDNAME];
 
        dst_init();
        if (msg == NULL || msglen == NULL || sig == NULL || siglen == NULL)
                return (-1);
 
        /* Name. */
-       if (key != NULL && error != ns_r_badsig && error != ns_r_badkey)
-               n = dn_comp(key->dk_key_name, cp, eob - cp, dnptrs, lastdnptr);
-       else
-               n = dn_comp("", cp, eob - cp, NULL, NULL);
+       if (key != NULL && error != ns_r_badsig && error != ns_r_badkey) {
+               n = ns_name_pton(key->dk_key_name, name, sizeof name);
+               if (n != -1)
+                       n = ns_name_pack(name, cp, eob - cp,
+                                        (const u_char **)dnptrs,
+                                        (const u_char **)lastdnptr);
+
+       } else {
+               n = ns_name_pton("", name, sizeof name);
+               if (n != -1)
+                       n = ns_name_pack(name, cp, eob - cp, NULL, NULL);
+       }
        if (n < 0)
                return (NS_TSIG_ERROR_NO_SPACE);
-       name = cp;
        cp += n;
 
        /* Type, class, ttl, length (not filled in yet). */
@@ -142,7 +151,7 @@ ns_sign2(u_char *msg, int *msglen, int msgsize, int error, void *k,
        /* Compute the signature. */
        if (key != NULL && error != ns_r_badsig && error != ns_r_badkey) {
                void *ctx;
-               u_char buf[MAXDNAME], *cp2;
+               u_char buf[NS_MAXCDNAME], *cp2;
                int n;
 
                dst_sign_data(SIG_MODE_INIT, key, &ctx, NULL, 0, NULL, 0);
@@ -162,6 +171,7 @@ ns_sign2(u_char *msg, int *msglen, int msgsize, int error, void *k,
 
                /* Digest the key name. */
                n = ns_name_ntol(name, buf, sizeof(buf));
+               INSIST(n > 0);
                dst_sign_data(SIG_MODE_UPDATE, key, &ctx, buf, n, NULL, 0);
 
                /* Digest the class and TTL. */
@@ -173,6 +183,7 @@ ns_sign2(u_char *msg, int *msglen, int msgsize, int error, void *k,
 
                /* Digest the algorithm. */
                n = ns_name_ntol(alg, buf, sizeof(buf));
+               INSIST(n > 0);
                dst_sign_data(SIG_MODE_UPDATE, key, &ctx, buf, n, NULL, 0);
 
                /* Digest the time signed, fudge, error, and other data */
index fcbc99c9d37be2a85cb43c1518ea4c6e6bcb3923..547fb7eac9982dd5fd918a2971b5dd125b014e56 100644 (file)
@@ -24,6 +24,8 @@
 @HAVE_STRNDUP@
 @USE_FIONBIO_IOCTL@
 @USE_SYSERROR_LIST@
+@INNETGR_ARGS@
+@SETNETGRENT_ARGS@
 
 /* XXX sunos and cygwin needs O_NDELAY */
 #define PORT_NONBLOCK O_NONBLOCK
@@ -363,8 +365,7 @@ int isc__gettimeofday(struct timeval *tvp, struct _TIMEZONE *tzp);
 int isc__gettimeofday(struct timeval *tp, struct timezone *tzp);
 #endif
 
-int getnetgrent(const char **machinep, const char **userp,
-               const char **domainp);
+int getnetgrent(char **machinep, char **userp, char **domainp);
 
 int getnetgrent_r(char **machinep, char **userp, char **domainp, NGR_R_ARGS);
 
index cb86b3f5bb1165f601ac7d22714e38ebda2b3916..ae430a5f8d6797ddbde453571bdeff4e21c2fbd8 100644 (file)
@@ -70,7 +70,7 @@
 
 #if defined(LIBC_SCCS) && !defined(lint)
 static const char sccsid[] = "@(#)res_comp.c   8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_comp.c,v 1.1 2001/03/29 06:31:58 marka Exp $";
+static const char rcsid[] = "$Id: res_comp.c,v 1.2 2003/06/03 04:39:34 marka Exp $";
 #endif /* LIBC_SCCS and not lint */
 
 #include "port_before.h"
@@ -86,10 +86,10 @@ static const char rcsid[] = "$Id: res_comp.c,v 1.1 2001/03/29 06:31:58 marka Exp
 #include "port_after.h"
 
 /*
- * Expand compressed domain name 'comp_dn' to full domain name.
+ * Expand compressed domain name 'src' to full domain name.
  * 'msg' is a pointer to the begining of the message,
- * 'eomorig' points to the first location after the message,
- * 'exp_dn' is a pointer to a buffer of size 'length' for the result.
+ * 'eom' points to the first location after the message,
+ * 'dst' is a pointer to a buffer of size 'dstsiz' for the result.
  * Return size of compressed name or -1 if there was an error.
  */
 int
index a541cf8e4f581aec1f93da1a55df0efcd96c0ed8..d0ef95af93c75f0dae89a742c0ac95277391244a 100644 (file)
@@ -95,7 +95,7 @@
 
 #if defined(LIBC_SCCS) && !defined(lint)
 static const char sccsid[] = "@(#)res_debug.c  8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_debug.c,v 1.7 2002/05/21 02:07:50 marka Exp $";
+static const char rcsid[] = "$Id: res_debug.c,v 1.8 2003/06/03 04:39:34 marka Exp $";
 #endif /* LIBC_SCCS and not lint */
 
 #include "port_before.h"
@@ -615,9 +615,6 @@ p_option(u_long option) {
 #ifdef RES_USE_EDNS0   /* KAME extension */
        case RES_USE_EDNS0:     return "edns0";
 #endif
-#ifdef RES_USE_A6
-       case RES_USE_A6:        return "a6";
-#endif
 #ifdef RES_USE_DNAME
        case RES_USE_DNAME:     return "dname";
 #endif
@@ -654,6 +651,33 @@ p_rcode(int rcode) {
        return (sym_ntos(__p_rcode_syms, rcode, (int *)0));
 }
 
+/*
+ * Return a string for a res_sockaddr_union.
+ */
+const char *
+p_sockun(union res_sockaddr_union u, char *buf, size_t size) {
+       char ret[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:123.123.123.123"];
+
+       switch (u.sin.sin_family) {
+       case AF_INET:
+               inet_ntop(AF_INET, &u.sin.sin_addr, ret, sizeof ret);
+               break;
+#ifdef HAS_INET6_STRUCTS
+       case AF_INET6:
+               inet_ntop(AF_INET6, &u.sin6.sin6_addr, ret, sizeof ret);
+               break;
+#endif
+       default:
+               sprintf(ret, "[af%d]", u.sin.sin_family);
+               break;
+       }
+       if (size > 0) {
+               strncpy(buf, ret, size - 1);
+               buf[size - 1] = '0';
+       }
+       return (buf);
+}
+
 /*
  * routines to convert between on-the-wire RR format and zone file format.
  * Does not contain conversion to/from decimal degrees; divide or multiply
@@ -1101,8 +1125,9 @@ res_nametoclass(const char *buf, int *successp) {
        if (strncasecmp(buf, "CLASS", 5) != 0 ||
            !isdigit((unsigned char)buf[5]))
                goto done;
+       errno = 0;
        result = strtoul(buf + 5, &endptr, 10);
-       if (*endptr == '\0' && result <= 0xffff)
+       if (errno == 0 && *endptr == '\0' && result <= 0xffff)
                success = 1;
  done:
        if (successp)
@@ -1123,8 +1148,9 @@ res_nametotype(const char *buf, int *successp) {
        if (strncasecmp(buf, "type", 4) != 0 ||
            !isdigit((unsigned char)buf[4]))
                goto done;
+       errno = 0;
        result = strtoul(buf + 4, &endptr, 10);
-       if (*endptr == '\0' && result <= 0xffff)
+       if (errno == 0 && *endptr == '\0' && result <= 0xffff)
                success = 1;
  done:
        if (successp)
index 68a40499dc7c629259f409037a56ce5590c0d486..b141307945aa146a6074424414cbe686d338810b 100644 (file)
@@ -1,5 +1,5 @@
 #if !defined(lint) && !defined(SABER)
-static const char rcsid[] = "$Id: res_findzonecut.c,v 1.4 2002/05/06 04:12:55 marka Exp $";
+static const char rcsid[] = "$Id: res_findzonecut.c,v 1.5 2003/06/03 04:39:34 marka Exp $";
 #endif /* not lint */
 
 /*
@@ -49,19 +49,21 @@ static const char rcsid[] = "$Id: res_findzonecut.c,v 1.4 2002/05/06 04:12:55 ma
 
 typedef struct rr_a {
        LINK(struct rr_a)       link;
-       union res_sockaddr_union                addr;
+       union res_sockaddr_union addr;
 } rr_a;
 typedef LIST(rr_a) rrset_a;
 
 typedef struct rr_ns {
        LINK(struct rr_ns)      link;
        const char *            name;
-       int                     have_v4;
-       int                     have_v6;
+       unsigned int            flags;
        rrset_a                 addrs;
 } rr_ns;
 typedef LIST(rr_ns) rrset_ns;
 
+#define        RR_NS_HAVE_V4           0x01
+#define        RR_NS_HAVE_V6           0x02
+
 /* Forward. */
 
 static int     satisfy(res_state, const char *, rrset_ns *,
@@ -149,7 +151,8 @@ static void res_dprintf(const char *, ...) ISC_FORMAT_PRINTF(1, 2);
 
 int
 res_findzonecut(res_state statp, const char *dname, ns_class class, int opts,
-               char *zname, size_t zsize, struct in_addr *addrs, int naddrs) {
+               char *zname, size_t zsize, struct in_addr *addrs, int naddrs)
+{
        int result, i;
        union res_sockaddr_union *u;
 
@@ -267,7 +270,7 @@ get_soa(res_state statp, const char *dname, ns_class class, int opts,
        rrset_ns *nsrrsp)
 {
        char tname[NS_MAXDNAME];
-       u_char resp[NS_PACKETSZ];
+       u_char *resp = NULL;
        int n, i, ancount, nscount;
        ns_sect sect;
        ns_msg msg;
@@ -279,9 +282,13 @@ get_soa(res_state statp, const char *dname, ns_class class, int opts,
 
        /* First canonicalize dname (exactly one unescaped trailing "."). */
        if (ns_makecanon(dname, tname, sizeof tname) < 0)
-               return (-1);
+               goto cleanup;
        dname = tname;
 
+       resp = malloc(NS_MAXMSG);
+       if (resp == NULL)
+               goto cleanup;
+
        /* Now grovel the subdomains, hunting for an SOA answer or auth. */
        for (;;) {
                /* Leading or inter-label '.' are skipped here. */
@@ -293,7 +300,7 @@ get_soa(res_state statp, const char *dname, ns_class class, int opts,
                if (n < 0) {
                        DPRINTF(("get_soa: do_query('%s', %s) failed (%d)",
                                 dname, p_class(class), n));
-                       return (-1);
+                       goto cleanup;
                }
                if (n > 0) {
                        DPRINTF(("get_soa: CNAME or DNAME found"));
@@ -318,7 +325,7 @@ get_soa(res_state statp, const char *dname, ns_class class, int opts,
                        if (ns_parserr(&msg, sect, i, &rr) < 0) {
                                DPRINTF(("get_soa: ns_parserr(%s, %d) failed",
                                         p_section(sect, ns_o_query), i));
-                               return (-1);
+                               goto cleanup;
                        }
                        if (ns_rr_type(rr) == ns_t_cname ||
                            ns_rr_type(rr) == ns_t_dname)
@@ -330,19 +337,23 @@ get_soa(res_state statp, const char *dname, ns_class class, int opts,
                        switch (sect) {
                        case ns_s_an:
                                if (ns_samedomain(dname, t) == 0) {
-                                       DPRINTF(("get_soa: ns_samedomain('%s', '%s') == 0",
-                                                dname, t));
+                                       DPRINTF(
+                                   ("get_soa: ns_samedomain('%s', '%s') == 0",
+                                               dname, t)
+                                               );
                                        errno = EPROTOTYPE;
-                                       return (-1);
+                                       goto cleanup;
                                }
                                break;
                        case ns_s_ns:
                                if (ns_samename(dname, t) == 1 ||
                                    ns_samedomain(dname, t) == 0) {
-                                       DPRINTF(("get_soa: ns_samename() || !ns_samedomain('%s', '%s')",
-                                                dname, t));
+                                       DPRINTF(
+                      ("get_soa: ns_samename() || !ns_samedomain('%s', '%s')",
+                                               dname, t)
+                                               );
                                        errno = EPROTOTYPE;
-                                       return (-1);
+                                       goto cleanup;
                                }
                                break;
                        default:
@@ -352,21 +363,23 @@ get_soa(res_state statp, const char *dname, ns_class class, int opts,
                                DPRINTF(("get_soa: zname(%d) too small (%d)",
                                         zsize, strlen(t) + 1));
                                errno = EMSGSIZE;
-                               return (-1);
+                               goto cleanup;
                        }
                        strcpy(zname, t);
                        rdata = ns_rr_rdata(rr);
                        rdlen = ns_rr_rdlen(rr);
                        if (ns_name_uncompress(resp, ns_msg_end(msg), rdata,
                                               mname, msize) < 0) {
-                               DPRINTF(("get_soa: ns_name_uncompress failed"));
-                               return (-1);
+                               DPRINTF(("get_soa: ns_name_uncompress failed")
+                                       );
+                               goto cleanup;
                        }
                        if (save_ns(statp, &msg, ns_s_ns,
                                    zname, class, opts, nsrrsp) < 0) {
                                DPRINTF(("get_soa: save_ns failed"));
-                               return (-1);
+                               goto cleanup;
                        }
+                       free(resp);
                        return (0);
                }
 
@@ -379,13 +392,16 @@ get_soa(res_state statp, const char *dname, ns_class class, int opts,
                        if (*dname == '\\')
                                if (*++dname == '\0') {
                                        errno = EMSGSIZE;
-                                       return (-1);
+                                       goto cleanup;
                                }
                        dname++;
                }
        }
        DPRINTF(("get_soa: out of labels"));
        errno = EDESTADDRREQ;
+ cleanup:
+       if (resp != NULL)
+               free(resp);
        return (-1);
 }
 
@@ -393,15 +409,20 @@ static int
 get_ns(res_state statp, const char *zname, ns_class class, int opts,
       rrset_ns *nsrrsp)
 {
-       u_char resp[NS_PACKETSZ];
+       u_char *resp;
        ns_msg msg;
        int n;
 
+       resp = malloc(NS_MAXMSG);
+       if (resp == NULL)
+               return (-1);
+
        /* Go and get the NS RRs for this zone. */
        n = do_query(statp, zname, class, ns_t_ns, resp, &msg);
        if (n != 0) {
                DPRINTF(("get_ns: do_query('%s', %s) failed (%d)",
                         zname, p_class(class), n));
+               free(resp);
                return (-1);
        }
 
@@ -409,31 +430,38 @@ get_ns(res_state statp, const char *zname, ns_class class, int opts,
        if (save_ns(statp, &msg, ns_s_an, zname, class, opts, nsrrsp) < 0) {
                DPRINTF(("get_ns save_ns('%s', %s) failed",
                         zname, p_class(class)));
+               free(resp);
                return (-1);
        }
 
+       free(resp);
        return (0);
 }
 
 static int
 get_glue(res_state statp, ns_class class, int opts, rrset_ns *nsrrsp) {
        rr_ns *nsrr, *nsrr_n;
+       u_char *resp;
+
+       resp = malloc(NS_MAXMSG);
+       if (resp == NULL)
+               return(-1);
 
        /* Go and get the A RRs for each empty NS RR on our list. */
        for (nsrr = HEAD(*nsrrsp); nsrr != NULL; nsrr = nsrr_n) {
-               u_char resp[NS_PACKETSZ];
                ns_msg msg;
                int n;
 
                nsrr_n = NEXT(nsrr, link);
 
-               if (!nsrr->have_v4) {
+               if ((nsrr->flags & RR_NS_HAVE_V4) == 0) {
                        n = do_query(statp, nsrr->name, class, ns_t_a,
                                     resp, &msg);
                        if (n < 0) {
-                               DPRINTF(("get_glue: do_query('%s', %s') failed",
-                                        nsrr->name, p_class(class)));
-                               return (-1);
+                               DPRINTF(
+                                      ("get_glue: do_query('%s', %s') failed",
+                                       nsrr->name, p_class(class)));
+                               goto cleanup;
                        }
                        if (n > 0) {
                                DPRINTF((
@@ -444,17 +472,18 @@ get_glue(res_state statp, ns_class class, int opts, rrset_ns *nsrrsp) {
                                   opts, nsrr) < 0) {
                                DPRINTF(("get_glue: save_r('%s', %s) failed",
                                         nsrr->name, p_class(class)));
-                               return (-1);
+                               goto cleanup;
                        }
                }
 
-               if (!nsrr->have_v6) {
+               if ((nsrr->flags & RR_NS_HAVE_V6) == 0) {
                        n = do_query(statp, nsrr->name, class, ns_t_aaaa,
                                     resp, &msg);
                        if (n < 0) {
-                               DPRINTF(("get_glue: do_query('%s', %s') failed",
-                                        nsrr->name, p_class(class)));
-                               return (-1);
+                               DPRINTF(
+                                      ("get_glue: do_query('%s', %s') failed",
+                                       nsrr->name, p_class(class)));
+                               goto cleanup;
                        }
                        if (n > 0) {
                                DPRINTF((
@@ -465,7 +494,7 @@ get_glue(res_state statp, ns_class class, int opts, rrset_ns *nsrrsp) {
                                   opts, nsrr) < 0) {
                                DPRINTF(("get_glue: save_r('%s', %s) failed",
                                         nsrr->name, p_class(class)));
-                               return (-1);
+                               goto cleanup;
                        }
                }
 
@@ -476,7 +505,12 @@ get_glue(res_state statp, ns_class class, int opts, rrset_ns *nsrrsp) {
                        free_nsrr(nsrrsp, nsrr);
                }
        }
+       free(resp);
        return (0);
+
+ cleanup:
+       free(resp);
+       return (-1);
 }
 
 static int
@@ -514,7 +548,8 @@ save_ns(res_state statp, ns_msg *msg, ns_sect sect,
                        if (ns_name_uncompress(ns_msg_base(*msg),
                                               ns_msg_end(*msg), rdata,
                                               tname, sizeof tname) < 0) {
-                               DPRINTF(("save_ns: ns_name_uncompress failed"));
+                               DPRINTF(("save_ns: ns_name_uncompress failed")
+                                       );
                                free(nsrr);
                                return (-1);
                        }
@@ -526,8 +561,7 @@ save_ns(res_state statp, ns_msg *msg, ns_sect sect,
                        }
                        INIT_LINK(nsrr, link);
                        INIT_LIST(nsrr->addrs);
-                       nsrr->have_v4 = 0;
-                       nsrr->have_v6 = 0;
+                       nsrr->flags = 0;
                        APPEND(*nsrrsp, nsrr, link);
                }
                if (save_a(statp, msg, ns_s_ar,
@@ -556,7 +590,8 @@ save_a(res_state statp, ns_msg *msg, ns_sect sect,
                                 p_section(sect, ns_o_query), i));
                        return (-1);
                }
-               if ((ns_rr_type(rr) != ns_t_a && ns_rr_type(rr) != ns_t_aaaa) ||
+               if ((ns_rr_type(rr) != ns_t_a &&
+                    ns_rr_type(rr) != ns_t_aaaa) ||
                    ns_rr_class(rr) != class ||
                    ns_samename(ns_rr_name(rr), owner) != 1 ||
                    ns_rr_rdlen(rr) != NS_INADDRSZ)
@@ -581,7 +616,7 @@ save_a(res_state statp, ns_msg *msg, ns_sect sect,
                        memcpy(&arr->addr.sin.sin_addr, ns_rr_rdata(rr),
                               NS_INADDRSZ);
                        arr->addr.sin.sin_port = htons(NAMESERVER_PORT);
-                       nsrr->have_v4 = 1;
+                       nsrr->flags |= RR_NS_HAVE_V4;
                        break;
                case ns_t_aaaa:
                        arr->addr.sin6.sin6_family = AF_INET6;
@@ -590,7 +625,7 @@ save_a(res_state statp, ns_msg *msg, ns_sect sect,
 #endif
                        memcpy(&arr->addr.sin6.sin6_addr, ns_rr_rdata(rr), 16);
                        arr->addr.sin.sin_port = htons(NAMESERVER_PORT);
-                       nsrr->have_v6 = 1;
+                       nsrr->flags |= RR_NS_HAVE_V6;
                        break;
                default:
                        abort();
@@ -646,7 +681,7 @@ do_query(res_state statp, const char *dname, ns_class class, ns_type qtype,
                DPRINTF(("do_query: res_nmkquery failed"));
                return (-1);
        }
-       n = res_nsend(statp, req, n, resp, NS_PACKETSZ);
+       n = res_nsend(statp, req, n, resp, NS_MAXMSG);
        if (n < 0) {
                DPRINTF(("do_query: res_nsend failed"));
                return (-1);
index c7fdd477e66f455c430da2eaeb85d98e335bf3d4..703eb4db4d544b2820c9fc8b791c0e3844551f70 100644 (file)
@@ -70,7 +70,7 @@
 
 #if defined(LIBC_SCCS) && !defined(lint)
 static const char sccsid[] = "@(#)res_init.c   8.1 (Berkeley) 6/7/93";
-static const char rcsid[] = "$Id: res_init.c,v 1.12 2002/06/03 00:34:57 marka Exp $";
+static const char rcsid[] = "$Id: res_init.c,v 1.13 2003/06/03 04:39:34 marka Exp $";
 #endif /* LIBC_SCCS and not lint */
 
 #include "port_before.h"
@@ -161,6 +161,7 @@ __res_vinit(res_state statp, int preinit) {
        char *net;
 #endif
        int dots;
+       union res_sockaddr_union u[2];
 
        if (!preinit) {
                statp->retrans = RES_TIMEOUT;
@@ -172,17 +173,32 @@ __res_vinit(res_state statp, int preinit) {
        if ((statp->options & RES_INIT) != 0)
                res_ndestroy(statp);
 
+       memset(u, 0, sizeof(u));
 #ifdef USELOOPBACK
-       statp->nsaddr.sin_addr = inet_makeaddr(IN_LOOPBACKNET, 1);
+       u[nserv].sin.sin_addr = inet_makeaddr(IN_LOOPBACKNET, 1);
 #else
-       statp->nsaddr.sin_addr.s_addr = INADDR_ANY;
+       u[nserv].sin.sin_addr.s_addr = INADDR_ANY;
 #endif
-       statp->nsaddr.sin_family = AF_INET;
-       statp->nsaddr.sin_port = htons(NAMESERVER_PORT);
+       u[nserv].sin.sin_family = AF_INET;
+       u[nserv].sin.sin_port = htons(NAMESERVER_PORT);
 #ifdef HAVE_SA_LEN
-       statp->nsaddr.sin_len = sizeof(struct sockaddr_in);
+       u[nserv].sin.sin_len = sizeof(struct sockaddr_in);
 #endif
-       statp->nscount = 1;
+       nserv++;
+#ifdef HAS_INET6_STRUCTS
+#ifdef USELOOPBACK
+       u[nserv].sin6.sin6_addr = in6addr_loopback;
+#else
+       u[nserv].sin6.sin6_addr = in6addr_any;
+#endif
+       u[nserv].sin6.sin6_family = AF_INET6;
+       u[nserv].sin6.sin6_port = htons(NAMESERVER_PORT);
+#ifdef HAVE_SA_LEN
+       u[nserv].sin6.sin6_len = sizeof(struct sockaddr_in6);
+#endif
+       nserv++;
+#endif
+       statp->nscount = 0;
        statp->ndots = 1;
        statp->pfcode = 0;
        statp->_vcsock = -1;
@@ -196,11 +212,11 @@ __res_vinit(res_state statp, int preinit) {
                statp->_u._ext.ext->nsaddrs[0].sin = statp->nsaddr;
                strcpy(statp->_u._ext.ext->nsuffix, "ip6.arpa");
                strcpy(statp->_u._ext.ext->nsuffix2, "ip6.int");
-               strcpy(statp->_u._ext.ext->bsuffix, "ip6.arpa");
        }
 #ifdef RESOLVSORT
        statp->nsort = 0;
 #endif
+       res_setservers(statp, u, nserv);
 
        /* Allow user to override the local domain definition */
        if ((cp = getenv("LOCALDOMAIN")) != NULL) {
@@ -242,6 +258,7 @@ __res_vinit(res_state statp, int preinit) {
        (line[sizeof(name) - 1] == ' ' || \
         line[sizeof(name) - 1] == '\t'))
 
+       nserv = 0;
        if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) {
            /* read the config file */
            while (fgets(buf, sizeof(buf), fp) != NULL) {
@@ -507,9 +524,6 @@ res_setoptions(res_state statp, const char *options, const char *source)
                        statp->options |= RES_USE_EDNS0;
                }
 #endif
-               else if (!strncmp(cp, "a6", sizeof("a6") - 1)) {
-                       statp->options |= RES_USE_A6;
-               }
                else if (!strncmp(cp, "dname", sizeof("dname") - 1)) {
                        statp->options |= RES_USE_DNAME;
                }
@@ -529,14 +543,6 @@ res_setoptions(res_state statp, const char *options, const char *source)
                        strncpy(ext->nsuffix2, cp, i);
                        ext->nsuffix2[i] = '\0';
                }
-               else if (!strncmp(cp, "bitstring:", sizeof("bitstring:") - 1)) {
-                       if (ext == NULL)
-                               goto skip;
-                       cp += sizeof("bitstring:") - 1;
-                       i = MIN(strcspn(cp, " \t"), sizeof(ext->bsuffix) - 1);
-                       strncpy(ext->bsuffix, cp, i);
-                       ext->bsuffix[i] = '\0';
-               }
                else if (!strncmp(cp, "v6revmode:", sizeof("v6revmode:") - 1)) {
                        cp += sizeof("v6revmode:") - 1;
                        /* "nibble" and "bitstring" used to be valid */
@@ -628,13 +634,6 @@ res_get_nibblesuffix2(res_state statp) {
        return ("ip6.int");
 }
 
-const char *
-res_get_bitstringsuffix(res_state statp) {
-       if (statp->_u._ext.ext)
-               return (statp->_u._ext.ext->bsuffix);
-       return ("ip6.arpa");
-}
-
 void
 res_setservers(res_state statp, const union res_sockaddr_union *set, int cnt) {
        int i, nserv;
index 474128fd096c1c45529fed74843d8577aad36a47..af1a1d538757bb90cb000cc051c42cc48587e1b1 100644 (file)
@@ -70,7 +70,7 @@
 
 #if defined(LIBC_SCCS) && !defined(lint)
 static const char sccsid[] = "@(#)res_mkquery.c        8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_mkquery.c,v 1.2 2001/11/01 04:59:17 marka Exp $";
+static const char rcsid[] = "$Id: res_mkquery.c,v 1.3 2003/06/03 04:39:34 marka Exp $";
 #endif /* LIBC_SCCS and not lint */
 
 #include "port_before.h"
@@ -105,7 +105,7 @@ res_nmkquery(res_state statp,
             int buflen)                /* size of buffer */
 {
        register HEADER *hp;
-       register u_char *cp;
+       register u_char *cp, *ep;
        register int n;
        u_char *dnptrs[20], **dpp, **lastdnptr;
 
@@ -128,7 +128,7 @@ res_nmkquery(res_state statp,
        hp->rd = (statp->options & RES_RECURSE) != 0;
        hp->rcode = NOERROR;
        cp = buf + HFIXEDSZ;
-       buflen -= HFIXEDSZ;
+       ep = buf + buflen;
        dpp = dnptrs;
        *dpp++ = buf;
        *dpp++ = NULL;
@@ -139,15 +139,15 @@ res_nmkquery(res_state statp,
        switch (op) {
        case QUERY:     /*FALLTHROUGH*/
        case NS_NOTIFY_OP:
-               if ((buflen -= QFIXEDSZ) < 0)
+               if (ep - cp < QFIXEDSZ)
                        return (-1);
-               if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0)
+               if ((n = dn_comp(dname, cp, ep - cp - QFIXEDSZ, dnptrs,
+                   lastdnptr)) < 0)
                        return (-1);
                cp += n;
-               buflen -= n;
-               __putshort(type, cp);
+               ns_put16(type, cp);
                cp += INT16SZ;
-               __putshort(class, cp);
+               ns_put16(class, cp);
                cp += INT16SZ;
                hp->qdcount = htons(1);
                if (op == QUERY || data == NULL)
@@ -155,19 +155,20 @@ res_nmkquery(res_state statp,
                /*
                 * Make an additional record for completion domain.
                 */
-               buflen -= RRFIXEDSZ;
-               n = dn_comp((const char *)data, cp, buflen, dnptrs, lastdnptr);
+               if ((ep - cp) < RRFIXEDSZ)
+                       return (-1);
+               n = dn_comp((const char *)data, cp, ep - cp - RRFIXEDSZ,
+                           dnptrs, lastdnptr);
                if (n < 0)
                        return (-1);
                cp += n;
-               buflen -= n;
-               __putshort(T_NULL, cp);
+               ns_put16(T_NULL, cp);
                cp += INT16SZ;
-               __putshort(class, cp);
+               ns_put16(class, cp);
                cp += INT16SZ;
-               __putlong(0, cp);
+               ns_put32(0, cp);
                cp += INT32SZ;
-               __putshort(0, cp);
+               ns_put16(0, cp);
                cp += INT16SZ;
                hp->arcount = htons(1);
                break;
@@ -176,16 +177,16 @@ res_nmkquery(res_state statp,
                /*
                 * Initialize answer section
                 */
-               if (buflen < 1 + RRFIXEDSZ + datalen)
+               if (ep - cp < 1 + RRFIXEDSZ + datalen)
                        return (-1);
                *cp++ = '\0';   /* no domain name */
-               __putshort(type, cp);
+               ns_put16(type, cp);
                cp += INT16SZ;
-               __putshort(class, cp);
+               ns_put16(class, cp);
                cp += INT16SZ;
-               __putlong(0, cp);
+               ns_put32(0, cp);
                cp += INT32SZ;
-               __putshort(datalen, cp);
+               ns_put16(datalen, cp);
                cp += INT16SZ;
                if (datalen) {
                        memcpy(cp, data, datalen);
@@ -207,15 +208,14 @@ res_nmkquery(res_state statp,
 #endif
 
 int
-res_nopt(statp, n0, buf, buflen, anslen)
-       res_state statp;
-       int n0;
-       u_char *buf;            /* buffer to put query */
-       int buflen;             /* size of buffer */
-       int anslen;             /* answer buffer length */
+res_nopt(res_state statp,
+        int n0,                /* current offset in buffer */
+        u_char *buf,           /* buffer to put query */
+        int buflen,            /* size of buffer */
+        int anslen)            /* UDP answer buffer size */
 {
        register HEADER *hp;
-       register u_char *cp;
+       register u_char *cp, *ep;
        u_int16_t flags = 0;
 
 #ifdef DEBUG
@@ -225,17 +225,16 @@ res_nopt(statp, n0, buf, buflen, anslen)
 
        hp = (HEADER *) buf;
        cp = buf + n0;
-       buflen -= n0;
+       ep = buf + buflen;
 
-       if (buflen < 1 + RRFIXEDSZ)
-               return -1;
+       if ((ep - cp) < 1 + RRFIXEDSZ)
+               return (-1);
 
        *cp++ = 0;      /* "." */
-       buflen--;
 
-       __putshort(T_OPT, cp);  /* TYPE */
+       ns_put16(T_OPT, cp);    /* TYPE */
        cp += INT16SZ;
-       __putshort(anslen & 0xffff, cp);        /* CLASS = UDP payload size */
+       ns_put16(anslen & 0xffff, cp);  /* CLASS = UDP payload size */
        cp += INT16SZ;
        *cp++ = NOERROR;        /* extended RCODE */
        *cp++ = 0;              /* EDNS version */
@@ -246,13 +245,12 @@ res_nopt(statp, n0, buf, buflen, anslen)
 #endif
                flags |= NS_OPT_DNSSEC_OK;
        }
-       __putshort(flags, cp);
+       ns_put16(flags, cp);
        cp += INT16SZ;
-       __putshort(0, cp);      /* RDLEN */
+       ns_put16(0, cp);        /* RDLEN */
        cp += INT16SZ;
        hp->arcount = htons(ntohs(hp->arcount) + 1);
-       buflen -= RRFIXEDSZ;
 
-       return cp - buf;
+       return (cp - buf);
 }
 #endif
index 3eea590e75ee9b0fc748ffebdd76e1fc45c9db82..bb79f26d5a6f3211eec9ac5157008605ede2480b 100644 (file)
@@ -21,7 +21,7 @@
  */
 
 #if !defined(lint) && !defined(SABER)
-static const char rcsid[] = "$Id: res_mkupdate.c,v 1.1 2001/03/29 06:31:59 marka Exp $";
+static const char rcsid[] = "$Id: res_mkupdate.c,v 1.2 2003/06/03 04:39:34 marka Exp $";
 #endif /* not lint */
 
 #include "port_before.h"
@@ -302,7 +302,7 @@ res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) {
 
                        if (!getword_str(buf2, sizeof buf2, &startp, endp))
                                return (-1);
-                       n = dn_comp(buf2, cp, buflen, dnptrs, lastdnptr);
+                       n = dn_comp(buf2, cp, buflen, NULL, NULL);
                        if (n < 0)
                                return (-1);
                        cp += n;
@@ -482,8 +482,10 @@ res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) {
                                char *ulendp;
                                u_int32_t ottl;
 
+                               errno = 0;
                                ottl = strtoul(buf2, &ulendp, 10);
-                               if (ulendp != NULL && *ulendp != '\0')
+                               if (errno != 0 ||
+                                   (ulendp != NULL && *ulendp != '\0'))
                                        return (-1);
                                ShrinkBuffer(INT32SZ);
                                PUTLONG(ottl, cp);
@@ -572,7 +574,7 @@ res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) {
                        /* next name */
                        if (!getword_str(buf2, sizeof buf2, &startp, endp))
                                return (-1);
-                       n = dn_comp(buf2, cp, buflen, dnptrs, lastdnptr);
+                       n = dn_comp(buf2, cp, buflen, NULL, NULL);
                        if (n < 0)
                                return (-1);
                        cp += n;
@@ -636,6 +638,62 @@ res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) {
                        memcpy(cp, &in6a, NS_IN6ADDRSZ);
                        cp += NS_IN6ADDRSZ;
                        break;
+               case ns_t_naptr:
+                       /* Order Preference Flags Service Replacement Regexp */
+                       /* Order */
+                       n = getnum_str(&startp, endp);
+                       if (n < 0 || n > 65535)
+                               return (-1);
+                       ShrinkBuffer(INT16SZ);
+                       PUTSHORT(n, cp);
+                       /* Preference */
+                       n = getnum_str(&startp, endp);
+                       if (n < 0 || n > 65535)
+                               return (-1);
+                       ShrinkBuffer(INT16SZ);
+                       PUTSHORT(n, cp);
+                       /* Flags */
+                       if ((n = getstr_str(buf2, sizeof buf2,
+                                       &startp, endp)) < 0) {
+                               return (-1);
+                       }
+                       if (n > 255)
+                               return (-1);
+                       ShrinkBuffer(n+1);
+                       *cp++ = n;
+                       memcpy(cp, buf2, n);
+                       cp += n;
+                       /* Service Classes */
+                       if ((n = getstr_str(buf2, sizeof buf2,
+                                       &startp, endp)) < 0) {
+                               return (-1);
+                       }
+                       if (n > 255)
+                               return (-1);
+                       ShrinkBuffer(n+1);
+                       *cp++ = n;
+                       memcpy(cp, buf2, n);
+                       cp += n;
+                       /* Pattern */
+                       if ((n = getstr_str(buf2, sizeof buf2,
+                                       &startp, endp)) < 0) {
+                               return (-1);
+                       }
+                       if (n > 255)
+                               return (-1);
+                       ShrinkBuffer(n+1);
+                       *cp++ = n;
+                       memcpy(cp, buf2, n);
+                       cp += n;
+                       /* Replacement */
+                       if (!getword_str(buf2, sizeof buf2, &startp, endp))
+                               return (-1);
+                       n = dn_comp(buf2, cp, buflen, NULL, NULL);
+                       if (n < 0)
+                               return (-1);
+                       cp += n;
+                       ShrinkBuffer(n);
+                       break;
                default:
                        return (-1);
                } /*switch*/
@@ -807,7 +865,7 @@ gethexnum_str(u_char **startpp, u_char *endp) {
 }
 
 /*
- * Get a whitespace delimited base 16 number from a string (not file) into buf
+ * Get a whitespace delimited base 10 number from a string (not file) into buf
  * update the start pointer to point after the number in the string.
  */
 static int
index ec9b384b91168c9fcd6741832c2ec5de2e050d76..d7b66cd691bc698b9a7421c1ef40312d1e3c80a5 100644 (file)
@@ -11,7 +11,6 @@ struct __res_state_ext {
                } addr, mask;
        } sort_list[MAXRESOLVSORT];
        char nsuffix[64];
-       char bsuffix[64];
        char nsuffix2[64];
 };
 
index ee928cfe270fbc5ec1e05897ebc580ef7de5d877..783893fb0bd6ff18e92a990894660bfb9c951fbc 100644 (file)
@@ -70,7 +70,7 @@
 
 #if defined(LIBC_SCCS) && !defined(lint)
 static const char sccsid[] = "@(#)res_query.c  8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_query.c,v 1.4 2001/11/01 04:59:18 marka Exp $";
+static const char rcsid[] = "$Id: res_query.c,v 1.5 2003/06/03 04:39:34 marka Exp $";
 #endif /* LIBC_SCCS and not lint */
 
 #include "port_before.h"
@@ -167,8 +167,11 @@ again:
        if (hp->rcode != NOERROR || ntohs(hp->ancount) == 0) {
 #ifdef DEBUG
                if (statp->options & RES_DEBUG)
-                       printf(";; rcode = %d, ancount=%d\n", hp->rcode,
-                           ntohs(hp->ancount));
+                       printf(";; rcode = (%s), counts = an:%d ns:%d ar:%d\n",
+                              p_rcode(hp->rcode),
+                              ntohs(hp->ancount),
+                              ntohs(hp->nscount),
+                              ntohs(hp->arcount));
 #endif
                switch (hp->rcode) {
                case NXDOMAIN:
index c58dddbf126ec5e9d1cb8fe22a05dacb59e5dd9f..4065c53f79ede2bd2cb2cfb33d5ef4c9830b697e 100644 (file)
@@ -70,7 +70,7 @@
 
 #if defined(LIBC_SCCS) && !defined(lint)
 static const char sccsid[] = "@(#)res_send.c   8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_send.c,v 1.6 2002/05/03 06:13:27 marka Exp $";
+static const char rcsid[] = "$Id: res_send.c,v 1.7 2003/06/03 04:39:34 marka Exp $";
 #endif /* LIBC_SCCS and not lint */
 
 /*
@@ -171,6 +171,9 @@ res_ourserver_p(const res_state statp, const struct sockaddr *sa) {
                        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);
@@ -386,6 +389,8 @@ res_nsend(res_state statp,
                int nsaplen;
                nsap = get_nsaddr(statp, ns);
                nsaplen = get_salen(nsap);
+               statp->_flags &= ~RES_F_LASTMASK;
+               statp->_flags |= (ns << RES_F_LASTSHIFT);
  same_ns:
                if (statp->qhook) {
                        int done = 0, loops = 0;
@@ -623,7 +628,7 @@ send_vc(res_state statp,
        /*
         * Send length & message
         */
-       putshort((u_short)buflen, (u_char*)&len);
+       ns_put16((u_short)buflen, (u_char*)&len);
        iov[0] = evConsIovec(&len, INT16SZ);
        DE_CONST(buf, tmp);
        iov[1] = evConsIovec(tmp, buflen);
index 221f62e09b0ccc7de81dc2c6a0f5004fd39291c5..6019fe59faf7e7aeafc85c17f9105f1f3692b8a0 100644 (file)
@@ -1,5 +1,5 @@
 #if !defined(lint) && !defined(SABER)
-static const char rcsid[] = "$Id: res_update.c,v 1.9 2002/05/06 04:12:54 marka Exp $";
+static const char rcsid[] = "$Id: res_update.c,v 1.10 2003/06/03 04:39:35 marka Exp $";
 #endif /* not lint */
 
 /*
@@ -77,7 +77,7 @@ struct zonegrp {
 
 /* Forward. */
 
-static void    res_dprintf(const char *, ...);
+static void    res_dprintf(const char *, ...) ISC_FORMAT_PRINTF(1, 2);
 
 /* Macros. */
 
@@ -92,12 +92,18 @@ static void res_dprintf(const char *, ...);
 int
 res_nupdate(res_state statp, ns_updrec *rrecp_in, ns_tsig_key *key) {
        ns_updrec *rrecp;
-       u_char answer[PACKETSZ], packet[2*PACKETSZ];
+       u_char answer[PACKETSZ];
+       u_char *packet;
        struct zonegrp *zptr, tgrp;
        LIST(struct zonegrp) zgrps;
        int nzones = 0, nscount = 0, n;
        union res_sockaddr_union nsaddrs[MAXNS];
 
+       packet = malloc(NS_MAXMSG);
+       if (packet == NULL) {
+               DPRINTF(("malloc failed"));
+               return (0);
+       }
        /* Thread all of the updates onto a list of groups. */
        INIT_LIST(zgrps);
        memset(&tgrp, 0, sizeof (tgrp));
@@ -150,7 +156,7 @@ res_nupdate(res_state statp, ns_updrec *rrecp_in, ns_tsig_key *key) {
 
                /* Marshall the update message. */
                n = res_nmkupdate(statp, HEAD(zptr->z_rrlist),
-                                 packet, sizeof packet);
+                                 packet, NS_MAXMSG);
                DPRINTF(("res_mkupdate -> %d", n));
                if (n < 0)
                        goto done;
@@ -188,6 +194,7 @@ res_nupdate(res_state statp, ns_updrec *rrecp_in, ns_tsig_key *key) {
        if (nscount != 0)
                res_setservers(statp, nsaddrs, nscount);
 
+       free(packet);
        return (nzones);
 }