mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
resolv: Remove unsupported hook functions from the API [BZ #20016]
This commit is contained in:
15
ChangeLog
15
ChangeLog
@ -1,3 +1,18 @@
|
|||||||
|
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>
|
2016-09-21 Florian Weimer <fweimer@redhat.com>
|
||||||
|
|
||||||
malloc: Use __libc_lock wrappers.
|
malloc: Use __libc_lock wrappers.
|
||||||
|
5
NEWS
5
NEWS
@ -56,6 +56,11 @@ Version 2.25
|
|||||||
meta-RR types is not officially standardized, subject to revision, and
|
meta-RR types is not officially standardized, subject to revision, and
|
||||||
thus not suitable for encoding in a macro.
|
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:
|
Security related changes:
|
||||||
|
|
||||||
On ARM EABI (32-bit), generating a backtrace for execution contexts which
|
On ARM EABI (32-bit), generating a backtrace for execution contexts which
|
||||||
|
@ -33,8 +33,6 @@ extern u_int32_t _getlong (const u_char *__src);
|
|||||||
extern u_int16_t _getshort (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,
|
extern void res_pquery (const res_state __statp, const u_char *__msg,
|
||||||
int __len, FILE *__file);
|
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,
|
extern int res_ourserver_p (const res_state __statp,
|
||||||
const struct sockaddr_in6 *__inp);
|
const struct sockaddr_in6 *__inp);
|
||||||
extern void __res_iclose (res_state statp, bool free_addr);
|
extern void __res_iclose (res_state statp, bool free_addr);
|
||||||
|
@ -46,7 +46,7 @@ libresolv-routines := gethnamaddr res_comp res_debug \
|
|||||||
res_data res_mkquery res_query res_send \
|
res_data res_mkquery res_query res_send \
|
||||||
inet_net_ntop inet_net_pton inet_neta base64 \
|
inet_net_ntop inet_net_pton inet_neta base64 \
|
||||||
ns_parse ns_name ns_netint ns_ttl ns_print \
|
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 \
|
libanl-routines := gai_cancel gai_error gai_misc gai_notify gai_suspend \
|
||||||
getaddrinfo_a
|
getaddrinfo_a
|
||||||
|
56
resolv/compat-hooks.c
Normal file
56
resolv/compat-hooks.c
Normal file
@ -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
|
@ -104,16 +104,6 @@ res_query(const char *name, /* domain name */
|
|||||||
return (res_nquery(&_res, name, class, type, answer, anslen));
|
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
|
int
|
||||||
res_isourserver(const struct sockaddr_in *inp) {
|
res_isourserver(const struct sockaddr_in *inp) {
|
||||||
return (res_ourserver_p(&_res, (const struct sockaddr_in6 *) inp));
|
return (res_ourserver_p(&_res, (const struct sockaddr_in6 *) inp));
|
||||||
|
@ -144,8 +144,8 @@ __res_vinit(res_state statp, int preinit) {
|
|||||||
statp->pfcode = 0;
|
statp->pfcode = 0;
|
||||||
statp->_vcsock = -1;
|
statp->_vcsock = -1;
|
||||||
statp->_flags = 0;
|
statp->_flags = 0;
|
||||||
statp->qhook = NULL;
|
statp->__glibc_unused_qhook = NULL;
|
||||||
statp->rhook = NULL;
|
statp->__glibc_unused_rhook = NULL;
|
||||||
statp->_u._ext.nscount = 0;
|
statp->_u._ext.nscount = 0;
|
||||||
for (n = 0; n < MAXNS; n++)
|
for (n = 0; n < MAXNS; n++)
|
||||||
statp->_u._ext.nsaddrs[n] = NULL;
|
statp->_u._ext.nsaddrs[n] = NULL;
|
||||||
|
@ -364,22 +364,6 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen,
|
|||||||
return (-1);
|
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),
|
DprintQ((statp->options & RES_DEBUG) || (statp->pfcode & RES_PRF_QUERY),
|
||||||
(stdout, ";; res_send()\n"), buf, buflen);
|
(stdout, ";; res_send()\n"), buf, buflen);
|
||||||
v_circuit = ((statp->options & RES_USEVC)
|
v_circuit = ((statp->options & RES_USEVC)
|
||||||
@ -468,47 +452,10 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen,
|
|||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
char tmpbuf[40];
|
char tmpbuf[40];
|
||||||
#endif
|
|
||||||
#if defined USE_HOOKS || defined DEBUG
|
|
||||||
struct sockaddr *nsap = get_nsaddr (statp, ns);
|
struct sockaddr *nsap = get_nsaddr (statp, ns);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
same_ns:
|
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,
|
Dprint(statp->options & RES_DEBUG,
|
||||||
(stdout, ";; Querying server (# %d) address = %s\n",
|
(stdout, ";; Querying server (# %d) address = %s\n",
|
||||||
ns + 1, inet_ntop(nsap->sa_family,
|
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) {
|
(statp->options & RES_STAYOPEN) == 0) {
|
||||||
__res_iclose(statp, false);
|
__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);
|
return (resplen);
|
||||||
next_ns: ;
|
next_ns: ;
|
||||||
} /*foreach ns*/
|
} /*foreach ns*/
|
||||||
|
@ -68,23 +68,6 @@
|
|||||||
#ifndef __res_state_defined
|
#ifndef __res_state_defined
|
||||||
# define __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.
|
* Global defines and variables for resolver stub.
|
||||||
*/
|
*/
|
||||||
@ -123,8 +106,8 @@ struct __res_state {
|
|||||||
u_int32_t mask;
|
u_int32_t mask;
|
||||||
} sort_list[MAXRESOLVSORT];
|
} sort_list[MAXRESOLVSORT];
|
||||||
/* 4 byte hole here on 64-bit architectures. */
|
/* 4 byte hole here on 64-bit architectures. */
|
||||||
res_send_qhook qhook; /* query hook */
|
void * __glibc_unused_qhook;
|
||||||
res_send_rhook rhook; /* response hook */
|
void * __glibc_unused_rhook;
|
||||||
int res_h_errno; /* last one set for this context */
|
int res_h_errno; /* last one set for this context */
|
||||||
int _vcsock; /* PRIVATE: for res_send VC i/o */
|
int _vcsock; /* PRIVATE: for res_send VC i/o */
|
||||||
u_int _flags; /* PRIVATE: see below */
|
u_int _flags; /* PRIVATE: see below */
|
||||||
|
Reference in New Issue
Block a user