--- old/usr/src/lib/libresolv2/Makefile Fri Jul 3 12:24:02 2009 +++ new/usr/src/lib/libresolv2/Makefile Fri Jul 3 12:24:01 2009 @@ -19,11 +19,12 @@ # CDDL HEADER END # # -# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # + include ../../Makefile.master include ../Makefile.lib @@ -39,14 +40,7 @@ SUBDIRS= include $(MACH) $(BUILD64)SUBDIRS += $(MACH64) -SUBDIRS += .WAIT irs -# EXPORT DELETE START -# CRYPT DELETE START -SUBDIRS += cylink dnssafe -# CRYPT DELETE END -# EXPORT DELETE END - all := TARGET= all clean := TARGET= clean clobber := TARGET= clobber @@ -85,31 +79,6 @@ check: $(CHECKHDRS) $(CHKMANIFEST) -# EXPORT DELETE START -# CRYPT DELETE START -# Special targets to clean up the source tree for export distribution -# Warning: These target change the source tree -EXPORT_SRC: - $(RM) Makefile+ - $(SED) -e "/^# EXPORT DELETE START/,/^# EXPORT DELETE END/d" \ - < Makefile > Makefile+ - $(MV) Makefile+ Makefile - $(CHMOD) 444 Makefile - /usr/bin/find cylink dnssafe common/cylink common/dnssafe \ - -name SCCS -prune -o -type f -exec $(RM) {} \; - -CRYPT_SRC: - $(RM) Makefile+ - $(SED) -e "/^# CRYPT DELETE START/,/^# CRYPT DELETE END/d" \ - < Makefile > Makefile+ - $(MV) Makefile+ Makefile - $(CHMOD) 444 Makefile - /usr/bin/find cylink dnssafe common/cylink common/dnssafe \ - -name SCCS -prune -o -type f -exec $(RM) {} \; - -# CRYPT DELETE END -# EXPORT DELETE END - _msg: $(MSGDOMAIN) $(POFILE) $(RM) $(MSGDOMAIN)/$(POFILE) $(CP) $(POFILE) $(MSGDOMAIN) @@ -128,3 +97,4 @@ @cd $@; pwd; $(MAKE) $(TARGET); echo FRC: + --- old/usr/src/lib/libresolv2/Makefile.com Fri Jul 3 12:24:03 2009 +++ new/usr/src/lib/libresolv2/Makefile.com Fri Jul 3 12:24:03 2009 @@ -19,7 +19,7 @@ # CDDL HEADER END # # -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "%Z%%M% %I% %E% SMI" @@ -33,70 +33,48 @@ gettimeofday.o setenv.o strerror.o utimes.o \ mktemp.o setitimer.o strpbrk.o writev.o -DSTOBJS= dst_api.o prandom.o support.o +DSTOBJS= dst_api.o support.o hmac_link.o -DSTLINKOBJS= bsafe_link.o cylink_link.o eay_dss_link.o hmac_link.o \ - rsaref_link.o +# inet_addr, inet_pton, inet_ntop, and inet_ntoa removed due to overlap with +# libnsl +INETOBJS= inet_net_pton.o inet_neta.o inet_lnaof.o \ + inet_netof.o nsap_addr.o inet_makeaddr.o \ + inet_network.o inet_net_ntop.o inet_cidr_ntop.o \ + inet_cidr_pton.o inet_data.o -INETOBJS= inet_net_pton.o inet_ntop.o \ - inet_neta.o inet_pton.o inet_lnaof.o inet_netof.o \ - nsap_addr.o inet_makeaddr.o inet_network.o \ - inet_net_ntop.o inet_ntoa.o inet_cidr_ntop.o \ - inet_cidr_pton.o inet_data.o +# build only the IRS objects that the ISC libbind's make would +IRSTHROBJS= gethostent_r.o getnetent_r.o getnetgrent_r.o \ + getprotoent_r.o getservent_r.o +IRSOBJS= ${IRSTHROBJS} \ + dns.o dns_ho.o dns_nw.o dns_pr.o \ + dns_sv.o gai_strerror.o gen.o gen_ho.o \ + gen_ng.o gen_nw.o gen_pr.o gen_sv.o \ + getaddrinfo.o gethostent.o getnameinfo.o getnetent.o \ + getnetgrent.o getprotoent.o getservent.o hesiod.o \ + irp.o irp_ho.o irp_ng.o irp_nw.o \ + irp_pr.o irp_sv.o irpmarshall.o irs_data.o \ + lcl.o lcl_ho.o lcl_ng.o lcl_nw.o \ + lcl_pr.o lcl_sv.o nis.o nul_ng.o \ + util.o -IRSOBJS= dns.o gen_ho.o getnetgrent.o lcl_ng.o \ - nis_nw.o dns_gr.o gen_ng.o getprotoent.o \ - lcl_nw.o nis_pr.o dns_ho.o gen_nw.o \ - getpwent.o lcl_pr.o nis_pw.o dns_nw.o \ - gen_pr.o getservent.o lcl_pw.o nis_sv.o \ - dns_pr.o gen_pw.o hesiod.o lcl_sv.o \ - nul_ng.o dns_pw.o gen_sv.o irs_data.o \ - nis.o util.o dns_sv.o getgrent.o \ - lcl.o nis_gr.o gen.o gethostent.o \ - lcl_gr.o nis_ho.o gen_gr.o getnetent.o \ - lcl_ho.o nis_ng.o getpwent_r.o \ - getservent_r.o gai_strerror.o getgrent_r.o \ - gethostent_r.o getnetent_r.o getnetgrent_r.o \ - getprotoent_r.o getnameinfo.o irp.o irpmarshall.o \ - irp_ho.o irp_nw.o irp_pr.o irp_sv.o \ - irp_gr.o irp_ng.o irp_pw.o +ISCOBJS= assertions.o base64.o bitncmp.o ctl_clnt.o \ + ctl_p.o ctl_srvr.o ev_connects.o ev_files.o \ + ev_streams.o ev_timers.o ev_waits.o eventlib.o \ + heap.o hex.o logging.o memcluster.o \ + movefile.o tree.o -IRSRESOBJS= dns.o gen_ho.o lcl_ng.o dns_gr.o \ - gen_ng.o lcl_nw.o dns_ho.o gen_nw.o \ - lcl_pr.o dns_nw.o gen_pr.o lcl_pw.o \ - dns_pr.o gen_pw.o hesiod.o lcl_sv.o \ - nul_ng.o dns_pw.o gen_sv.o irs_data.o \ - util.o dns_sv.o lcl.o gen.o \ - gethostent.o lcl_gr.o gen_gr.o lcl_ho.o \ - gethostent_r.o getaddrinfo.o +NAMESEROBJS= ns_date.o ns_name.o ns_netint.o ns_parse.o \ + ns_print.o ns_samedomain.o ns_sign.o ns_ttl.o \ + ns_verify.o ns_rdata.o ns_newmsg.o -IRSDYNOBJS= nis_nw.o nis_pr.o nis_pw.o nis_sv.o \ - nis.o nis_gr.o nis_ho.o nis_ng.o \ - irp.o irpmarshall.o irp_ho.o irp_nw.o \ - irp_pr.o irp_sv.o irp_gr.o irp_ng.o \ - irp_pw.o getnetent.o getpwent_r.o getgrent_r.o \ - getservent_r.o getnetent_r.o getnetgrent_r.o getgrent.o \ - getnetgrent.o getprotoent.o getpwent.o getservent.o \ - getprotoent_r.o getnameinfo.o gai_strerror.o +RESOLVOBJS= herror.o mtctxres.o res_comp.o res_data.o \ + res_debug.o res_findzonecut.o res_init.o \ + res_mkquery.o res_mkupdate.o res_query.o res_send.o \ + res_sendsigned.o res_update.o -ISCOBJS= base64.o ev_files.o ev_waits.o logging.o \ - bitncmp.o ev_streams.o eventlib.o tree.o \ - ev_connects.o ev_timers.o heap.o assertions.o \ - memcluster.o ctl_p.o ctl_clnt.o ctl_srvr.o \ - hex.o +SUNWOBJS= sunw_mtctxres.o sunw_updrec.o sunw_wrappers.o -NAMESEROBJS= ns_name.o ns_netint.o ns_parse.o ns_print.o \ - ns_ttl.o ns_sign.o ns_verify.o ns_date.o \ - ns_samedomain.o - -RESOLVOBJS= herror.o res_debug.o res_data.o res_comp.o \ - res_init.o res_mkquery.o res_mkupdate.o res_query.o \ - res_send.o res_update.o res_sendsigned.o \ - res_findzonecut.o - -SUNWOBJS= sunw_mtctxres.o sunw_dst_init.o sunw_irs_init.o sunw_updrec.o - -OBJECTS= $(BSDOBJS) $(DSTOBJS) $(INETOBJS) $(IRSRESOBJS) $(ISCOBJS) \ +OBJECTS= $(BSDOBJS) $(DSTOBJS) $(INETOBJS) $(IRSOBJS) $(ISCOBJS) \ $(NAMESEROBJS) $(RESOLVOBJS) $(SUNWOBJS) # include library definitions @@ -105,11 +83,14 @@ # install this library in the root filesystem include ../../Makefile.rootfs +# CC -v complains about things we aren't going to change in the ISC code +CCVERBOSE= + SRCDIR = ../common SRCS= $(BSDOBJS:%.o=../common/bsd/%.c) \ $(DSTOBJS:%.o=../common/dst/%.c) \ $(INETOBJS:%.o=../common/inet/%.c) \ - $(IRSRESOBJS:%.o=../common/irs/%.c) \ + $(IRSOBJS:%.o=../common/irs/%.c) \ $(ISCOBJS:%.o=../common/isc/%.c) \ $(NAMESEROBJS:%.o=../common/nameser/%.c) \ $(RESOLVOBJS:%.o=../common/resolv/%.c) \ @@ -120,20 +101,9 @@ $(LINTLIB):= SRCS = ../common/llib-lresolv # Local Libresolv definitions -SOLCOMPAT = -Dgethostbyname=res_gethostbyname \ - -Dgethostbyaddr=res_gethostbyaddr -Dgetnetbyname=res_getnetbyname \ - -Dgethostbyname2=res_gethostbyname2\ - -Dgetnetbyaddr=res_getnetbyaddr -Dsethostent=res_sethostent \ - -Dendhostent=res_endhostent -Dgethostent=res_gethostent \ - -Dsetnetent=res_setnetent -Dendnetent=res_endnetent \ - -Dgetnetent=res_getnetent -Dsocket=_socket \ - -Dgetipnodebyname=res_getipnodebyname \ - -Dgetipnodebyaddr=res_getipnodebyaddr \ - -Dfreehostent=res_freehostent \ - -Dgetaddrinfo=res_getaddrinfo \ - -Dfreeaddrinfo=res_freeaddrinfo -CRYPTFLAGS= -DCYLINK_DSS -DHMAC_MD5 -DUSE_MD5 -DDNSSAFE +SOLCOMPAT = -Dsocket=_socket +CRYPTFLAGS= -DHMAC_MD5 -DUSE_MD5 LOCFLAGS += $(CRYPTFLAGS) LOCFLAGS += -D_SYS_STREAM_H -D_REENTRANT -DSVR4 -DSUNW_OPTIONS \ @@ -141,8 +111,9 @@ CPPFLAGS += $(LOCFLAGS) DYNFLAGS += $(ZNODELETE) -LDLIBS += -lsocket -lnsl -lc +LDLIBS += -lsocket -lnsl -lc -lmd + .KEEP_STATE: all: $(LIBS) --- old/usr/src/lib/libresolv2/include/res_update.h Fri Jul 3 12:24:04 2009 +++ new/usr/src/lib/libresolv2/include/res_update.h Fri Jul 3 12:24:04 2009 @@ -1,11 +1,11 @@ /* - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" /* + * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 1999 by Internet Software Consortium, Inc. * * Permission to use, copy, modify, and distribute this software for any @@ -12,57 +12,56 @@ * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* - * $Id: res_update.h,v 8.1 1999/10/07 08:24:13 vixie Exp $ + * $Id: res_update.h,v 1.3 2005/04/27 04:56:15 sra Exp $ */ #ifndef __RES_UPDATE_H #define __RES_UPDATE_H +/*! \file */ + #include -#include #include #include #include -#ifdef ORIGINAL_ISC_CODE -#else -/* - * ISC changed the ns_updrec structure. However, it's a public interface - * in Solaris, so it's time to break out that old #define magic. - */ -#define ns_updrec __ISC_ns_updrec +#ifndef ORIGINAL_ISC_CODE +/* definition of u_int32_t needed on Solaris */ +#include +/* need to rename ns_updrec before we define it here */ +#include "arpa/port_nameser.h" #endif /* ORIGINAL_ISC_CODE */ -/* + + +/*% * This RR-like structure is particular to UPDATE. */ struct ns_updrec { LINK(struct ns_updrec) r_link, r_glink; - ns_sect r_section; /* ZONE/PREREQUISITE/UPDATE */ - char * r_dname; /* owner of the RR */ - ns_class r_class; /* class number */ - ns_type r_type; /* type number */ - u_int32_t r_ttl; /* time to live */ - u_char * r_data; /* rdata fields as text string */ - u_int r_size; /* size of r_data field */ - int r_opcode; /* type of operation */ + ns_sect r_section; /*%< ZONE/PREREQUISITE/UPDATE */ + char * r_dname; /*%< owner of the RR */ + ns_class r_class; /*%< class number */ + ns_type r_type; /*%< type number */ + u_int32_t r_ttl; /*%< time to live */ + u_char * r_data; /*%< rdata fields as text string */ + u_int r_size; /*%< size of r_data field */ + int r_opcode; /*%< type of operation */ /* following fields for private use by the resolver/server routines */ - struct databuf *r_dp; /* databuf to process */ - struct databuf *r_deldp; /* databuf's deleted/overwritten */ - u_int r_zone; /* zone number on server */ + struct databuf *r_dp; /*%< databuf to process */ + struct databuf *r_deldp; /*%< databuf's deleted/overwritten */ + u_int r_zone; /*%< zone number on server */ }; typedef struct ns_updrec ns_updrec; - typedef LIST(ns_updrec) ns_updque; #ifdef ORIGINAL_ISC_CODE @@ -73,27 +72,10 @@ #define res_nmkupdate __res_nmkupdate #define res_nupdate __res_nupdate #else -/* - * For BIND 8.2.2, ISC removed the dynamic update functions, and the - * definition of the ns_updrec structure, from the public include files - * (, . However, res_update(), res_mkupdate(), - * and res_mkupdrec() are in the public libresolv interface in Solaris, - * so we can't easily remove them. Thus, ISC's new versions of res_mkupdate() - * etc. can't be exposed under their original names. - * - * res_nmkupdate() and res_nupdate are new. We could either change them - * to accept the ns_updrec, or leave them unchanged and - * undocumented. Since ISC may change ns_updrec again, we pick the latter - * solution for now. - */ -#define res_mkupdate __ISC_res_mkupdate -#define res_update __ISC_res_update -#define res_mkupdrec __ISC_res_mkupdrec -#define res_freeupdrec __ISC_res_freeupdrec -#define res_nmkupdate __ISC_res_nmkupdate -#define res_nupdate __ISC_res_nupdate +/* these are renamed in "port_nameser.h" */ #endif /* ORIGINAL_ISC_CODE */ + int res_mkupdate __P((ns_updrec *, u_char *, int)); int res_update __P((ns_updrec *)); ns_updrec * res_mkupdrec __P((int, const char *, u_int, u_int, u_long)); @@ -102,3 +84,5 @@ int res_nupdate __P((res_state, ns_updrec *, ns_tsig_key *)); #endif /*__RES_UPDATE_H*/ + +/*! \file */ --- old/usr/src/lib/libresolv2/include/port_before.h Fri Jul 3 12:24:05 2009 +++ new/usr/src/lib/libresolv2/include/port_before.h Fri Jul 3 12:24:05 2009 @@ -1,128 +1,189 @@ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" -#ifdef SUNW_OPTIONS -#include "conf/sunoptions.h" +/* + * Copyright (C) 2005-2008 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: port_before.h.in,v 1.31 2008/02/28 05:36:10 marka Exp $ */ + +#ifndef port_before_h +#define port_before_h +/* Solaris-specific changes */ +#include "sunw_port_before.h" +#include + +#ifdef NEED_SUN4PROTOS +#define _PARAMS(x) x #endif -#define __EXTENSIONS__ -/* #define SVR4 */ -#ifdef WANT_IRS_NIS -#undef WANT_IRS_NIS +struct group; /* silence warning */ +struct passwd; /* silence warning */ +struct timeval; /* silence warning */ +struct timezone; /* silence warning */ + +#ifdef HAVE_SYS_TIMERS_H +#include #endif -#undef WANT_IRS_PW -#undef WANT_IRS_GR -#define SIG_FN void -#define ISC_SOCKLEN_T int -#include "os_version.h" -#if (OS_MAJOR == 5 && OS_MINOR < 5) -#undef HAS_PTHREADS -#else -#define HAS_PTHREADS -#endif +#include -#if defined(HAS_PTHREADS) && defined(_REENTRANT) -#define DO_PTHREADS +#ifdef ISC_PLATFORM_NEEDTIMESPEC +#include /* For time_t */ +struct timespec { + time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; #endif +#ifndef HAVE_MEMMOVE +#define memmove(a,b,c) bcopy(b,a,c) +#endif +#undef WANT_IRS_GR +#undef WANT_IRS_NIS +#undef WANT_IRS_PW + +#define BSD_COMP 1 +#define USE_POLL 1 +#define HAVE_MD5 1 +#define SOLARIS2 1 + +/* DO_PTHREADS is conditionally defined in sunw_port_before.h + * #define DO_PTHREADS 1 */ +#define GETGROUPLIST_ARGS const char *name, gid_t basegid, gid_t *groups, int *ngroups +#define GETNETBYADDR_ADDR_T long +#define SETPWENT_VOID 1 +#define SETGRENT_VOID 1 + +#define NET_R_ARGS char *buf, int buflen +#define NET_R_BAD NULL +#define NET_R_COPY buf, buflen +#define NET_R_COPY_ARGS NET_R_ARGS +#define NET_R_END_RESULT(x) /*empty*/ +#define NET_R_END_RETURN void +#undef NET_R_ENT_ARGS /*empty*/ +#define NET_R_OK nptr +#define NET_R_RETURN struct netent * +#undef NET_R_SET_RESULT /*empty*/ +#undef NET_R_SETANSWER +#define NET_R_SET_RETURN void +#undef NETENT_DATA + #define GROUP_R_RETURN struct group * #define GROUP_R_SET_RETURN void #undef GROUP_R_SET_RESULT /*empty*/ #define GROUP_R_END_RETURN void -#undef GROUP_R_END_RESULT /*empty*/ +#define GROUP_R_END_RESULT(x) /*empty*/ #define GROUP_R_ARGS char *buf, int buflen -#undef GROUP_R_ENT_ARGS /*empty*/ +#define GROUP_R_ENT_ARGS void #define GROUP_R_OK gptr #define GROUP_R_BAD NULL -#define GETGROUPLIST_ARGS const char *name, gid_t basegid, gid_t *groups, \ - int *ngroups -#define HOST_R_RETURN struct hostent * -#define HOST_R_SET_RETURN void -#undef HOST_R_SET_RESULT /*empty*/ -#define HOST_R_END_RETURN void -#define HOST_R_END_RESULT(x) /*empty*/ #define HOST_R_ARGS char *buf, int buflen, int *h_errnop -#undef HOST_R_ENT_ARGS /*empty*/ +#define HOST_R_BAD NULL #define HOST_R_COPY buf, buflen #define HOST_R_COPY_ARGS char *buf, int buflen +#define HOST_R_END_RESULT(x) /*empty*/ +#define HOST_R_END_RETURN void +#undef HOST_R_ENT_ARGS /*empty*/ #define HOST_R_ERRNO *h_errnop = h_errno #define HOST_R_OK hptr -#define HOST_R_BAD NULL +#define HOST_R_RETURN struct hostent * +#undef HOST_R_SETANSWER +#undef HOST_R_SET_RESULT +#define HOST_R_SET_RETURN void +#undef HOSTENT_DATA -#define NET_R_RETURN struct netent * -#define NET_R_SET_RETURN void -#undef NET_R_SET_RESULT /*empty*/ -#define NET_R_END_RETURN void -#define NET_R_END_RESULT(x) /*empty*/ -#define NET_R_ARGS char *buf, int buflen -#undef NET_R_ENT_ARGS /*empty*/ -#define NET_R_COPY buf, buflen -#define NET_R_COPY_ARGS NET_R_ARGS -#define NET_R_OK nptr -#define NET_R_BAD NULL - -#define NGR_R_RETURN int -#define NGR_R_SET_RETURN void -#undef NGR_R_SET_RESULT /*empty*/ -#define NGR_R_END_RETURN void -#ifdef ORIGINAL_ISC_CODE -#undef NGR_R_END_RESULT /*empty*/ -#else -#define NGR_R_END_RESULT(x) /*empty*/ -#endif #define NGR_R_ARGS char *buf, int buflen -#undef NGR_R_ENT_ARGS /*empty*/ +#define NGR_R_BAD (0) #define NGR_R_COPY buf, buflen #define NGR_R_COPY_ARGS NGR_R_ARGS +#define NGR_R_CONST +#define NGR_R_END_RESULT(x) /*empty*/ +#define NGR_R_END_RETURN void +#undef NGR_R_END_ARGS /*empty*/ #define NGR_R_OK 1 -#define NGR_R_BAD (0) +#define NGR_R_RETURN int +#define NGR_R_SET_CONST const +#undef NGR_R_SET_RESULT /*empty*/ +#define NGR_R_SET_RETURN void +#undef NGR_R_SET_ARGS -#define PROTO_R_RETURN struct protoent * -#define PROTO_R_SET_RETURN void -#undef PROTO_R_SET_RESULT /*empty*/ -#define PROTO_R_END_RETURN void -#define PROTO_R_END_RESULT(x) /*empty*/ + +#if !defined(NGR_R_SET_ARGS) && defined(NGR_R_END_ARGS) +#define NGR_R_SET_ARGS NGR_R_END_ARGS +#endif + #define PROTO_R_ARGS char *buf, int buflen -#undef PROTO_R_ENT_ARGS /*empty*/ +#define PROTO_R_BAD NULL #define PROTO_R_COPY buf, buflen #define PROTO_R_COPY_ARGS PROTO_R_ARGS +#define PROTO_R_END_RESULT(x) /*empty*/ +#define PROTO_R_END_RETURN void +#undef PROTO_R_ENT_ARGS /*empty*/ +#undef PROTO_R_ENT_UNUSED #define PROTO_R_OK pptr -#define PROTO_R_BAD NULL +#undef PROTO_R_SETANSWER +#define PROTO_R_RETURN struct protoent * +#undef PROTO_R_SET_RESULT +#define PROTO_R_SET_RETURN void +#undef PROTOENT_DATA -#define PASS_R_RETURN struct passwd * -#define PASS_R_SET_RETURN void -#undef PASS_R_SET_RESULT /*empty*/ -#define PASS_R_END_RETURN void -#undef PASS_R_END_RESULT /*empty*/ #define PASS_R_ARGS char *buf, int buflen -#undef PASS_R_ENT_ARGS /*empty*/ +#define PASS_R_BAD NULL #define PASS_R_COPY buf, buflen #define PASS_R_COPY_ARGS PASS_R_ARGS +#define PASS_R_END_RESULT(x) /*empty*/ +#define PASS_R_END_RETURN void +#undef PASS_R_ENT_ARGS #define PASS_R_OK pwptr -#define PASS_R_BAD NULL +#define PASS_R_RETURN struct passwd * +#undef PASS_R_SET_RESULT /*empty*/ +#define PASS_R_SET_RETURN void -#define SERV_R_RETURN struct servent * -#define SERV_R_SET_RETURN void -#undef SERV_R_SET_RESULT /*empty*/ -#define SERV_R_END_RETURN void -#define SERV_R_END_RESULT(x) /*empty*/ #define SERV_R_ARGS char *buf, int buflen -#undef SERV_R_ENT_ARGS /*empty*/ +#define SERV_R_BAD NULL #define SERV_R_COPY buf, buflen #define SERV_R_COPY_ARGS SERV_R_ARGS +#define SERV_R_END_RESULT(x) /*empty*/ +#define SERV_R_END_RETURN void +#undef SERV_R_ENT_ARGS /*empty*/ +#undef SERV_R_ENT_UNUSED /*empty*/ #define SERV_R_OK sptr -#define SERV_R_BAD NULL +#undef SERV_R_SETANSWER +#define SERV_R_RETURN struct servent * +#undef SERV_R_SET_RESULT +#define SERV_R_SET_RETURN void -/* make #include also #include */ -#define BSD_COMP -#include /* _POSIX_PATH_MAX */ +#define DE_CONST(konst, var) \ + do { \ + union { const void *k; void *v; } _u; \ + _u.k = konst; \ + var = _u.v; \ + } while (0) + +#define UNUSED(x) (x) = (x) + +#undef NEED_SOLARIS_BITTYPES +#define ISC_SOCKLEN_T int + #ifdef __GNUC__ #define ISC_FORMAT_PRINTF(fmt, args) \ __attribute__((__format__(__printf__, fmt, args))) @@ -130,17 +191,11 @@ #define ISC_FORMAT_PRINTF(fmt, args) #endif -/* - * Remove compiler warnings without modifying ISC source by including - * various headers here, mostly to get function prototypes. - */ -#include -#include -#include +/* Pull in host order macros when _XOPEN_SOURCE_EXTENDED is defined. */ +#if defined(__hpux) && defined(_XOPEN_SOURCE_EXTENDED) +#include +#endif -#include -#include "sys/bitypes.h" -#include "sys/cdefs.h" +#endif -#define HAS_INET6_STRUCTS -#define H_ERRNO_IS_FUNCTION +/*! \file */ --- old/usr/src/lib/libresolv2/include/port_after.h Fri Jul 3 12:24:06 2009 +++ new/usr/src/lib/libresolv2/include/port_after.h Fri Jul 3 12:24:06 2009 @@ -1,57 +1,84 @@ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" -#ifndef PORT_AFTER_H -#define PORT_AFTER_H -#include "os_version.h" +/* + * Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2001-2003 Internet Software Consortium. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ -#undef HAVE_SA_LEN -#define USE_POSIX -#define POSIX_SIGNALS -#define NETREAD_BROKEN -#define USE_WAITPID -#define HAVE_FCHMOD -#define NEED_PSELECT -#define SETGRENT_VOID -#define SETPWENT_VOID -#define SIOCGIFCONF_ADDR -#define IP_OPT_BUF_SIZE 40 -#define HAVE_CHROOT -#define CAN_CHANGE_ID -#define POSIX_GETPWNAM_R -#define POSIX_GETPWUID_R -#define POSIX_GETGRGID_R -#define POSIX_GETGRNAM_R -#define NEED_SECURE_DIRECTORY -#define HAVE_DEV_RANDOM -#define NO_MSG_CONTROL +/* $Id: port_after.h.in,v 1.60 2008/02/28 05:34:17 marka Exp $ */ -#define PORT_NONBLOCK O_NONBLOCK -#define PORT_WOULDBLK EWOULDBLOCK -#define WAIT_T int -#ifndef SUNW_LIBNSL -#define INADDR_NONE 0xffffffff -#endif +#ifndef port_after_h +#define port_after_h +#include #include #include #include +#include #if (!defined(BSD)) || (BSD < 199306) #include #endif -#include +#ifdef HAVE_INTTYPES_H +#include +#endif +#ifdef HAVE_SYS_SELECT_H +#include +#endif /* HAVE_SYS_SELECT_H */ -#ifndef MIN -#define MIN(x, y) ((x > y) ?y :x) +#ifdef REENABLE_SEND +#undef send #endif -#ifndef MAX -#define MAX(x, y) ((x > y) ?x :y) + +#undef NEED_PSELECT +#undef HAVE_SA_LEN +#undef HAVE_MINIMUM_IFREQ +#define NEED_DAEMON 1 +#undef NEED_STRSEP +#undef NEED_STRERROR +#ifdef NEED_STRERROR +const char *isc_strerror(int); +#define strerror isc_strerror #endif +/* HAS_INET6_STRUCTS and HAVE_SIN6_SCOPE_ID are defined by port_ipv6.h + * #define HAS_INET6_STRUCTS 1 + * #define HAVE_SIN6_SCOPE_ID 1 + */ +#include +#undef NEED_IN6ADDR_ANY +#undef HAS_IN_ADDR6 +#define HAVE_SOCKADDR_STORAGE 1 +#undef NEED_GETTIMEOFDAY +#undef HAVE_STRNDUP +#undef USE_FIONBIO_IOCTL +#undef INNETGR_ARGS + +#undef USE_IFNAMELINKID +#define PORT_NONBLOCK O_NONBLOCK + +#ifndef _POSIX_PATH_MAX +#define _POSIX_PATH_MAX 255 +#endif +#ifndef PATH_MAX +#define PATH_MAX _POSIX_PATH_MAX +#endif + /* * We need to know the IPv6 address family number even on IPv4-only systems. * Note that this is NOT a protocol constant, and that if the system has its @@ -61,58 +88,105 @@ * derived systems for which AF_INET6 is defined. */ #ifndef AF_INET6 -#define AF_INET6 24 +#define AF_INET6 24 #endif -#ifndef PF_INET6 -#define PF_INET6 AF_INET6 +#ifndef PF_INET6 +#define PF_INET6 AF_INET6 #endif -#include +#ifdef HAS_IN_ADDR6 +/* Map to pre-RFC structure. */ +#define in6_addr in_addr6 +#endif + #ifndef HAS_INET6_STRUCTS /* Replace with structure from later rev of O/S if known. */ struct in6_addr { - u_int8_t s6_addr[16]; + u_int8_t s6_addr[16]; }; +#define IN6ADDR_ANY_INIT \ + {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }} + +#define IN6ADDR_LOOPBACK_INIT \ + {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }} + /* Replace with structure from later rev of O/S if known. */ struct sockaddr_in6 { -#ifdef HAVE_SA_LEN - u_int8_t sin6_len; /* length of this struct */ - u_int8_t sin6_family; /* AF_INET6 */ +#ifdef HAVE_SA_LEN + u_int8_t sin6_len; /* length of this struct */ + u_int8_t sin6_family; /* AF_INET6 */ #else - u_int16_t sin6_family; /* AF_INET6 */ + u_int16_t sin6_family; /* AF_INET6 */ #endif - u_int16_t sin6_port; /* transport layer port # */ - u_int32_t sin6_flowinfo; /* IPv6 flow information */ - struct in6_addr sin6_addr; /* IPv6 address */ - u_int32_t sin6_scope_id; /* set of interfaces for a scope */ + u_int16_t sin6_port; /* transport layer port # */ + u_int32_t sin6_flowinfo; /* IPv6 flow information */ + struct in6_addr sin6_addr; /* IPv6 address */ + u_int32_t sin6_scope_id; /* set of interfaces for a scope */ }; +#endif /* HAS_INET6_STRUCTS */ +#ifdef BROKEN_IN6ADDR_INIT_MACROS +#undef IN6ADDR_ANY_INIT +#undef IN6ADDR_LOOPBACK_INIT +#endif + +#ifdef _AIX #ifndef IN6ADDR_ANY_INIT -#define IN6ADDR_ANY_INIT {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}} +#define IN6ADDR_ANY_INIT {{{ 0, 0, 0, 0 }}} #endif #ifndef IN6ADDR_LOOPBACK_INIT -#define IN6ADDR_LOOPBACK_INIT {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}} +#if BYTE_ORDER == BIG_ENDIAN +#define IN6ADDR_LOOPBACK_INIT {{{ 0, 0, 0, 1 }}} +#else +#define IN6ADDR_LOOPBACK_INIT {{{0, 0, 0, 0x01000000}}} #endif -#endif /* HAS_INET6_STRUCTS */ +#endif +#endif -#if defined(NEED_SOCKADDR_STORAGE) || !defined(HAS_INET6_STRUCTS) -#define __SS_MAXSIZE 128 -#define __SS_ALLIGSIZE (sizeof (long)) +#ifndef IN6ADDR_ANY_INIT +#ifdef s6_addr +#define IN6ADDR_ANY_INIT \ + {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}} +#else +#define IN6ADDR_ANY_INIT \ + {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }} +#endif +#endif +#ifndef IN6ADDR_LOOPBACK_INIT +#ifdef s6_addr +#define IN6ADDR_LOOPBACK_INIT \ + {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} +#else +#define IN6ADDR_LOOPBACK_INIT \ + {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }} +#endif +#endif + +#ifndef HAVE_SOCKADDR_STORAGE +#define __SS_MAXSIZE 128 +#define __SS_ALLIGSIZE (sizeof (long)) + struct sockaddr_storage { #ifdef HAVE_SA_LEN - u_int8_t ss_len; /* address length */ - u_int8_t ss_family; /* address family */ - char __ss_pad1[__SS_ALLIGSIZE - 2 * sizeof (u_int8_t)]; - long __ss_align; - char __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE]; + u_int8_t ss_len; /* address length */ + u_int8_t ss_family; /* address family */ + char __ss_pad1[__SS_ALLIGSIZE - 2 * sizeof(u_int8_t)]; + long __ss_align; + char __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE]; #else - u_int16_t ss_family; /* address family */ - char __ss_pad1[__SS_ALLIGSIZE - sizeof (u_int16_t)]; - long __ss_align; - char __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE]; + u_int16_t ss_family; /* address family */ + char __ss_pad1[__SS_ALLIGSIZE - sizeof(u_int16_t)]; + long __ss_align; + char __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE]; #endif }; #endif @@ -119,185 +193,349 @@ #if !defined(HAS_INET6_STRUCTS) || defined(NEED_IN6ADDR_ANY) -#define in6addr_any isc_in6addr_any +#define in6addr_any isc_in6addr_any extern const struct in6_addr in6addr_any; #endif +/* + * IN6_ARE_ADDR_EQUAL, IN6_IS_ADDR_UNSPECIFIED, IN6_IS_ADDR_V4COMPAT and + * IN6_IS_ADDR_V4MAPPED are broken in glibc 2.1. + */ +#ifdef __GLIBC__ +#if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2) +#undef IN6_ARE_ADDR_EQUAL +#undef IN6_IS_ADDR_UNSPECIFIED +#undef IN6_IS_ADDR_V4COMPAT +#undef IN6_IS_ADDR_V4MAPPED +#endif +#endif + #ifndef IN6_ARE_ADDR_EQUAL -#define IN6_ARE_ADDR_EQUAL(a, b) \ - (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof (struct in6_addr)) == 0) +#define IN6_ARE_ADDR_EQUAL(a,b) \ + (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0) #endif #ifndef IN6_IS_ADDR_UNSPECIFIED -#define IN6_IS_ADDR_UNSPECIFIED(a) \ +#define IN6_IS_ADDR_UNSPECIFIED(a) \ IN6_ARE_ADDR_EQUAL(a, &in6addr_any) #endif #ifndef IN6_IS_ADDR_LOOPBACK extern const struct in6_addr isc_in6addr_loopback; -#define IN6_IS_ADDR_LOOPBACK(a) \ +#define IN6_IS_ADDR_LOOPBACK(a) \ IN6_ARE_ADDR_EQUAL(a, &isc_in6addr_loopback) #endif -#ifndef IN6_IS_ADDR_V4COMPAT -#define IN6_IS_ADDR_V4COMPAT(a) \ - ((a)->s6_addr[0] == 0x00 && (a)->s6_addr[1] == 0x00 && \ - (a)->s6_addr[2] == 0x00 && (a)->s6_addr[3] == 0x00 && \ - (a)->s6_addr[4] == 0x00 && (a)->s6_addr[5] == 0x00 && \ - (a)->s6_addr[6] == 0x00 && (a)->s6_addr[7] == 0x00 && \ - (a)->s6_addr[8] == 0x00 && (a)->s6_addr[9] == 0x00 && \ - (a)->s6_addr[10] == 0x00 && (a)->s6_addr[11] == 0x00 && \ - ((a)->s6_addr[12] != 0x00 || (a)->s6_addr[13] != 0x00 || \ - (a)->s6_addr[14] != 0x00 || \ - ((a)->s6_addr[15] != 0x00 && (a)->s6_addr[15] != 1))) -#endif - #ifndef IN6_IS_ADDR_V4MAPPED -#define IN6_IS_ADDR_V4MAPPED(a) \ +#define IN6_IS_ADDR_V4MAPPED(a) \ ((a)->s6_addr[0] == 0x00 && (a)->s6_addr[1] == 0x00 && \ (a)->s6_addr[2] == 0x00 && (a)->s6_addr[3] == 0x00 && \ (a)->s6_addr[4] == 0x00 && (a)->s6_addr[5] == 0x00 && \ - (a)->s6_addr[6] == 0x00 && (a)->s6_addr[7] == 0x00 && \ + (a)->s6_addr[6] == 0x00 && (a)->s6_addr[9] == 0x00 && \ (a)->s6_addr[8] == 0x00 && (a)->s6_addr[9] == 0x00 && \ (a)->s6_addr[10] == 0xff && (a)->s6_addr[11] == 0xff) #endif #ifndef IN6_IS_ADDR_SITELOCAL -#define IN6_IS_ADDR_SITELOCAL(a) \ +#define IN6_IS_ADDR_SITELOCAL(a) \ (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0)) #endif #ifndef IN6_IS_ADDR_LINKLOCAL -#define IN6_IS_ADDR_LINKLOCAL(a) \ +#define IN6_IS_ADDR_LINKLOCAL(a) \ (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80)) #endif #ifndef IN6_IS_ADDR_MULTICAST -#define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff) +#define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff) #endif #ifndef __IPV6_ADDR_MC_SCOPE -#define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f) +#define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f) #endif #ifndef __IPV6_ADDR_SCOPE_SITELOCAL -#define __IPV6_ADDR_SCOPE_SITELOCAL 0x05 +#define __IPV6_ADDR_SCOPE_SITELOCAL 0x05 #endif - #ifndef __IPV6_ADDR_SCOPE_ORGLOCAL -#define __IPV6_ADDR_SCOPE_ORGLOCAL 0x08 +#define __IPV6_ADDR_SCOPE_ORGLOCAL 0x08 #endif #ifndef IN6_IS_ADDR_MC_SITELOCAL -#define IN6_IS_ADDR_MC_SITELOCAL(a) \ +#define IN6_IS_ADDR_MC_SITELOCAL(a) \ (IN6_IS_ADDR_MULTICAST(a) && \ - (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL)) + (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL)) #endif #ifndef IN6_IS_ADDR_MC_ORGLOCAL -#define IN6_IS_ADDR_MC_ORGLOCAL(a) \ +#define IN6_IS_ADDR_MC_ORGLOCAL(a) \ (IN6_IS_ADDR_MULTICAST(a) && \ - (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL)) + (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL)) #endif -#ifndef INET6_ADDRSTRLEN -#define INET6_ADDRSTRLEN 46 +#ifndef INADDR_NONE +#define INADDR_NONE 0xffffffff #endif -/* - * Prior to 2.6, Solaris needs a prototype for gethostname(). - */ -#if (OS_MAJOR == 5 && OS_MINOR < 6) -extern int gethostname(char *, size_t); +#ifndef MAXHOSTNAMELEN +#define MAXHOSTNAMELEN 256 #endif -/* - * gethostid() was not available until 2.5 - * setsockopt(SO_REUSEADDR) fails on unix domain sockets before 2.5 - * use ioctl(FIONBIO) rather than fcntl() calls to set/clear non-blocking i/o. - */ -#if (OS_MAJOR == 5 && OS_MINOR < 5) -#define GET_HOST_ID_MISSING -#define NO_UNIX_REUSEADDR -#define USE_FIONBIO_IOCTL + +#ifndef INET6_ADDRSTRLEN +/* sizeof("aaaa:bbbb:cccc:dddd:eeee:ffff:123.123.123.123") */ +#define INET6_ADDRSTRLEN 46 #endif -#define NEED_STRSEP -extern char *strsep(char **, const char *); +#ifndef MIN +#define MIN(x,y) (((x) <= (y)) ? (x) : (y)) +#endif -#define NEED_DAEMON +#ifndef MAX +#define MAX(x,y) (((x) >= (y)) ? (x) : (y)) +#endif + +#ifdef NEED_DAEMON int daemon(int nochdir, int noclose); +#endif -/* - * Solaris defines this in instead of in . We don't - * define it in our , so we define it here. - */ -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN 256 +#ifdef NEED_STRSEP +char * strsep(char **stringp, const char *delim); #endif -/* - * Solaris 2.5 and later have getrlimit(), setrlimit() and getrusage(). - */ -#if (OS_MAJOR > 5 || (OS_MAJOR == 5 && OS_MINOR >= 5)) -#include -#define HAVE_GETRUSAGE -#define RLIMIT_TYPE rlim_t -#define RLIMIT_FILE_INFINITY +#ifndef ALIGN +#define ALIGN(p) (((uintptr_t)(p) + (sizeof(long) - 1)) & ~(sizeof(long) - 1)) #endif -#include -#include -#include -#include -#include -#include +#ifdef NEED_SETGROUPENT +int setgroupent(int stayopen); +#endif -#ifdef ORIGINAL_ISC_CODE -const char *isc_strerror(int errnum); -#define strerror isc_strerror +#ifdef NEED_GETGROUPLIST +int getgrouplist(GETGROUPLIST_ARGS); #endif -#ifndef ISC_FACILITY -#define ISC_FACILITY LOG_DAEMON +#ifdef POSIX_GETGRNAM_R +int +__posix_getgrnam_r(const char *, struct group *, char *, int, struct group **); #endif -/* res_mkquery.c refers explicitly to __putlong and __putshort */ -#define __putlong putlong -#define __putshort putshort +#ifdef NEED_GETGRNAM_R +int +getgrnam_r(const char *, struct group *, char *, size_t, struct group **); +#endif -/* - * If one wanted to use isc__gettimeofday for Solaris, they would - * need to define NEED_GETTIMEOFDAY (common/bsd/gettimeofday.c), - * which is not defined for Solaris. Hence there is no reason to - * change the current definition of gettimeofday which currently - * comes from libc and we comment the following out. - */ -#ifdef ORIGINAL_ISC_CODE -int isc__gettimeofday(struct timeval *, struct timezone *); -#define gettimeofday isc__gettimeofday +#ifdef POSIX_GETGRGID_R +int +__posix_getgrgid_r(gid_t, struct group *, char *, int, struct group **) ; #endif -/* - * Solaris 8 has if_nametoindex(). - */ -#if (OS_MAJOR > 5 || (OS_MAJOR == 5 && OS_MINOR >= 8)) -#define USE_IFNAMELINKID +#ifdef NEED_GETGRGID_R +int +getgrgid_r(gid_t, struct group *, char *, size_t, struct group **); #endif - -#define UNUSED(x) (x) = (x) -#define DE_CONST(konst, var) \ - do { \ - union { const void *k; void *v; } _u; \ - _u.k = konst; \ - var = _u.v; \ - } while (0) -#ifndef ALIGN -#if (OS_MAJOR == 5 && OS_MINOR > 8) -#define ALIGN(x) (((uintptr_t)(x) + (sizeof(char*) - 1UL)) & ~(sizeof(char*) - 1UL)) +#ifdef NEED_GETGRENT_R +GROUP_R_RETURN getgrent_r(struct group *gptr, GROUP_R_ARGS); +#endif + +#ifdef NEED_SETGRENT_R +GROUP_R_SET_RETURN setgrent_r(GROUP_R_ENT_ARGS); +#endif + +#ifdef NEED_ENDGRENT_R +GROUP_R_END_RETURN endgrent_r(GROUP_R_ENT_ARGS); +#endif + +#if defined(NEED_INNETGR_R) && defined(NGR_R_RETURN) +NGR_R_RETURN +innetgr_r(const char *, const char *, const char *, const char *); +#endif + +#ifdef NEED_SETNETGRENT_R +#ifdef NGR_R_SET_ARGS +NGR_R_SET_RETURN setnetgrent_r(NGR_R_SET_CONST char *netgroup, NGR_R_SET_ARGS); #else -#define ALIGN(x) (((unsigned long)(x) + (sizeof(char*) - 1UL)) & ~(sizeof(char*) - 1UL)) +NGR_R_SET_RETURN setnetgrent_r(NGR_R_SET_CONST char *netgroup); #endif #endif -#endif /* ! PORT_AFTER_H */ +#ifdef NEED_ENDNETGRENT_R +#ifdef NGR_R_END_ARGS +NGR_R_END_RETURN endnetgrent_r(NGR_R_END_ARGS); +#else +NGR_R_END_RETURN endnetgrent_r(void); +#endif +#endif + +#ifdef POSIX_GETPWNAM_R +int +__posix_getpwnam_r(const char *login, struct passwd *pwptr, + char *buf, size_t buflen, struct passwd **result); +#endif + +#ifdef NEED_GETPWNAM_R +int +getpwnam_r(const char *login, struct passwd *pwptr, + char *buf, size_t buflen, struct passwd **result); +#endif + +#ifdef POSIX_GETPWUID_R +int +__posix_getpwuid_r(uid_t uid, struct passwd *pwptr, + char *buf, int buflen, struct passwd **result); +#endif + +#ifdef NEED_GETPWUID_R +int +getpwuid_r(uid_t uid, struct passwd *pwptr, + char *buf, size_t buflen, struct passwd **result); +#endif + +#ifdef NEED_SETPWENT_R +#ifdef PASS_R_ENT_ARGS +PASS_R_SET_RETURN setpwent_r(PASS_R_ENT_ARGS); +#else +PASS_R_SET_RETURN setpwent_r(void); +#endif + +#endif + +#ifdef NEED_SETPASSENT_R +#ifdef PASS_R_ENT_ARGS +PASS_R_SET_RETURN setpassent_r(int stayopen, PASS_R_ENT_ARGS); +#else +PASS_R_SET_RETURN setpassent_r(int stayopen); +#endif +#endif + +#ifdef NEED_GETPWENT_R +PASS_R_RETURN getpwent_r(struct passwd *pwptr, PASS_R_ARGS); +#endif + +#ifdef NEED_ENDPWENT_R +void endpwent_r(void); +#endif + +#ifdef NEED_SETPASSENT +int setpassent(int stayopen); +#endif + +#define gettimeofday isc__gettimeofday +#ifdef NEED_GETTIMEOFDAY +int isc__gettimeofday(struct timeval *tvp, struct _TIMEZONE *tzp); +#else +int isc__gettimeofday(struct timeval *tp, struct timezone *tzp); +#endif + +int getnetgrent(NGR_R_CONST char **machinep, NGR_R_CONST char **userp, + NGR_R_CONST char **domainp); + +#ifdef NGR_R_ARGS +int getnetgrent_r(NGR_R_CONST char **machinep, NGR_R_CONST char **userp, + NGR_R_CONST char **domainp, NGR_R_ARGS); +#endif + +/* setnetgrent and endnetgrent are defined in sunw_port_after.h +#ifdef SETNETGRENT_ARGS +void setnetgrent(SETNETGRENT_ARGS); +#else +void setnetgrent(const char *netgroup); +#endif + +void endnetgrent(void); +*/ + +#ifdef INNETGR_ARGS +int innetgr(INNETGR_ARGS); +#else +int innetgr(const char *netgroup, const char *machine, + const char *user, const char *domain); +#endif + +#ifdef NGR_R_SET_ARGS +NGR_R_SET_RETURN +setnetgrent_r(NGR_R_SET_CONST char *netgroup, NGR_R_SET_ARGS); +#else +NGR_R_SET_RETURN +setnetgrent_r(NGR_R_SET_CONST char *netgroup); +#endif + +#ifdef NEED_STRTOUL +unsigned long strtoul(const char *, char **, int); +#endif + +#ifdef NEED_SUN4PROTOS +#include +#ifndef __SIZE_TYPE__ +#define __SIZE_TYPE__ int +#endif +struct sockaddr; +struct iovec; +struct timeval; +struct timezone; +int fprintf(FILE *, const char *, ...); +int getsockname(int, struct sockaddr *, int *); +int getpeername(int, struct sockaddr *, int *); +int socket(int, int, int); +int connect(int, const struct sockaddr *, int); +int writev(int, struct iovec *, int); +int readv(int, struct iovec *, int); +int send(int, const char *, int, int); +void bzero(char *, int); +int recvfrom(int, char *, int, int, struct sockaddr *, int *); +int syslog(int, const char *, ... ); +int printf(const char *, ...); +__SIZE_TYPE__ fread(void *, __SIZE_TYPE__, __SIZE_TYPE__, FILE *); +__SIZE_TYPE__ fwrite(const void *, __SIZE_TYPE__, __SIZE_TYPE__, FILE *); +int fclose(FILE *); +int ungetc(int, FILE *); +int scanf(const char *, ...); +int sscanf(const char *, const char *, ... ); +int tolower(int); +int toupper(int); +int strcasecmp(const char *, const char *); +int strncasecmp(const char *, const char *, int); +int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); +#ifdef gettimeofday +#undef gettimeofday +int gettimeofday(struct timeval *, struct timezone *); +#define gettimeofday isc__gettimeofday +#else +int gettimeofday(struct timeval *, struct timezone *); +#endif +long strtol(const char*, char **, int); +int fseek(FILE *, long, int); +int setsockopt(int, int, int, const char *, int); +int bind(int, const struct sockaddr *, int); +void bcopy(char *, char *, int); +int fputc(char, FILE *); +int listen(int, int); +int accept(int, struct sockaddr *, int *); +int getsockopt(int, int, int, char *, int *); +int vfprintf(FILE *, const char *, va_list); +int fflush(FILE *); +int fgetc(FILE *); +int fputs(const char *, FILE *); +int fchown(int, int, int); +void setbuf(FILE *, char *); +int gethostname(char *, int); +int rename(const char *, const char *); +time_t time(time_t *); +int fscanf(FILE *, const char *, ...); +int sscanf(const char *, const char *, ...); +int ioctl(int, int, caddr_t); +void perror(const char *); + +#if !defined(__USE_FIXED_PROTOTYPES__) && !defined(__cplusplus) && !defined(__STRICT_ANSI__) +/* + * 'gcc -ansi' changes the prototype for vsprintf(). + * Use this prototype when 'gcc -ansi' is not in effect. + */ +char *vsprintf(char *, const char *, va_list); +#endif +#endif + +/* Solaris-specific changes */ +#include "sunw_port_after.h" + +#endif --- /dev/null Fri Jul 3 12:24:08 2009 +++ new/usr/src/lib/libresolv2/include/sunw_port_before.h Fri Jul 3 12:24:08 2009 @@ -0,0 +1,40 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SUNW_PORT_BEFORE_H +#define _SUNW_PORT_BEFORE_H + +#ifdef SUNW_OPTIONS +#include +#endif + +/* version-specific defines */ +#include +#if (OS_MAJOR == 5 && OS_MINOR < 6) +#ifndef SOLARIS_BITTYPES +#define NEED_SOLARIS_BITTYPES 1 +#endif +#endif + +#if (OS_MAJOR == 5 && OS_MINOR < 5) +#undef HAS_PTHREADS +#else +#define HAS_PTHREADS +#endif + + +/* + * need these if we are using public versions of nameser.h, resolv.h, and + * inet.h + */ +#include +#if (!defined(BSD)) || (BSD < 199306) +#include +#else +#include +#endif +#include + +#endif /* _SUNW_PORT_BEFORE_H */ --- /dev/null Fri Jul 3 12:24:08 2009 +++ new/usr/src/lib/libresolv2/include/sunw_port_after.h Fri Jul 3 12:24:08 2009 @@ -0,0 +1,123 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SUNW_PORT_AFTER_H +#define _SUNW_PORT_AFTER_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * rename setnetgrent and endnetgrent which were formerly in a separate irs + * shared library. These functions should come from libc.so + */ +#define setnetgrent res_setnetgrent +#ifdef SETNETGRENT_ARGS +void setnetgrent(SETNETGRENT_ARGS); +#else +void setnetgrent(const char *netgroup); +#endif + +#define endnetgrent res_endnetgrent +void endnetgrent(void); + + +/* + * include ports for the public header files. ISC's versions are quite different + * from those currently in OpenSolaris. + */ + +#ifdef _RESOLV_H_ +#include +#endif /* _RESOLV_H_ */ + +#ifdef _NETDB_H +#include +#endif /* _NETDB_H */ + +#ifdef _ARPA_INET_H +#include +#endif /* _ARPA_INET_H */ + +#ifdef _ARPA_NAMESER_H +#include +#endif /* _ARPA_NAMESER_H */ + + +#ifdef _ARPA_NAMESER_COMPAT_H +/* no changes */ +#endif /* _ARPA_NAMESER_COMPAT_H */ + +/* version-specific defines */ +#include + +/* + * Prior to 2.6, Solaris needs a prototype for gethostname(). + */ +#if (OS_MAJOR == 5 && OS_MINOR < 6) +extern int gethostname(char *, size_t); +#endif +/* + * gethostid() was not available until 2.5 + * setsockopt(SO_REUSEADDR) fails on unix domain sockets before 2.5 + * use ioctl(FIONBIO) rather than fcntl() calls to set/clear non-blocking i/o. + */ +#if (OS_MAJOR == 5 && OS_MINOR < 5) +#define GET_HOST_ID_MISSING +#define NO_UNIX_REUSEADDR +#define USE_FIONBIO_IOCTL +#endif + +#if (OS_MAJOR == 5 && OS_MINOR < 11) +#define NEED_STRSEP +extern char *strsep(char **, const char *); +#endif + + +/* + * Solaris 2.5 and later have getrlimit(), setrlimit() and getrusage(). + */ +#if (OS_MAJOR > 5 || (OS_MAJOR == 5 && OS_MINOR >= 5)) +#include +#define HAVE_GETRUSAGE +#define RLIMIT_TYPE rlim_t +#define RLIMIT_FILE_INFINITY +#endif + +/* the default syslog facility of named/lwresd. */ +#ifndef ISC_FACILITY +#define ISC_FACILITY LOG_DAEMON +#endif + + +/* + * Solaris 8 has if_nametoindex(). + */ +#if (OS_MAJOR > 5 || (OS_MAJOR == 5 && OS_MINOR >= 8)) +#define USE_IFNAMELINKID +#endif + +#undef ALIGN +#if (OS_MAJOR == 5 && OS_MINOR > 8) +#define ALIGN(x) (((uintptr_t)(x) + (sizeof (char *) - 1UL)) & \ + ~(sizeof (char *) - 1UL)) +#else +#define ALIGN(x) (((unsigned long)(x) + (sizeof (char *) - 1UL)) & \ + ~(sizeof (char *) - 1UL)) +#endif + +#if (OS_MAJOR == 5 && OS_MINOR < 5) +#ifndef USE_FIONBIO_IOCTL +#define USE_FIONBIO_IOCTL 1 +#endif +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* _SUNW_PORT_AFTER_H */ --- /dev/null Fri Jul 3 12:24:09 2009 +++ new/usr/src/lib/libresolv2/include/config.h Fri Jul 3 12:24:09 2009 @@ -0,0 +1,75 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +/* config.h. Generated from config.h.in by configure. */ +/* #undef _SOCKADDR_LEN */ +#define HAVE_FCNTL_H 1 +/* #undef HAVE_PATHS_H */ +#define HAVE_INTTYPES_H 1 +#define HAVE_STROPTS_H 1 +/* #undef HAVE_SYS_TIMERS_H */ +#define HAVE_SYS_SELECT_H 1 +#define HAVE_MEMORY_H 1 +/* #undef SYS_CDEFS_H */ +#define _POSIX_PTHREAD_SEMANTICS 1 +#define POSIX_GETPWUID_R 1 +#define POSIX_GETPWNAM_R 1 +#define POSIX_GETGRGID_R 1 +#define POSIX_GETGRNAM_R 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCHR 1 +/* #undef SPRINTF_CHAR */ +/* #undef VSPRINTF_CHAR */ +#define USE_SYSERROR_LIST 1 +/* #undef NEED_STRTOUL */ +/* #undef NEED_SUN4PROTOS */ +/* #undef REENABLE_SEND */ + +#define NEED_SETGROUPENT 1 +#define NEED_GETGROUPLIST 1 + +/* define if prototype for getgrnam_r() is required */ +/* #undef NEED_GETGRNAM_R */ +/* #undef NEED_GETGRGID_R */ +/* #undef NEED_GETGRENT_R */ +#define NEED_SETGRENT_R 1 +#define NEED_ENDGRENT_R 1 + +#define NEED_INNETGR_R 1 +/* #undef NEED_SETNETGRENT_R */ +#define NEED_ENDNETGRENT_R 1 + +/* #undef NEED_GETPWNAM_R */ +/* #undef NEED_GETPWUID_R */ +#define NEED_SETPWENT_R 1 +#define NEED_SETPASSENT_R 1 +#define NEED_SETPWENT_R 1 +/* #undef NEED_GETPWENT_R */ +#define NEED_ENDPWENT_R 1 + +#define NEED_SETPASSENT 1 + +/* #undef HAS_PW_CLASS */ + +/* #undef ssize_t */ +/* #undef uintptr_t */ + +/* Shut up warnings about sputaux in stdio.h on BSD/OS pre-4.1 */ +/* #undef SHUTUP_SPUTAUX */ +#ifdef SHUTUP_SPUTAUX +struct __sFILE; +extern __inline int __sputaux(int _c, struct __sFILE *_p); +#endif +#define BROKEN_IN6ADDR_INIT_MACROS 1 +#define HAVE_STRLCAT 1 +/* Shut up warnings about missing braces */ +/* #undef SHUTUP_MUTEX_INITIALIZER */ +#ifdef SHUTUP_MUTEX_INITIALIZER +#define LIBBIND_MUTEX_INITIALIZER { PTHREAD_MUTEX_INITIALIZER } +#else +#define LIBBIND_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER +#endif + --- /dev/null Fri Jul 3 12:24:10 2009 +++ new/usr/src/lib/libresolv2/include/port_netdb.h Fri Jul 3 12:24:10 2009 @@ -0,0 +1,185 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#ifndef _PORT_NETDB_H +#define _PORT_NETDB_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* EAI_OVERFLOW was removed from ISC */ +#define EAI_BADHINTS 12 + +/* + * these are libresolv2 functions that were renamed in previous versions to + * res_* because they conflict with libnsl or libsocket + */ + +#define endhostent res_endhostent /* libnsl */ +void endhostent __P((void)); +#define endnetent res_endnetent /* libsocket */ +void endnetent __P((void)); +#define freeaddrinfo res_freeaddrinfo /* libsocket */ +void freeaddrinfo __P((struct addrinfo *)); +#define freehostent res_freehostent /* libsocket and libnsl */ +void freehostent __P((struct hostent *)); +#define getaddrinfo res_getaddrinfo /* libsocket */ +int getaddrinfo __P((const char *, const char *, + const struct addrinfo *, struct addrinfo **)); +#define gethostbyaddr res_gethostbyaddr /* libnsl */ +struct hostent *gethostbyaddr __P((const char *, int, int)); +#define gethostbyname res_gethostbyname /* libnsl */ +struct hostent *gethostbyname __P((const char *)); +#define gethostbyname2 res_gethostbyname2 /* lib/nsswitch/dns */ +struct hostent *gethostbyname2 __P((const char *, int)); +#define gethostent res_gethostent /* libnsl */ +struct hostent *gethostent __P((void)); +#define getipnodebyaddr res_getipnodebyaddr /* libnsl and libsocket */ +struct hostent *getipnodebyaddr __P((const void *, size_t, int, int *)); +#define getipnodebyname res_getipnodebyname /* libnsl and libsocket */ +struct hostent *getipnodebyname __P((const char *, int, int, int *)); + +#define getnetbyaddr res_getnetbyaddr /* libsocket */ +struct netent *getnetbyaddr __P((unsigned long, int)); +#define getnetbyname res_getnetbyname /* libsocket */ +struct netent *getnetbyname __P((const char *)); +#define getnetent res_getnetent /* libsocket */ +struct netent *getnetent __P((void)); +#define sethostent res_sethostent /* libnsl */ +void sethostent __P((int)); +#define setnetent res_setnetent /* libsocket */ +void setnetent __P((int)); + +/* + * these are other irs functions now included in libresolv.so.2. We rename the + * ones that overlap with libsocket or libnsl + */ + +/* endprotoent is in libsocket.so.1 */ +#define endprotoent res_endprotoent +void endprotoent __P((void)); + +/* endservent is in libsocket.so.1 */ +#define endservent res_endservent +void endservent __P((void)); + +/* note: the next two symbols are variables, not functions */ + +/* gai_errlist is in libsocket.so.1 */ +#define gai_errlist res_gai_errlist + +/* gai_nerr is in libsocket.so.1 */ +#define gai_nerr res_gai_nerr + +/* gai_strerror is in libsocket.so.1 */ +#define gai_strerror res_gai_strerror +const char *gai_strerror __P((int ecode)); + +/* gethostbyaddr_r is in libnsl.so.1 */ +#define gethostbyaddr_r res_gethostbyaddr_r +struct hostent *gethostbyaddr_r __P((const char *addr, int len, int type, + struct hostent *hptr, char *buf, + int buflen, int *h_errnop)); + +/* gethostbyname_r is in libnsl.so.1 */ +#define gethostbyname_r res_gethostbyname_r +struct hostent *gethostbyname_r __P((const char *name, struct hostent *hptr, + char *buf, int buflen, int *h_errnop)); + +/* gethostent_r is in libnsl.so.1 */ +#define gethostent_r res_gethostent_r +struct hostent *gethostent_r __P((struct hostent *hptr, char *buf, int buflen, + int *h_errnop)); + +/* getnameinfo is in libsocket.so.1 */ +#define getnameinfo res_getnameinfo +int getnameinfo __P((const struct sockaddr *, size_t, char *, + size_t, char *, size_t, int)); + +/* getnetbyaddr_r is in libsocket.so.1 */ +#define getnetbyaddr_r res_getnetbyaddr_r +struct netent *getnetbyaddr_r __P((long, int, struct netent *, char *, int)); + +/* getnetbyname_r is in libsocket.so.1 */ +#define getnetbyname_r res_getnetbyname_r +struct netent *getnetbyname_r __P((const char *, struct netent *, char *, int)); + +/* getnetent_r is in libsocket.so.1 */ +#define getnetent_r res_getnetent_r +struct netent *getnetent_r __P((struct netent *, char *, int)); + +/* getprotobyname is in libsocket.so.1 */ +#define getprotobyname res_getprotobyname +struct protoent *getprotobyname __P((const char *)); + +/* getprotobyname_r is in libsocket.so.1 */ +#define getprotobyname_r res_getprotobyname_r +struct protoent *getprotobyname_r __P((const char *, struct protoent *, + char *, int)); + +/* getprotobynumber is in libsocket.so.1 */ +#define getprotobynumber res_getprotobynumber +struct protoent *getprotobynumber __P((int)); + +/* getprotobynumber_r is in libsocket.so.1 */ +#define getprotobynumber_r res_getprotobynumber_r +struct protoent *getprotobynumber_r __P((int, + struct protoent *, char *, int)); + +/* getprotoent is in libsocket.so.1 */ +#define getprotoent res_getprotoent +struct protoent *getprotoent __P((void)); + +/* getprotoent_r is in libsocket.so.1 */ +#define getprotoent_r res_getprotoent_r +struct protoent *getprotoent_r __P((struct protoent *, char *, int)); + +/* getservbyname is in libsocket.so.1 and libnsl.so.1 */ +#define getservbyname res_getservbyname +struct servent *getservbyname __P((const char *, const char *)); + +/* getservbyname_r is in libsocket.so.1 and libnsl.so.1 */ +#define getservbyname_r res_getservbyname_r +struct servent *getservbyname_r __P((const char *name, const char *, + struct servent *, char *, int)); + +/* getservbyport is in libsocket.so.1 and libnsl.so.1 */ +#define getservbyport res_getservbyport +struct servent *getservbyport __P((int, const char *)); + +/* getservbyport_r is in libsocket.so.1 and libnsl.so.1 */ +#define getservbyport_r res_getservbyport_r +struct servent *getservbyport_r __P((int port, const char *, + struct servent *, char *, int)); + +/* getservent is in libsocket.so.1 */ +#define getservent res_getservent +struct servent *getservent __P((void)); + +/* getservent_r is in libsocket.so.1 */ +#define getservent_r res_getservent_r +struct servent *getservent_r __P((struct servent *, char *, int)); + +/* innetgr is in libsocket.so.1 */ +#define innetgr res_innetgr +int innetgr __P((const char *, const char *, const char *, const char *)); + +/* setprotoent is in libsocket.so.1 */ +#define setprotoent res_setprotoent +void setprotoent __P((int)); + +/* setservent is in libsocket.so.1 */ +#define setservent res_setservent +void setservent __P((int)); + + + +#ifdef __cplusplus +} +#endif + +#endif /* _PORT_NETDB_H */ --- /dev/null Fri Jul 3 12:24:10 2009 +++ new/usr/src/lib/libresolv2/include/port_resolv.h Fri Jul 3 12:24:10 2009 @@ -0,0 +1,42 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _PORT_RESOLV_H +#define _PORT_RESOLV_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* RES_NSID has the same value as RES_NO_NIBBLE, which has been deleted */ +#define RES_NSID 0x00040000 /* request name server ID */ + +/* RES_DEFAULT has a new value in libbind-6.0 */ +#undef RES_DEFAULT +#define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | \ + RES_DNSRCH | RES_NO_NIBBLE2) + +#ifndef __ultrix__ +u_int16_t _getshort __P((const uchar_t *)); +u_int32_t _getlong __P((const uchar_t *)); +#endif + +/* rename functions so they can be wrapped (see sunw/sunw_wrappers.c */ +#define p_option isc_p_option +const char *p_option(ulong_t option); +#define p_secstodate isc_p_secstodate +char *p_secstodate(ulong_t secs); + +/* prevent namespace pollution */ +#define res_protocolnumber __res_protocolnumber +#define res_servicenumber __res_servicenumber + + + +#ifdef __cplusplus +} +#endif + +#endif /* _PORT_RESOLV_H */ --- /dev/null Fri Jul 3 12:24:11 2009 +++ new/usr/src/lib/libresolv2/include/arpa/port_nameser.h Fri Jul 3 12:24:11 2009 @@ -0,0 +1,40 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _ARPA_PORT_NAMESER_H +#define _ARPA_PORT_NAMESER_H + +/* + * ISC changed the ns_updrec structure. However, it's a public interface + * in Solaris, so we rename it here and wrap in sunw_updrec.c + */ +#define ns_updrec __ISC_ns_updrec + + +/* + * Due to the above, the following functions need to be renamed and + * wrapped in sunw_updrec.c. + * + * For BIND 8.2.2, ISC removed the dynamic update functions, and the + * definition of the ns_updrec structure, from the public include files + * (, . However, res_update(), res_mkupdate(), + * and res_mkupdrec() are in the public libresolv interface in Solaris, + * so we can't easily remove them. Thus, ISC's new versions of res_mkupdate() + * etc. can't be exposed under their original names. + * + * res_nmkupdate() and res_nupdate are new. We could either change them + * to accept the ns_updrec, or leave them unchanged and + * undocumented. Since ISC may change ns_updrec again, we pick the latter + * solution for now. + */ +#define res_mkupdate __ISC_res_mkupdate +#define res_update __ISC_res_update +#define res_mkupdrec __ISC_res_mkupdrec +#define res_freeupdrec __ISC_res_freeupdrec +#define res_nmkupdate __ISC_res_nmkupdate +#define res_nupdate __ISC_res_nupdate + + +#endif /* _ARPA_PORT_NAMESER_H */ --- /dev/null Fri Jul 3 12:24:11 2009 +++ new/usr/src/lib/libresolv2/include/arpa/port_inet.h Fri Jul 3 12:24:11 2009 @@ -0,0 +1,41 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * + * All rights reserved. + */ + +#ifndef _ARPA_PORT_INET_H +#define _ARPA_PORT_INET_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * these are libresolv2 functions that were made local in previous versions + * we rename them res_* because they conflict with libnsl or libsocket + */ + +#define inet_lnaof res_inet_lnaof /* libsocket */ +ulong_t inet_lnaof(struct in_addr in); + +#define inet_makeaddr res_inet_makeaddr /* libsocket */ +struct in_addr inet_makeaddr(ulong_t net, ulong_t host); + +#define inet_netof res_inet_netof /* libnsl */ +ulong_t inet_netof(struct in_addr in); + +#define inet_network res_inet_network /* libsocket */ +ulong_t inet_network(register const char *cp); + +#ifdef __cplusplus +} +#endif + + + +#endif /* _ARPA_PORT_INET_H */ --- /dev/null Fri Jul 3 12:24:11 2009 +++ new/usr/src/lib/libresolv2/include/isc/platform.h Fri Jul 3 12:24:11 2009 @@ -0,0 +1,42 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +/* + * Copyright (C) 2008 Internet Systems Consortium, Inc. ("ISC") + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: platform.h.in,v 1.3 2008/01/23 02:15:56 tbox Exp $ */ + +/*! \file */ + +#ifndef ISC_PLATFORM_H +#define ISC_PLATFORM_H + +/* + * Define if the OS does not define struct timespec. + */ +#undef ISC_PLATFORM_NEEDTIMESPEC +#ifdef ISC_PLATFORM_NEEDTIMESPEC +#include /* For time_t */ +struct timespec { + time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; +#endif + +#endif --- old/usr/src/lib/libresolv2/include/conf/sunoptions.h Fri Jul 3 12:24:12 2009 +++ new/usr/src/lib/libresolv2/include/conf/sunoptions.h Fri Jul 3 12:24:12 2009 @@ -1,5 +1,5 @@ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -6,45 +6,18 @@ #ifndef _SUNOPTIONS_H #define _SUNOPTIONS_H -#pragma ident "%Z%%M% %I% %E% SMI" +#define USELOOPBACK /* Resolver library defaults to 127.0.0.1 */ -/* - * The following options are PP flags available in the reference implementation - * but do not get compiled due to the elimination of the options.h file - * This section selectively reintroduces them - */ - -#define HAVE_GETRUSAGE - -/* - * The following options are PP flags introduced as part of the Sun/Solaris - * port. - */ - -/* We may have to pull this out */ -#define SUNW_LIBNSL /* conflicts for inet_addr, inet_ntoa */ - /* Additions for Solaris 2 */ -#define SUNW_NSSEARCH /* fix nslookup domain search */ -#define SUNW_AVOIDOVERFLOW /* Avoid buffer overflows */ -#define SUNW_INITCHKIF /* Check if any non-loopback interface is up */ -#define SUNW_DOMAINFROMNIS /* Default domain name from NIS/NIS+ */ -#define USELOOPBACK /* Resolver library defaults to 127.0.0.1 */ -#define SUNW_CONFCHECK /* Abort quickly if no /etc/resolv.conf or local */ - /* named */ -#define SUNW_AREWEINNAMED /* Override _confcheck if proc is in.named */ -#define SUNW_OPENFDOFFSET /* Open non-stdio fd:s with offset */ -#define SUNW_POLL /* Use poll(2) instead of select(3) */ + +#define SUNW_INITCHKIF /* Check if any non-loopback interface is up */ +#define SUNW_CONFCHECK /* Abort quickly if no /etc/resolv.conf or */ + /* local named */ #define SUNW_HOSTS_FALLBACK /* Configurable /etc/hosts fallback */ -#define SUNW_LISTEN_BACKLOG /* Configurable listen(3N) backlog (named) */ -#define SUNW_REJECT_BOGUS_H_LENGTH /* (libresolv) */ #define SUNW_HNOK_UNDERSCORE /* Allow underscore in hostnames (libresolv) */ #define SUNW_MT_RESOLVER /* MT hot extensions (libresolv) */ -#define SUNW_QSTREAM_CLEANUP /* Avoid using free()d struct qstreams */ #define SUNW_SETHERRNO /* ISC does not set h_errno in gethostbyname */ #define SUNW_OVERRIDE_RETRY /* Allow NS switch to override res->retry */ -#define SUNW_CLOSEFROM /* closefrom(3C) per PSARC 2000/193 */ -#define SUNW_AVOIDSTDIO_FDLIMIT /* Avoid 256 file descriptor limit in stdio */ #define SUNW_LIBMD5 /* Use md5(3EXT) instead of internal implementation */ /* If compiling an MT warm libresolv, we also need reentrancy */ @@ -52,11 +25,6 @@ #define _REENTRANT #endif -/* SUNW_AREWEINNAMED and SUNW_CONFCHECCK are mutually inclusive */ -#if defined(SUNW_AREWEINNAMED) && !defined(SUNW_CONFCHECK) -#define SUNW_CONFCHECK -#endif - /* End additions for Solaris 2 */ #endif /* _SUNOPTIONS_H */ --- old/usr/src/lib/libresolv2/common/dst/hmac_link.c Fri Jul 3 12:24:13 2009 +++ new/usr/src/lib/libresolv2/common/dst/hmac_link.c Fri Jul 3 12:24:13 2009 @@ -1,13 +1,12 @@ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" #ifdef HMAC_MD5 #ifndef LINT -static const char rcsid[] = "$Header: /proj/cvs/isc/bind8/src/lib/dst/hmac_link.c,v 1.9 2001/05/29 05:48:10 marka Exp $"; +static const char rcsid[] = "$Header: /proj/cvs/prod/libbind/dst/hmac_link.c,v 1.8 2007/09/24 17:18:25 each Exp $"; #endif /* * Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc. @@ -26,7 +25,7 @@ * WITH THE USE OR PERFORMANCE OF THE SOFTWARE. */ -/* +/*% * This file contains an implementation of the HMAC-MD5 algorithm. */ #include "port_before.h" @@ -43,14 +42,17 @@ #include #include "dst_internal.h" + #ifdef USE_MD5 -#ifndef SUNW_LIBMD5 -# include "md5.h" -#else -#include -#endif +# ifndef HAVE_MD5 +# include "md5.h" +# else +# ifdef SOLARIS2 +# include +# endif +# endif # ifndef _MD5_H_ -# define _MD5_H_ 1 /* make sure we do not include rsaref md5.h file */ +# define _MD5_H_ 1 /*%< make sure we do not include rsaref md5.h file */ # endif #endif @@ -97,6 +99,9 @@ int sign_len = 0; MD5_CTX *ctx = NULL; + if (d_key == NULL || d_key->dk_KEY_struct == NULL) + return (-1); + if (mode & SIG_MODE_INIT) ctx = (MD5_CTX *) malloc(sizeof(*ctx)); else if (context) @@ -104,8 +109,6 @@ if (ctx == NULL) return (-1); - if (d_key == NULL || d_key->dk_KEY_struct == NULL) - return (-1); key = (HMAC_Key *) d_key->dk_KEY_struct; if (mode & SIG_MODE_INIT) { @@ -164,6 +167,9 @@ HMAC_Key *key; MD5_CTX *ctx = NULL; + if (d_key == NULL || d_key->dk_KEY_struct == NULL) + return (-1); + if (mode & SIG_MODE_INIT) ctx = (MD5_CTX *) malloc(sizeof(*ctx)); else if (context) @@ -171,9 +177,6 @@ if (ctx == NULL) return (-1); - if (d_key == NULL || d_key->dk_KEY_struct == NULL) - return (-1); - key = (HMAC_Key *) d_key->dk_KEY_struct; if (mode & SIG_MODE_INIT) { MD5Init(ctx); @@ -226,6 +229,7 @@ HMAC_Key *hkey = NULL; MD5_CTX ctx; int local_keylen = keylen; + u_char tk[MD5_LEN]; if (dkey == NULL || key == NULL || keylen < 0) return (-1); @@ -238,7 +242,6 @@ /* if key is longer than HMAC_LEN bytes reset it to key=MD5(key) */ if (keylen > HMAC_LEN) { - u_char tk[MD5_LEN]; MD5Init(&ctx); MD5Update(&ctx, key, keylen); MD5Final(tk, &ctx); @@ -276,25 +279,28 @@ static int dst_hmac_md5_key_to_file_format(const DST_KEY *dkey, char *buff, - const int buff_len) + const int buff_len) { char *bp; - int len, b_len, i, key_len; + int len, i, key_len; u_char key[HMAC_LEN]; HMAC_Key *hkey; if (dkey == NULL || dkey->dk_KEY_struct == NULL) return (0); - if (buff == NULL || buff_len <= (int) strlen(key_file_fmt_str)) - return (-1); /* no OR not enough space in output area */ - + /* + * Using snprintf() would be so much simpler here. + */ + if (buff == NULL || + buff_len <= (int)(strlen(key_file_fmt_str) + + strlen(KEY_FILE_FORMAT) + 4)) + return (-1); /*%< no OR not enough space in output area */ hkey = (HMAC_Key *) dkey->dk_KEY_struct; - memset(buff, 0, buff_len); /* just in case */ + memset(buff, 0, buff_len); /*%< just in case */ /* write file header */ sprintf(buff, key_file_fmt_str, KEY_FILE_FORMAT, KEY_HMAC_MD5, "HMAC"); - bp = (char *) strchr(buff, '\0'); - b_len = buff_len - (bp - buff); + bp = buff + strlen(buff); memset(key, 0, HMAC_LEN); for (i = 0; i < HMAC_LEN; i++) @@ -304,19 +310,21 @@ break; key_len = i + 1; + if (buff_len - (bp - buff) < 6) + return (-1); strcat(bp, "Key: "); bp += strlen("Key: "); - b_len = buff_len - (bp - buff); - len = b64_ntop(key, key_len, bp, b_len); + len = b64_ntop(key, key_len, bp, buff_len - (bp - buff)); if (len < 0) return (-1); bp += len; + if (buff_len - (bp - buff) < 2) + return (-1); *(bp++) = '\n'; *bp = '\0'; - b_len = buff_len - (bp - buff); - return (buff_len - b_len); + return (bp - buff); } @@ -338,9 +346,9 @@ { const char *p = buff, *eol; u_char key[HMAC_LEN+1]; /* b64_pton needs more than 64 bytes do decode - * it should probably be fixed rather than doing - * this - */ + * it should probably be fixed rather than doing + * this + */ u_char *tmp; int key_len, len; @@ -359,9 +367,11 @@ return (-4); len = eol - p; tmp = malloc(len + 2); + if (tmp == NULL) + return (-5); memcpy(tmp, p, len); *(tmp + len) = 0x0; - key_len = b64_pton((char *)tmp, key, HMAC_LEN+1); /* see above */ + key_len = b64_pton((char *)tmp, key, HMAC_LEN+1); /*%< see above */ SAFE_FREE2(tmp, len + 2); if (dst_buffer_to_hmac_md5(dkey, key, key_len) < 0) { @@ -370,7 +380,7 @@ return (0); } -/* +/*% * dst_hmac_md5_to_dns_key() * function to extract hmac key from DST_KEY structure * intput: @@ -439,43 +449,17 @@ static int dst_hmac_md5_generate_key(DST_KEY *key, const int nothing) { - u_char *buff; - int i, n, size; - - i = nothing; - - if (key == NULL || key->dk_alg != KEY_HMAC_MD5) - return (0); - size = (key->dk_key_size + 7) / 8; /* convert to bytes */ - if (size <= 0) - return(0); - - i = size > 64 ? 64 : size; - buff = malloc(i+8); - - n = dst_random(DST_RAND_SEMI, i, buff); - n += dst_random(DST_RAND_KEY, i, buff); - if (n <= i) { /* failed getting anything */ - SAFE_FREE2(buff, i); - return (-1); - } - n = dst_buffer_to_hmac_md5(key, buff, i); - SAFE_FREE2(buff, i); - if (n <= 0) - return (n); - return (1); + (void)key; + (void)nothing; + return (-1); } -/* +/*% * dst_hmac_md5_init() Function to answer set up function pointers for HMAC * related functions */ int -#ifdef ORIGINAL_ISC_CODE dst_hmac_md5_init() -#else -dst_md5_hmac_init() -#endif { if (dst_t_func[KEY_HMAC_MD5] != NULL) return (1); @@ -496,6 +480,8 @@ } #else +#define dst_hmac_md5_init __dst_hmac_md5_init + int dst_hmac_md5_init(){ return (0); @@ -502,9 +488,4 @@ } #endif - - - - - - +/*! \file */ --- old/usr/src/lib/libresolv2/common/mapfile-vers Fri Jul 3 12:24:15 2009 +++ new/usr/src/lib/libresolv2/common/mapfile-vers Fri Jul 3 12:24:15 2009 @@ -114,7 +114,6 @@ SUNWprivate_2.1 { global: - __areweinnamed; __assertion_failed; assertion_type_to_text; b64_ntop; @@ -134,27 +133,24 @@ dn_count_labels; __dn_count_labels; dn_skipname; - dst_buffer_to_key; - dst_check_algorithm; - dst_dnskey_to_key; - dst_free_key; - dst_generate_key; - dst_init; - dst_key_to_buffer; - dst_random; - dst_read_key; - dst_s_calculate_bits; - dst_s_conv_bignum_b64_to_u8; - dst_s_conv_bignum_u8_to_b64; - dst_s_dns_key_id; - dst_s_get_int16; - dst_s_id_calc; - dst_sign_data; - dst_s_put_int16; - dst_s_verify_str; + __dst_buffer_to_key; + __dst_check_algorithm; + __dst_dnskey_to_key; + __dst_free_key; + __dst_generate_key; + __dst_init; + __dst_key_to_buffer; + __dst_read_key; + __dst_s_calculate_bits; + __dst_s_dns_key_id; + __dst_s_get_int16; + __dst_s_id_calc; + __dst_sign_data; + __dst_s_put_int16; + __dst_s_verify_str; dst_t_func; - dst_verify_data; - dst_write_key; + __dst_verify_data; + __dst_write_key; __evAddTime; __evCancelConn; __evCancelRW; @@ -187,11 +183,14 @@ __h_errno; __h_errno_set; hostalias; + inet_cidr_ntop; + inet_cidr_pton; + inet_neta; inet_net_ntop; inet_net_pton; inet_nsap_addr; inet_nsap_ntoa; - irs_destroy; + __irs_destroy; __ISC_res_freeupdrec; __ISC_res_mkupdate; __ISC_res_mkupdrec; @@ -227,7 +226,7 @@ __memput_record; __memstats; __net_data_init; - net_data_minimize; + __net_data_minimize; __ns_datetosecs; __ns_find_tsig; _ns_flagdata; @@ -237,14 +236,35 @@ __ns_initparse; __ns_makecanon; __ns_msg_getflag; + __ns_name_compress; + __ns_name_eq; + __ns_name_labels; + __ns_name_length; + __ns_name_map; __ns_name_ntol; __ns_name_ntop; + __ns_name_owned; + __ns_name_pack; __ns_name_pton; __ns_name_rollback; + __ns_name_skip; + __ns_name_uncompress; __ns_name_unpack; + __ns_newmsg_copy; + __ns_newmsg_done; + __ns_newmsg_flag; + __ns_newmsg_id; + __ns_newmsg_init; + __ns_newmsg_q; + __ns_newmsg_rr; __ns_parserr; __ns_parse_ttl; + __ns_parserr2; __ns_put16; + __ns_put32; + __ns_rdata_equal; + __ns_rdata_refers; + __ns_rdata_unpack; __ns_samedomain; __ns_samename; __ns_sign; @@ -264,6 +284,8 @@ __p_class_syms; p_fqnname; __p_key_syms; + p_option; + __p_option; p_query; p_rcode; p_secstodate; @@ -302,6 +324,9 @@ res_nameinquery; __res_nameinquery; res_nisourserver; + res_nmkupdate; + res_nupdate; + __res_no_hosts_fallback; _res_opcodes; __res_override_retry; res_ownok; @@ -309,6 +334,7 @@ res_pquery; res_queriesmatch; __res_queriesmatch; + res_rndinit; res_randomid; __res_randomid; res_sendsigned; @@ -323,11 +349,11 @@ __sym_ntos; sym_ston; __sym_ston; - tree_add; - tree_init; - tree_mung; - tree_srch; - tree_trav; + __tree_add; + __tree_init; + __tree_mung; + __tree_srch; + __tree_trav; local: *; }; --- old/usr/src/lib/libresolv2/common/dst/hmac_link.c Fri Jul 3 12:24:16 2009 +++ new/usr/src/lib/libresolv2/common/dst/hmac_link.c Fri Jul 3 12:24:16 2009 @@ -1,13 +1,12 @@ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" #ifdef HMAC_MD5 #ifndef LINT -static const char rcsid[] = "$Header: /proj/cvs/isc/bind8/src/lib/dst/hmac_link.c,v 1.9 2001/05/29 05:48:10 marka Exp $"; +static const char rcsid[] = "$Header: /proj/cvs/prod/libbind/dst/hmac_link.c,v 1.8 2007/09/24 17:18:25 each Exp $"; #endif /* * Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc. @@ -26,7 +25,7 @@ * WITH THE USE OR PERFORMANCE OF THE SOFTWARE. */ -/* +/*% * This file contains an implementation of the HMAC-MD5 algorithm. */ #include "port_before.h" @@ -43,14 +42,17 @@ #include #include "dst_internal.h" + #ifdef USE_MD5 -#ifndef SUNW_LIBMD5 -# include "md5.h" -#else -#include -#endif +# ifndef HAVE_MD5 +# include "md5.h" +# else +# ifdef SOLARIS2 +# include +# endif +# endif # ifndef _MD5_H_ -# define _MD5_H_ 1 /* make sure we do not include rsaref md5.h file */ +# define _MD5_H_ 1 /*%< make sure we do not include rsaref md5.h file */ # endif #endif @@ -97,6 +99,9 @@ int sign_len = 0; MD5_CTX *ctx = NULL; + if (d_key == NULL || d_key->dk_KEY_struct == NULL) + return (-1); + if (mode & SIG_MODE_INIT) ctx = (MD5_CTX *) malloc(sizeof(*ctx)); else if (context) @@ -104,8 +109,6 @@ if (ctx == NULL) return (-1); - if (d_key == NULL || d_key->dk_KEY_struct == NULL) - return (-1); key = (HMAC_Key *) d_key->dk_KEY_struct; if (mode & SIG_MODE_INIT) { @@ -164,6 +167,9 @@ HMAC_Key *key; MD5_CTX *ctx = NULL; + if (d_key == NULL || d_key->dk_KEY_struct == NULL) + return (-1); + if (mode & SIG_MODE_INIT) ctx = (MD5_CTX *) malloc(sizeof(*ctx)); else if (context) @@ -171,9 +177,6 @@ if (ctx == NULL) return (-1); - if (d_key == NULL || d_key->dk_KEY_struct == NULL) - return (-1); - key = (HMAC_Key *) d_key->dk_KEY_struct; if (mode & SIG_MODE_INIT) { MD5Init(ctx); @@ -226,6 +229,7 @@ HMAC_Key *hkey = NULL; MD5_CTX ctx; int local_keylen = keylen; + u_char tk[MD5_LEN]; if (dkey == NULL || key == NULL || keylen < 0) return (-1); @@ -238,7 +242,6 @@ /* if key is longer than HMAC_LEN bytes reset it to key=MD5(key) */ if (keylen > HMAC_LEN) { - u_char tk[MD5_LEN]; MD5Init(&ctx); MD5Update(&ctx, key, keylen); MD5Final(tk, &ctx); @@ -276,25 +279,28 @@ static int dst_hmac_md5_key_to_file_format(const DST_KEY *dkey, char *buff, - const int buff_len) + const int buff_len) { char *bp; - int len, b_len, i, key_len; + int len, i, key_len; u_char key[HMAC_LEN]; HMAC_Key *hkey; if (dkey == NULL || dkey->dk_KEY_struct == NULL) return (0); - if (buff == NULL || buff_len <= (int) strlen(key_file_fmt_str)) - return (-1); /* no OR not enough space in output area */ - + /* + * Using snprintf() would be so much simpler here. + */ + if (buff == NULL || + buff_len <= (int)(strlen(key_file_fmt_str) + + strlen(KEY_FILE_FORMAT) + 4)) + return (-1); /*%< no OR not enough space in output area */ hkey = (HMAC_Key *) dkey->dk_KEY_struct; - memset(buff, 0, buff_len); /* just in case */ + memset(buff, 0, buff_len); /*%< just in case */ /* write file header */ sprintf(buff, key_file_fmt_str, KEY_FILE_FORMAT, KEY_HMAC_MD5, "HMAC"); - bp = (char *) strchr(buff, '\0'); - b_len = buff_len - (bp - buff); + bp = buff + strlen(buff); memset(key, 0, HMAC_LEN); for (i = 0; i < HMAC_LEN; i++) @@ -304,19 +310,21 @@ break; key_len = i + 1; + if (buff_len - (bp - buff) < 6) + return (-1); strcat(bp, "Key: "); bp += strlen("Key: "); - b_len = buff_len - (bp - buff); - len = b64_ntop(key, key_len, bp, b_len); + len = b64_ntop(key, key_len, bp, buff_len - (bp - buff)); if (len < 0) return (-1); bp += len; + if (buff_len - (bp - buff) < 2) + return (-1); *(bp++) = '\n'; *bp = '\0'; - b_len = buff_len - (bp - buff); - return (buff_len - b_len); + return (bp - buff); } @@ -338,9 +346,9 @@ { const char *p = buff, *eol; u_char key[HMAC_LEN+1]; /* b64_pton needs more than 64 bytes do decode - * it should probably be fixed rather than doing - * this - */ + * it should probably be fixed rather than doing + * this + */ u_char *tmp; int key_len, len; @@ -359,9 +367,11 @@ return (-4); len = eol - p; tmp = malloc(len + 2); + if (tmp == NULL) + return (-5); memcpy(tmp, p, len); *(tmp + len) = 0x0; - key_len = b64_pton((char *)tmp, key, HMAC_LEN+1); /* see above */ + key_len = b64_pton((char *)tmp, key, HMAC_LEN+1); /*%< see above */ SAFE_FREE2(tmp, len + 2); if (dst_buffer_to_hmac_md5(dkey, key, key_len) < 0) { @@ -370,7 +380,7 @@ return (0); } -/* +/*% * dst_hmac_md5_to_dns_key() * function to extract hmac key from DST_KEY structure * intput: @@ -439,43 +449,17 @@ static int dst_hmac_md5_generate_key(DST_KEY *key, const int nothing) { - u_char *buff; - int i, n, size; - - i = nothing; - - if (key == NULL || key->dk_alg != KEY_HMAC_MD5) - return (0); - size = (key->dk_key_size + 7) / 8; /* convert to bytes */ - if (size <= 0) - return(0); - - i = size > 64 ? 64 : size; - buff = malloc(i+8); - - n = dst_random(DST_RAND_SEMI, i, buff); - n += dst_random(DST_RAND_KEY, i, buff); - if (n <= i) { /* failed getting anything */ - SAFE_FREE2(buff, i); - return (-1); - } - n = dst_buffer_to_hmac_md5(key, buff, i); - SAFE_FREE2(buff, i); - if (n <= 0) - return (n); - return (1); + (void)key; + (void)nothing; + return (-1); } -/* +/*% * dst_hmac_md5_init() Function to answer set up function pointers for HMAC * related functions */ int -#ifdef ORIGINAL_ISC_CODE dst_hmac_md5_init() -#else -dst_md5_hmac_init() -#endif { if (dst_t_func[KEY_HMAC_MD5] != NULL) return (1); @@ -496,6 +480,8 @@ } #else +#define dst_hmac_md5_init __dst_hmac_md5_init + int dst_hmac_md5_init(){ return (0); @@ -502,9 +488,4 @@ } #endif - - - - - - +/*! \file */ --- old/usr/src/lib/libresolv2/common/irs/gethostent.c Fri Jul 3 12:24:17 2009 +++ new/usr/src/lib/libresolv2/common/irs/gethostent.c Fri Jul 3 12:24:17 2009 @@ -3,7 +3,9 @@ * Use is subject to license terms. */ + /* + * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 1996-1999 by Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -10,18 +12,17 @@ * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #if !defined(LINT) && !defined(CODECENTER) -static const char rcsid[] = "$Id: gethostent.c,v 1.34 2003/05/29 00:05:18 marka Exp $"; +static const char rcsid[] = "$Id: gethostent.c,v 1.8 2006/01/10 05:06:00 marka Exp $"; #endif /* Imports */ @@ -77,6 +78,7 @@ extern int __res_retry_reset(void); #endif /* SUNW_OVERRIDE_RETRY */ + /* Public */ struct hostent * @@ -94,11 +96,7 @@ } struct hostent * -#ifdef ORIGINAL_ISC_CODE gethostbyaddr(const char *addr, int len, int af) { -#else -gethostbyaddr(const void *addr, socklen_t len, int af) { -#endif /* ORIGINAL_ISC_CODE */ struct net_data *net_data = init(); return (gethostbyaddr_p(addr, len, af, net_data)); @@ -111,33 +109,17 @@ return (gethostent_p(net_data)); } -#ifdef ORIGINAL_ISC_CODE void -#else -int -#endif sethostent(int stayopen) { struct net_data *net_data = init(); sethostent_p(stayopen, net_data); -#ifdef ORIGINAL_ISC_CODE -#else - return (0); -#endif } -#ifdef ORIGINAL_ISC_CODE void -#else -int -#endif endhostent() { struct net_data *net_data = init(); endhostent_p(net_data); -#ifdef ORIGINAL_ISC_CODE -#else - return (0); -#endif } /* Shared private. */ @@ -147,18 +129,7 @@ struct hostent *hp; if (!net_data) -#ifdef SUNW_SETHERRNO - { - /* - * Should set the context h_errno, but since net_data - * is NULL, we don't have a context. - */ - h_errno = NETDB_INTERNAL; return (NULL); - } -#else - return (NULL); -#endif /* SUNW_SETHERRNO */ if (net_data->res->options & RES_USE_INET6) { hp = gethostbyname2_p(name, AF_INET6, net_data); @@ -177,16 +148,9 @@ char **hap; if (!net_data || !(ho = net_data->ho)) -#ifdef SUNW_SETHERRNO - { - h_errno = NETDB_INTERNAL; return (NULL); - } -#else - return (NULL); -#endif /* SUNW_SETHERRNO */ if (net_data->ho_stayopen && net_data->ho_last && - net_data->ho_last->h_addrtype == af) { + net_data->ho_last->h_addrtype == af) { if (ns_samename(name, net_data->ho_last->h_name) == 1) return (net_data->ho_last); for (hap = net_data->ho_last->h_aliases; hap && *hap; hap++) @@ -216,14 +180,7 @@ char **hap; if (!net_data || !(ho = net_data->ho)) -#ifdef SUNW_SETHERRNO - { - h_errno = NETDB_INTERNAL; return (NULL); - } -#else - return (NULL); -#endif /* SUNW_SETHERRNO */ if (net_data->ho_stayopen && net_data->ho_last && net_data->ho_last->h_length == len) for (hap = net_data->ho_last->h_addr_list; @@ -244,17 +201,10 @@ struct hostent *hp; if (!net_data || !(ho = net_data->ho)) -#ifdef SUNW_SETHERRNO - { - h_errno = NETDB_INTERNAL; return (NULL); - } -#else - return (NULL); -#endif /* SUNW_SETHERRNO */ while ((hp = (*ho->next)(ho)) != NULL && hp->h_addrtype == AF_INET6 && - (net_data->res->options & RES_USE_INET6) == 0) + (net_data->res->options & RES_USE_INET6) == 0U) continue; net_data->ho_last = hp; return (net_data->ho_last); @@ -302,11 +252,11 @@ static int scan_interfaces(int *, int *); static struct hostent *copyandmerge(struct hostent *, struct hostent *, int, int *); -/* +/*% * Public functions */ -/* +/*% * AI_V4MAPPED + AF_INET6 * If no IPv6 address then a query for IPv4 and map returned values. * @@ -416,20 +366,25 @@ struct net_data *net_data = init(); /* Sanity Checks. */ - if (src == NULL || net_data == NULL) { +#ifdef ORIGINAL_ISC_CODE + if (src == NULL) { +#else + /* this change was added circa May 2009, but not in ISC libbind 6.0 */ + if (src == NULL|| net_data == NULL) { +#endif /* ORIGINAL_ISC_CODE */ *error_num = NO_RECOVERY; return (NULL); } - + switch (af) { case AF_INET: - if (len != INADDRSZ) { + if (len != (size_t)INADDRSZ) { *error_num = NO_RECOVERY; return (NULL); } break; case AF_INET6: - if (len != IN6ADDRSZ) { + if (len != (size_t)IN6ADDRSZ) { *error_num = NO_RECOVERY; return (NULL); } @@ -512,11 +467,11 @@ memput(he, sizeof *he); } -/* +/*% * Private */ -/* +/*% * Scan the interface table and set have_v4 and have_v6 depending * upon whether there are IPv4 and IPv6 interface addresses. * @@ -528,9 +483,26 @@ #if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR) && \ !defined(IRIX_EMUL_IOCTL_SIOCGIFCONF) +#ifdef __hpux +#define lifc_len iflc_len +#define lifc_buf iflc_buf +#define lifc_req iflc_req +#define LIFCONF if_laddrconf +#else #define SETFAMILYFLAGS #define LIFCONF lifconf +#endif + +#ifdef __hpux +#define lifr_addr iflr_addr +#define lifr_name iflr_name +#define lifr_dstaddr iflr_dstaddr +#define lifr_flags iflr_flags +#define ss_family sa_family +#define LIFREQ if_laddrreq +#else #define LIFREQ lifreq +#endif static void scan_interfaces6(int *have_v4, int *have_v6) { @@ -555,7 +527,7 @@ if (buf == NULL) goto cleanup; #ifdef SETFAMILYFLAGS - lifc.lifc_family = AF_UNSPEC; /* request all families */ + lifc.lifc_family = AF_UNSPEC; /*%< request all families */ lifc.lifc_flags = 0; #endif lifc.lifc_len = bufsiz; @@ -583,7 +555,7 @@ } /* Parse system's interface list. */ - cplim = buf + lifc.lifc_len; /* skip over if's with big ifr_addr's */ + cplim = buf + lifc.lifc_len; /*%< skip over if's with big ifr_addr's */ for (cp = buf; (*have_v4 == 0 || *have_v6 == 0) && cp < cplim; cp += cpsize) { @@ -658,11 +630,38 @@ } #endif +#if ( defined(__linux__) || defined(__linux) || defined(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 scan_interfaces(int *have_v4, int *have_v6) { struct ifconf ifc; union { - char _pad[256]; /* leave space for IPv6 addresses */ + char _pad[256]; /*%< leave space for IPv6 addresses */ struct ifreq ifreq; } u; struct in_addr in4; @@ -684,6 +683,9 @@ if (*have_v4 != 0 && *have_v6 != 0) return (0); #endif +#ifdef __linux + scan_linux6(have_v6); +#endif /* Get interface list from system. */ if ((s = socket(AF_INET, SOCK_DGRAM, 0)) == -1) @@ -732,7 +734,7 @@ } /* Parse system's interface list. */ - cplim = buf + ifc.ifc_len; /* skip over if's with big ifr_addr's */ + cplim = buf + ifc.ifc_len; /*%< skip over if's with big ifr_addr's */ for (cp = buf; (*have_v4 == 0 || *have_v6 == 0) && cp < cplim; cp += cpsize) { @@ -812,8 +814,8 @@ static struct hostent * copyandmerge(struct hostent *he1, struct hostent *he2, int af, int *error_num) { struct hostent *he = NULL; - int addresses = 1; /* NULL terminator */ - int names = 1; /* NULL terminator */ + int addresses = 1; /*%< NULL terminator */ + int names = 1; /*%< NULL terminator */ int len = 0; char **cpp, **npp; @@ -972,6 +974,10 @@ if (!net_data->ho || !net_data->res) { error: errno = EIO; + +#ifdef SUNW_SETHERRNO + h_errno = NETDB_INTERNAL; +#endif /* SUNW_SETHERRNO */ if (net_data && net_data->res) RES_SET_H_ERRNO(net_data->res, NETDB_INTERNAL); return (NULL); @@ -1027,7 +1033,7 @@ } strncpy(pvt->name, name, NS_MAXDNAME); pvt->name[NS_MAXDNAME] = '\0'; - if (af == AF_INET && (net_data->res->options & RES_USE_INET6) != 0) { + if (af == AF_INET && (net_data->res->options & RES_USE_INET6) != 0U) { map_v4v6_address(pvt->addr, pvt->addr); af = AF_INET6; } @@ -1054,7 +1060,7 @@ return (&pvt->host); } -#ifdef grot /* for future use in gethostbyaddr(), for "SUNSECURITY" */ +#ifdef grot /*%< for future use in gethostbyaddr(), for "SUNSECURITY" */ struct hostent *rhp; char **haddr; u_long old_options; @@ -1085,5 +1091,6 @@ } } #endif /* grot */ - #endif /*__BIND_NOSTATIC*/ + +/*! \file */ --- old/usr/src/lib/libresolv2/common/irs/gen.c Fri Jul 3 12:24:18 2009 +++ new/usr/src/lib/libresolv2/common/irs/gen.c Fri Jul 3 12:24:18 2009 @@ -1,9 +1,11 @@ /* - * Copyright 1997-2002 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ + /* + * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 1996-1999 by Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -10,23 +12,21 @@ * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #if !defined(LINT) && !defined(CODECENTER) -static const char rcsid[] = "$Id: gen.c,v 1.26 2001/05/29 05:48:35 marka Exp $"; +static const char rcsid[] = "$Id: gen.c,v 1.7 2005/04/27 04:56:23 sra Exp $"; #endif -/* +/*! \file + * \brief * this is the top level dispatcher * * The dispatcher is implemented as an accessor class; it is an @@ -186,7 +186,7 @@ gen_res_set(this, res, free); } - if (((irs->res->options & RES_INIT) == 0) && res_ninit(irs->res) < 0) + if (((irs->res->options & RES_INIT) == 0U) && res_ninit(irs->res) < 0) return (NULL); return (irs->res); @@ -418,8 +418,10 @@ default_map_rules(irs); return; } - (void) sprintf(pattern, "%%%ds %%%ds %%%ds\n", - sizeof mapname, sizeof accname, sizeof options); + (void) sprintf(pattern, "%%%lus %%%lus %%%lus\n", + (unsigned long)sizeof mapname, + (unsigned long)sizeof accname, + (unsigned long)sizeof options); while (fgets(line, sizeof line, conf)) { enum irs_map_id map; enum irs_acc_id acc; --- old/usr/src/lib/libresolv2/common/isc/base64.c Fri Jul 3 12:24:20 2009 +++ new/usr/src/lib/libresolv2/common/isc/base64.c Fri Jul 3 12:24:20 2009 @@ -1,9 +1,11 @@ /* - * Copyright (c) 1997-2000 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ + /* + * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 1996-1999 by Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -10,18 +12,15 @@ * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * Portions Copyright (c) 1995 by International Business Machines, Inc. * @@ -48,7 +47,7 @@ */ #if !defined(LINT) && !defined(CODECENTER) -static const char rcsid[] = "$Id: base64.c,v 8.7 1999/10/13 16:39:33 vixie Exp $"; +static const char rcsid[] = "$Id: base64.c,v 1.4 2005/04/27 04:56:34 sra Exp $"; #endif /* not lint */ #include "port_before.h" @@ -69,8 +68,7 @@ #include "port_after.h" -#ifdef ORIGINAL_ISC_CODE -#else +#ifndef ORIGINAL_ISC_CODE #pragma weak __b64_ntop = b64_ntop #pragma weak __b64_pton = b64_pton #endif /* ORIGINAL_ISC_CODE */ @@ -82,7 +80,7 @@ static const char Pad64 = '='; /* (From RFC1521 and draft-ietf-dnssec-secext-03.txt) - The following encoding technique is taken from RFC 1521 by Borenstein + The following encoding technique is taken from RFC1521 by Borenstein and Freed. It is reproduced here in a slightly edited form for convenience. @@ -151,7 +149,7 @@ u_char output[4]; size_t i; - while (2 < srclength) { + while (2U < srclength) { input[0] = *src++; input[1] = *src++; input[2] = *src++; @@ -175,7 +173,7 @@ } /* Now we worry about padding. */ - if (0 != srclength) { + if (0U != srclength) { /* Get what's left. */ input[0] = input[1] = input[2] = '\0'; for (i = 0; i < srclength; i++) @@ -192,7 +190,7 @@ return (-1); target[datalength++] = Base64[output[0]]; target[datalength++] = Base64[output[1]]; - if (srclength == 1) + if (srclength == 1U) target[datalength++] = Pad64; else target[datalength++] = Base64[output[2]]; @@ -200,7 +198,7 @@ } if (datalength >= targsize) return (-1); - target[datalength] = '\0'; /* Returned value doesn't count \0. */ + target[datalength] = '\0'; /*%< Returned value doesn't count \\0. */ return (datalength); } @@ -223,7 +221,7 @@ tarindex = 0; while ((ch = *src++) != '\0') { - if (isspace(ch)) /* Skip whitespace anywhere. */ + if (isspace(ch)) /*%< Skip whitespace anywhere. */ continue; if (ch == Pad64) @@ -230,7 +228,7 @@ break; pos = strchr(Base64, ch); - if (pos == 0) /* A non-base64 character. */ + if (pos == 0) /*%< A non-base64 character. */ return (-1); switch (state) { @@ -283,14 +281,14 @@ * on a byte boundary, and/or with erroneous trailing characters. */ - if (ch == Pad64) { /* We got a pad char. */ - ch = *src++; /* Skip it, get next. */ + if (ch == Pad64) { /*%< We got a pad char. */ + ch = *src++; /*%< Skip it, get next. */ switch (state) { - case 0: /* Invalid = in first position */ - case 1: /* Invalid = in second position */ + case 0: /*%< Invalid = in first position */ + case 1: /*%< Invalid = in second position */ return (-1); - case 2: /* Valid, means one byte of info */ + case 2: /*%< Valid, means one byte of info */ /* Skip any number of spaces. */ for ((void)NULL; ch != '\0'; ch = *src++) if (!isspace(ch)) @@ -298,11 +296,11 @@ /* Make sure there is another trailing = sign. */ if (ch != Pad64) return (-1); - ch = *src++; /* Skip the = */ + ch = *src++; /*%< Skip the = */ /* Fall through to "single trailing =" case. */ /* FALLTHROUGH */ - case 3: /* Valid, means two bytes of info */ + case 3: /*%< Valid, means two bytes of info */ /* * We know this char is an =. Is there anything but * whitespace after it? @@ -331,3 +329,5 @@ return (tarindex); } + +/*! \file */ --- /dev/null Fri Jul 3 12:24:21 2009 +++ new/usr/src/lib/libresolv2/common/nameser/ns_newmsg.c Fri Jul 3 12:24:21 2009 @@ -0,0 +1,273 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +/* + * Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC") + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef lint +static const char rcsid[] = "$Id: ns_newmsg.c,v 1.3 2009/02/26 10:48:57 marka Exp $"; +#endif + +#include + +#include + +#include +#include +#include + +#include + +static int rdcpy(ns_newmsg *, ns_type, const u_char *, size_t); + +/* Initialize a "newmsg" object to empty. + */ +int +ns_newmsg_init(u_char *buffer, size_t bufsiz, ns_newmsg *handle) { + ns_msg *msg = &handle->msg; + + memset(handle, 0, sizeof *handle); + msg->_msg = buffer; + msg->_eom = buffer + bufsiz; + msg->_sect = ns_s_qd; + msg->_rrnum = 0; + msg->_msg_ptr = buffer + NS_HFIXEDSZ; + handle->dnptrs[0] = msg->_msg; + handle->dnptrs[1] = NULL; + handle->lastdnptr = &handle->dnptrs[sizeof handle->dnptrs / + sizeof handle->dnptrs[0] - 1]; + return (0); +} + +/* Initialize a "newmsg" object by copying an existing parsed message. + */ +int +ns_newmsg_copy(ns_newmsg *handle, ns_msg *msg) { + ns_flag flag; + ns_sect sect; + + ns_newmsg_id(handle, ns_msg_id(*msg)); + for (flag = ns_f_qr; flag < ns_f_max; flag++) + ns_newmsg_flag(handle, flag, ns_msg_getflag(*msg, flag)); + for (sect = ns_s_qd; sect < ns_s_max; sect++) { + int i, count; + + count = ns_msg_count(*msg, sect); + for (i = 0; i < count; i++) { + ns_rr2 rr; + int x; + + if (ns_parserr2(msg, sect, i, &rr) < 0) + return (-1); + if (sect == ns_s_qd) + x = ns_newmsg_q(handle, + ns_rr_nname(rr), + ns_rr_type(rr), + ns_rr_class(rr)); + else + x = ns_newmsg_rr(handle, sect, + ns_rr_nname(rr), + ns_rr_type(rr), + ns_rr_class(rr), + ns_rr_ttl(rr), + ns_rr_rdlen(rr), + ns_rr_rdata(rr)); + if (x < 0) + return (-1); + } + } + return (0); +} + +/* Set the message-ID in a "newmsg" object. + */ +void +ns_newmsg_id(ns_newmsg *handle, u_int16_t id) { + ns_msg *msg = &handle->msg; + + msg->_id = id; +} + +/* Set a flag (including rcode or opcode) in a "newmsg" object. + */ +void +ns_newmsg_flag(ns_newmsg *handle, ns_flag flag, u_int value) { + extern struct _ns_flagdata _ns_flagdata[16]; + struct _ns_flagdata *fd = &_ns_flagdata[flag]; + ns_msg *msg = &handle->msg; + + assert(flag < ns_f_max); + msg->_flags &= (~fd->mask); + msg->_flags |= (value << fd->shift); +} + +/* Add a question (or zone, if it's an update) to a "newmsg" object. + */ +int +ns_newmsg_q(ns_newmsg *handle, ns_nname_ct qname, + ns_type qtype, ns_class qclass) +{ + ns_msg *msg = &handle->msg; + u_char *t; + int n; + + if (msg->_sect != ns_s_qd) { + errno = ENODEV; + return (-1); + } + t = (u_char *) (unsigned long) msg->_msg_ptr; + if (msg->_rrnum == 0) + msg->_sections[ns_s_qd] = t; + n = ns_name_pack(qname, t, msg->_eom - t, + handle->dnptrs, handle->lastdnptr); + if (n < 0) + return (-1); + t += n; + if (t + QFIXEDSZ >= msg->_eom) { + errno = EMSGSIZE; + return (-1); + } + NS_PUT16(qtype, t); + NS_PUT16(qclass, t); + msg->_msg_ptr = t; + msg->_counts[ns_s_qd] = ++msg->_rrnum; + return (0); +} + +/* Add an RR to a "newmsg" object. + */ +int +ns_newmsg_rr(ns_newmsg *handle, ns_sect sect, + ns_nname_ct name, ns_type type, + ns_class rr_class, u_int32_t ttl, + u_int16_t rdlen, const u_char *rdata) +{ + ns_msg *msg = &handle->msg; + u_char *t; + int n; + + if (sect < msg->_sect) { + errno = ENODEV; + return (-1); + } + t = (u_char *) (unsigned long) msg->_msg_ptr; + if (sect > msg->_sect) { + msg->_sect = sect; + msg->_sections[sect] = t; + msg->_rrnum = 0; + } + n = ns_name_pack(name, t, msg->_eom - t, + handle->dnptrs, handle->lastdnptr); + if (n < 0) + return (-1); + t += n; + if (t + RRFIXEDSZ + rdlen >= msg->_eom) { + errno = EMSGSIZE; + return (-1); + } + NS_PUT16(type, t); + NS_PUT16(rr_class, t); + NS_PUT32(ttl, t); + msg->_msg_ptr = t; + if (rdcpy(handle, type, rdata, rdlen) < 0) + return (-1); + msg->_counts[sect] = ++msg->_rrnum; + return (0); +} + +/* Complete a "newmsg" object and return its size for use in write(). + * (Note: the "newmsg" object is also made ready for ns_parserr() etc.) + */ +size_t +ns_newmsg_done(ns_newmsg *handle) { + ns_msg *msg = &handle->msg; + ns_sect sect; + u_char *t; + + t = (u_char *) (unsigned long) msg->_msg; + NS_PUT16(msg->_id, t); + NS_PUT16(msg->_flags, t); + for (sect = 0; sect < ns_s_max; sect++) + NS_PUT16(msg->_counts[sect], t); + msg->_eom = msg->_msg_ptr; + msg->_sect = ns_s_max; + msg->_rrnum = -1; + msg->_msg_ptr = NULL; + return (msg->_eom - msg->_msg); +} + +/* Private. */ + +/* Copy an RDATA, using compression pointers where RFC1035 permits. + */ +static int +rdcpy(ns_newmsg *handle, ns_type type, const u_char *rdata, size_t rdlen) { + ns_msg *msg = &handle->msg; + u_char *p = (u_char *) (unsigned long) msg->_msg_ptr; + u_char *t = p + NS_INT16SZ; + u_char *s = t; + int n; + + switch (type) { + case ns_t_soa: + /* MNAME. */ + n = ns_name_pack(rdata, t, msg->_eom - t, + handle->dnptrs, handle->lastdnptr); + if (n < 0) + return (-1); + t += n; + if (ns_name_skip(&rdata, msg->_eom) < 0) + return (-1); + + /* ANAME. */ + n = ns_name_pack(rdata, t, msg->_eom - t, + handle->dnptrs, handle->lastdnptr); + if (n < 0) + return (-1); + t += n; + if (ns_name_skip(&rdata, msg->_eom) < 0) + return (-1); + + /* Serial, Refresh, Retry, Expiry, and Minimum. */ + if ((msg->_eom - t) < (NS_INT32SZ * 5)) { + errno = EMSGSIZE; + return (-1); + } + memcpy(t, rdata, NS_INT32SZ * 5); + t += (NS_INT32SZ * 5); + break; + case ns_t_ptr: + case ns_t_cname: + case ns_t_ns: + /* PTRDNAME, CNAME, or NSDNAME. */ + n = ns_name_pack(rdata, t, msg->_eom - t, + handle->dnptrs, handle->lastdnptr); + if (n < 0) + return (-1); + t += n; + break; + default: + memcpy(t, rdata, rdlen); + t += rdlen; + } + NS_PUT16(t - s, p); + msg->_msg_ptr = t; + return (0); +} + --- old/usr/src/lib/libresolv2/common/resolv/res_comp.c Fri Jul 3 12:24:21 2009 +++ new/usr/src/lib/libresolv2/common/resolv/res_comp.c Fri Jul 3 12:24:21 2009 @@ -1,8 +1,9 @@ /* - * Copyright 2003 by Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ + /* * Copyright (c) 1985, 1993 * The Regents of the University of California. All rights reserved. @@ -57,6 +58,7 @@ */ /* + * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") * Portions Copyright (c) 1996-1999 by Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -63,21 +65,18 @@ * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #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 8.16 2002/08/07 03:47:34 marka Exp $"; +static const char rcsid[] = "$Id: res_comp.c,v 1.5 2005/07/28 06:51:50 marka Exp $"; #endif /* LIBC_SCCS and not lint */ #include "port_before.h" @@ -92,8 +91,7 @@ #include #include "port_after.h" -#ifdef ORIGINAL_ISC_CODE -#else +#ifndef ORIGINAL_ISC_CODE #pragma weak __dn_skipname = dn_skipname #pragma weak __res_dnok = res_dnok #pragma weak __res_hnok = res_hnok @@ -100,12 +98,14 @@ #pragma weak __res_mailok = res_mailok #pragma weak __res_ownok = res_ownok #endif /* ORIGINAL_ISC_CODE */ -/* + +/*% * Expand compressed domain name 'src' to full domain name. - * 'msg' is a pointer to the begining of the message, - * '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. + * + * \li 'msg' is a pointer to the begining of the message, + * \li 'eom' points to the first location after the message, + * \li 'dst' is a pointer to a buffer of size 'dstsiz' for the result. + * \li Return size of compressed name or -1 if there was an error. */ int dn_expand(const u_char *msg, const u_char *eom, const u_char *src, @@ -118,10 +118,11 @@ return (n); } -/* +/*% * Pack domain name 'exp_dn' in presentation form into 'comp_dn'. - * Return the size of the compressed name or -1. - * 'length' is the size of the array pointed to by 'comp_dn'. + * + * \li Return the size of the compressed name or -1. + * \li 'length' is the size of the array pointed to by 'comp_dn'. */ int dn_comp(const char *src, u_char *dst, int dstsiz, @@ -132,7 +133,8 @@ (const u_char **)lastdnptr)); } -/* + +/*% * Skip over a compressed domain name. Return the size or -1. */ int @@ -144,11 +146,9 @@ return (ptr - saveptr); } -/* +/*% * Verify that a domain name uses an acceptable character set. - */ - -/* + * * Note the conspicuous absence of ctype macros in these definitions. On * non-ASCII hosts, we can't depend on string literals or ctype macros to * tell us anything about network-format data. The rest of the BIND system @@ -176,7 +176,7 @@ int res_hnok(const char *dn) { - int ppch = '\0', pch = PERIOD, ch = *dn++; + int pch = PERIOD, ch = *dn++; while (ch != '\0') { int nch = *dn++; @@ -193,12 +193,12 @@ if (!middlechar(ch)) return (0); } - ppch = pch, pch = ch, ch = nch; + pch = ch, ch = nch; } return (1); } -/* +/*% * hostname-like (A, MX, WKS) owners can have "*" as their first label * but must otherwise be as a host name. */ @@ -213,7 +213,7 @@ return (res_hnok(dn)); } -/* +/*% * SOA RNAMEs and RP RNAMEs can have any printable character in their first * label, but the rest of the name has to look like a host name. */ @@ -241,8 +241,8 @@ return (0); } -/* - * This function is quite liberal, since RFC 1034's character sets are only +/*% + * This function is quite liberal, since RFC1034's character sets are only * recommendations. */ int @@ -256,7 +256,7 @@ } #ifdef BIND_4_COMPAT -/* +/*% * This module must export the following externally-visible symbols: * ___putlong * ___putshort @@ -264,17 +264,18 @@ * __getshort * Note that one _ comes from C and the others come from us. */ -#ifdef ORIGINAL_ISC_CODE -#else -#ifdef __putlong -#undef __putlong + +#ifdef SOLARIS2 +#ifdef __putlong +#undef __putlong #endif -#ifdef __putshort -#undef __putshort +#ifdef __putshort +#undef __putshort #endif -#pragma weak putlong = __putlong -#pragma weak putshort = __putshort -#endif /* ORIGINAL_ISC_CODE */ +#pragma weak putlong = __putlong +#pragma weak putshort = __putshort +#endif /* SOLARIS2 */ + void __putlong(u_int32_t src, u_char *dst) { ns_put32(src, dst); } void __putshort(u_int16_t src, u_char *dst) { ns_put16(src, dst); } #ifndef __ultrix__ @@ -282,3 +283,5 @@ u_int16_t _getshort(const u_char *src) { return (ns_get16(src)); } #endif /*__ultrix__*/ #endif /*BIND_4_COMPAT*/ + +/*! \file */ --- old/usr/src/lib/libresolv2/common/resolv/res_debug.c Fri Jul 3 12:24:23 2009 +++ new/usr/src/lib/libresolv2/common/resolv/res_debug.c Fri Jul 3 12:24:23 2009 @@ -1,12 +1,30 @@ /* - * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ + /* + * Portions Copyright (C) 2004, 2005, 2008, 2009 Internet Systems Consortium, Inc. ("ISC") + * Portions Copyright (C) 1996-2003 Internet Software Consortium. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* * Copyright (c) 1985 * The Regents of the University of California. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -22,7 +40,7 @@ * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -38,7 +56,7 @@ /* * Portions Copyright (c) 1993 by Digital Equipment Corporation. - * + * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies, and that @@ -45,7 +63,7 @@ * the name of Digital Equipment Corporation not be used in advertising or * publicity pertaining to distribution of the document or software without * specific, written prior permission. - * + * * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT @@ -81,28 +99,9 @@ * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES. */ -/* - * Portions Copyright (c) 1996-1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - #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 8.50 2003/04/16 04:55:40 marka Exp $"; +static const char rcsid[] = "$Id: res_debug.c,v 1.19 2009/02/26 11:20:20 tbox Exp $"; #endif /* LIBC_SCCS and not lint */ #include "port_before.h" @@ -120,6 +119,7 @@ #include #include #include +#include #include #include #include @@ -136,8 +136,7 @@ extern const char *_res_opcodes[]; extern const char *_res_sectioncodes[]; -#ifdef ORIGINAL_ISC_CODE -#else +#ifndef ORIGINAL_ISC_CODE #pragma weak __dn_count_labels = dn_count_labels #pragma weak __fp_resstat = fp_resstat #pragma weak __loc_aton = loc_aton @@ -144,7 +143,6 @@ #pragma weak __loc_ntoa = loc_ntoa #pragma weak __p_cdname = p_cdname #pragma weak __p_class = p_class -#pragma weak __p_secstodate = p_secstodate #pragma weak __p_section = p_section #pragma weak __p_time = p_time #pragma weak __p_type = p_type @@ -153,7 +151,7 @@ #pragma weak __sym_ston = sym_ston #endif /* ORIGINAL_ISC_CODE */ -/* +/*% * Print the current options. */ void @@ -161,7 +159,7 @@ u_long mask; fprintf(file, ";; res options:"); - for (mask = 1; mask != 0; mask <<= 1) + for (mask = 1; mask != 0U; mask <<= 1) if (statp->options & mask) fprintf(file, " %s", p_option(mask)); putc('\n', file); @@ -212,10 +210,56 @@ p_type(ns_rr_type(rr)), p_class(ns_rr_class(rr))); else if (section == ns_s_ar && ns_rr_type(rr) == ns_t_opt) { + u_int16_t optcode, optlen, rdatalen = ns_rr_rdlen(rr); u_int32_t ttl = ns_rr_ttl(rr); + fprintf(file, "; EDNS: version: %u, udp=%u, flags=%04x\n", (ttl>>16)&0xff, ns_rr_class(rr), ttl&0xffff); + + while (rdatalen >= 4) { + const u_char *cp = ns_rr_rdata(rr); + int i; + + GETSHORT(optcode, cp); + GETSHORT(optlen, cp); + + if (optcode == NS_OPT_NSID) { + fputs("; NSID: ", file); + if (optlen == 0) { + fputs("; NSID\n", file); + } else { + fputs("; NSID: ", file); + for (i = 0; i < optlen; i++) + fprintf(file, "%02x ", + cp[i]); + fputs(" (",file); + for (i = 0; i < optlen; i++) + fprintf(file, "%c", + isprint(cp[i])? + cp[i] : '.'); + fputs(")\n", file); + } + } else { + if (optlen == 0) { + fprintf(file, "; OPT=%u\n", + optcode); + } else { + fprintf(file, "; OPT=%u: ", + optcode); + for (i = 0; i < optlen; i++) + fprintf(file, "%02x ", + cp[i]); + fputs(" (",file); + for (i = 0; i < optlen; i++) + fprintf(file, "%c", + isprint(cp[i]) ? + cp[i] : '.'); + fputs(")\n", file); + } + } + rdatalen -= 4 + optlen; + } } else { n = ns_sprintrr(handle, &rr, NULL, NULL, buf, buflen); @@ -227,7 +271,7 @@ buf = malloc(buflen += 1024); if (buf == NULL) { fprintf(file, - ";; memory allocation failure\n"); + ";; memory allocation failure\n"); return; } continue; @@ -246,7 +290,7 @@ free(buf); } -/* +/*% * Print the contents of a query. * This is intended to be primarily a debugging routine. */ @@ -306,7 +350,7 @@ fprintf(file, ", %s: %d", p_section(ns_s_ar, opcode), arcount); } - if ((!statp->pfcode) || (statp->pfcode & + if ((!statp->pfcode) || (statp->pfcode & (RES_PRF_HEADX | RES_PRF_HEAD2 | RES_PRF_HEAD1))) { putc('\n',file); } @@ -341,7 +385,8 @@ return (p_cdnname(cp, msg, PACKETSZ, file)); } -/* Return a fully-qualified domain name from a compressed name (with +/*% + * Return a fully-qualified domain name from a compressed name (with length supplied). */ const u_char * @@ -357,7 +402,7 @@ return (NULL); newlen = strlen(name); if (newlen == 0 || name[newlen - 1] != '.') { - if (newlen + 1 >= namelen) /* Lack space for final dot */ + if (newlen + 1 >= namelen) /*%< Lack space for final dot */ return (NULL); else strcpy(name + newlen, "."); @@ -379,7 +424,7 @@ return (n); } -/* +/*% * Names of RR classes and qclasses. Classes and qclasses are the same, except * that C_ANY is a qclass but not a class. (You can ask for records of class * C_ANY, but you can't have any records of that class in the database.) @@ -386,6 +431,7 @@ */ const struct res_sym __p_class_syms[] = { {C_IN, "IN", (char *)0}, + {C_CHAOS, "CH", (char *)0}, {C_CHAOS, "CHAOS", (char *)0}, {C_HS, "HS", (char *)0}, {C_HS, "HESIOD", (char *)0}, @@ -394,7 +440,7 @@ {C_IN, (char *)0, (char *)0} }; -/* +/*% * Names of message sections. */ const struct res_sym __p_default_section_syms[] = { @@ -402,7 +448,7 @@ {ns_s_an, "ANSWER", (char *)0}, {ns_s_ns, "AUTHORITY", (char *)0}, {ns_s_ar, "ADDITIONAL", (char *)0}, - {0, (char *)0, (char *)0} + {0, (char *)0, (char *)0} }; const struct res_sym __p_update_section_syms[] = { @@ -410,7 +456,7 @@ {S_PREREQ, "PREREQUISITE", (char *)0}, {S_UPDATE, "UPDATE", (char *)0}, {S_ADDT, "ADDITIONAL", (char *)0}, - {0, (char *)0, (char *)0} + {0, (char *)0, (char *)0} }; const struct res_sym __p_key_syms[] = { @@ -431,7 +477,7 @@ {0, NULL, NULL} }; -/* +/*% * Names of RR types and qtypes. Types and qtypes are the same, except * that T_ANY is a qtype but not a type. (You can ask for records of type * T_ANY, but you can't have any records of that type in the database.) @@ -471,6 +517,24 @@ {ns_t_nimloc, "NIMLOC", "NIMROD locator (unimplemented)"}, {ns_t_srv, "SRV", "server selection"}, {ns_t_atma, "ATMA", "ATM address (unimplemented)"}, + {ns_t_naptr, "NAPTR", "naptr"}, + {ns_t_kx, "KX", "key exchange"}, + {ns_t_cert, "CERT", "certificate"}, + {ns_t_a6, "A", "IPv6 address (experminental)"}, + {ns_t_dname, "DNAME", "non-terminal redirection"}, + {ns_t_opt, "OPT", "opt"}, + {ns_t_apl, "apl", "apl"}, + {ns_t_ds, "DS", "delegation signer"}, + {ns_t_sshfp, "SSFP", "SSH fingerprint"}, + {ns_t_ipseckey, "IPSECKEY", "IPSEC key"}, + {ns_t_rrsig, "RRSIG", "rrsig"}, + {ns_t_nsec, "NSEC", "nsec"}, + {ns_t_dnskey, "DNSKEY", "DNS key"}, + {ns_t_dhcid, "DHCID", "dynamic host configuration identifier"}, + {ns_t_nsec3, "NSEC3", "nsec3"}, + {ns_t_nsec3param, "NSEC3PARAM", "NSEC3 parameters"}, + {ns_t_hip, "HIP", "host identity protocol"}, + {ns_t_spf, "SPF", "sender policy framework"}, {ns_t_tkey, "TKEY", "tkey"}, {ns_t_tsig, "TSIG", "transaction signature"}, {ns_t_ixfr, "IXFR", "incremental zone transfer"}, @@ -486,10 +550,11 @@ {ns_t_sink, "SINK", "Kitchen Sink (experimental)"}, {ns_t_opt, "OPT", "EDNS Options"}, {ns_t_any, "ANY", "\"any\""}, + {ns_t_dlv, "DLV", "DNSSEC look-aside validation"}, {0, NULL, NULL} }; -/* +/*% * Names of DNS rcodes. */ const struct res_sym __p_rcode_syms[] = { @@ -522,16 +587,12 @@ } if (success) *success = 0; - return (syms->number); /* The default value. */ + return (syms->number); /*%< The default value. */ } const char * sym_ntos(const struct res_sym *syms, int number, int *success) { -#ifdef SUNW_MT_RESOLVER - char *unname = sym_ntos_unname; -#else - static char unname[20]; -#endif /* SUNW_MT_RESOLVER */ + char *unname = sym_ntos_unname; for ((void)NULL; syms->name != 0; syms++) { if (number == syms->number) { @@ -541,7 +602,7 @@ } } - sprintf(unname, "%d", number); /* XXX nonreentrant */ + sprintf(unname, "%d", number); /*%< XXX nonreentrant */ if (success) *success = 0; return (unname); @@ -549,11 +610,7 @@ const char * sym_ntop(const struct res_sym *syms, int number, int *success) { -#ifdef SUNW_MT_RESOLVER - char *unname = sym_ntop_unname; -#else - static char unname[20]; -#endif /* SUNW_MT_RESOLVER */ + char *unname = sym_ntop_unname; for ((void)NULL; syms->name != 0; syms++) { if (number == syms->number) { @@ -562,13 +619,13 @@ return (syms->humanname); } } - sprintf(unname, "%d", number); /* XXX nonreentrant */ + sprintf(unname, "%d", number); /*%< XXX nonreentrant */ if (success) *success = 0; return (unname); } -/* +/*% * Return a string for the type. */ const char * @@ -580,13 +637,13 @@ result = sym_ntos(__p_type_syms, type, &success); if (success) return (result); - if (type < 0 || type > 0xfff) + if (type < 0 || type > 0xffff) return ("BADTYPE"); sprintf(typebuf, "TYPE%d", type); return (typebuf); } -/* +/*% * Return a string for the type. */ const char * @@ -604,7 +661,7 @@ return (sym_ntos(symbols, section, (int *)0)); } -/* +/*% * Return a mnemonic for class. */ const char * @@ -616,26 +673,18 @@ result = sym_ntos(__p_class_syms, class, &success); if (success) return (result); - if (class < 0 || class > 0xfff) + if (class < 0 || class > 0xffff) return ("BADCLASS"); sprintf(classbuf, "CLASS%d", class); return (classbuf); } -/* +/*% * Return a mnemonic for an option */ const char * -#ifdef ORIGINAL_ISC_CODE p_option(u_long option) { -#else -p_option(u_int option) { -#endif -#ifdef SUNW_MT_RESOLVER - char *nbuf = p_option_nbuf; -#else - static char nbuf[40]; -#endif /* SUNW_MT_RESOLVER */ + char *nbuf = p_option_nbuf; switch (option) { case RES_INIT: return "init"; @@ -652,8 +701,9 @@ case RES_INSECURE2: return "insecure2"; case RES_NOALIASES: return "noaliases"; case RES_USE_INET6: return "inet6"; -#ifdef RES_USE_EDNS0 /* KAME extension */ +#ifdef RES_USE_EDNS0 /*%< KAME extension */ case RES_USE_EDNS0: return "edns0"; + case RES_NSID: return "nsid"; #endif #ifdef RES_USE_DNAME case RES_USE_DNAME: return "dname"; @@ -664,26 +714,21 @@ #ifdef RES_NOTLDQUERY case RES_NOTLDQUERY: return "no-tld-query"; #endif -#ifdef ORIGINAL_ISC_CODE +#ifdef RES_NO_NIBBLE2 + case RES_NO_NIBBLE2: return "no-nibble2"; +#endif /* XXX nonreentrant */ default: sprintf(nbuf, "?0x%lx?", (u_long)option); -#else - default: sprintf(nbuf, "?0x%x?", (u_int)option); -#endif return (nbuf); } } -/* +/*% * Return a mnemonic for a time to live. */ const char * p_time(u_int32_t value) { -#ifdef SUNW_MT_RESOLVER - char *nbuf = p_time_nbuf; -#else - static char nbuf[40]; /* XXX nonreentrant */ -#endif /* SUNW_MT_RESOLVER */ + char *nbuf = p_time_nbuf; if (ns_format_ttl(value, nbuf, sizeof nbuf) < 0) sprintf(nbuf, "%u", value); @@ -690,7 +735,7 @@ return (nbuf); } -/* +/*% * Return a string for the rcode. */ const char * @@ -698,7 +743,7 @@ return (sym_ntos(__p_rcode_syms, rcode, (int *)0)); } -/* +/*% * Return a string for a res_sockaddr_union. */ const char * @@ -718,7 +763,7 @@ sprintf(ret, "[af%d]", u.sin.sin_family); break; } - if (size > 0) { + if (size > 0U) { strncpy(buf, ret, size - 1); buf[size - 1] = '0'; } @@ -725,7 +770,7 @@ 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 * by 60*60*1000 for that. @@ -734,16 +779,12 @@ static unsigned int poweroften[10] = {1, 10, 100, 1000, 10000, 100000, 1000000,10000000,100000000,1000000000}; -/* takes an XeY precision/size value, returns a string representation. */ +/*% takes an XeY precision/size value, returns a string representation. */ static const char * precsize_ntoa(prec) u_int8_t prec; { -#ifdef SUNW_MT_RESOLVER - char *retbuf = precsize_ntoa_retbuf; -#else - static char retbuf[sizeof "90000000.00"]; /* XXX nonreentrant */ -#endif /* SUNW_MT_RESOLVER */ + char *retbuf = precsize_ntoa_retbuf; unsigned long val; int mantissa, exponent; @@ -756,7 +797,7 @@ return (retbuf); } -/* converts ascii size/precision X * 10**Y(cm) to 0xXY. moves pointer. */ +/*% converts ascii size/precision X * 10**Y(cm) to 0xXY. moves pointer. */ static u_int8_t precsize_aton(const char **strptr) { unsigned int mval = 0, cmval = 0; @@ -770,7 +811,7 @@ while (isdigit((unsigned char)*cp)) mval = mval * 10 + (*cp++ - '0'); - if (*cp == '.') { /* centimeters */ + if (*cp == '.') { /*%< centimeters */ cp++; if (isdigit((unsigned char)*cp)) { cmval = (*cp++ - '0') * 10; @@ -796,7 +837,7 @@ return (retval); } -/* converts ascii lat/lon to unsigned encoded 32-bit number. moves pointer. */ +/*% converts ascii lat/lon to unsigned encoded 32-bit number. moves pointer. */ static u_int32_t latlon2ul(const char **latlonstrptr, int *which) { const char *cp; @@ -826,7 +867,7 @@ while (isdigit((unsigned char)*cp)) secs = secs * 10 + (*cp++ - '0'); - if (*cp == '.') { /* decimal seconds */ + if (*cp == '.') { /*%< decimal seconds */ cp++; if (isdigit((unsigned char)*cp)) { secsfrac = (*cp++ - '0') * 100; @@ -839,7 +880,7 @@ } } - while (!isspace((unsigned char)*cp)) /* if any trailing garbage */ + while (!isspace((unsigned char)*cp)) /*%< if any trailing garbage */ cp++; while (isspace((unsigned char)*cp)) @@ -860,7 +901,7 @@ - secsfrac; break; default: - retval = 0; /* invalid value -- indicates error */ + retval = 0; /*%< invalid value -- indicates error */ break; } @@ -867,23 +908,22 @@ switch (*cp) { case 'N': case 'n': case 'S': case 's': - *which = 1; /* latitude */ + *which = 1; /*%< latitude */ break; case 'E': case 'e': case 'W': case 'w': - *which = 2; /* longitude */ + *which = 2; /*%< longitude */ break; default: - *which = 0; /* error */ + *which = 0; /*%< error */ break; } - cp++; /* skip the hemisphere */ - - while (!isspace((unsigned char)*cp)) /* if any trailing garbage */ + cp++; /*%< skip the hemisphere */ + while (!isspace((unsigned char)*cp)) /*%< if any trailing garbage */ cp++; - while (isspace((unsigned char)*cp)) /* move to next field */ + while (isspace((unsigned char)*cp)) /*%< move to next field */ cp++; *latlonstrptr = cp; @@ -891,7 +931,8 @@ return (retval); } -/* converts a zone file representation in a string to an RDATA on-the-wire +/*% + * converts a zone file representation in a string to an RDATA on-the-wire * representation. */ int loc_aton(ascii, binary) @@ -904,9 +945,9 @@ u_int32_t latit = 0, longit = 0, alt = 0; u_int32_t lltemp1 = 0, lltemp2 = 0; int altmeters = 0, altfrac = 0, altsign = 1; - u_int8_t hp = 0x16; /* default = 1e6 cm = 10000.00m = 10km */ - u_int8_t vp = 0x13; /* default = 1e3 cm = 10.00m */ - u_int8_t siz = 0x12; /* default = 1e2 cm = 1.00m */ + u_int8_t hp = 0x16; /*%< default = 1e6 cm = 10000.00m = 10km */ + u_int8_t vp = 0x13; /*%< default = 1e3 cm = 10.00m */ + u_int8_t siz = 0x12; /*%< default = 1e2 cm = 1.00m */ int which1 = 0, which2 = 0; cp = ascii; @@ -917,18 +958,18 @@ lltemp2 = latlon2ul(&cp, &which2); switch (which1 + which2) { - case 3: /* 1 + 2, the only valid combination */ - if ((which1 == 1) && (which2 == 2)) { /* normal case */ + case 3: /*%< 1 + 2, the only valid combination */ + if ((which1 == 1) && (which2 == 2)) { /*%< normal case */ latit = lltemp1; longit = lltemp2; - } else if ((which1 == 2) && (which2 == 1)) { /* reversed */ + } else if ((which1 == 2) && (which2 == 1)) { /*%< reversed */ longit = lltemp1; latit = lltemp2; - } else { /* some kind of brokenness */ + } else { /*%< some kind of brokenness */ return (0); } break; - default: /* we didn't get one of each */ + default: /*%< we didn't get one of each */ return (0); } @@ -937,7 +978,7 @@ altsign = -1; cp++; } - + if (*cp == '+') cp++; @@ -944,7 +985,7 @@ while (isdigit((unsigned char)*cp)) altmeters = altmeters * 10 + (*cp++ - '0'); - if (*cp == '.') { /* decimal meters */ + if (*cp == '.') { /*%< decimal meters */ cp++; if (isdigit((unsigned char)*cp)) { altfrac = (*cp++ - '0') * 10; @@ -956,7 +997,7 @@ alt = (10000000 + (altsign * (altmeters * 100 + altfrac))); - while (!isspace((unsigned char)*cp) && (cp < maxcp)) /* if trailing garbage or m */ + while (!isspace((unsigned char)*cp) && (cp < maxcp)) /*%< if trailing garbage or m */ cp++; while (isspace((unsigned char)*cp) && (cp < maxcp)) @@ -966,8 +1007,8 @@ goto defaults; siz = precsize_aton(&cp); - - while (!isspace((unsigned char)*cp) && (cp < maxcp)) /* if trailing garbage or m */ + + while (!isspace((unsigned char)*cp) && (cp < maxcp)) /*%< if trailing garbage or m */ cp++; while (isspace((unsigned char)*cp) && (cp < maxcp)) @@ -978,7 +1019,7 @@ hp = precsize_aton(&cp); - while (!isspace((unsigned char)*cp) && (cp < maxcp)) /* if trailing garbage or m */ + while (!isspace((unsigned char)*cp) && (cp < maxcp)) /*%< if trailing garbage or m */ cp++; while (isspace((unsigned char)*cp) && (cp < maxcp)) @@ -992,7 +1033,7 @@ defaults: bcp = binary; - *bcp++ = (u_int8_t) 0; /* version byte */ + *bcp++ = (u_int8_t) 0; /*%< version byte */ *bcp++ = siz; *bcp++ = hp; *bcp++ = vp; @@ -999,11 +1040,11 @@ PUTLONG(latit,bcp); PUTLONG(longit,bcp); PUTLONG(alt,bcp); - - return (16); /* size of RR in octets */ + + return (16); /*%< size of RR in octets */ } -/* takes an on-the-wire LOC RR and formats it in a human readable format. */ +/*% takes an on-the-wire LOC RR and formats it in a human readable format. */ const char * loc_ntoa(binary, ascii) const u_char *binary; @@ -1010,12 +1051,8 @@ char *ascii; { static const char *error = "?"; -#ifdef SUNW_MT_RESOLVER - char *tmpbuf = loc_ntoa_tmpbuf; -#else static char tmpbuf[sizeof "1000 60 60.000 N 1000 60 60.000 W -12345678.00m 90000000.00m 90000000.00m 90000000.00m"]; -#endif /* SUNW_MT_RESOLVER */ const u_char *cp = binary; int latdeg, latmin, latsec, latsecfrac; @@ -1029,7 +1066,7 @@ int32_t latval, longval, altval; u_int32_t templ; u_int8_t sizeval, hpval, vpval, versionval; - + char *sizestr, *hpstr, *vpstr; versionval = *cp++; @@ -1054,7 +1091,7 @@ longval = (templ - ((unsigned)1<<31)); GETLONG(templ, cp); - if (templ < referencealt) { /* below WGS 84 spheroid */ + if (templ < referencealt) { /*%< below WGS 84 spheroid */ altval = referencealt - templ; altsign = "-"; } else { @@ -1117,7 +1154,7 @@ } -/* Return the number of DNS hierarchy levels in the name. */ +/*% Return the number of DNS hierarchy levels in the name. */ int dn_count_labels(const char *name) { int i, len, count; @@ -1142,28 +1179,19 @@ return (count); } - -/* - * Make dates expressed in seconds-since-Jan-1-1970 easy to read. +/*% + * Make dates expressed in seconds-since-Jan-1-1970 easy to read. * SIG records are required to be printed like this, by the Secure DNS RFC. */ char * -#ifdef ORIGINAL_ISC_CODE p_secstodate (u_long secs) { -#else -p_secstodate (u_int secs) { -#endif -#ifdef SUNW_MT_RESOLVER - char *output = p_secstodate_output; -#else - /* XXX nonreentrant */ - static char output[15]; /* YYYYMMDDHHMMSS and null */ -#endif /* SUNW_MT_RESOLVER */ + char *output = p_secstodate_output; time_t clock = secs; struct tm *time; - #ifdef HAVE_TIME_R - gmtime_r(&clock, &time); + struct tm res; + + time = gmtime_r(&clock, &res); #else time = gmtime(&clock); #endif @@ -1190,7 +1218,7 @@ goto done; errno = 0; result = strtoul(buf + 5, &endptr, 10); - if (errno == 0 && *endptr == '\0' && result <= 0xffff) + if (errno == 0 && *endptr == '\0' && result <= 0xffffU) success = 1; done: if (successp) @@ -1213,7 +1241,7 @@ goto done; errno = 0; result = strtoul(buf + 4, &endptr, 10); - if (errno == 0 && *endptr == '\0' && result <= 0xffff) + if (errno == 0 && *endptr == '\0' && result <= 0xffffU) success = 1; done: if (successp) @@ -1220,3 +1248,5 @@ *successp = success; return (result); } + +/*! \file */ --- old/usr/src/lib/libresolv2/common/resolv/res_init.c Fri Jul 3 12:24:24 2009 +++ new/usr/src/lib/libresolv2/common/resolv/res_init.c Fri Jul 3 12:24:24 2009 @@ -1,8 +1,9 @@ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ + /* * Copyright (c) 1985, 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -57,6 +58,7 @@ */ /* + * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") * Portions Copyright (c) 1996-1999 by Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -63,21 +65,18 @@ * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #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 8.32 2003/04/03 06:31:10 marka Exp $"; +static const char rcsid[] = "$Id: res_init.c,v 1.26 2008/12/11 09:59:00 marka Exp $"; #endif /* LIBC_SCCS and not lint */ #include "port_before.h" @@ -98,14 +97,30 @@ #include #include +#ifndef HAVE_MD5 +# include "../dst/md5.h" +#else +# ifdef SOLARIS2 +# include +# endif +#endif +#ifndef _MD5_H_ +# define _MD5_H_ 1 /*%< make sure we do not include rsaref md5.h file */ +#endif + + #include "port_after.h" /* ensure that sockaddr_in6 and IN6ADDR_ANY_INIT are declared / defined */ #include +/* ISC purposely put port_after.h before to force in6 stuff + * (above) so we explicitly include port_resolv.h here */ +#include "port_resolv.h" + #include "res_private.h" -/* Options. Should all be left alone. */ +/*% Options. Should all be left alone. */ #define RESOLVSORT #define DEBUG @@ -116,16 +131,10 @@ #define MAXIFS 8192 #endif /* SUNW_INITCHKIF */ -#ifdef SUNW_DOMAINFROMNIS +#ifdef SOLARIS2 #include -#include -#endif /* SUNW_DOMAINFROMNIS */ +#endif -#ifdef ORIGINAL_ISC_CODE -#else -#pragma weak __res_randomid = res_randomid -#endif /* ORIGINAL_ISC_CODE */ - static void res_setoptions __P((res_state, const char *, const char *)); #ifdef RESOLVSORT @@ -134,7 +143,7 @@ static u_int32_t net_mask __P((struct in_addr)); #endif -#if !defined(isascii) /* XXX - could be a function */ +#if !defined(isascii) /*%< XXX - could be a function */ # define isascii(c) (!(c & 0200)) #endif @@ -142,7 +151,7 @@ * Resolver state default settings. */ -/* +/*% * Set up default settings. If the configuration file exist, the values * there will have precedence. Otherwise, the server address is set to * INADDR_ANY and the default domain name comes from the gethostname(). @@ -166,11 +175,10 @@ int res_ninit(res_state statp) { extern int __res_vinit(res_state, int); - return (__res_vinit(statp, 0)); } -/* This function has to be reachable by res_data.c but not publically. */ +/*% This function has to be reachable by res_data.c but not publically. */ int __res_vinit(res_state statp, int preinit) { register FILE *fp; @@ -177,7 +185,7 @@ register char *cp, **pp; register int n; char buf[BUFSIZ]; - int nserv = 0; /* number of nameserver records read from file */ + int nserv = 0; /*%< number of nameserver records read from file */ int haveenv = 0; int havesearch = 0; #ifdef RESOLVSORT @@ -186,7 +194,9 @@ #endif int dots; union res_sockaddr_union u[2]; + int maxns = MAXNS; + RES_SET_H_ERRNO(statp, 0); if (statp->_u._ext.ext != NULL) res_ndestroy(statp); @@ -194,7 +204,8 @@ statp->retrans = RES_TIMEOUT; statp->retry = RES_DFLRETRY; statp->options = RES_DEFAULT; - statp->id = res_randomid(); + res_rndinit(statp); + statp->id = res_nrandomid(statp); } memset(u, 0, sizeof(u)); @@ -236,8 +247,22 @@ 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"); - } else - return (-1); + } else { + /* + * Historically res_init() rarely, if at all, failed. + * Examples and applications exist which do not check + * our return code. Furthermore several applications + * simply call us to get the systems domainname. So + * rather then immediately fail here we store the + * failure, which is returned later, in h_errno. And + * prevent the collection of 'nameserver' information + * by setting maxns to 0. Thus applications that fail + * to check our return code wont be able to make + * queries anyhow. + */ + RES_SET_H_ERRNO(statp, NETDB_INTERNAL); + maxns = 0; + } #ifdef RESOLVSORT statp->nsort = 0; #endif @@ -328,26 +353,28 @@ } #endif /* SUNW_INITCHKIF */ -#ifdef SUNW_DOMAINFROMNIS -/* - * The old (4.8.3) libresolv derived the default domainname from NIS/NIS+. - */ - { - char buf[sizeof(statp->defdname)], *cp; - int ret; - if ((ret = sysinfo(SI_SRPC_DOMAIN, buf, sizeof(buf))) > 0 && - ret <= sizeof(buf)) { - if (buf[0] == '+') - buf[0] = '.'; - cp = strchr(buf, '.'); - if (cp == 0) - strcpy(statp->defdname, buf); - else - strcpy(statp->defdname, cp+1); - } - } -#endif /* SUNW_DOMAINFROMNIS */ +#ifdef SOLARIS2 + /* + * The old libresolv derived the defaultdomain from NIS/NIS+. + * We want to keep this behaviour + */ + { + char buf[sizeof(statp->defdname)], *cp; + int ret; + if ((ret = sysinfo(SI_SRPC_DOMAIN, buf, sizeof(buf))) > 0 && + (unsigned int)ret <= sizeof(buf)) { + if (buf[0] == '+') + buf[0] = '.'; + cp = strchr(buf, '.'); + cp = (cp == NULL) ? buf : (cp + 1); + strncpy(statp->defdname, cp, + sizeof(statp->defdname) - 1); + statp->defdname[sizeof(statp->defdname) - 1] = '\0'; + } + } +#endif /* SOLARIS2 */ + /* Allow user to override the local domain definition */ if ((cp = getenv("LOCALDOMAIN")) != NULL) { (void)strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1); @@ -365,7 +392,7 @@ pp = statp->dnsrch; *pp++ = cp; for (n = 0; *cp && pp < statp->dnsrch + MAXDNSRCH; cp++) { - if (*cp == '\n') /* silly backwards compat */ + if (*cp == '\n') /*%< silly backwards compat */ break; else if (*cp == ' ' || *cp == '\t') { *cp = 0; @@ -389,12 +416,7 @@ line[sizeof(name) - 1] == '\t')) nserv = 0; - -#ifdef SUNW_AVOIDSTDIO_FDLIMIT - if ((fp = fopen(_PATH_RESCONF, "rF")) != NULL) { -#else if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) { -#endif /* read the config file */ while (fgets(buf, sizeof(buf), fp) != NULL) { /* skip comments */ @@ -402,7 +424,7 @@ continue; /* read default domain name */ if (MATCH(buf, "domain")) { - if (haveenv) /* skip if have from environ */ + if (haveenv) /*%< skip if have from environ */ continue; cp = buf + sizeof("domain") - 1; while (*cp == ' ' || *cp == '\t') @@ -418,7 +440,7 @@ } /* set search list */ if (MATCH(buf, "search")) { - if (haveenv) /* skip if have from environ */ + if (haveenv) /*%< skip if have from environ */ continue; cp = buf + sizeof("search") - 1; while (*cp == ' ' || *cp == '\t') @@ -454,7 +476,7 @@ continue; } /* read nameservers to query */ - if (MATCH(buf, "nameserver") && nserv < MAXNS) { + if (MATCH(buf, "nameserver") && nserv < maxns) { struct addrinfo hints, *ai; char sbuf[NI_MAXSERV]; const size_t minsiz = @@ -542,7 +564,7 @@ #ifdef RESOLVSORT statp->nsort = nsort; #endif - (void) fclose(fp); + (void) fclose(fp); } /* * Last chance to get a nameserver. This should not normally @@ -572,7 +594,7 @@ while (pp < statp->dnsrch + MAXDFLSRCH) { if (dots < LOCALDOMAINPARTS) break; - cp = strchr(cp, '.') + 1; /* we know there is one */ + cp = strchr(cp, '.') + 1; /*%< we know there is one */ *pp++ = cp; dots--; } @@ -590,7 +612,7 @@ if ((cp = getenv("RES_OPTIONS")) != NULL) res_setoptions(statp, cp, "env"); statp->options |= RES_INIT; - return (0); + return (statp->res_h_errno); #ifdef SUNW_INITCHKIF freedata: if (statp->_u._ext.ext != NULL) { @@ -599,6 +621,7 @@ } return (-1); #endif /* SUNW_INITCHKIF */ + } static void @@ -634,20 +657,17 @@ statp->retrans = i; else statp->retrans = RES_MAXRETRANS; - } else if (!strncmp(cp, "attempts:", sizeof("attempts:") - 1)){ - i = atoi(cp + sizeof("attempts:") - 1); - if (i <= RES_MAXRETRY) - statp->retry = i; - else - statp->retry = RES_MAXRETRY; -#ifdef ORIGINAL_ISC_CODE -#else +#ifdef DEBUG + if (statp->options & RES_DEBUG) + printf(";;\ttimeout=%d\n", statp->retrans); +#endif +#ifdef SOLARIS2 } else if (!strncmp(cp, "retrans:", sizeof("retrans:") - 1)) { /* - * For backward compatibility, 'retrans' is - * supported as an alias for 'timeout', though - * without an imposed maximum. - */ + * For backward compatibility, 'retrans' is + * supported as an alias for 'timeout', though + * without an imposed maximum. + */ statp->retrans = atoi(cp + sizeof("retrans:") - 1); } else if (!strncmp(cp, "retry:", sizeof("retry:") - 1)){ /* @@ -656,7 +676,17 @@ * without an imposed maximum. */ statp->retry = atoi(cp + sizeof("retry:") - 1); -#endif /* ORIGINAL_ISC_CODE */ +#endif /* SOLARIS2 */ + } else if (!strncmp(cp, "attempts:", sizeof("attempts:") - 1)){ + i = atoi(cp + sizeof("attempts:") - 1); + if (i <= RES_MAXRETRY) + statp->retry = i; + else + statp->retry = RES_MAXRETRY; +#ifdef DEBUG + if (statp->options & RES_DEBUG) + printf(";;\tattempts=%d\n", statp->retry); +#endif } else if (!strncmp(cp, "debug", sizeof("debug") - 1)) { #ifdef DEBUG if (!(statp->options & RES_DEBUG)) { @@ -726,7 +756,7 @@ #ifdef RESOLVSORT /* XXX - should really support CIDR which means explicit masks always. */ static u_int32_t -net_mask(in) /* XXX - should really use system's version of this */ +net_mask(in) /*!< XXX - should really use system's version of this */ struct in_addr in; { register u_int32_t i = ntohl(in.s_addr); @@ -739,15 +769,49 @@ } #endif +void +res_rndinit(res_state statp) +{ + struct timeval now; + u_int32_t u32; + u_int16_t u16; + + gettimeofday(&now, NULL); + u32 = now.tv_sec; + memcpy(statp->_u._ext._rnd, &u32, 4); + u32 = now.tv_usec; + memcpy(statp->_u._ext._rnd + 4, &u32, 4); + u32 += now.tv_sec; + memcpy(statp->_u._ext._rnd + 8, &u32, 4); + u16 = getpid(); + memcpy(statp->_u._ext._rnd + 12, &u16, 2); + +} + u_int -res_randomid(void) { +res_nrandomid(res_state statp) { struct timeval now; + u_int16_t u16; + MD5_CTX ctx; gettimeofday(&now, NULL); - return (0xffff & (now.tv_sec ^ now.tv_usec ^ getpid())); + u16 = (u_int16_t) (now.tv_sec ^ now.tv_usec); + + memcpy(statp->_u._ext._rnd + 14, &u16, 2); +#ifndef HAVE_MD5 + MD5_Init(&ctx); + MD5_Update(&ctx, statp->_u._ext._rnd, 16); + MD5_Final(statp->_u._ext._rnd, &ctx); +#else + MD5Init(&ctx); + MD5Update(&ctx, statp->_u._ext._rnd, 16); + MD5Final(statp->_u._ext._rnd, &ctx); +#endif + memcpy(&u16, statp->_u._ext._rnd + 14, 2); + return ((u_int) u16); } -/* +/*% * This routine is for closing the socket if a virtual circuit is used and * the program wants to close it. This provides support for endhostent() * which expects to close the socket. @@ -890,3 +954,5 @@ } return (statp->nscount); } + +/*! \file */ --- old/usr/src/lib/libresolv2/common/resolv/res_data.c Fri Jul 3 12:24:26 2009 +++ new/usr/src/lib/libresolv2/common/resolv/res_data.c Fri Jul 3 12:24:26 2009 @@ -1,9 +1,11 @@ /* - * Copyright 2003 by Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ + /* + * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 1995-1999 by Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -10,20 +12,17 @@ * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$Id: res_data.c,v 8.18 2000/12/23 08:14:58 vixie Exp $"; +static const char rcsid[] = "$Id: res_data.c,v 1.7 2008/12/11 09:59:00 marka Exp $"; #endif /* LIBC_SCCS and not lint */ #include "port_before.h" @@ -47,14 +46,13 @@ #include #include "port_after.h" -#undef _res -#ifdef ORIGINAL_ISC_CODE -#else +#ifndef ORIGINAL_ISC_CODE #pragma weak __fp_nquery = fp_nquery #pragma weak __fp_query = fp_query #pragma weak __p_query = p_query #pragma weak __hostalias = hostalias +#pragma weak __res_randomid = res_randomid #endif const char *_res_opcodes[] = { @@ -61,8 +59,8 @@ "QUERY", "IQUERY", "CQUERYM", - "CQUERYU", /* experimental */ - "NOTIFY", /* experimental */ + "CQUERYU", /*%< experimental */ + "NOTIFY", /*%< experimental */ "UPDATE", "6", "7", @@ -85,13 +83,18 @@ }; #endif +#undef _res #ifndef __BIND_NOSTATIC struct __res_state _res # if defined(__BIND_RES_TEXT) - = { RES_TIMEOUT, } /* Motorola, et al. */ + = { RES_TIMEOUT, } /*%< Motorola, et al. */ # endif ; +#if defined(DO_PTHREADS) || defined(__linux) +#define _res (*__res_state()) +#endif + /* Proto. */ int res_ourserver_p(const res_state, const struct sockaddr_in *); @@ -131,7 +134,7 @@ * has set it to something in particular, we can randomize it now. */ if (!_res.id) - _res.id = res_randomid(); + _res.id = res_nrandomid(&_res); return (__res_vinit(&_res, 1)); } @@ -148,7 +151,7 @@ void fp_nquery(const u_char *msg, int len, FILE *file) { - if ((_res.options & RES_INIT) == 0 && res_init() == -1) + if ((_res.options & RES_INIT) == 0U && res_init() == -1) return; res_pquery(&_res, msg, len, file); @@ -155,16 +158,16 @@ } int -res_mkquery(int op, /* opcode of query */ - const char *dname, /* domain name */ - int class, int type, /* class and type of query */ - const u_char *data, /* resource record data */ - int datalen, /* length of data */ - const u_char *newrr_in, /* new rr for modify or append */ - u_char *buf, /* buffer to put query */ - int buflen) /* size of buffer */ +res_mkquery(int op, /*!< opcode of query */ + const char *dname, /*!< domain name */ + int class, int type, /*!< class and type of query */ + const u_char *data, /*!< resource record data */ + int datalen, /*!< length of data */ + const u_char *newrr_in, /*!< new rr for modify or append */ + u_char *buf, /*!< buffer to put query */ + int buflen) /*!< size of buffer */ { - if ((_res.options & RES_INIT) == 0 && res_init() == -1) { + if ((_res.options & RES_INIT) == 0U && res_init() == -1) { RES_SET_H_ERRNO(&_res, NETDB_INTERNAL); return (-1); } @@ -175,7 +178,7 @@ int res_mkupdate(ns_updrec *rrecp_in, u_char *buf, int buflen) { - if ((_res.options & RES_INIT) == 0 && res_init() == -1) { + if ((_res.options & RES_INIT) == 0U && res_init() == -1) { RES_SET_H_ERRNO(&_res, NETDB_INTERNAL); return (-1); } @@ -184,12 +187,12 @@ } int -res_query(const char *name, /* domain name */ - int class, int type, /* class and type of query */ - u_char *answer, /* buffer to put answer */ - int anslen) /* size of answer buffer */ +res_query(const char *name, /*!< domain name */ + int class, int type, /*!< class and type of query */ + u_char *answer, /*!< buffer to put answer */ + int anslen) /*!< size of answer buffer */ { - if ((_res.options & RES_INIT) == 0 && res_init() == -1) { + if ((_res.options & RES_INIT) == 0U && res_init() == -1) { RES_SET_H_ERRNO(&_res, NETDB_INTERNAL); return (-1); } @@ -213,7 +216,7 @@ int res_send(const u_char *buf, int buflen, u_char *ans, int anssiz) { - if ((_res.options & RES_INIT) == 0 && res_init() == -1) { + if ((_res.options & RES_INIT) == 0U && res_init() == -1) { /* errno should have been set by res_init() in this case. */ return (-1); } @@ -225,7 +228,7 @@ res_sendsigned(const u_char *buf, int buflen, ns_tsig_key *key, u_char *ans, int anssiz) { - if ((_res.options & RES_INIT) == 0 && res_init() == -1) { + if ((_res.options & RES_INIT) == 0U && res_init() == -1) { /* errno should have been set by res_init() in this case. */ return (-1); } @@ -240,7 +243,7 @@ int res_update(ns_updrec *rrecp_in) { - if ((_res.options & RES_INIT) == 0 && res_init() == -1) { + if ((_res.options & RES_INIT) == 0U && res_init() == -1) { RES_SET_H_ERRNO(&_res, NETDB_INTERNAL); return (-1); } @@ -249,12 +252,12 @@ } int -res_search(const char *name, /* domain name */ - int class, int type, /* class and type of query */ - u_char *answer, /* buffer to put answer */ - int anslen) /* size of answer */ +res_search(const char *name, /*!< domain name */ + int class, int type, /*!< class and type of query */ + u_char *answer, /*!< buffer to put answer */ + int anslen) /*!< size of answer */ { - if ((_res.options & RES_INIT) == 0 && res_init() == -1) { + if ((_res.options & RES_INIT) == 0U && res_init() == -1) { RES_SET_H_ERRNO(&_res, NETDB_INTERNAL); return (-1); } @@ -265,11 +268,11 @@ int res_querydomain(const char *name, const char *domain, - int class, int type, /* class and type of query */ - u_char *answer, /* buffer to put answer */ - int anslen) /* size of answer */ + int class, int type, /*!< class and type of query */ + u_char *answer, /*!< buffer to put answer */ + int anslen) /*!< size of answer */ { - if ((_res.options & RES_INIT) == 0 && res_init() == -1) { + if ((_res.options & RES_INIT) == 0U && res_init() == -1) { RES_SET_H_ERRNO(&_res, NETDB_INTERNAL); return (-1); } @@ -279,6 +282,16 @@ answer, anslen)); } +u_int +res_randomid(void) { + if ((_res.options & RES_INIT) == 0U && res_init() == -1) { + RES_SET_H_ERRNO(&_res, NETDB_INTERNAL); + return (-1); + } + + return (res_nrandomid(&_res)); +} + const char * hostalias(const char *name) { static char abuf[MAXDNAME]; @@ -304,3 +317,5 @@ #endif /*ultrix*/ #endif + +/*! \file */ --- old/usr/src/lib/libresolv2/common/resolv/res_mkquery.c Fri Jul 3 12:24:27 2009 +++ new/usr/src/lib/libresolv2/common/resolv/res_mkquery.c Fri Jul 3 12:24:27 2009 @@ -1,12 +1,30 @@ /* - * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ + /* + * Portions Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc. ("ISC") + * Portions Copyright (C) 1996, 1997, 1988, 1999, 2001, 2003 Internet Software Consortium. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* * Copyright (c) 1985, 1993 * The Regents of the University of California. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -22,7 +40,7 @@ * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -38,7 +56,7 @@ /* * Portions Copyright (c) 1993 by Digital Equipment Corporation. - * + * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies, and that @@ -45,7 +63,7 @@ * the name of Digital Equipment Corporation not be used in advertising or * publicity pertaining to distribution of the document or software without * specific, written prior permission. - * + * * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT @@ -56,28 +74,9 @@ * SOFTWARE. */ -/* - * Portions Copyright (c) 1996-1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - #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 8.16 2003/04/29 02:13:08 marka Exp $"; +static const char rcsid[] = "$Id: res_mkquery.c,v 1.10 2008/12/11 09:59:00 marka Exp $"; #endif /* LIBC_SCCS and not lint */ #include "port_before.h" @@ -90,8 +89,9 @@ #include #include #include -#endif +#endif /* SUNW_CONFCHECK */ + #include #include #include @@ -105,22 +105,23 @@ #ifdef SUNW_CONFCHECK static int _confcheck(res_state statp); -#endif +#endif /* SUNW_CONFCHECK */ -/* + +/*% * Form all types of queries. * Returns the size of the result or -1. */ int res_nmkquery(res_state statp, - int op, /* opcode of query */ - const char *dname, /* domain name */ - int class, int type, /* class and type of query */ - const u_char *data, /* resource record data */ - int datalen, /* length of data */ - const u_char *newrr_in, /* new rr for modify or append */ - u_char *buf, /* buffer to put query */ - int buflen) /* size of buffer */ + int op, /*!< opcode of query */ + const char *dname, /*!< domain name */ + int class, int type, /*!< class and type of query */ + const u_char *data, /*!< resource record data */ + int datalen, /*!< length of data */ + const u_char *newrr_in, /*!< new rr for modify or append */ + u_char *buf, /*!< buffer to put query */ + int buflen) /*!< size of buffer */ { register HEADER *hp; register u_char *cp, *ep; @@ -144,8 +145,8 @@ RES_SET_H_ERRNO(statp, NO_RECOVERY); return(-1); } -#endif - +#endif /* SUNW_CONFCHECK */ + /* * Initialize header fields. */ @@ -153,9 +154,10 @@ return (-1); memset(buf, 0, HFIXEDSZ); hp = (HEADER *) buf; - hp->id = htons(++statp->id); + statp->id = res_nrandomid(statp); + hp->id = htons(statp->id); hp->opcode = op; - hp->rd = (statp->options & RES_RECURSE) != 0; + hp->rd = (statp->options & RES_RECURSE) != 0U; hp->rcode = NOERROR; cp = buf + HFIXEDSZ; ep = buf + buflen; @@ -209,7 +211,7 @@ */ if (ep - cp < 1 + RRFIXEDSZ + datalen) return (-1); - *cp++ = '\0'; /* no domain name */ + *cp++ = '\0'; /*%< no domain name */ ns_put16(type, cp); cp += INT16SZ; ns_put16(class, cp); @@ -233,20 +235,13 @@ #ifdef RES_USE_EDNS0 /* attach OPT pseudo-RR, as documented in RFC2671 (EDNS0). */ -#ifndef T_OPT -#define T_OPT 41 -#endif int res_nopt(res_state statp, - int n0, /* current offset in buffer */ -#ifdef ORIGINAL_ISC_CODE - u_char *buf, /* buffer to put query */ -#else - uchar_t *buf, /* buffer to put query */ -#endif - int buflen, /* size of buffer */ - int anslen) /* UDP answer buffer size */ + 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, *ep; @@ -253,7 +248,7 @@ u_int16_t flags = 0; #ifdef DEBUG - if ((statp->options & RES_DEBUG) != 0) + if ((statp->options & RES_DEBUG) != 0U) printf(";; res_nopt()\n"); #endif @@ -264,14 +259,14 @@ if ((ep - cp) < 1 + RRFIXEDSZ) return (-1); - *cp++ = 0; /* "." */ - - ns_put16(T_OPT, cp); /* TYPE */ + *cp++ = 0; /*%< "." */ + ns_put16(ns_t_opt, cp); /*%< TYPE */ cp += INT16SZ; - ns_put16(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 */ + *cp++ = NOERROR; /*%< extended RCODE */ + *cp++ = 0; /*%< EDNS version */ + if (statp->options & RES_USE_DNSSEC) { #ifdef DEBUG if (statp->options & RES_DEBUG) @@ -281,34 +276,68 @@ } ns_put16(flags, cp); cp += INT16SZ; - ns_put16(0, cp); /* RDLEN */ + + ns_put16(0U, cp); /*%< RDLEN */ cp += INT16SZ; + hp->arcount = htons(ntohs(hp->arcount) + 1); return (cp - buf); } -#endif -#ifdef SUNW_CONFCHECK /* - * Kludge to time out quickly if there is no /etc/resolv.conf - * and a TCP connection to the local DNS server fails. - * - * Moved function from res_send.c to res_mkquery.c. This - * solves a long timeout problem with nslookup. - * - * __areweinnamed is needed because there is a possibility that the - * user might do bad things to resolv.conf and cause in.named to call - * _confcheck and deadlock the server. + * Construct variable data (RDATA) block for OPT psuedo-RR, append it + * to the buffer, then update the RDLEN field (previously set to zero by + * res_nopt()) with the new RDATA length. */ - -#ifdef SUNW_AREWEINNAMED -int __areweinnamed() +int +res_nopt_rdata(res_state statp, + int n0, /*%< current offset in buffer */ + u_char *buf, /*%< buffer to put query */ + int buflen, /*%< size of buffer */ + u_char *rdata, /*%< ptr to start of opt rdata */ + u_short code, /*%< OPTION-CODE */ + u_short len, /*%< OPTION-LENGTH */ + u_char *data) /*%< OPTION_DATA */ { - return (0); + register u_char *cp, *ep; + +#ifdef DEBUG + if ((statp->options & RES_DEBUG) != 0U) + printf(";; res_nopt_rdata()\n"); +#endif + + cp = buf + n0; + ep = buf + buflen; + + if ((ep - cp) < (4 + len)) + return (-1); + + if (rdata < (buf + 2) || rdata >= ep) + return (-1); + + ns_put16(code, cp); + cp += INT16SZ; + + ns_put16(len, cp); + cp += INT16SZ; + + memcpy(cp, data, len); + cp += len; + + len = cp - rdata; + ns_put16(len, rdata - 2); /* Update RDLEN field */ + + return (cp - buf); } -#endif /* SUNW_AREWEINNAMED */ +#endif +#ifdef SUNW_CONFCHECK + +/* + * Time out quickly if there is no /etc/resolv.conf and a TCP connection + * to the local DNS server fails. + */ static int _confcheck(res_state statp) { int ns; @@ -315,10 +344,6 @@ struct stat rc_stat; struct sockaddr_in ns_sin; - - if (__areweinnamed()) - return (0); - /* First, we check to see if /etc/resolv.conf exists. * If it doesn't, then it is likely that the localhost is * the nameserver. @@ -356,4 +381,6 @@ return (0); } -#endif +#endif /* SUNW_CONFCHECK */ + +/*! \file */ --- old/usr/src/lib/libresolv2/common/resolv/res_send.c Fri Jul 3 12:24:29 2009 +++ new/usr/src/lib/libresolv2/common/resolv/res_send.c Fri Jul 3 12:24:29 2009 @@ -1,12 +1,30 @@ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ + /* + * Portions Copyright (C) 2004-2009 Internet Systems Consortium, Inc. ("ISC") + * Portions Copyright (C) 1996-2003 Internet Software Consortium. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* * Copyright (c) 1985, 1989, 1993 * The Regents of the University of California. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -22,7 +40,7 @@ * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -38,7 +56,7 @@ /* * Portions Copyright (c) 1993 by Digital Equipment Corporation. - * + * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies, and that @@ -45,7 +63,7 @@ * the name of Digital Equipment Corporation not be used in advertising or * publicity pertaining to distribution of the document or software without * specific, written prior permission. - * + * * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT @@ -56,31 +74,13 @@ * SOFTWARE. */ -/* - * Portions Copyright (c) 1996-1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - #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 8.52 2003/04/29 02:13:08 marka Exp $"; +static const char rcsid[] = "$Id: res_send.c,v 1.22 2009/01/22 23:49:23 tbox Exp $"; #endif /* LIBC_SCCS and not lint */ -/* +/*! \file + * \brief * Send query to name server and wait for reply. */ @@ -110,14 +110,12 @@ #include "port_after.h" -#ifdef SUNW_POLL +#ifdef USE_POLL +#ifdef HAVE_STROPTS_H #include -#include -#if defined(pselect) -#undef pselect #endif -#define pselect Pselect -#endif /* SUNW_POLL */ +#include +#endif /* USE_POLL */ /* Options. Leave them on. */ #define DEBUG @@ -126,7 +124,7 @@ #define EXT(res) ((res)->_u._ext) -#ifdef ORIGINAL_ISC_CODE +#ifndef USE_POLL static const int highestFD = FD_SETSIZE - 1; #else static int highestFD = 0; @@ -139,13 +137,13 @@ static int send_vc(res_state, const u_char *, int, u_char *, int, int *, int); static int send_dg(res_state, const u_char *, int, - u_char *, int, int *, int, + u_char *, int, int *, int, int, int *, int *); static void Aerror(const res_state, FILE *, const char *, int, const struct sockaddr *, int); static void Perror(const res_state, FILE *, const char *, int); static int sock_eq(struct sockaddr *, struct sockaddr *); -#ifdef NEED_PSELECT +#if defined(NEED_PSELECT) && !defined(USE_POLL) static int pselect(int, void *, void *, void *, struct timespec *, const sigset_t *); @@ -152,8 +150,7 @@ #endif void res_pquery(const res_state, const u_char *, int, FILE *); -#ifdef ORIGINAL_ISC_CODE -#else +#ifndef ORIGINAL_ISC_CODE #pragma weak __res_nameinquery = res_nameinquery #pragma weak __res_queriesmatch = res_queriesmatch #pragma weak res_nisourserver = res_ourserver_p @@ -163,14 +160,15 @@ /* Public. */ -/* int - * res_isourserver(ina) +/*% * looks up "ina" in _res.ns_addr_list[] + * * returns: - * 0 : not found - * >0 : found + *\li 0 : not found + *\li >0 : found + * * author: - * paul vixie, 29may94 + *\li paul vixie, 29may94 */ int res_ourserver_p(const res_state statp, const struct sockaddr *sa) { @@ -199,8 +197,8 @@ if (srv6->sin6_family == in6p->sin6_family && srv6->sin6_port == in6p->sin6_port && #ifdef HAVE_SIN6_SCOPE_ID - (srv6->sin6_scope_id == 0 || - srv6->sin6_scope_id == in6p->sin6_scope_id) && + (srv6->sin6_scope_id == 0 || + 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))) @@ -213,17 +211,19 @@ return (0); } -/* int - * res_nameinquery(name, type, class, buf, eom) +/*% * look for (name,type,class) in the query section of packet (buf,eom) + * * requires: - * buf + HFIXEDSZ <= eom + *\li buf + HFIXEDSZ <= eom + * * returns: - * -1 : format error - * 0 : not found - * >0 : found + *\li -1 : format error + *\li 0 : not found + *\li >0 : found + * * author: - * paul vixie, 29may94 + *\li paul vixie, 29may94 */ int res_nameinquery(const char *name, int type, int class, @@ -251,16 +251,17 @@ return (0); } -/* int - * res_queriesmatch(buf1, eom1, buf2, eom2) +/*% * is there a 1:1 mapping of (name,type,class) * in (buf1,eom1) and (buf2,eom2)? + * * returns: - * -1 : format error - * 0 : not a 1:1 mapping - * >0 : is a 1:1 mapping + *\li -1 : format error + *\li 0 : not a 1:1 mapping + *\li >0 : is a 1:1 mapping + * * author: - * paul vixie, 29may94 + *\li paul vixie, 29may94 */ int res_queriesmatch(const u_char *buf1, const u_char *eom1, @@ -304,14 +305,14 @@ res_nsend(res_state statp, const u_char *buf, int buflen, u_char *ans, int anssiz) { - int gotsomewhere, terrno, try, v_circuit, resplen, ns, n; + int gotsomewhere, terrno, tries, v_circuit, resplen, ns, n; char abuf[NI_MAXHOST]; -#ifdef SUNW_POLL +#ifdef USE_POLL highestFD = sysconf(_SC_OPEN_MAX) - 1; #endif - /* No name servers or previous res_ninit() failure */ + /* No name servers or res_init() failure */ if (statp->nscount == 0 || EXT(statp).ext == NULL) { errno = ESRCH; return (-1); @@ -349,7 +350,7 @@ if (EXT(statp).nssocks[ns] == -1) continue; peerlen = sizeof(peer); - if (getsockname(EXT(statp).nssocks[ns], + if (getpeername(EXT(statp).nssocks[ns], (struct sockaddr *)&peer, &peerlen) < 0) { needclose++; break; @@ -385,8 +386,8 @@ * Some resolvers want to even out the load on their nameservers. * Note that RES_BLAST overrides RES_ROTATE. */ - if ((statp->options & RES_ROTATE) != 0 && - (statp->options & RES_BLAST) == 0) { + if ((statp->options & RES_ROTATE) != 0U && + (statp->options & RES_BLAST) == 0U) { union res_sockaddr_union inu; struct sockaddr_in ina; int lastns = statp->nscount - 1; @@ -400,7 +401,7 @@ nstime = EXT(statp).nstimes[0]; for (ns = 0; ns < lastns; ns++) { if (EXT(statp).ext != NULL) - EXT(statp).ext->nsaddrs[ns] = + EXT(statp).ext->nsaddrs[ns] = EXT(statp).ext->nsaddrs[ns + 1]; statp->nsaddr_list[ns] = statp->nsaddr_list[ns + 1]; EXT(statp).nssocks[ns] = EXT(statp).nssocks[ns + 1]; @@ -416,7 +417,7 @@ /* * Send request, RETRY times, or until successful. */ - for (try = 0; try < statp->retry; try++) { + for (tries = 0; tries < statp->retry; tries++) { for (ns = 0; ns < statp->nscount; ns++) { struct sockaddr *nsap; int nsaplen; @@ -464,7 +465,7 @@ if (v_circuit) { /* Use VC; at most one attempt per server. */ - try = statp->retry; + tries = statp->retry; n = send_vc(statp, buf, buflen, ans, anssiz, &terrno, ns); if (n < 0) @@ -475,7 +476,7 @@ } else { /* Use datagrams. */ n = send_dg(statp, buf, buflen, ans, anssiz, &terrno, - ns, &v_circuit, &gotsomewhere); + ns, tries, &v_circuit, &gotsomewhere); if (n < 0) goto fail; if (n == 0) @@ -500,8 +501,8 @@ * or if we haven't been asked to keep a socket open, * close the socket. */ - if ((v_circuit && (statp->options & RES_USEVC) == 0) || - (statp->options & RES_STAYOPEN) == 0) { + if ((v_circuit && (statp->options & RES_USEVC) == 0U) || + (statp->options & RES_STAYOPEN) == 0U) { res_nclose(statp); } if (statp->rhook) { @@ -540,9 +541,9 @@ res_nclose(statp); if (!v_circuit) { if (!gotsomewhere) - errno = ECONNREFUSED; /* no nameservers found */ + errno = ECONNREFUSED; /*%< no nameservers found */ else - errno = ETIMEDOUT; /* no answer obtained */ + errno = ETIMEDOUT; /*%< no answer obtained */ } else errno = terrno; return (-1); @@ -569,10 +570,10 @@ else if (sa->sa_family == AF_INET6) return (sizeof(struct sockaddr_in6)); else - return (0); /* unknown, die on connect */ + return (0); /*%< unknown, die on connect */ } -/* +/*% * pick appropriate nsaddr_list for use. see res_init() for initialization. */ static struct sockaddr * @@ -612,6 +613,9 @@ u_short len; u_char *cp; void *tmp; +#ifdef SO_NOSIGPIPE + int on = 1; +#endif nsap = get_nsaddr(statp, ns); nsaplen = get_salen(nsap); @@ -643,10 +647,31 @@ errno = ENOTSOCK; } if (statp->_vcsock < 0) { - *terrno = errno; - Perror(statp, stderr, "socket(vc)", errno); - return (-1); + switch (errno) { + case EPROTONOSUPPORT: +#ifdef EPFNOSUPPORT + case EPFNOSUPPORT: +#endif + case EAFNOSUPPORT: + Perror(statp, stderr, "socket(vc)", errno); + return (0); + default: + *terrno = errno; + Perror(statp, stderr, "socket(vc)", errno); + return (-1); + } } +#ifdef SO_NOSIGPIPE + /* + * Disable generation of SIGPIPE when writing to a closed + * socket. Write should return -1 and set errno to EPIPE + * instead. + * + * Push on even if setsockopt(SO_NOSIGPIPE) fails. + */ + (void)setsockopt(statp->_vcsock, SOL_SOCKET, SO_NOSIGPIPE, &on, + sizeof(on)); +#endif errno = 0; if (connect(statp->_vcsock, nsap, nsaplen) < 0) { *terrno = errno; @@ -679,7 +704,7 @@ len = INT16SZ; while ((n = read(statp->_vcsock, (char *)cp, (int)len)) > 0) { cp += n; - if ((len -= n) <= 0) + if ((len -= n) == 0) break; } if (n <= 0) { @@ -739,14 +764,6 @@ */ anhp->tc = 1; len = resplen - anssiz; - /* - * Reset the value of resplen to anssiz, - * this is done because the caller assumes - * resplen contains the size of message read - * into the "ans" buffer passed in. - */ - resplen = anssiz; - while (len != 0) { char junk[PACKETSZ]; @@ -781,9 +798,9 @@ } static int -send_dg(res_state statp, - const u_char *buf, int buflen, u_char *ans, int anssiz, - int *terrno, int ns, int *v_circuit, int *gotsomewhere) +send_dg(res_state statp, const u_char *buf, int buflen, u_char *ans, + int anssiz, int *terrno, int ns, int tries, int *v_circuit, + int *gotsomewhere) { const HEADER *hp = (const HEADER *) buf; HEADER *anhp = (HEADER *) ans; @@ -790,13 +807,14 @@ const struct sockaddr *nsap; int nsaplen; struct timespec now, timeout, finish; - fd_set dsmask; struct sockaddr_storage from; ISC_SOCKLEN_T fromlen; int resplen, seconds, n, s; -#ifdef SUNW_POLL - int polltimeout; +#ifdef USE_POLL + int polltimeout; struct pollfd pollfd; +#else + fd_set dsmask; #endif nsap = get_nsaddr(statp, ns); @@ -808,9 +826,19 @@ errno = ENOTSOCK; } if (EXT(statp).nssocks[ns] < 0) { - *terrno = errno; - Perror(statp, stderr, "socket(dg)", errno); - return (-1); + switch (errno) { + case EPROTONOSUPPORT: +#ifdef EPFNOSUPPORT + case EPFNOSUPPORT: +#endif + case EAFNOSUPPORT: + Perror(statp, stderr, "socket(dg)", errno); + return (0); + default: + *terrno = errno; + Perror(statp, stderr, "socket(dg)", errno); + return (-1); + } } #ifndef CANNOT_CONNECT_DGRAM /* @@ -853,7 +881,7 @@ /* * Wait for reply. */ - seconds = (statp->retrans << ns); + seconds = (statp->retrans << tries); if (ns > 0) seconds /= statp->nscount; if (seconds <= 0) @@ -865,7 +893,15 @@ wait: now = evNowTime(); nonow: -#ifdef SUNW_POLL +#ifndef USE_POLL + FD_ZERO(&dsmask); + FD_SET(s, &dsmask); + if (evCmpTime(finish, now) > 0) + timeout = evSubTime(finish, now); + else + timeout = evConsTime(0, 0); + n = pselect(s + 1, &dsmask, NULL, NULL, &timeout, NULL); +#else timeout = evSubTime(finish, now); if (timeout.tv_sec < 0) timeout = evConsTime(0, 0); @@ -874,15 +910,8 @@ pollfd.fd = s; pollfd.events = POLLRDNORM; n = poll(&pollfd, 1, polltimeout); -#else - FD_ZERO(&dsmask); - FD_SET(s, &dsmask); - if (evCmpTime(finish, now) > 0) - timeout = evSubTime(finish, now); - else - timeout = evConsTime(0, 0); - n = pselect(s + 1, &dsmask, NULL, NULL, &timeout, NULL); -#endif +#endif /* USE_POLL */ + if (n == 0) { Dprint(statp->options & RES_DEBUG, (stdout, ";; timeout\n")); *gotsomewhere = 1; @@ -891,11 +920,11 @@ if (n < 0) { if (errno == EINTR) goto wait; -#ifdef SUNW_POLL - Perror(statp, stderr, "poll", errno); -#else +#ifndef USE_POLL Perror(statp, stderr, "select", errno); -#endif +#else + Perror(statp, stderr, "poll", errno); +#endif /* USE_POLL */ res_nclose(statp); return (0); } @@ -946,7 +975,7 @@ goto wait; } #ifdef RES_USE_EDNS0 - if (anhp->rcode == FORMERR && (statp->options & RES_USE_EDNS0) != 0) { + if (anhp->rcode == FORMERR && (statp->options & RES_USE_EDNS0) != 0U) { /* * Do not retry if the server do not understand EDNS0. * The case has to be captured here, as FORMERR packet do not @@ -1014,7 +1043,7 @@ alen = alen; - if ((statp->options & RES_DEBUG) != 0) { + if ((statp->options & RES_DEBUG) != 0U) { if (getnameinfo(address, alen, hbuf, sizeof(hbuf), sbuf, sizeof(sbuf), niflags)) { strncpy(hbuf, "?", sizeof(hbuf) - 1); @@ -1032,7 +1061,7 @@ Perror(const res_state statp, FILE *file, const char *string, int error) { int save = errno; - if ((statp->options & RES_DEBUG) != 0) + if ((statp->options & RES_DEBUG) != 0U) fprintf(file, "res_send: %s: %s\n", string, strerror(error)); errno = save; @@ -1064,7 +1093,7 @@ } } -#ifdef NEED_PSELECT +#if defined(NEED_PSELECT) && !defined(USE_POLL) /* XXX needs to move to the porting library. */ static int pselect(int nfds, void *rfds, void *wfds, void *efds, --- old/usr/src/lib/libresolv2/common/sunw/sunw_mtctxres.c Fri Jul 3 12:24:30 2009 +++ new/usr/src/lib/libresolv2/common/sunw/sunw_mtctxres.c Fri Jul 3 12:24:30 2009 @@ -1,9 +1,8 @@ /* - * Copyright (c) 1998-2000 by Sun Microsystems, Inc. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include #include #include @@ -14,108 +13,13 @@ #include #include -static int thr_keycreate_ret = 0; - -static thread_key_t key; -static int mt_key_initialized = 0; - -static mtctxres_t sharedctx; - -static int __res_init_ctx(thread_key_t); -static void __res_destroy_ctx(void *); - -#pragma init (_mtctxres_init) - /* - * Initialize the TSD key. By doing this at library load time, we're - * implicitly running without interference from other threads, so there's - * no need for locking. + * much of the original version of sunw_mtxtxres.c was incorporated into + * ISC libbind as resolv/mtctxres.c. The following bits have not yet made + * it into ISC libbind. */ -static void -_mtctxres_init(void) { - if ((thr_keycreate_ret = thr_keycreate(&key, __res_destroy_ctx)) == 0) { - mt_key_initialized = 1; - } -} - - /* - * To support binaries that used the private MT-safe interface in - * on998 or on28, we still need to provide the __res_enable_mt() - * and __res_disable_mt() entry points. They're do-nothing routines. - */ -int -__res_enable_mt(void) { - return (-1); -} - -int -__res_disable_mt(void) { - return (0); -} - - -static int -__res_init_ctx(thread_key_t key) { - - mtctxres_t *mt; - int ret; - - - if (thr_getspecific(key, (void **)&mt) == 0 && mt != 0) { - /* Already exists */ - return (0); - } - - if ((mt = malloc(sizeof (mtctxres_t))) == 0) { - errno = ENOMEM; - return (-1); - } - - memset(mt, 0, sizeof (*mt)); - - if ((ret = thr_setspecific(key, mt)) != 0) { - errno = ret; - free(mt); - return (-1); - } - - return (0); - -} - - -static void -__res_destroy_ctx(void *value) { - - mtctxres_t *mt = (mtctxres_t *)value; - - if (mt != 0) { - free(mt); - } -} - - -mtctxres_t * -___mtctxres() { - - mtctxres_t *mt; - - - if (mt_key_initialized) { - if ((thr_getspecific(key, (void **)&mt) == 0 && mt != 0) || - (__res_init_ctx(key) == 0 && - thr_getspecific(key, (void **)&mt) == 0 && mt != 0)) { - return (mt); - } - } - - return (&sharedctx); -} - - -/* * There used to be a private, MT-safe resolver interface that used TSD * to store per-thread _res, h_errno, etc. We continue to provide the * access functions __res_get_res() and __res_get_h_errno() so that binaries --- /dev/null Fri Jul 3 12:24:31 2009 +++ new/usr/src/lib/libresolv2/common/sunw/sunw_wrappers.c Fri Jul 3 12:24:31 2009 @@ -0,0 +1,23 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#include +#include +#include +#include + +#undef p_option +/* extern const char * isc_p_option(); */ +const char *p_option(uint_t option) { + return (isc_p_option((ulong_t)option)); +} +#pragma weak __p_option = p_option + +#undef p_secstodate +/* extern char * isc_p_secstodate (); */ +char *p_secstodate(uint_t secs) { + return (isc_p_secstodate((ulong_t)secs)); +} +#pragma weak __p_secstodate = p_secstodate --- old/usr/src/lib/libresolv2/common/sunw/sunw_updrec.c Fri Jul 3 12:24:32 2009 +++ new/usr/src/lib/libresolv2/common/sunw/sunw_updrec.c Fri Jul 3 12:24:31 2009 @@ -1,10 +1,8 @@ /* - * Copyright (c) 1999 by Sun Microsystems, Inc. - * All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * As of BIND 8.2.2, ISC (a) removed res_mkupdate(), res_update(), and * res_mkupdrec() from what they consider the supported interface. The @@ -25,19 +23,25 @@ #include #include +/* get the Solaris ns_updrec before any renaming happens */ +#include + +/* get the __ISC_ns_updrec */ #include + +#include + +/* un-rename ns_updrec and res_* functions so we can wrap them */ #undef ns_updrec #undef res_mkupdate #undef res_update #undef res_mkupdrec #undef res_freeupdrec -#include +#undef res_nmkupdate +#undef res_nupdate -#include - void res_freeupdrec(ns_updrec *); - static int old2new(ns_updrec *old, __ISC_ns_updrec *new) { @@ -106,7 +110,7 @@ static __ISC_ns_updrec * -copy_list(ns_updrec *old) { +copy_list(ns_updrec *old, int do_glink) { __ISC_ns_updrec *list = 0, *r, *p; @@ -122,23 +126,34 @@ } r->r_link.prev = p; r->r_link.next = 0; - if (p != 0) + /* res_update and res_nupdate want r_glink set up like this */ + if (do_glink) { + r->r_glink.prev = p; + r->r_glink.next = 0; + } else { + r->r_glink.prev = (void *)-1; + r->r_glink.next = (void *)-1; + } + if (p != 0) { p->r_link.next = r; - else + if (do_glink) { + p->r_glink.next = r; + } + } else { list = r; + } } - return (list); } int -res_mkupdate(ns_updrec *rrecp_in, u_char *buf, int length) { +res_mkupdate(ns_updrec *rrecp_in, uchar_t *buf, int length) { __ISC_ns_updrec *r; int ret; - if ((r = copy_list(rrecp_in)) == 0) + if ((r = copy_list(rrecp_in, 1)) == 0) return (-1); ret = __ISC_res_mkupdate(r, buf, length); @@ -148,7 +163,23 @@ return (ret); } +int +res_nmkupdate(res_state statp, ns_updrec *rrecp_in, uchar_t *buf, int length) { + __ISC_ns_updrec *r; + int ret; + + if ((r = copy_list(rrecp_in, 1)) == 0) + return (-1); + + ret = __ISC_res_nmkupdate(statp, r, buf, length); + + delete_list(r); + + return (ret); +} + + int res_update(ns_updrec *rrecp_in) { @@ -155,12 +186,28 @@ __ISC_ns_updrec *r; int ret; - if ((r = copy_list(rrecp_in)) == 0) + if ((r = copy_list(rrecp_in, 0)) == 0) return (-1); ret = __ISC_res_update(r); delete_list(r); + + return (ret); +} + +int +res_nupdate(res_state statp, ns_updrec *rrecp_in, ns_tsig_key *key) { + + __ISC_ns_updrec *r; + int ret; + + if ((r = copy_list(rrecp_in, 0)) == 0) + return (-1); + + ret = __ISC_res_nupdate(statp, r, key); + + delete_list(r); return (ret); } --- /dev/null Fri Jul 3 12:24:33 2009 +++ new/usr/src/lib/libresolv2/common/nameser/ns_rdata.c Fri Jul 3 12:24:33 2009 @@ -0,0 +1,300 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +/* + * Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC") + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef lint +static const char rcsid[] = "$Id: ns_rdata.c,v 1.2 2009/01/23 23:49:15 tbox Exp $"; +#endif + +#include "port_before.h" + +#if __OpenBSD__ +#include +#endif +#include +#include + +#include +#include +#include + +#include "port_after.h" + +#define CONSUME_SRC \ + do { \ + rdata += n, rdlen -= n; \ + } while (0) + +#define CONSUME_DST \ + do { \ + nrdata += n, nrdsiz -= n, nrdlen += n; \ + } while (0) + +#define UNPACK_DNAME \ + do { \ + size_t t; \ + \ + if ((n = ns_name_unpack2(msg,eom,rdata,nrdata,nrdsiz,&t))<0) {\ + errno = EMSGSIZE; \ + return (-1); \ + } \ + CONSUME_SRC; \ + n = t; \ + CONSUME_DST; \ + } while (0) + +#define UNPACK_SOME(x) \ + do { \ + n = (x); \ + if ((size_t)n > rdlen || (size_t)n > nrdsiz) { \ + errno = EMSGSIZE; \ + return (-1); \ + } \ + memcpy(nrdata, rdata, n); \ + CONSUME_SRC; CONSUME_DST; \ + } while (0) + +#define UNPACK_REST(x) \ + do { \ + n = (x); \ + if ((size_t)n != rdlen) { \ + errno = EMSGSIZE; \ + return (-1); \ + } \ + memcpy(nrdata, rdata, n); \ + CONSUME_SRC; CONSUME_DST; \ + } while (0) + +ssize_t +ns_rdata_unpack(const u_char *msg, const u_char *eom, + ns_type type, const u_char *rdata, size_t rdlen, + u_char *nrdata, size_t nrdsiz) +{ + size_t nrdlen = 0; + int n; + + switch (type) { + case ns_t_a: + UNPACK_REST(NS_INADDRSZ); + break; + case ns_t_aaaa: + UNPACK_REST(NS_IN6ADDRSZ); + break; + case ns_t_cname: + case ns_t_mb: + case ns_t_mg: + case ns_t_mr: + case ns_t_ns: + case ns_t_ptr: + case ns_t_dname: + UNPACK_DNAME; + break; + case ns_t_soa: + UNPACK_DNAME; + UNPACK_DNAME; + UNPACK_SOME(NS_INT32SZ * 5); + break; + case ns_t_mx: + case ns_t_afsdb: + case ns_t_rt: + UNPACK_SOME(NS_INT16SZ); + UNPACK_DNAME; + break; + case ns_t_px: + UNPACK_SOME(NS_INT16SZ); + UNPACK_DNAME; + UNPACK_DNAME; + break; + case ns_t_srv: + UNPACK_SOME(NS_INT16SZ * 3); + UNPACK_DNAME; + break; + case ns_t_minfo: + case ns_t_rp: + UNPACK_DNAME; + UNPACK_DNAME; + break; + default: + UNPACK_SOME(rdlen); + break; + } + if (rdlen > 0) { + errno = EMSGSIZE; + return (-1); + } + return (nrdlen); +} + +#define EQUAL_CONSUME \ + do { \ + rdata1 += n, rdlen1 -= n; \ + rdata2 += n, rdlen2 -= n; \ + } while (0) + +#define EQUAL_DNAME \ + do { \ + ssize_t n; \ + \ + if (rdlen1 != rdlen2) \ + return (0); \ + n = ns_name_eq(rdata1, rdlen1, rdata2, rdlen2); \ + if (n <= 0) \ + return (n); \ + n = rdlen1; \ + EQUAL_CONSUME; \ + } while (0) + +#define EQUAL_SOME(x) \ + do { \ + size_t n = (x); \ + \ + if (n > rdlen1 || n > rdlen2) { \ + errno = EMSGSIZE; \ + return (-1); \ + } \ + if (memcmp(rdata1, rdata2, n) != 0) \ + return (0); \ + EQUAL_CONSUME; \ + } while (0) + +int +ns_rdata_equal(ns_type type, + const u_char *rdata1, size_t rdlen1, + const u_char *rdata2, size_t rdlen2) +{ + switch (type) { + case ns_t_cname: + case ns_t_mb: + case ns_t_mg: + case ns_t_mr: + case ns_t_ns: + case ns_t_ptr: + case ns_t_dname: + EQUAL_DNAME; + break; + case ns_t_soa: + /* "There can be only one." --Highlander */ + break; + case ns_t_mx: + case ns_t_afsdb: + case ns_t_rt: + EQUAL_SOME(NS_INT16SZ); + EQUAL_DNAME; + break; + case ns_t_px: + EQUAL_SOME(NS_INT16SZ); + EQUAL_DNAME; + EQUAL_DNAME; + break; + case ns_t_srv: + EQUAL_SOME(NS_INT16SZ * 3); + EQUAL_DNAME; + break; + case ns_t_minfo: + case ns_t_rp: + EQUAL_DNAME; + EQUAL_DNAME; + break; + default: + EQUAL_SOME(rdlen1); + break; + } + if (rdlen1 != 0 || rdlen2 != 0) + return (0); + return (1); +} + +#define REFERS_DNAME \ + do { \ + int n; \ + \ + n = ns_name_eq(rdata, rdlen, nname, NS_MAXNNAME); \ + if (n < 0) \ + return (-1); \ + if (n > 0) \ + return (1); \ + n = dn_skipname(rdata, rdata + rdlen); \ + if (n < 0) \ + return (-1); \ + CONSUME_SRC; \ + } while (0) + +#define REFERS_SOME(x) \ + do { \ + size_t n = (x); \ + \ + if (n > rdlen) { \ + errno = EMSGSIZE; \ + return (-1); \ + } \ + CONSUME_SRC; \ + } while (0) + +int +ns_rdata_refers(ns_type type, + const u_char *rdata, size_t rdlen, + const u_char *nname) +{ + switch (type) { + case ns_t_cname: + case ns_t_mb: + case ns_t_mg: + case ns_t_mr: + case ns_t_ns: + case ns_t_ptr: + case ns_t_dname: + REFERS_DNAME; + break; + case ns_t_soa: + REFERS_DNAME; + REFERS_DNAME; + REFERS_SOME(NS_INT32SZ * 5); + break; + case ns_t_mx: + case ns_t_afsdb: + case ns_t_rt: + REFERS_SOME(NS_INT16SZ); + REFERS_DNAME; + break; + case ns_t_px: + REFERS_SOME(NS_INT16SZ); + REFERS_DNAME; + REFERS_DNAME; + break; + case ns_t_srv: + REFERS_SOME(NS_INT16SZ * 3); + REFERS_DNAME; + break; + case ns_t_minfo: + case ns_t_rp: + REFERS_DNAME; + REFERS_DNAME; + break; + default: + REFERS_SOME(rdlen); + break; + } + if (rdlen != 0) { + errno = EMSGSIZE; + return (-1); + } + return (0); +} --- /dev/null Fri Jul 3 12:24:33 2009 +++ new/usr/src/lib/libresolv2/common/nameser/ns_newmsg.c Fri Jul 3 12:24:33 2009 @@ -0,0 +1,273 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +/* + * Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC") + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef lint +static const char rcsid[] = "$Id: ns_newmsg.c,v 1.3 2009/02/26 10:48:57 marka Exp $"; +#endif + +#include + +#include + +#include +#include +#include + +#include + +static int rdcpy(ns_newmsg *, ns_type, const u_char *, size_t); + +/* Initialize a "newmsg" object to empty. + */ +int +ns_newmsg_init(u_char *buffer, size_t bufsiz, ns_newmsg *handle) { + ns_msg *msg = &handle->msg; + + memset(handle, 0, sizeof *handle); + msg->_msg = buffer; + msg->_eom = buffer + bufsiz; + msg->_sect = ns_s_qd; + msg->_rrnum = 0; + msg->_msg_ptr = buffer + NS_HFIXEDSZ; + handle->dnptrs[0] = msg->_msg; + handle->dnptrs[1] = NULL; + handle->lastdnptr = &handle->dnptrs[sizeof handle->dnptrs / + sizeof handle->dnptrs[0] - 1]; + return (0); +} + +/* Initialize a "newmsg" object by copying an existing parsed message. + */ +int +ns_newmsg_copy(ns_newmsg *handle, ns_msg *msg) { + ns_flag flag; + ns_sect sect; + + ns_newmsg_id(handle, ns_msg_id(*msg)); + for (flag = ns_f_qr; flag < ns_f_max; flag++) + ns_newmsg_flag(handle, flag, ns_msg_getflag(*msg, flag)); + for (sect = ns_s_qd; sect < ns_s_max; sect++) { + int i, count; + + count = ns_msg_count(*msg, sect); + for (i = 0; i < count; i++) { + ns_rr2 rr; + int x; + + if (ns_parserr2(msg, sect, i, &rr) < 0) + return (-1); + if (sect == ns_s_qd) + x = ns_newmsg_q(handle, + ns_rr_nname(rr), + ns_rr_type(rr), + ns_rr_class(rr)); + else + x = ns_newmsg_rr(handle, sect, + ns_rr_nname(rr), + ns_rr_type(rr), + ns_rr_class(rr), + ns_rr_ttl(rr), + ns_rr_rdlen(rr), + ns_rr_rdata(rr)); + if (x < 0) + return (-1); + } + } + return (0); +} + +/* Set the message-ID in a "newmsg" object. + */ +void +ns_newmsg_id(ns_newmsg *handle, u_int16_t id) { + ns_msg *msg = &handle->msg; + + msg->_id = id; +} + +/* Set a flag (including rcode or opcode) in a "newmsg" object. + */ +void +ns_newmsg_flag(ns_newmsg *handle, ns_flag flag, u_int value) { + extern struct _ns_flagdata _ns_flagdata[16]; + struct _ns_flagdata *fd = &_ns_flagdata[flag]; + ns_msg *msg = &handle->msg; + + assert(flag < ns_f_max); + msg->_flags &= (~fd->mask); + msg->_flags |= (value << fd->shift); +} + +/* Add a question (or zone, if it's an update) to a "newmsg" object. + */ +int +ns_newmsg_q(ns_newmsg *handle, ns_nname_ct qname, + ns_type qtype, ns_class qclass) +{ + ns_msg *msg = &handle->msg; + u_char *t; + int n; + + if (msg->_sect != ns_s_qd) { + errno = ENODEV; + return (-1); + } + t = (u_char *) (unsigned long) msg->_msg_ptr; + if (msg->_rrnum == 0) + msg->_sections[ns_s_qd] = t; + n = ns_name_pack(qname, t, msg->_eom - t, + handle->dnptrs, handle->lastdnptr); + if (n < 0) + return (-1); + t += n; + if (t + QFIXEDSZ >= msg->_eom) { + errno = EMSGSIZE; + return (-1); + } + NS_PUT16(qtype, t); + NS_PUT16(qclass, t); + msg->_msg_ptr = t; + msg->_counts[ns_s_qd] = ++msg->_rrnum; + return (0); +} + +/* Add an RR to a "newmsg" object. + */ +int +ns_newmsg_rr(ns_newmsg *handle, ns_sect sect, + ns_nname_ct name, ns_type type, + ns_class rr_class, u_int32_t ttl, + u_int16_t rdlen, const u_char *rdata) +{ + ns_msg *msg = &handle->msg; + u_char *t; + int n; + + if (sect < msg->_sect) { + errno = ENODEV; + return (-1); + } + t = (u_char *) (unsigned long) msg->_msg_ptr; + if (sect > msg->_sect) { + msg->_sect = sect; + msg->_sections[sect] = t; + msg->_rrnum = 0; + } + n = ns_name_pack(name, t, msg->_eom - t, + handle->dnptrs, handle->lastdnptr); + if (n < 0) + return (-1); + t += n; + if (t + RRFIXEDSZ + rdlen >= msg->_eom) { + errno = EMSGSIZE; + return (-1); + } + NS_PUT16(type, t); + NS_PUT16(rr_class, t); + NS_PUT32(ttl, t); + msg->_msg_ptr = t; + if (rdcpy(handle, type, rdata, rdlen) < 0) + return (-1); + msg->_counts[sect] = ++msg->_rrnum; + return (0); +} + +/* Complete a "newmsg" object and return its size for use in write(). + * (Note: the "newmsg" object is also made ready for ns_parserr() etc.) + */ +size_t +ns_newmsg_done(ns_newmsg *handle) { + ns_msg *msg = &handle->msg; + ns_sect sect; + u_char *t; + + t = (u_char *) (unsigned long) msg->_msg; + NS_PUT16(msg->_id, t); + NS_PUT16(msg->_flags, t); + for (sect = 0; sect < ns_s_max; sect++) + NS_PUT16(msg->_counts[sect], t); + msg->_eom = msg->_msg_ptr; + msg->_sect = ns_s_max; + msg->_rrnum = -1; + msg->_msg_ptr = NULL; + return (msg->_eom - msg->_msg); +} + +/* Private. */ + +/* Copy an RDATA, using compression pointers where RFC1035 permits. + */ +static int +rdcpy(ns_newmsg *handle, ns_type type, const u_char *rdata, size_t rdlen) { + ns_msg *msg = &handle->msg; + u_char *p = (u_char *) (unsigned long) msg->_msg_ptr; + u_char *t = p + NS_INT16SZ; + u_char *s = t; + int n; + + switch (type) { + case ns_t_soa: + /* MNAME. */ + n = ns_name_pack(rdata, t, msg->_eom - t, + handle->dnptrs, handle->lastdnptr); + if (n < 0) + return (-1); + t += n; + if (ns_name_skip(&rdata, msg->_eom) < 0) + return (-1); + + /* ANAME. */ + n = ns_name_pack(rdata, t, msg->_eom - t, + handle->dnptrs, handle->lastdnptr); + if (n < 0) + return (-1); + t += n; + if (ns_name_skip(&rdata, msg->_eom) < 0) + return (-1); + + /* Serial, Refresh, Retry, Expiry, and Minimum. */ + if ((msg->_eom - t) < (NS_INT32SZ * 5)) { + errno = EMSGSIZE; + return (-1); + } + memcpy(t, rdata, NS_INT32SZ * 5); + t += (NS_INT32SZ * 5); + break; + case ns_t_ptr: + case ns_t_cname: + case ns_t_ns: + /* PTRDNAME, CNAME, or NSDNAME. */ + n = ns_name_pack(rdata, t, msg->_eom - t, + handle->dnptrs, handle->lastdnptr); + if (n < 0) + return (-1); + t += n; + break; + default: + memcpy(t, rdata, rdlen); + t += rdlen; + } + NS_PUT16(t - s, p); + msg->_msg_ptr = t; + return (0); +} + --- /dev/null Fri Jul 3 12:24:33 2009 +++ new/usr/src/lib/libresolv2/common/resolv/mtctxres.c Fri Jul 3 12:24:33 2009 @@ -0,0 +1,135 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +#include +#ifdef DO_PTHREADS +#include +#endif +#include +#include +#include +#include +#include +#include +#include + +#ifdef DO_PTHREADS +static pthread_key_t key; +static int mt_key_initialized = 0; + +static int __res_init_ctx(void); +static void __res_destroy_ctx(void *); + +#if defined(sun) && !defined(__GNUC__) +#pragma init (_mtctxres_init) +#endif +#endif + +static mtctxres_t sharedctx; + +#ifdef DO_PTHREADS +/* + * Initialize the TSD key. By doing this at library load time, we're + * implicitly running without interference from other threads, so there's + * no need for locking. + */ +static void +_mtctxres_init(void) { + int pthread_keycreate_ret; + + pthread_keycreate_ret = pthread_key_create(&key, __res_destroy_ctx); + if (pthread_keycreate_ret == 0) + mt_key_initialized = 1; +} +#endif + +/* + * To support binaries that used the private MT-safe interface in + * Solaris 8, we still need to provide the __res_enable_mt() + * and __res_disable_mt() entry points. They're do-nothing routines. + */ +int +__res_enable_mt(void) { + return (-1); +} + +int +__res_disable_mt(void) { + return (0); +} + +#ifdef DO_PTHREADS +static int +__res_init_ctx(void) { + + mtctxres_t *mt; + int ret; + + + if (pthread_getspecific(key) != 0) { + /* Already exists */ + return (0); + } + + if ((mt = malloc(sizeof (mtctxres_t))) == 0) { + errno = ENOMEM; + return (-1); + } + + memset(mt, 0, sizeof (mtctxres_t)); + + if ((ret = pthread_setspecific(key, mt)) != 0) { + free(mt); + errno = ret; + return (-1); + } + + return (0); +} + +static void +__res_destroy_ctx(void *value) { + + mtctxres_t *mt = (mtctxres_t *)value; + + if (mt != 0) + free(mt); +} +#endif + +mtctxres_t * +___mtctxres(void) { +#ifdef DO_PTHREADS + mtctxres_t *mt; + + /* + * This if clause should only be executed if we are linking + * statically. When linked dynamically _mtctxres_init() should + * be called at binding time due the #pragma above. + */ + if (!mt_key_initialized) { + static pthread_mutex_t keylock = PTHREAD_MUTEX_INITIALIZER; + if (pthread_mutex_lock(&keylock) == 0) { + _mtctxres_init(); + (void) pthread_mutex_unlock(&keylock); + } + } + + /* + * If we have already been called in this thread return the existing + * context. Otherwise recreat a new context and return it. If + * that fails return a global context. + */ + if (mt_key_initialized) { + if (((mt = pthread_getspecific(key)) != 0) || + (__res_init_ctx() == 0 && + (mt = pthread_getspecific(key)) != 0)) { + return (mt); + } + } +#endif + return (&sharedctx); +} --- /dev/null Fri Jul 3 12:24:34 2009 +++ new/usr/src/lib/libresolv2/common/isc/movefile.c Fri Jul 3 12:24:34 2009 @@ -0,0 +1,43 @@ +/* + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + +/* + * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") + * Copyright (c) 2000 by Internet Software Consortium, Inc. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#include +#include +#include +#include +#ifndef HAVE_MOVEFILE +/* + * rename() is lame (can't overwrite an existing file) on some systems. + * use movefile() instead, and let lame OS ports do what they need to. + */ + +int +isc_movefile(const char *oldname, const char *newname) { + return (rename(oldname, newname)); +} +#else + static int os_port_has_isc_movefile = 1; +#endif + +/*! \file */