aboutsummaryrefslogtreecommitdiff
path: root/resolv
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2016-09-21 16:30:27 +0200
committerFlorian Weimer <fweimer@redhat.com>2016-09-21 16:30:27 +0200
commit6815a33d53164e7f1a3b87cec905c17c7a14a007 (patch)
tree36746b90972604ea29e28a698e8bd1dbc6dedea4 /resolv
parentcbb47fa1c6476af73f393a81cd62fc926e1b8f6e (diff)
downloadglibc-6815a33d53164e7f1a3b87cec905c17c7a14a007.zip
glibc-6815a33d53164e7f1a3b87cec905c17c7a14a007.tar.gz
glibc-6815a33d53164e7f1a3b87cec905c17c7a14a007.tar.bz2
resolv: Remove unsupported hook functions from the API [BZ #20016]
Diffstat (limited to 'resolv')
-rw-r--r--resolv/Makefile2
-rw-r--r--resolv/compat-hooks.c56
-rw-r--r--resolv/res_data.c10
-rw-r--r--resolv/res_init.c4
-rw-r--r--resolv/res_send.c85
-rw-r--r--resolv/resolv.h21
6 files changed, 61 insertions, 117 deletions
diff --git a/resolv/Makefile b/resolv/Makefile
index 8be41d3..b8b8620 100644
--- a/resolv/Makefile
+++ b/resolv/Makefile
@@ -46,7 +46,7 @@ libresolv-routines := gethnamaddr res_comp res_debug \
res_data res_mkquery res_query res_send \
inet_net_ntop inet_net_pton inet_neta base64 \
ns_parse ns_name ns_netint ns_ttl ns_print \
- ns_samedomain ns_date
+ ns_samedomain ns_date compat-hooks
libanl-routines := gai_cancel gai_error gai_misc gai_notify gai_suspend \
getaddrinfo_a
diff --git a/resolv/compat-hooks.c b/resolv/compat-hooks.c
new file mode 100644
index 0000000..5e38260
--- /dev/null
+++ b/resolv/compat-hooks.c
@@ -0,0 +1,56 @@
+/* Compatibility functions for obsolete libresolv hooks.
+ Copyright (C) 1999-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/*
+ * Copyright (c) 1995-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.
+ */
+
+#include <resolv.h>
+
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT (libresolv, GLIBC_2_0, GLIBC_2_25)
+
+void
+attribute_compat_text_section
+res_send_setqhook(void *hook) {
+ _res.__glibc_unused_qhook = hook;
+}
+compat_symbol (libresolv, res_send_setqhook, res_send_setqhook, GLIBC_2_0);
+
+void
+attribute_compat_text_section
+res_send_setrhook(void *hook) {
+ _res.__glibc_unused_rhook = hook;
+}
+compat_symbol (libresolv, res_send_setrhook, res_send_setrhook, GLIBC_2_0);
+
+#endif
diff --git a/resolv/res_data.c b/resolv/res_data.c
index f44c517..569ff4c 100644
--- a/resolv/res_data.c
+++ b/resolv/res_data.c
@@ -104,16 +104,6 @@ res_query(const char *name, /* domain name */
return (res_nquery(&_res, name, class, type, answer, anslen));
}
-void
-res_send_setqhook(res_send_qhook hook) {
- _res.qhook = hook;
-}
-
-void
-res_send_setrhook(res_send_rhook hook) {
- _res.rhook = hook;
-}
-
int
res_isourserver(const struct sockaddr_in *inp) {
return (res_ourserver_p(&_res, (const struct sockaddr_in6 *) inp));
diff --git a/resolv/res_init.c b/resolv/res_init.c
index bfae537..0a01fd5 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -144,8 +144,8 @@ __res_vinit(res_state statp, int preinit) {
statp->pfcode = 0;
statp->_vcsock = -1;
statp->_flags = 0;
- statp->qhook = NULL;
- statp->rhook = NULL;
+ statp->__glibc_unused_qhook = NULL;
+ statp->__glibc_unused_rhook = NULL;
statp->_u._ext.nscount = 0;
for (n = 0; n < MAXNS; n++)
statp->_u._ext.nsaddrs[n] = NULL;
diff --git a/resolv/res_send.c b/resolv/res_send.c
index 869294f..6d46bb2 100644
--- a/resolv/res_send.c
+++ b/resolv/res_send.c
@@ -364,22 +364,6 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen,
return (-1);
}
-#ifdef USE_HOOKS
- if (__glibc_unlikely (statp->qhook || statp->rhook)) {
- if (anssiz < MAXPACKET && ansp) {
- /* Always allocate MAXPACKET, callers expect
- this specific size. */
- u_char *buf = malloc (MAXPACKET);
- if (buf == NULL)
- return (-1);
- memcpy (buf, ans, HFIXEDSZ);
- *ansp = buf;
- ans = buf;
- anssiz = MAXPACKET;
- }
- }
-#endif
-
DprintQ((statp->options & RES_DEBUG) || (statp->pfcode & RES_PRF_QUERY),
(stdout, ";; res_send()\n"), buf, buflen);
v_circuit = ((statp->options & RES_USEVC)
@@ -468,47 +452,10 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen,
{
#ifdef DEBUG
char tmpbuf[40];
-#endif
-#if defined USE_HOOKS || defined DEBUG
struct sockaddr *nsap = get_nsaddr (statp, ns);
#endif
same_ns:
-#ifdef USE_HOOKS
- if (__glibc_unlikely (statp->qhook != NULL)) {
- int done = 0, loops = 0;
-
- do {
- res_sendhookact act;
-
- struct sockaddr_in *nsap4;
- nsap4 = (struct sockaddr_in *) nsap;
- act = (*statp->qhook)(&nsap4, &buf, &buflen,
- ans, anssiz, &resplen);
- nsap = (struct sockaddr_in6 *) nsap4;
- switch (act) {
- case res_goahead:
- done = 1;
- break;
- case res_nextns:
- __res_iclose(statp, false);
- goto next_ns;
- case res_done:
- return (resplen);
- case res_modified:
- /* give the hook another try */
- if (++loops < 42) /*doug adams*/
- break;
- /*FALLTHROUGH*/
- case res_error:
- /*FALLTHROUGH*/
- default:
- return (-1);
- }
- } while (!done);
- }
-#endif
-
Dprint(statp->options & RES_DEBUG,
(stdout, ";; Querying server (# %d) address = %s\n",
ns + 1, inet_ntop(nsap->sa_family,
@@ -571,38 +518,6 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen,
(statp->options & RES_STAYOPEN) == 0) {
__res_iclose(statp, false);
}
-#ifdef USE_HOOKS
- if (__glibc_unlikely (statp->rhook)) {
- int done = 0, loops = 0;
-
- do {
- res_sendhookact act;
-
- act = (*statp->rhook)((struct sockaddr_in *)
- nsap, buf, buflen,
- ans, anssiz, &resplen);
- switch (act) {
- case res_goahead:
- case res_done:
- done = 1;
- break;
- case res_nextns:
- __res_iclose(statp, false);
- goto next_ns;
- case res_modified:
- /* give the hook another try */
- if (++loops < 42) /*doug adams*/
- break;
- /*FALLTHROUGH*/
- case res_error:
- /*FALLTHROUGH*/
- default:
- return (-1);
- }
- } while (!done);
-
- }
-#endif
return (resplen);
next_ns: ;
} /*foreach ns*/
diff --git a/resolv/resolv.h b/resolv/resolv.h
index f55e7ce..a6f4dad 100644
--- a/resolv/resolv.h
+++ b/resolv/resolv.h
@@ -68,23 +68,6 @@
#ifndef __res_state_defined
# define __res_state_defined
-typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error }
- res_sendhookact;
-
-typedef res_sendhookact (*res_send_qhook) (struct sockaddr_in * const *__ns,
- const u_char **__query,
- int *__querylen,
- u_char *__ans,
- int __anssiz,
- int *__resplen);
-
-typedef res_sendhookact (*res_send_rhook) (const struct sockaddr_in *__ns,
- const u_char *__query,
- int __querylen,
- u_char *__ans,
- int __anssiz,
- int *__resplen);
-
/*
* Global defines and variables for resolver stub.
*/
@@ -123,8 +106,8 @@ struct __res_state {
u_int32_t mask;
} sort_list[MAXRESOLVSORT];
/* 4 byte hole here on 64-bit architectures. */
- res_send_qhook qhook; /* query hook */
- res_send_rhook rhook; /* response hook */
+ void * __glibc_unused_qhook;
+ void * __glibc_unused_rhook;
int res_h_errno; /* last one set for this context */
int _vcsock; /* PRIVATE: for res_send VC i/o */
u_int _flags; /* PRIVATE: see below */