aboutsummaryrefslogtreecommitdiff
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
parentcbb47fa1c6476af73f393a81cd62fc926e1b8f6e (diff)
downloadglibc-6815a33d53164e7f1a3b87cec905c17c7a14a007.tar
glibc-6815a33d53164e7f1a3b87cec905c17c7a14a007.tar.gz
glibc-6815a33d53164e7f1a3b87cec905c17c7a14a007.tar.bz2
glibc-6815a33d53164e7f1a3b87cec905c17c7a14a007.zip
resolv: Remove unsupported hook functions from the API [BZ #20016]
-rw-r--r--ChangeLog15
-rw-r--r--NEWS5
-rw-r--r--include/resolv.h2
-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
9 files changed, 81 insertions, 119 deletions
diff --git a/ChangeLog b/ChangeLog
index b6f97dcca4..96b2a06804 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
2016-09-21 Florian Weimer <fweimer@redhat.com>
+ [BZ #20016]
+ * resolv/res_send.c (__libc_res_nsend): Remove USE_HOOK code.
+ * resolv/res_data.c (res_send_setqhook, res_send_setrhook):
+ Move ...
+ * resolv/compat-hooks.c (res_send_setqhook, res_send_setrhook):
+ ... here, as compatibility symbols in a new file.
+ * resolv/Makefile (libresolv-routines): Add compat-hooks.
+ * resolv/res_init.c (__res_vinit): Adjust member names.
+ * include/resolv.h (res_send_setqhook, res_send_setrhook): Remove.
+ * resolv/resolv.h (res_sendhookact, res_send_qhook)
+ (res_send_rhook): Remove.
+ (struct __res_state): Rename qhook, rhook members.
+
+2016-09-21 Florian Weimer <fweimer@redhat.com>
+
malloc: Use __libc_lock wrappers.
* malloc/arena.c (list_lock, free_list_lock): Define using
__libc_lock_define_initialized.
diff --git a/NEWS b/NEWS
index 26b8045db5..1c38a615dd 100644
--- a/NEWS
+++ b/NEWS
@@ -56,6 +56,11 @@ Version 2.25
meta-RR types is not officially standardized, subject to revision, and
thus not suitable for encoding in a macro.
+* The types res_sendhookact, res_send_qhook, re_send_rhook, and the qhook
+ and rhook members of the res_state type in <resolv.h> have been removed.
+ The glibc stub resolver did not support these hooks, but the header file
+ did not reflect that.
+
Security related changes:
On ARM EABI (32-bit), generating a backtrace for execution contexts which
diff --git a/include/resolv.h b/include/resolv.h
index 4c614760a8..d7c98dc807 100644
--- a/include/resolv.h
+++ b/include/resolv.h
@@ -33,8 +33,6 @@ extern u_int32_t _getlong (const u_char *__src);
extern u_int16_t _getshort (const u_char *__src);
extern void res_pquery (const res_state __statp, const u_char *__msg,
int __len, FILE *__file);
-extern void res_send_setqhook (res_send_qhook __hook);
-extern void res_send_setrhook (res_send_rhook __hook);
extern int res_ourserver_p (const res_state __statp,
const struct sockaddr_in6 *__inp);
extern void __res_iclose (res_state statp, bool free_addr);
diff --git a/resolv/Makefile b/resolv/Makefile
index 8be41d3ae1..b8b862065e 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 0000000000..5e38260e9e
--- /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 f44c517062..569ff4c0ea 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 bfae537da4..0a01fd56db 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 869294fb95..6d46bb2c15 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 f55e7ceaba..a6f4dadf12 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 */