diff options
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/lib/libresolv/Makefile | 6 | ||||
-rw-r--r-- | usr/src/lib/libresolv/crossl.h | 49 | ||||
-rw-r--r-- | usr/src/lib/libresolv/res_debug.c | 13 | ||||
-rw-r--r-- | usr/src/lib/libresolv/res_gethost.c | 18 | ||||
-rw-r--r-- | usr/src/lib/libresolv/res_init.c | 35 | ||||
-rw-r--r-- | usr/src/lib/libresolv/res_mkquery.c | 37 | ||||
-rw-r--r-- | usr/src/lib/libresolv/res_query.c | 9 | ||||
-rw-r--r-- | usr/src/lib/libresolv/res_send.c | 21 | ||||
-rw-r--r-- | usr/src/lib/libresolv/res_sethost.c | 5 |
9 files changed, 134 insertions, 59 deletions
diff --git a/usr/src/lib/libresolv/Makefile b/usr/src/lib/libresolv/Makefile index 7351ef9048..b53ce5c037 100644 --- a/usr/src/lib/libresolv/Makefile +++ b/usr/src/lib/libresolv/Makefile @@ -19,6 +19,7 @@ # CDDL HEADER END # # +# Copyright 2015 Gary Mills # Copyright 2006 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # @@ -54,13 +55,10 @@ C99MODE= $(C99_DISABLE) # so we must put -I. ahead of the default include directories: CPPFLAGS = -I. -I../common/inc $(CPPFLAGS.master) -DDEBUG -DSYSV -D_REENTRANT LDLIBS += -lsocket -lnsl -lc +CFLAGS += $(CCVERBOSE) -CERRWARN += -_gcc=-Wno-implicit-function-declaration CERRWARN += -_gcc=-Wno-parentheses -CERRWARN += -_gcc=-Wno-unused-variable CERRWARN += -_gcc=-Wno-uninitialized -CERRWARN += -_gcc=-Wno-implicit-int -CERRWARN += -_gcc=-Wno-extra ROOTDYNLIBS= $(DYNLIB:%=$(ROOTLIBDIR)/%) diff --git a/usr/src/lib/libresolv/crossl.h b/usr/src/lib/libresolv/crossl.h new file mode 100644 index 0000000000..647a807c53 --- /dev/null +++ b/usr/src/lib/libresolv/crossl.h @@ -0,0 +1,49 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2015 Gary Mills + */ + +#ifndef _CROSSL_H +#define _CROSSL_H + +/* + * Definitions needed for cross-linkages between source files + */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int dn_comp(u_char *, u_char *, int, u_char **, u_char **); +extern int dn_expand(u_char *, u_char *, u_char *, u_char *, int); +extern int dn_skipname(u_char *, u_char *); + +extern int res_init(void); +extern int res_mkquery(int, char *, int, int, char *, int, struct rrec *, + char *, int); +extern int res_query(char *, int, int, u_char *, int); +extern int res_querydomain(char *, char *, int, int, u_char *, int); +extern int res_search(char *, int, int, u_char *, int); +extern int res_send(char *, int, char *, int); + +extern void putlong(u_long, u_char *); +extern void putshort(u_short, u_char *); +extern void p_query(char *); +extern void _res_close(); + + +#ifdef __cplusplus +} +#endif + +#endif /* _CROSSL_H */ diff --git a/usr/src/lib/libresolv/res_debug.c b/usr/src/lib/libresolv/res_debug.c index 6d05865e6b..a931e74580 100644 --- a/usr/src/lib/libresolv/res_debug.c +++ b/usr/src/lib/libresolv/res_debug.c @@ -20,6 +20,7 @@ */ /* + * Copyright 2015 Gary Mills * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -37,15 +38,16 @@ * contributors. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/types.h> +#include <sys/socket.h> #include <netinet/in.h> +#include <arpa/inet.h> #include <stdio.h> +#include <string.h> #include <arpa/nameser.h> +#include <resolv.h> +#include "crossl.h" -extern char *p_cdname(), *p_rr(), *p_type(), *p_class(), *p_time(); -extern char *inet_ntoa(); void fp_query(char *msg, FILE *file); char *_res_opcodes[] = { @@ -195,7 +197,8 @@ p_cdname(cp, msg, file) char name[MAXDNAME]; int n; - if ((n = dn_expand(msg, msg + 512, cp, name, sizeof (name))) < 0) + if ((n = dn_expand((u_char *)msg, (u_char *)(msg + 512), (u_char *)cp, + (u_char *)name, sizeof (name))) < 0) return (NULL); if (name[0] == '\0') { name[0] = '.'; diff --git a/usr/src/lib/libresolv/res_gethost.c b/usr/src/lib/libresolv/res_gethost.c index bc25771d6d..9649677d2a 100644 --- a/usr/src/lib/libresolv/res_gethost.c +++ b/usr/src/lib/libresolv/res_gethost.c @@ -1,4 +1,5 @@ /* + * Copyright 2015 Gary Mills * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -23,10 +24,12 @@ #include <netdb.h> #include <stdio.h> #include <errno.h> +#include <string.h> #include <arpa/inet.h> #include <arpa/nameser.h> #include <resolv.h> #include <syslog.h> +#include "crossl.h" /* * When the name service switch calls libresolv, it doesn't want fallback @@ -103,8 +106,8 @@ getanswer(answer, anslen, iquery) cp = answer->buf + sizeof (HEADER); if (qdcount) { if (iquery) { - if ((n = dn_expand((char *)answer->buf, eom, - cp, bp, buflen)) < 0) { + if ((n = dn_expand(answer->buf, eom, + cp, (u_char *)bp, buflen)) < 0) { h_errno = NO_RECOVERY; return ((struct hostent *) NULL); } @@ -132,8 +135,8 @@ getanswer(answer, anslen, iquery) #endif haveanswer = 0; while (--ancount >= 0 && cp < eom && haveanswer < MAXADDRS) { - if ((n = dn_expand((char *)answer->buf, eom, - cp, bp, buflen)) < 0) + if ((n = dn_expand(answer->buf, eom, + cp, (u_char *)bp, buflen)) < 0) break; cp += n; type = _getshort(cp); @@ -153,8 +156,8 @@ getanswer(answer, anslen, iquery) continue; } if (iquery && type == T_PTR) { - if ((n = dn_expand((char *)answer->buf, eom, - cp, bp, buflen)) < 0) { + if ((n = dn_expand(answer->buf, eom, + cp, (u_char *)bp, buflen)) < 0) { cp += n; continue; } @@ -231,7 +234,6 @@ res_gethostbyname(name) querybuf buf; register char *cp; int n; - struct hostent *hp, *gethostdomain(); /* * disallow names consisting only of digits/dots, unless @@ -281,7 +283,7 @@ _getrhbyaddr(addr, len, type) ((unsigned)addr[2] & 0xff), ((unsigned)addr[1] & 0xff), ((unsigned)addr[0] & 0xff)); - n = res_query(qbuf, C_IN, T_PTR, (char *)&buf, sizeof (buf)); + n = res_query(qbuf, C_IN, T_PTR, (u_char *)&buf, sizeof (buf)); if (n < 0) { #ifdef DEBUG if (_res.options & RES_DEBUG) diff --git a/usr/src/lib/libresolv/res_init.c b/usr/src/lib/libresolv/res_init.c index 329de88923..44e4a72e9b 100644 --- a/usr/src/lib/libresolv/res_init.c +++ b/usr/src/lib/libresolv/res_init.c @@ -20,6 +20,7 @@ */ /* + * Copyright 2015 Gary Mills * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -37,13 +38,15 @@ * contributors. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/types.h> #include <sys/sockio.h> #include <sys/socket.h> #include <netinet/in.h> #include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <unistd.h> +#include <stropts.h> #include <arpa/nameser.h> #include <resolv.h> @@ -52,6 +55,12 @@ #include <netinet/if_ether.h> #include <arpa/inet.h> +/* + * Undocumented external function in libnsl + */ +extern int +getdomainname(char *, int); + #define MAXIFS 256 /* @@ -87,13 +96,6 @@ res_init(void) register char *cp, **pp; register int n; char buf[BUFSIZ]; -#ifdef SYSV - extern char *strchr(); -#else - extern char *index(); -#endif - extern char *strcpy(), *strncpy(); - extern char *getenv(); int nserv = 0; /* number of nameserver records read from file */ int haveenv = 0; int havesearch = 0; @@ -111,7 +113,6 @@ res_init(void) unsigned bufsize; unsigned int flags; char *buf; - extern void *malloc(); if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { perror("socket"); @@ -124,14 +125,14 @@ res_init(void) buf = (char *)malloc(bufsize); if (buf == NULL) { perror("out of memory"); - close(s); + (void) close(s); return (-1); } ifc.ifc_len = bufsize; ifc.ifc_buf = buf; if (ioctl(s, SIOCGIFCONF, (char *)&ifc) < 0) { perror("ifconfig: SIOCGIFCONF"); - close(s); + (void) close(s); free(buf); return (-1); } @@ -140,12 +141,12 @@ res_init(void) ifrp = ifc.ifc_req; for (n = ifc.ifc_len / sizeof (struct ifreq); n > 0; n--, ifrp++) { - memset((void *) &ifr, 0, sizeof (ifr)); + (void) memset((void *) &ifr, 0, sizeof (ifr)); strncpy(ifr.ifr_name, ifrp->ifr_name, sizeof (ifr.ifr_name)); if (ioctl(s, SIOCGIFFLAGS, (char *)&ifr) < 0) { perror("SIOCGIFFLAGS"); - close(s); + (void) close(s); free(buf); return (-1); } @@ -154,7 +155,7 @@ res_init(void) if ((flags & IFF_UP) && ((flags & IFF_LOOPBACK) == 0)) int_up = 1; } - close(s); + (void) close(s); free(buf); if (int_up == 0) /* all the non-LOOPBACK interfaces are DOWN */ return (-1); @@ -166,9 +167,9 @@ res_init(void) * for the benefit of hidden NIS domains, we use the same procedure * as sendmail: convert leading + to dot, then drop to first dot */ - getdomainname(buf, BUFSIZ); + (void) getdomainname(buf, BUFSIZ); if (buf[0] == '+') - buf[0] = '.'; + buf[0] = '.'; #ifdef SYSV cp = strchr(buf, (int)'.'); #else diff --git a/usr/src/lib/libresolv/res_mkquery.c b/usr/src/lib/libresolv/res_mkquery.c index d2d316fecd..d97f45fa70 100644 --- a/usr/src/lib/libresolv/res_mkquery.c +++ b/usr/src/lib/libresolv/res_mkquery.c @@ -20,6 +20,7 @@ */ /* + * Copyright 2015 Gary Mills * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -37,8 +38,6 @@ * contributors. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdio.h> #include <sys/types.h> #include <sys/socket.h> @@ -46,8 +45,12 @@ #include <netinet/in.h> #include <arpa/nameser.h> #include <resolv.h> +#include <string.h> +#include <stdlib.h> +#include <unistd.h> #include <errno.h> #include <netdb.h> +#include "crossl.h" /* * Kludge to time out quickly if there is no /etc/resolv.conf @@ -97,11 +100,11 @@ static int _confcheck() ns_sin.sin_port = htons(NAMESERVER_PORT); if (connect(ns, (struct sockaddr *) &ns_sin, sizeof ns_sin) == -1) { - close(ns); + (void) close(ns); return(-1); } else { - close(ns); + (void) close(ns); return(0); } } @@ -128,9 +131,9 @@ res_mkquery(op, dname, class, type, data, datalen, newrr, buf, buflen) int buflen; /* size of buffer */ { register HEADER *hp; - register char *cp; + register u_char *cp; register int n; - char *dnptrs[10], **dpp, **lastdnptr; + u_char *dnptrs[10], **dpp, **lastdnptr; #ifdef DEBUG if (_res.options & RES_DEBUG) @@ -159,7 +162,7 @@ res_mkquery(op, dname, class, type, data, datalen, newrr, buf, buflen) if ((buf == NULL) || (buflen < sizeof (HEADER))) return (-1); #ifdef SYSV - memset(buf, 0, sizeof (HEADER)); + (void) memset(buf, 0, sizeof (HEADER)); #else bzero(buf, sizeof (HEADER)); #endif @@ -169,10 +172,10 @@ res_mkquery(op, dname, class, type, data, datalen, newrr, buf, buflen) hp->pr = (_res.options & RES_PRIMARY) != 0; hp->rd = (_res.options & RES_RECURSE) != 0; hp->rcode = NOERROR; - cp = buf + sizeof (HEADER); + cp = (u_char *)(buf + sizeof (HEADER)); buflen -= sizeof (HEADER); dpp = dnptrs; - *dpp++ = buf; + *dpp++ = (u_char *)buf; *dpp++ = NULL; lastdnptr = dnptrs + sizeof (dnptrs) / sizeof (dnptrs[0]); /* @@ -182,7 +185,8 @@ res_mkquery(op, dname, class, type, data, datalen, newrr, buf, buflen) case QUERY: if ((buflen -= QFIXEDSZ) < 0) return (-1); - if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0) + if ((n = dn_comp((u_char *)dname, cp, buflen, + dnptrs, lastdnptr)) < 0) return (-1); cp += n; buflen -= n; @@ -197,7 +201,8 @@ res_mkquery(op, dname, class, type, data, datalen, newrr, buf, buflen) * Make an additional record for completion domain. */ buflen -= RRFIXEDSZ; - if ((n = dn_comp(data, cp, buflen, dnptrs, lastdnptr)) < 0) + if ((n = dn_comp((u_char *)data, cp, buflen, + dnptrs, lastdnptr)) < 0) return (-1); cp += n; buflen -= n; @@ -229,7 +234,7 @@ res_mkquery(op, dname, class, type, data, datalen, newrr, buf, buflen) cp += sizeof (u_short); if (datalen) { #ifdef SYSV - memcpy((void *)cp, (void *)data, datalen); + (void) memcpy((void *)cp, (void *)data, datalen); #else bcopy(data, cp, datalen); #endif @@ -254,7 +259,8 @@ res_mkquery(op, dname, class, type, data, datalen, newrr, buf, buflen) */ case UPDATEDA: buflen -= RRFIXEDSZ + datalen; - if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0) + if ((n = dn_comp((u_char *)dname, cp, buflen, + dnptrs, lastdnptr)) < 0) return (-1); cp += n; putshort(type, cp); @@ -281,7 +287,8 @@ res_mkquery(op, dname, class, type, data, datalen, newrr, buf, buflen) case UPDATEA: /* Add new resource record */ buflen -= RRFIXEDSZ + datalen; - if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0) + if ((n = dn_comp((u_char *)dname, cp, buflen, + dnptrs, lastdnptr)) < 0) return (-1); cp += n; putshort(newrr->r_type, cp); @@ -305,5 +312,5 @@ res_mkquery(op, dname, class, type, data, datalen, newrr, buf, buflen) #endif /* ALLOW_UPDATES */ } - return (cp - buf); + return ((char *)cp - buf); } diff --git a/usr/src/lib/libresolv/res_query.c b/usr/src/lib/libresolv/res_query.c index 578086be6a..1c4d95b7c6 100644 --- a/usr/src/lib/libresolv/res_query.c +++ b/usr/src/lib/libresolv/res_query.c @@ -20,6 +20,7 @@ */ /* + * Copyright 2015 Gary Mills * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -37,8 +38,6 @@ * contributors. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/param.h> #include <sys/socket.h> #include <netinet/in.h> @@ -47,9 +46,11 @@ #include <stdio.h> #include <errno.h> #include <string.h> +#include <stdlib.h> #include <arpa/inet.h> #include <arpa/nameser.h> #include <resolv.h> +#include "crossl.h" #if PACKETSZ > 1024 #define MAXPACKET PACKETSZ @@ -96,7 +97,7 @@ res_query(name, class, type, answer, anslen) h_errno = NO_RECOVERY; return (n); } - n = res_send(buf, n, answer, anslen); + n = res_send(buf, n, (char *)answer, anslen); if (n < 0) { #ifdef DEBUG if (_res.options & RES_DEBUG) @@ -271,7 +272,7 @@ hostalias(name) { register char *C1, *C2; FILE *fp; - char *file, *getenv(), *strcpy(), *strncpy(); + char *file; char buf[BUFSIZ]; static char abuf[MAXDNAME]; diff --git a/usr/src/lib/libresolv/res_send.c b/usr/src/lib/libresolv/res_send.c index 6bd187b210..03168909d8 100644 --- a/usr/src/lib/libresolv/res_send.c +++ b/usr/src/lib/libresolv/res_send.c @@ -20,6 +20,7 @@ */ /* + * Copyright 2015 Gary Mills * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -37,8 +38,6 @@ * contributors. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * Send query to name server and wait for reply. */ @@ -50,13 +49,24 @@ #include <sys/stat.h> #include <netinet/in.h> #include <stdio.h> +#include <string.h> +#include <unistd.h> #include <errno.h> #include <arpa/nameser.h> +#include <arpa/inet.h> #include <resolv.h> +#include "crossl.h" +/* + * Undocumented external function in libsocket + */ +extern int +_socket(int, int, int); static int s = -1; /* socket used for communications */ +#if BSD >= 43 static struct sockaddr no_addr; +#endif /* BSD */ #ifndef FD_SET @@ -66,7 +76,7 @@ static struct sockaddr no_addr; #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) #ifdef SYSV -#define FD_ZERO(p) memset((void *)(p), 0, sizeof (*(p))) +#define FD_ZERO(p) (void) memset((void *)(p), 0, sizeof (*(p))) #else #define FD_ZERO(p) bzero((char *)(p), sizeof (*(p))) #endif @@ -129,7 +139,10 @@ res_send(buf, buflen, answer, anslen) { register int n; int try, v_circuit, resplen, ns; - int gotsomewhere = 0, connected = 0; + int gotsomewhere = 0; +#if BSD >= 43 + int connected = 0; +#endif /* BSD */ int connreset = 0; u_short id, len; char *cp; diff --git a/usr/src/lib/libresolv/res_sethost.c b/usr/src/lib/libresolv/res_sethost.c index e565ecf63a..2ccbdc36cb 100644 --- a/usr/src/lib/libresolv/res_sethost.c +++ b/usr/src/lib/libresolv/res_sethost.c @@ -20,6 +20,7 @@ */ /* + * Copyright 2015 Gary Mills * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -37,15 +38,15 @@ * contributors. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/types.h> #include <arpa/nameser.h> #include <netinet/in.h> #include <resolv.h> +#include "crossl.h" void res_sethostent(stayopen) +int stayopen; { if (stayopen) _res.options |= RES_STAYOPEN | RES_USEVC; |