From patchwork Fri Sep 9 12:31:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 667996 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sVxQS1MSYz9rxm for ; Fri, 9 Sep 2016 22:31:27 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=K2C3mZ5R; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:to:subject:mime-version:content-type :content-transfer-encoding:message-id:from; q=dns; s=default; b= stVypbUQfsRp/gk/YMUWubiL+Kd1LvN7bH9xfixF8cUO/YlQFt5Oh4MnOhQ6V+CE xOEaBYlGfxoyAs6ZwWopxAeb/TnYT9/cL2lFGaKPwlccuI1AElh21ZTPykpc/VWV 7IoNCDhY5IZH70uCutaQ9i7tiJnJx4xuw67tqaf8Fog= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:to:subject:mime-version:content-type :content-transfer-encoding:message-id:from; s=default; bh=Dmjm6e VfZa9PFkFB+KlMi38wtyw=; b=K2C3mZ5RE13osPqEU8ISWiVRlUqBSWTH9kLm/1 nUuus7dGar23cvA9WWIR8JWfKqrLwvFhhzCw1LO2J+DAULKNWa7sqLwKsYUq8J1o BDS2kD6Qt8o2M0uhaTFv1Ah0rrKd/WMIFpllVm88dFJ4V33/1oTFEUsHgWIXUwxC 4rBdQ= Received: (qmail 86920 invoked by alias); 9 Sep 2016 12:31:22 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 86902 invoked by uid 89); 9 Sep 2016 12:31:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=SPECIAL, profits, INTERNET, OTHER X-HELO: mx1.redhat.com Date: Fri, 09 Sep 2016 14:31:08 +0200 To: libc-alpha@sourceware.org Subject: [PATCH] resolv: Remove unsupported hook functions from the API [BZ #20016] User-Agent: Heirloom mailx 12.5 7/5/10 MIME-Version: 1.0 Message-Id: <20160909123108.9D781400F4DE5@oldenburg.str.redhat.com> From: fweimer@redhat.com (Florian Weimer) 2016-09-09 Florian Weimer [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. diff --git a/NEWS b/NEWS index ba1ec71..42ca354 100644 --- a/NEWS +++ b/NEWS @@ -40,6 +40,11 @@ Version 2.25 for the Linux quota interface which predates kernel version 2.4.22 has been removed. +* The types res_sendhookact, res_send_qhook, re_send_rhook, and the qhook + and rhook members of the res_state type in 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 4c61476..d7c98dc 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 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 + . */ + +/* + * 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 + +#include + +#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 cea4c8a..88ca374 100644 --- a/resolv/res_init.c +++ b/resolv/res_init.c @@ -143,8 +143,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 */