summaryrefslogtreecommitdiff
path: root/resolv
diff options
context:
space:
mode:
Diffstat (limited to 'resolv')
-rw-r--r--resolv/base64.c4
-rw-r--r--resolv/gethnamaddr.c48
-rw-r--r--resolv/getnetnamadr.c8
-rw-r--r--resolv/inet_neta.c1
-rw-r--r--resolv/netdb.h31
-rw-r--r--resolv/res_debug.c2
-rw-r--r--resolv/res_mkquery.c2
-rw-r--r--resolv/res_query.c28
8 files changed, 78 insertions, 46 deletions
diff --git a/resolv/base64.c b/resolv/base64.c
index 8b01de33f4..31cd18188f 100644
--- a/resolv/base64.c
+++ b/resolv/base64.c
@@ -280,7 +280,7 @@ b64_pton(src, target, targsize)
case 2: /* Valid, means one byte of info */
/* Skip any number of spaces. */
- for (NULL; ch != '\0'; ch = *src++)
+ for ( ; ch != '\0'; ch = *src++)
if (!isspace(ch))
break;
/* Make sure there is another trailing = sign. */
@@ -295,7 +295,7 @@ b64_pton(src, target, targsize)
* We know this char is an =. Is there anything but
* whitespace after it?
*/
- for (NULL; ch != '\0'; ch = *src++)
+ for ( ; ch != '\0'; ch = *src++)
if (!isspace(ch))
return (-1);
diff --git a/resolv/gethnamaddr.c b/resolv/gethnamaddr.c
index fb51e31003..1cae1f7295 100644
--- a/resolv/gethnamaddr.c
+++ b/resolv/gethnamaddr.c
@@ -145,7 +145,7 @@ dprintf(msg, num)
int save = errno;
printf(msg, num);
- errno = save;
+ __set_errno (save);
}
}
#else
@@ -195,12 +195,12 @@ getanswer(answer, anslen, qname, qtype)
buflen = sizeof hostbuf;
cp = answer->buf + HFIXEDSZ;
if (qdcount != 1) {
- h_errno = NO_RECOVERY;
+ __set_h_errno (NO_RECOVERY);
return (NULL);
}
n = dn_expand(answer->buf, eom, cp, bp, buflen);
if ((n < 0) || !(*name_ok)(bp)) {
- h_errno = NO_RECOVERY;
+ __set_h_errno (NO_RECOVERY);
return (NULL);
}
cp += n + QFIXEDSZ;
@@ -330,7 +330,7 @@ getanswer(answer, anslen, qname, qtype)
buflen -= n;
map_v4v6_hostent(&host, &bp, &buflen);
}
- h_errno = NETDB_SUCCESS;
+ __set_h_errno (NETDB_SUCCESS);
return (&host);
#endif
case T_A:
@@ -403,11 +403,11 @@ getanswer(answer, anslen, qname, qtype)
}
if (_res.options & RES_USE_INET6)
map_v4v6_hostent(&host, &bp, &buflen);
- h_errno = NETDB_SUCCESS;
+ __set_h_errno (NETDB_SUCCESS);
return (&host);
}
try_again:
- h_errno = TRY_AGAIN;
+ __set_h_errno (TRY_AGAIN);
return (NULL);
}
@@ -418,7 +418,7 @@ gethostbyname(name)
struct hostent *hp;
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
- h_errno = NETDB_INTERNAL;
+ __set_h_errno (NETDB_INTERNAL);
return (NULL);
}
if (_res.options & RES_USE_INET6) {
@@ -441,7 +441,7 @@ gethostbyname2(name, af)
extern struct hostent *_gethtbyname2();
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
- h_errno = NETDB_INTERNAL;
+ __set_h_errno (NETDB_INTERNAL);
return (NULL);
}
@@ -455,7 +455,7 @@ gethostbyname2(name, af)
type = T_AAAA;
break;
default:
- h_errno = NETDB_INTERNAL;
+ __set_h_errno (NETDB_INTERNAL);
errno = EAFNOSUPPORT;
return (NULL);
}
@@ -486,7 +486,7 @@ gethostbyname2(name, af)
* done a lookup.
*/
if (inet_pton(af, name, host_addr) <= 0) {
- h_errno = HOST_NOT_FOUND;
+ __set_h_errno (HOST_NOT_FOUND);
return (NULL);
}
strncpy(hostbuf, name, MAXDNAME);
@@ -501,7 +501,7 @@ gethostbyname2(name, af)
host.h_addr_list = h_addr_ptrs;
if (_res.options & RES_USE_INET6)
map_v4v6_hostent(&host, &bp, &len);
- h_errno = NETDB_SUCCESS;
+ __set_h_errno (NETDB_SUCCESS);
return (&host);
}
if (!isdigit(*cp) && *cp != '.')
@@ -518,7 +518,7 @@ gethostbyname2(name, af)
* done a lookup.
*/
if (inet_pton(af, name, host_addr) <= 0) {
- h_errno = HOST_NOT_FOUND;
+ __set_h_errno (HOST_NOT_FOUND);
return (NULL);
}
strncpy(hostbuf, name, MAXDNAME);
@@ -531,7 +531,7 @@ gethostbyname2(name, af)
h_addr_ptrs[0] = (char *)host_addr;
h_addr_ptrs[1] = NULL;
host.h_addr_list = h_addr_ptrs;
- h_errno = NETDB_SUCCESS;
+ __set_h_errno (NETDB_SUCCESS);
return (&host);
}
if (!isxdigit(*cp) && *cp != ':' && *cp != '.')
@@ -568,7 +568,7 @@ gethostbyaddr(addr, len, af)
extern struct hostent *_gethtbyaddr();
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
- h_errno = NETDB_INTERNAL;
+ __set_h_errno (NETDB_INTERNAL);
return (NULL);
}
if (af == AF_INET6 && len == IN6ADDRSZ &&
@@ -588,13 +588,13 @@ gethostbyaddr(addr, len, af)
size = IN6ADDRSZ;
break;
default:
- errno = EAFNOSUPPORT;
- h_errno = NETDB_INTERNAL;
+ __set_errno (EAFNOSUPPORT);
+ __set_h_errno (NETDB_INTERNAL);
return (NULL);
}
if (size != len) {
- errno = EINVAL;
- h_errno = NETDB_INTERNAL;
+ __set_errno (EINVAL);
+ __set_h_errno (NETDB_INTERNAL);
return (NULL);
}
switch (af) {
@@ -642,7 +642,7 @@ gethostbyaddr(addr, len, af)
"gethostbyaddr: No A record for %s (verifying [%s])",
hname2, inet_ntoa(*((struct in_addr *)addr)));
_res.options = old_options;
- h_errno = HOST_NOT_FOUND;
+ __set_h_errno (HOST_NOT_FOUND);
return (NULL);
}
_res.options = old_options;
@@ -653,7 +653,7 @@ gethostbyaddr(addr, len, af)
syslog(LOG_NOTICE|LOG_AUTH,
"gethostbyaddr: A record of %s != PTR record [%s]",
hname2, inet_ntoa(*((struct in_addr *)addr)));
- h_errno = HOST_NOT_FOUND;
+ __set_h_errno (HOST_NOT_FOUND);
return (NULL);
}
}
@@ -668,7 +668,7 @@ gethostbyaddr(addr, len, af)
hp->h_addrtype = AF_INET6;
hp->h_length = IN6ADDRSZ;
}
- h_errno = NETDB_SUCCESS;
+ __set_h_errno (NETDB_SUCCESS);
return (hp);
}
@@ -700,12 +700,12 @@ _gethtent()
int af, len;
if (!hostf && !(hostf = fopen(_PATH_HOSTS, "r" ))) {
- h_errno = NETDB_INTERNAL;
+ __set_h_errno (NETDB_INTERNAL);
return (NULL);
}
again:
if (!(p = fgets(hostbuf, sizeof hostbuf, hostf))) {
- h_errno = HOST_NOT_FOUND;
+ __set_h_errno (HOST_NOT_FOUND);
return (NULL);
}
if (*p == '#')
@@ -760,7 +760,7 @@ _gethtent()
map_v4v6_hostent(&host, &bp, &buflen);
}
- h_errno = NETDB_SUCCESS;
+ __set_h_errno (NETDB_SUCCESS);
return (&host);
}
diff --git a/resolv/getnetnamadr.c b/resolv/getnetnamadr.c
index 8e503dae12..6f5bf008c7 100644
--- a/resolv/getnetnamadr.c
+++ b/resolv/getnetnamadr.c
@@ -127,9 +127,9 @@ static char *net_aliases[MAXALIASES], netbuf[BUFSIZ+1];
cp = answer->buf + HFIXEDSZ;
if (!qdcount) {
if (hp->aa)
- h_errno = HOST_NOT_FOUND;
+ __set_h_errno (HOST_NOT_FOUND);
else
- h_errno = TRY_AGAIN;
+ __set_h_errno (TRY_AGAIN);
return (NULL);
}
while (qdcount-- > 0)
@@ -197,7 +197,7 @@ static char *net_aliases[MAXALIASES], netbuf[BUFSIZ+1];
net_entry.n_aliases++;
return (&net_entry);
}
- h_errno = TRY_AGAIN;
+ __set_h_errno (TRY_AGAIN);
return (NULL);
}
@@ -267,7 +267,7 @@ getnetbyname(net)
struct netent *net_entry;
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
- h_errno = NETDB_INTERNAL;
+ __set_h_errno (NETDB_INTERNAL);
return (NULL);
}
strcpy(&qbuf[0], net);
diff --git a/resolv/inet_neta.c b/resolv/inet_neta.c
index 27908d4a47..324c01b696 100644
--- a/resolv/inet_neta.c
+++ b/resolv/inet_neta.c
@@ -26,6 +26,7 @@ static const char rcsid[] = "$Id$";
#include <errno.h>
#include <stdio.h>
+#include <string.h>
#ifdef SPRINTF_CHAR
# define SPRINTF(x) strlen(sprintf/**/x)
diff --git a/resolv/netdb.h b/resolv/netdb.h
index 1269443cb9..954085f97d 100644
--- a/resolv/netdb.h
+++ b/resolv/netdb.h
@@ -52,6 +52,12 @@ extern int __h_errno;
/* Use a macro to access always the thread specific `h_errno' variable. */
#define h_errno (*__h_errno_location ())
+
+/* Retain some binary compatibility with old libraries by having both the
+ global variable and the per-thread variable set on error. */
+#define __set_h_errno(x) (h_errno = __h_errno = (x))
+#else
+#define __set_h_errno(x) (h_errno = (x))
#endif
/* Possible values left in `h_errno'. */
@@ -326,6 +332,31 @@ extern struct protoent *getprotobynumber_r __P ((int __proto,
#endif /* reentrant */
+/* Establish network group NETGROUP for enumeration. */
+extern int setnetgrent __P ((__const char *__netgroup));
+
+/* Free all space allocated by previous `setnetgrent' call. */
+extern void endnetgrent __P ((void));
+
+/* Get next member of netgroup established by last `setnetgrent' call
+ and return pointers to elements in HOSTP, USERP, and DOMAINP. */
+extern int getnetgrent __P ((char **__hostp, char **__userp,
+ char **__domainp));
+
+/* Test whether NETGROUP contains the triple (HOST,USER,DOMAIN). */
+extern int innetgr __P ((__const char *__netgroup, __const char *__host,
+ __const char *__user, __const char *domain));
+
+#ifdef __USE_REENTRANT
+/* Reentrant version of `getnetgrent' where result is placed in BUFFER. */
+extern int __getnetgrent_r __P ((char **__hostp, char **__userp,
+ char **__domainp,
+ char *__buffer, int __buflen));
+extern int getnetgrent_r __P ((char **__hostp, char **__userp,
+ char **__domainp,
+ char *__buffer, int __buflen));
+#endif
+
__END_DECLS
#endif /* netdb.h */
diff --git a/resolv/res_debug.c b/resolv/res_debug.c
index 842e63c2fb..cc6f84fea1 100644
--- a/resolv/res_debug.c
+++ b/resolv/res_debug.c
@@ -496,7 +496,7 @@ __p_rr(cp, msg, file)
char base64_key[MAX_KEY_BASE64];
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
- h_errno = NETDB_INTERNAL;
+ __set_h_errno (NETDB_INTERNAL);
return (NULL);
}
cp = __p_fqnname(cp, msg, MAXCDNAME, rrname, sizeof rrname);
diff --git a/resolv/res_mkquery.c b/resolv/res_mkquery.c
index 505c3914a9..d894a8b991 100644
--- a/resolv/res_mkquery.c
+++ b/resolv/res_mkquery.c
@@ -97,7 +97,7 @@ res_mkquery(op, dname, class, type, data, datalen, newrr_in, buf, buflen)
u_char *dnptrs[20], **dpp, **lastdnptr;
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
- h_errno = NETDB_INTERNAL;
+ __set_h_errno (NETDB_INTERNAL);
return (-1);
}
#ifdef DEBUG
diff --git a/resolv/res_query.c b/resolv/res_query.c
index ac50a9c7c5..3ddeb20bb2 100644
--- a/resolv/res_query.c
+++ b/resolv/res_query.c
@@ -113,7 +113,7 @@ res_query(name, class, type, answer, anslen)
hp->rcode = NOERROR; /* default */
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
- h_errno = NETDB_INTERNAL;
+ __set_h_errno (NETDB_INTERNAL);
return (-1);
}
#ifdef DEBUG
@@ -128,7 +128,7 @@ res_query(name, class, type, answer, anslen)
if (_res.options & RES_DEBUG)
printf(";; res_query: mkquery failed\n");
#endif
- h_errno = NO_RECOVERY;
+ __set_h_errno (NO_RECOVERY);
return (n);
}
n = res_send(buf, n, answer, anslen);
@@ -137,7 +137,7 @@ res_query(name, class, type, answer, anslen)
if (_res.options & RES_DEBUG)
printf(";; res_query: send error\n");
#endif
- h_errno = TRY_AGAIN;
+ __set_h_errno (TRY_AGAIN);
return (n);
}
@@ -149,19 +149,19 @@ res_query(name, class, type, answer, anslen)
#endif
switch (hp->rcode) {
case NXDOMAIN:
- h_errno = HOST_NOT_FOUND;
+ __set_h_errno (HOST_NOT_FOUND);
break;
case SERVFAIL:
- h_errno = TRY_AGAIN;
+ __set_h_errno (TRY_AGAIN);
break;
case NOERROR:
- h_errno = NO_DATA;
+ __set_h_errno (NO_DATA);
break;
case FORMERR:
case NOTIMP:
case REFUSED:
default:
- h_errno = NO_RECOVERY;
+ __set_h_errno (NO_RECOVERY);
break;
}
return (-1);
@@ -189,11 +189,11 @@ res_search(name, class, type, answer, anslen)
int got_nodata = 0, got_servfail = 0, tried_as_is = 0;
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
- h_errno = NETDB_INTERNAL;
+ __set_h_errno (NETDB_INTERNAL);
return (-1);
}
__set_errno (0);
- h_errno = HOST_NOT_FOUND; /* default, if we never query */
+ __set_h_errno (HOST_NOT_FOUND); /* default, if we never query */
dots = 0;
for (cp = name; *cp; cp++)
dots += (*cp == '.');
@@ -253,7 +253,7 @@ res_search(name, class, type, answer, anslen)
* fully-qualified.
*/
if (errno == ECONNREFUSED) {
- h_errno = TRY_AGAIN;
+ __set_h_errno (TRY_AGAIN);
return (-1);
}
@@ -302,11 +302,11 @@ res_search(name, class, type, answer, anslen)
* the last DNSRCH we did.
*/
if (saved_herrno != -1)
- h_errno = saved_herrno;
+ __set_h_errno (saved_herrno);
else if (got_nodata)
- h_errno = NO_DATA;
+ __set_h_errno (NO_DATA);
else if (got_servfail)
- h_errno = TRY_AGAIN;
+ __set_h_errno (TRY_AGAIN);
return (-1);
}
@@ -326,7 +326,7 @@ res_querydomain(name, domain, class, type, answer, anslen)
int n;
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
- h_errno = NETDB_INTERNAL;
+ __set_h_errno (NETDB_INTERNAL);
return (-1);
}
#ifdef DEBUG