diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | resolv/README | 3 | ||||
-rw-r--r-- | resolv/inet_addr.c | 39 | ||||
-rw-r--r-- | resolv/res_data.c | 76 | ||||
-rw-r--r-- | resolv/res_init.c | 16 | ||||
-rw-r--r-- | resolv/res_libc.c | 8 | ||||
-rw-r--r-- | resolv/res_mkquery.c | 2 |
7 files changed, 13 insertions, 140 deletions
diff --git a/ChangeLog b/ChangeLog index ccb2780c18..c4aec9445e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2016-04-28 Florian Weimer <fweimer@redhat.com> + * resolv/inet_addr.c: Remove _LIBC conditionals. + * resolv/res_data.c: Likewise. + * resolv/res_init.c: Likewise. + * resolv/res_mkquery.c: Likewise. + * resolv/res_libc.c: Update comment. + * resolv/README: Update. + +2016-04-28 Florian Weimer <fweimer@redhat.com> + * resolv/gethnamaddr.c: Remove SCSS keyword. * resolv/herror.c: Likewise. * resolv/inet_addr.c: Likewise. diff --git a/resolv/README b/resolv/README index dbb15108ae..1296e1c5bd 100644 --- a/resolv/README +++ b/resolv/README @@ -149,8 +149,7 @@ src/lib/isc/ base64.c Some of these files have been optimised a bit, and adaptations have -been made to make them fit in with the rest of glibc. The more -non-obvious changes are wrapped in something like `#ifdef _LIBC'. +been made to make them fit in with the rest of glibc. res_libc.c is home-brewn, although parts of it are taken from res_data.c. diff --git a/resolv/inet_addr.c b/resolv/inet_addr.c index a16b51386a..10d9a1e24d 100644 --- a/resolv/inet_addr.c +++ b/resolv/inet_addr.c @@ -72,13 +72,11 @@ #include <ctype.h> -#ifdef _LIBC # include <endian.h> # include <stdint.h> # include <stdlib.h> # include <limits.h> # include <errno.h> -#endif /* * Ascii internet address interpretation routine. @@ -106,9 +104,6 @@ __inet_aton(const char *cp, struct in_addr *addr) { static const in_addr_t max[4] = { 0xffffffff, 0xffffff, 0xffff, 0xff }; in_addr_t val; -#ifndef _LIBC - int base; -#endif char c; union iaddr { uint8_t bytes[4]; @@ -117,10 +112,8 @@ __inet_aton(const char *cp, struct in_addr *addr) uint8_t *pp = res.bytes; int digit; -#ifdef _LIBC int saved_errno = errno; __set_errno (0); -#endif res.word = 0; @@ -133,7 +126,6 @@ __inet_aton(const char *cp, struct in_addr *addr) */ if (!isdigit(c)) goto ret_0; -#ifdef _LIBC { char *endp; unsigned long ul = strtoul (cp, (char **) &endp, 0); @@ -146,33 +138,6 @@ __inet_aton(const char *cp, struct in_addr *addr) cp = endp; } c = *cp; -#else - val = 0; base = 10; digit = 0; - if (c == '0') { - c = *++cp; - if (c == 'x' || c == 'X') - base = 16, c = *++cp; - else { - base = 8; - digit = 1 ; - } - } - for (;;) { - if (isascii(c) && isdigit(c)) { - if (base == 8 && (c == '8' || c == '9')) - return (0); - val = (val * base) + (c - '0'); - c = *++cp; - digit = 1; - } else if (base == 16 && isascii(c) && isxdigit(c)) { - val = (val << 4) | - (c + 10 - (islower(c) ? 'a' : 'A')); - c = *++cp; - digit = 1; - } else - break; - } -#endif if (c == '.') { /* * Internet format: @@ -206,15 +171,11 @@ __inet_aton(const char *cp, struct in_addr *addr) if (addr != NULL) addr->s_addr = res.word | htonl (val); -#ifdef _LIBC __set_errno (saved_errno); -#endif return (1); ret_0: -#ifdef _LIBC __set_errno (saved_errno); -#endif return (0); } weak_alias (__inet_aton, inet_aton) diff --git a/resolv/res_data.c b/resolv/res_data.c index f7ec21e65a..986fc375e7 100644 --- a/resolv/res_data.c +++ b/resolv/res_data.c @@ -65,67 +65,6 @@ const char *_res_sectioncodes[] attribute_hidden = { #endif #ifndef __BIND_NOSTATIC -#ifdef _LIBC -/* The definition has been moved to res_libc.c. */ -#else -#undef _res -struct __res_state _res -# if defined(__BIND_RES_TEXT) - = { RES_TIMEOUT, } /* Motorola, et al. */ -# endif - ; -#endif - -/* Proto. */ -#ifndef _LIBC -int res_ourserver_p(const res_state, const struct sockaddr_in *); -void res_pquery(const res_state, const u_char *, int, FILE *); -#endif - -#ifndef _LIBC -/* Moved to res_libc.c since res_init() should go into libc.so but the - rest of this file not. */ -int -res_init(void) { - extern int __res_vinit(res_state, int); - - /* - * These three fields used to be statically initialized. This made - * it hard to use this code in a shared library. It is necessary, - * now that we're doing dynamic initialization here, that we preserve - * the old semantics: if an application modifies one of these three - * fields of _res before res_init() is called, res_init() will not - * alter them. Of course, if an application is setting them to - * _zero_ before calling res_init(), hoping to override what used - * to be the static default, we can't detect it and unexpected results - * will follow. Zero for any of these fields would make no sense, - * so one can safely assume that the applications were already getting - * unexpected results. - * - * _res.options is tricky since some apps were known to diddle the bits - * before res_init() was first called. We can't replicate that semantic - * with dynamic initialization (they may have turned bits off that are - * set in RES_DEFAULT). Our solution is to declare such applications - * "broken". They could fool us by setting RES_INIT but none do (yet). - */ - if (!_res.retrans) - _res.retrans = RES_TIMEOUT; - if (!_res.retry) - _res.retry = 4; - if (!(_res.options & RES_INIT)) - _res.options = RES_DEFAULT; - - /* - * This one used to initialize implicitly to zero, so unless the app - * has set it to something in particular, we can randomize it now. - */ - if (!_res.id) - _res.id = res_randomid(); - - return (__res_vinit(&_res, 1)); -} -#endif - void p_query(const u_char *msg) { fp_query(msg, stdout); @@ -215,23 +154,9 @@ res_send(const u_char *buf, int buflen, u_char *ans, int anssiz) { return (res_nsend(&_res, buf, buflen, ans, anssiz)); } -#ifndef _LIBC -int -res_sendsigned(const u_char *buf, int buflen, ns_tsig_key *key, - u_char *ans, int anssiz) -{ - if (__res_maybe_init (&_res, 1) == -1) { - /* errno should have been set by res_init() in this case. */ - return (-1); - } - - return (res_nsendsigned(&_res, buf, buflen, key, ans, anssiz)); -} -#endif void res_close(void) { -#ifdef _LIBC /* * Some stupid programs out there call res_close() before res_init(). * Since _res._vcsock isn't explicitly initialized, these means that @@ -241,7 +166,6 @@ res_close(void) { * early. */ if ((_res.options & RES_INIT) == 0) return; -#endif /* We don't free the name server addresses because we never did it and it would be done implicitly on shutdown. */ __res_iclose(&_res, false); diff --git a/resolv/res_init.c b/resolv/res_init.c index 4fb7f1eb64..de96d84b5d 100644 --- a/resolv/res_init.c +++ b/resolv/res_init.c @@ -102,9 +102,7 @@ static u_int32_t net_mask (struct in_addr) __THROW; # define isascii(c) (!(c & 0200)) #endif -#ifdef _LIBC unsigned long long int __res_initstamp attribute_hidden; -#endif /* * Resolver state default settings. @@ -123,9 +121,7 @@ res_ninit(res_state statp) { return (__res_vinit(statp, 0)); } -#ifdef _LIBC libc_hidden_def (__res_ninit) -#endif /* This function has to be reachable by res_data.c but not publically. */ int @@ -145,9 +141,7 @@ __res_vinit(res_state statp, int preinit) { #ifndef RFC1535 int dots; #endif -#ifdef _LIBC statp->_u._ext.initstamp = __res_initstamp; -#endif if (!preinit) { statp->retrans = RES_TIMEOUT; @@ -283,7 +277,6 @@ __res_vinit(res_state statp, int preinit) { statp->nsaddr_list[nserv].sin_port = htons(NAMESERVER_PORT); nserv++; -#ifdef _LIBC } else { struct in6_addr a6; char *el; @@ -332,7 +325,6 @@ __res_vinit(res_state statp, int preinit) { nserv++; } } -#endif } continue; } @@ -385,12 +377,10 @@ __res_vinit(res_state statp, int preinit) { } } statp->nscount = nserv; -#ifdef _LIBC if (have_serv6) { /* We try IPv6 servers again. */ statp->ipv6_unavail = false; } -#endif #ifdef RESOLVSORT statp->nsort = nsort; #endif @@ -554,9 +544,7 @@ u_int res_randomid(void) { return 0xffff & __getpid(); } -#ifdef _LIBC libc_hidden_def (__res_randomid) -#endif /* @@ -594,11 +582,8 @@ res_nclose(res_state statp) { __res_iclose (statp, true); } -#ifdef _LIBC libc_hidden_def (__res_nclose) -#endif -#ifdef _LIBC # ifdef _LIBC_REENTRANT /* This is called when a thread is exiting to free resources held in _res. */ static void __attribute__ ((section ("__libc_thread_freeres_fn"))) @@ -616,4 +601,3 @@ res_thread_freeres (void) text_set_element (__libc_thread_subfreeres, res_thread_freeres); text_set_element (__libc_subfreeres, res_thread_freeres); # endif -#endif diff --git a/resolv/res_libc.c b/resolv/res_libc.c index a8394e0e7b..a4b376f15b 100644 --- a/resolv/res_libc.c +++ b/resolv/res_libc.c @@ -15,6 +15,9 @@ * SOFTWARE. */ +/* This file contains the definitions related to res_init which are + linked into libc instead of libresolv. */ + #include <atomic.h> #include <limits.h> #include <sys/types.h> @@ -23,11 +26,6 @@ #include <resolv.h> #include <libc-lock.h> - -/* The following bit is copied from res_data.c (where it is #ifdef'ed - out) since res_init() should go into libc.so but the rest of that - file should not. */ - extern unsigned long long int __res_initstamp attribute_hidden; /* We have atomic increment operations on 64-bit platforms. */ #if __WORDSIZE == 64 diff --git a/resolv/res_mkquery.c b/resolv/res_mkquery.c index 200b59fe59..9a11d169a3 100644 --- a/resolv/res_mkquery.c +++ b/resolv/res_mkquery.c @@ -77,13 +77,11 @@ /* Options. Leave them on. */ /* #define DEBUG */ -#ifdef _LIBC # include <hp-timing.h> # include <stdint.h> # if HP_TIMING_AVAIL # define RANDOM_BITS(Var) { uint64_t v64; HP_TIMING_NOW (v64); Var = v64; } # endif -#endif /* * Form all types of queries. |