2016-04-29 15:08:06 +00:00
|
|
|
/* Convert socket address to string using Name Service Switch modules.
|
2019-01-01 00:11:28 +00:00
|
|
|
Copyright (C) 1997-2019 Free Software Foundation, Inc.
|
2016-04-29 15:08:06 +00:00
|
|
|
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
|
Prefer https to http for gnu.org and fsf.org URLs
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:
sed -ri '
s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
$(find $(git ls-files) -prune -type f \
! -name '*.po' \
! -name 'ChangeLog*' \
! -path COPYING ! -path COPYING.LIB \
! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
! -path manual/texinfo.tex ! -path scripts/config.guess \
! -path scripts/config.sub ! -path scripts/install-sh \
! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
! -path INSTALL ! -path locale/programs/charmap-kw.h \
! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
! '(' -name configure \
-execdir test -f configure.ac -o -f configure.in ';' ')' \
! '(' -name preconfigure \
-execdir test -f preconfigure.ac ';' ')' \
-print)
and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:
chmod a+x sysdeps/unix/sysv/linux/riscv/configure
# Omit irrelevant whitespace and comment-only changes,
# perhaps from a slightly-different Autoconf version.
git checkout -f \
sysdeps/csky/configure \
sysdeps/hppa/configure \
sysdeps/riscv/configure \
sysdeps/unix/sysv/linux/csky/configure
# Omit changes that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
git checkout -f \
sysdeps/powerpc/powerpc64/ppc-mcount.S \
sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
# Omit change that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 05:40:42 +00:00
|
|
|
<https://www.gnu.org/licenses/>. */
|
2016-04-29 15:08:06 +00:00
|
|
|
|
1997-02-19 04:43:53 +00:00
|
|
|
/* The Inner Net License, Version 2.00
|
|
|
|
|
|
|
|
The author(s) grant permission for redistribution and use in source and
|
|
|
|
binary forms, with or without modification, of the software and documentation
|
|
|
|
provided that the following conditions are met:
|
|
|
|
|
|
|
|
0. If you receive a version of the software that is specifically labelled
|
|
|
|
as not being for redistribution (check the version message and/or README),
|
|
|
|
you are not permitted to redistribute that version of the software in any
|
|
|
|
way or form.
|
|
|
|
1. All terms of the all other applicable copyrights and licenses must be
|
|
|
|
followed.
|
|
|
|
2. Redistributions of source code must retain the authors' copyright
|
|
|
|
notice(s), this list of conditions, and the following disclaimer.
|
|
|
|
3. Redistributions in binary form must reproduce the authors' copyright
|
|
|
|
notice(s), this list of conditions, and the following disclaimer in the
|
|
|
|
documentation and/or other materials provided with the distribution.
|
2002-07-06 06:36:39 +00:00
|
|
|
4. [The copyright holder has authorized the removal of this clause.]
|
1997-02-19 04:43:53 +00:00
|
|
|
5. Neither the name(s) of the author(s) nor the names of its contributors
|
|
|
|
may be used to endorse or promote products derived from this software
|
|
|
|
without specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY ITS AUTHORS AND CONTRIBUTORS ``AS IS'' AND ANY
|
|
|
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
|
|
|
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
|
|
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
If these license terms cause you a real problem, contact the author. */
|
|
|
|
|
|
|
|
/* This software is Copyright 1996 by Craig Metz, All Rights Reserved. */
|
|
|
|
|
|
|
|
#include <errno.h>
|
2000-03-23 21:34:58 +00:00
|
|
|
#include <netdb.h>
|
2007-03-17 17:09:13 +00:00
|
|
|
#include <stddef.h>
|
2004-03-16 00:08:09 +00:00
|
|
|
#include <stdlib.h>
|
1997-02-19 04:43:53 +00:00
|
|
|
#include <stdio.h>
|
2000-03-23 21:34:58 +00:00
|
|
|
#include <string.h>
|
1997-02-19 04:43:53 +00:00
|
|
|
#include <unistd.h>
|
2013-05-01 15:46:34 +00:00
|
|
|
#include <stdint.h>
|
update from main archive 970221
1997-02-22 00:17 Ulrich Drepper <drepper@cygnus.com>
* catgets/gencat.c: Change to use argp.
* db/makedb: Likewise.
* locale/programs/localedef.c: Likewise.
* locale/programs/locale.c: Little adjustment for better usage of
argp.
1997-02-20 20:07 Greg McGary <gkm@eng.ascend.com>
* Makeconfig: Add rules for libc with bounded pointers.
* Makerules: Likewise.
* config.make.in: Likewise.
* configure.in: Likewise.
1997-02-21 10:41 Miles Bader <miles@gnu.ai.mit.edu>
* argp.h (OPTION_NO_USAGE): New macro.
* argp-help.c (usage_long_opt, usage_argful_short_opt,
add_argless_short_opt): Implement OPTION_NO_USAGE.
1997-02-20 16:41 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* malloc/obstack.h: Fix typo.
1997-02-20 15:56 Miles Bader <miles@gnu.ai.mit.edu>
* argp-fmtstream.c (__argp_fmtstream_update): Account for case
where NEXTLINE points one past the end of the active buffer.
* argp-help.c <stddef.h>: New include.
(__argp_failure): Only exit if STATE says it's ok.
(print_header, hol_entry_help): Use UPARAMS fields rather than
constants.
(_help): Call fill_in_uparams if necessary.
(struct hol_help_state): New type.
(struct pentry_state): Add hhstate field. Remove prev_entry &
sep_groups fields.
(hol_entry_help): Add HHSTATE parameter. Remove prev_entry &
sep_groups parameters.
Suppress duplicate arguments if requested, and note the fact.
(print_header, comma): Use PEST->hhstate fields.
(hol_help): Add HHSTATE variable & pass to hol_entry_help.
Remove LAST_ENTRY & SEP_GROUPS variables.
If any suplicate arguments were suppressed, print explanatory note.
(filter_doc): Replace PEST parameter with STATE.
(struct uparams): New type.
(uparams): New variable.
(struct uparam_name): New type.
(uparam_names): New variable.
(fill_in_uparams): New function.
(__argp_failure, __argp_error, __argp_state_help): Make STATE
parameter const.
* argp.h (argp_state_help, __argp_state_help, argp_usage,
__argp_usage, argp_error, __argp_error, argp_failure,
__argp_failure): Make STATE parameter const.
(ARGP_KEY_HELP_DUP_ARGS_NOTE): New macro.
* argp.h (argp_program_bug_address): Make const.
1997-02-20 19:20 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/unix/mman/syscalls.list: Explain msync interface.
1997-02-19 01:37 Erik Troan <ewt@redhat.com>
* shadow/sgetspent_r.c: Accept empty third, fourth and fifth fields.
1997-02-20 14:44 Andreas Jaeger <aj@arthur.pfalz.de>
* stdio-common/test-fseek.c: Remove temporary file, add
copyright.
1997-02-20 17:51 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/generic/netinet/in.h: Protect contents using
__BEGIN/END_DECLS. Reported by a sun <asun@zoology.washington.edu>.
* inet/net/ethernet.h: Move to sysdeps/unix/sysv/linux/net.
* inet/Makefile (headers): Remove net/ethernet.h.
* sysdeps/unix/sysv/linux/Makefile: Install net/ethernet.h.
* sysdeps/unix/sysv/linux/Dist: Distribute net/ethernet.h.
1997-02-20 15:23 Thorsten Kukuk <kukuk@weber.uni-paderborn.de>
* nss/nsswitch.c (__nss_configure_lookup): Use correct test when
searching in sorted array.
1997-02-20 01:24 Philip Blundell <pjb27@cam.ac.uk>
* inet/getnameinfo.c: Change to use reentrant getXXbyYY functions
and protect modification of global data.
1997-02-19 18:48 Miles Bader <miles@gnu.ai.mit.edu>
* argp-parse.c (argp_default_parser): Set STATE->name for OPT_PROGNAME.
(parser_init): Use the basename for PARSER->state.name.
* argp-help.c (__argp_error, __argp_failure, __argp_state_help):
Use PROGRAM_INVOCATION_SHORT_NAME instead of PROGRAM_INVOCATION_NAME.
* argp-parse.c (parser_init): Set PARSER->state.flags.
Make check whether PARSER has the prog name in argv[0] at the
proper place.
1997-02-19 23:34 Ulrich Drepper <drepper@cygnus.com>
* locale/programs/ld-time.c (time_finish): t_fmt_ampm is optional.
Use default value instead of printing a warning.
* nss/XXX-lookup.c: Add misssing explanation.
1997-02-19 19:14 Andreas Jaeger <aj@arthur.pfalz.de>
* inet/in6_addr.c: Add missing braces.
* inet/getnameinfo.c: Include <arpa/inet.h>.
* sysdeps/posix/getaddrinfo.c: Include <arpa/inet.h>.
1997-02-19 11:46 Ulrich Drepper <drepper@cygnus.com>
* string/strxfrm.c (STRCOLL): Correct handling of `position'
levels with no non-IGNOREd element and handling of NUL byte.
* string/strcoll.c (STRXFRM): Likewise.
* locale/weight.h: Likewise.
* shadow/sgetspent_r.c (LINE_PARSER): Add missing ')'.
1997-02-22 01:20:46 +00:00
|
|
|
#include <arpa/inet.h>
|
2000-03-23 21:34:58 +00:00
|
|
|
#include <net/if.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/un.h>
|
|
|
|
#include <sys/utsname.h>
|
2015-09-08 21:11:03 +00:00
|
|
|
#include <libc-lock.h>
|
2015-04-08 18:56:35 +00:00
|
|
|
#include <scratch_buffer.h>
|
2018-05-23 13:26:19 +00:00
|
|
|
#include <net-internal.h>
|
2004-03-13 08:47:19 +00:00
|
|
|
|
1997-02-19 04:43:53 +00:00
|
|
|
#ifndef min
|
1997-07-14 21:49:20 +00:00
|
|
|
# define min(x,y) (((x) > (y)) ? (y) : (x))
|
1997-02-19 04:43:53 +00:00
|
|
|
#endif /* min */
|
|
|
|
|
2003-10-02 09:36:32 +00:00
|
|
|
libc_freeres_ptr (static char *domain);
|
|
|
|
|
2018-05-23 13:26:19 +00:00
|
|
|
/* Former NI_IDN_ALLOW_UNASSIGNED, NI_IDN_USE_STD3_ASCII_RULES flags,
|
|
|
|
now ignored. */
|
|
|
|
#define DEPRECATED_NI_IDN 192
|
1997-02-19 04:43:53 +00:00
|
|
|
|
1997-08-20 03:53:21 +00:00
|
|
|
static char *
|
1997-07-14 21:49:20 +00:00
|
|
|
nrl_domainname (void)
|
1997-02-19 04:43:53 +00:00
|
|
|
{
|
1999-04-28 21:56:46 +00:00
|
|
|
static int not_first;
|
1997-02-19 04:43:53 +00:00
|
|
|
|
1999-04-29 12:41:52 +00:00
|
|
|
if (! not_first)
|
1997-07-14 21:49:20 +00:00
|
|
|
{
|
|
|
|
__libc_lock_define_initialized (static, lock);
|
|
|
|
__libc_lock_lock (lock);
|
|
|
|
|
1999-04-29 12:41:52 +00:00
|
|
|
if (! not_first)
|
1997-07-14 21:49:20 +00:00
|
|
|
{
|
|
|
|
char *c;
|
|
|
|
struct hostent *h, th;
|
|
|
|
int herror;
|
2015-04-08 18:56:35 +00:00
|
|
|
struct scratch_buffer tmpbuf;
|
1997-07-14 21:49:20 +00:00
|
|
|
|
2015-04-08 18:56:35 +00:00
|
|
|
scratch_buffer_init (&tmpbuf);
|
1999-04-28 21:56:46 +00:00
|
|
|
not_first = 1;
|
1997-07-14 21:49:20 +00:00
|
|
|
|
2015-04-08 18:56:35 +00:00
|
|
|
while (__gethostbyname_r ("localhost", &th,
|
|
|
|
tmpbuf.data, tmpbuf.length,
|
|
|
|
&h, &herror))
|
1997-07-14 21:49:20 +00:00
|
|
|
{
|
|
|
|
if (herror == NETDB_INTERNAL && errno == ERANGE)
|
2015-04-08 18:56:35 +00:00
|
|
|
{
|
|
|
|
if (!scratch_buffer_grow (&tmpbuf))
|
|
|
|
goto done;
|
|
|
|
}
|
1997-07-14 21:49:20 +00:00
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
update from main archive 970221
1997-02-22 00:17 Ulrich Drepper <drepper@cygnus.com>
* catgets/gencat.c: Change to use argp.
* db/makedb: Likewise.
* locale/programs/localedef.c: Likewise.
* locale/programs/locale.c: Little adjustment for better usage of
argp.
1997-02-20 20:07 Greg McGary <gkm@eng.ascend.com>
* Makeconfig: Add rules for libc with bounded pointers.
* Makerules: Likewise.
* config.make.in: Likewise.
* configure.in: Likewise.
1997-02-21 10:41 Miles Bader <miles@gnu.ai.mit.edu>
* argp.h (OPTION_NO_USAGE): New macro.
* argp-help.c (usage_long_opt, usage_argful_short_opt,
add_argless_short_opt): Implement OPTION_NO_USAGE.
1997-02-20 16:41 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* malloc/obstack.h: Fix typo.
1997-02-20 15:56 Miles Bader <miles@gnu.ai.mit.edu>
* argp-fmtstream.c (__argp_fmtstream_update): Account for case
where NEXTLINE points one past the end of the active buffer.
* argp-help.c <stddef.h>: New include.
(__argp_failure): Only exit if STATE says it's ok.
(print_header, hol_entry_help): Use UPARAMS fields rather than
constants.
(_help): Call fill_in_uparams if necessary.
(struct hol_help_state): New type.
(struct pentry_state): Add hhstate field. Remove prev_entry &
sep_groups fields.
(hol_entry_help): Add HHSTATE parameter. Remove prev_entry &
sep_groups parameters.
Suppress duplicate arguments if requested, and note the fact.
(print_header, comma): Use PEST->hhstate fields.
(hol_help): Add HHSTATE variable & pass to hol_entry_help.
Remove LAST_ENTRY & SEP_GROUPS variables.
If any suplicate arguments were suppressed, print explanatory note.
(filter_doc): Replace PEST parameter with STATE.
(struct uparams): New type.
(uparams): New variable.
(struct uparam_name): New type.
(uparam_names): New variable.
(fill_in_uparams): New function.
(__argp_failure, __argp_error, __argp_state_help): Make STATE
parameter const.
* argp.h (argp_state_help, __argp_state_help, argp_usage,
__argp_usage, argp_error, __argp_error, argp_failure,
__argp_failure): Make STATE parameter const.
(ARGP_KEY_HELP_DUP_ARGS_NOTE): New macro.
* argp.h (argp_program_bug_address): Make const.
1997-02-20 19:20 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/unix/mman/syscalls.list: Explain msync interface.
1997-02-19 01:37 Erik Troan <ewt@redhat.com>
* shadow/sgetspent_r.c: Accept empty third, fourth and fifth fields.
1997-02-20 14:44 Andreas Jaeger <aj@arthur.pfalz.de>
* stdio-common/test-fseek.c: Remove temporary file, add
copyright.
1997-02-20 17:51 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/generic/netinet/in.h: Protect contents using
__BEGIN/END_DECLS. Reported by a sun <asun@zoology.washington.edu>.
* inet/net/ethernet.h: Move to sysdeps/unix/sysv/linux/net.
* inet/Makefile (headers): Remove net/ethernet.h.
* sysdeps/unix/sysv/linux/Makefile: Install net/ethernet.h.
* sysdeps/unix/sysv/linux/Dist: Distribute net/ethernet.h.
1997-02-20 15:23 Thorsten Kukuk <kukuk@weber.uni-paderborn.de>
* nss/nsswitch.c (__nss_configure_lookup): Use correct test when
searching in sorted array.
1997-02-20 01:24 Philip Blundell <pjb27@cam.ac.uk>
* inet/getnameinfo.c: Change to use reentrant getXXbyYY functions
and protect modification of global data.
1997-02-19 18:48 Miles Bader <miles@gnu.ai.mit.edu>
* argp-parse.c (argp_default_parser): Set STATE->name for OPT_PROGNAME.
(parser_init): Use the basename for PARSER->state.name.
* argp-help.c (__argp_error, __argp_failure, __argp_state_help):
Use PROGRAM_INVOCATION_SHORT_NAME instead of PROGRAM_INVOCATION_NAME.
* argp-parse.c (parser_init): Set PARSER->state.flags.
Make check whether PARSER has the prog name in argv[0] at the
proper place.
1997-02-19 23:34 Ulrich Drepper <drepper@cygnus.com>
* locale/programs/ld-time.c (time_finish): t_fmt_ampm is optional.
Use default value instead of printing a warning.
* nss/XXX-lookup.c: Add misssing explanation.
1997-02-19 19:14 Andreas Jaeger <aj@arthur.pfalz.de>
* inet/in6_addr.c: Add missing braces.
* inet/getnameinfo.c: Include <arpa/inet.h>.
* sysdeps/posix/getaddrinfo.c: Include <arpa/inet.h>.
1997-02-19 11:46 Ulrich Drepper <drepper@cygnus.com>
* string/strxfrm.c (STRCOLL): Correct handling of `position'
levels with no non-IGNOREd element and handling of NUL byte.
* string/strcoll.c (STRXFRM): Likewise.
* locale/weight.h: Likewise.
* shadow/sgetspent_r.c (LINE_PARSER): Add missing ')'.
1997-02-22 01:20:46 +00:00
|
|
|
|
1997-07-14 21:49:20 +00:00
|
|
|
if (h && (c = strchr (h->h_name, '.')))
|
|
|
|
domain = __strdup (++c);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* The name contains no domain information. Use the name
|
|
|
|
now to get more information. */
|
2015-04-08 18:56:35 +00:00
|
|
|
while (__gethostname (tmpbuf.data, tmpbuf.length))
|
|
|
|
if (!scratch_buffer_grow (&tmpbuf))
|
|
|
|
goto done;
|
update from main archive 970221
1997-02-22 00:17 Ulrich Drepper <drepper@cygnus.com>
* catgets/gencat.c: Change to use argp.
* db/makedb: Likewise.
* locale/programs/localedef.c: Likewise.
* locale/programs/locale.c: Little adjustment for better usage of
argp.
1997-02-20 20:07 Greg McGary <gkm@eng.ascend.com>
* Makeconfig: Add rules for libc with bounded pointers.
* Makerules: Likewise.
* config.make.in: Likewise.
* configure.in: Likewise.
1997-02-21 10:41 Miles Bader <miles@gnu.ai.mit.edu>
* argp.h (OPTION_NO_USAGE): New macro.
* argp-help.c (usage_long_opt, usage_argful_short_opt,
add_argless_short_opt): Implement OPTION_NO_USAGE.
1997-02-20 16:41 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* malloc/obstack.h: Fix typo.
1997-02-20 15:56 Miles Bader <miles@gnu.ai.mit.edu>
* argp-fmtstream.c (__argp_fmtstream_update): Account for case
where NEXTLINE points one past the end of the active buffer.
* argp-help.c <stddef.h>: New include.
(__argp_failure): Only exit if STATE says it's ok.
(print_header, hol_entry_help): Use UPARAMS fields rather than
constants.
(_help): Call fill_in_uparams if necessary.
(struct hol_help_state): New type.
(struct pentry_state): Add hhstate field. Remove prev_entry &
sep_groups fields.
(hol_entry_help): Add HHSTATE parameter. Remove prev_entry &
sep_groups parameters.
Suppress duplicate arguments if requested, and note the fact.
(print_header, comma): Use PEST->hhstate fields.
(hol_help): Add HHSTATE variable & pass to hol_entry_help.
Remove LAST_ENTRY & SEP_GROUPS variables.
If any suplicate arguments were suppressed, print explanatory note.
(filter_doc): Replace PEST parameter with STATE.
(struct uparams): New type.
(uparams): New variable.
(struct uparam_name): New type.
(uparam_names): New variable.
(fill_in_uparams): New function.
(__argp_failure, __argp_error, __argp_state_help): Make STATE
parameter const.
* argp.h (argp_state_help, __argp_state_help, argp_usage,
__argp_usage, argp_error, __argp_error, argp_failure,
__argp_failure): Make STATE parameter const.
(ARGP_KEY_HELP_DUP_ARGS_NOTE): New macro.
* argp.h (argp_program_bug_address): Make const.
1997-02-20 19:20 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/unix/mman/syscalls.list: Explain msync interface.
1997-02-19 01:37 Erik Troan <ewt@redhat.com>
* shadow/sgetspent_r.c: Accept empty third, fourth and fifth fields.
1997-02-20 14:44 Andreas Jaeger <aj@arthur.pfalz.de>
* stdio-common/test-fseek.c: Remove temporary file, add
copyright.
1997-02-20 17:51 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/generic/netinet/in.h: Protect contents using
__BEGIN/END_DECLS. Reported by a sun <asun@zoology.washington.edu>.
* inet/net/ethernet.h: Move to sysdeps/unix/sysv/linux/net.
* inet/Makefile (headers): Remove net/ethernet.h.
* sysdeps/unix/sysv/linux/Makefile: Install net/ethernet.h.
* sysdeps/unix/sysv/linux/Dist: Distribute net/ethernet.h.
1997-02-20 15:23 Thorsten Kukuk <kukuk@weber.uni-paderborn.de>
* nss/nsswitch.c (__nss_configure_lookup): Use correct test when
searching in sorted array.
1997-02-20 01:24 Philip Blundell <pjb27@cam.ac.uk>
* inet/getnameinfo.c: Change to use reentrant getXXbyYY functions
and protect modification of global data.
1997-02-19 18:48 Miles Bader <miles@gnu.ai.mit.edu>
* argp-parse.c (argp_default_parser): Set STATE->name for OPT_PROGNAME.
(parser_init): Use the basename for PARSER->state.name.
* argp-help.c (__argp_error, __argp_failure, __argp_state_help):
Use PROGRAM_INVOCATION_SHORT_NAME instead of PROGRAM_INVOCATION_NAME.
* argp-parse.c (parser_init): Set PARSER->state.flags.
Make check whether PARSER has the prog name in argv[0] at the
proper place.
1997-02-19 23:34 Ulrich Drepper <drepper@cygnus.com>
* locale/programs/ld-time.c (time_finish): t_fmt_ampm is optional.
Use default value instead of printing a warning.
* nss/XXX-lookup.c: Add misssing explanation.
1997-02-19 19:14 Andreas Jaeger <aj@arthur.pfalz.de>
* inet/in6_addr.c: Add missing braces.
* inet/getnameinfo.c: Include <arpa/inet.h>.
* sysdeps/posix/getaddrinfo.c: Include <arpa/inet.h>.
1997-02-19 11:46 Ulrich Drepper <drepper@cygnus.com>
* string/strxfrm.c (STRCOLL): Correct handling of `position'
levels with no non-IGNOREd element and handling of NUL byte.
* string/strcoll.c (STRXFRM): Likewise.
* locale/weight.h: Likewise.
* shadow/sgetspent_r.c (LINE_PARSER): Add missing ')'.
1997-02-22 01:20:46 +00:00
|
|
|
|
2015-04-08 18:56:35 +00:00
|
|
|
if ((c = strchr (tmpbuf.data, '.')))
|
1997-07-14 21:49:20 +00:00
|
|
|
domain = __strdup (++c);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* We need to preserve the hostname. */
|
2015-04-08 18:56:35 +00:00
|
|
|
const char *hstname = strdupa (tmpbuf.data);
|
1997-07-14 21:49:20 +00:00
|
|
|
|
2015-04-08 18:56:35 +00:00
|
|
|
while (__gethostbyname_r (hstname, &th,
|
|
|
|
tmpbuf.data, tmpbuf.length,
|
1997-07-14 21:49:20 +00:00
|
|
|
&h, &herror))
|
|
|
|
{
|
|
|
|
if (herror == NETDB_INTERNAL && errno == ERANGE)
|
2015-04-08 18:56:35 +00:00
|
|
|
{
|
|
|
|
if (!scratch_buffer_grow (&tmpbuf))
|
|
|
|
goto done;
|
|
|
|
}
|
1997-07-14 21:49:20 +00:00
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (h && (c = strchr(h->h_name, '.')))
|
|
|
|
domain = __strdup (++c);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct in_addr in_addr;
|
|
|
|
|
2000-09-29 15:41:23 +00:00
|
|
|
in_addr.s_addr = htonl (INADDR_LOOPBACK);
|
1997-07-14 21:49:20 +00:00
|
|
|
|
|
|
|
while (__gethostbyaddr_r ((const char *) &in_addr,
|
|
|
|
sizeof (struct in_addr),
|
2015-04-08 18:56:35 +00:00
|
|
|
AF_INET, &th,
|
|
|
|
tmpbuf.data, tmpbuf.length,
|
|
|
|
&h, &herror))
|
1997-07-14 21:49:20 +00:00
|
|
|
{
|
|
|
|
if (herror == NETDB_INTERNAL && errno == ERANGE)
|
2015-04-08 18:56:35 +00:00
|
|
|
{
|
|
|
|
if (!scratch_buffer_grow (&tmpbuf))
|
|
|
|
goto done;
|
|
|
|
}
|
1997-07-14 21:49:20 +00:00
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (h && (c = strchr (h->h_name, '.')))
|
|
|
|
domain = __strdup (++c);
|
|
|
|
}
|
|
|
|
}
|
update from main archive 970221
1997-02-22 00:17 Ulrich Drepper <drepper@cygnus.com>
* catgets/gencat.c: Change to use argp.
* db/makedb: Likewise.
* locale/programs/localedef.c: Likewise.
* locale/programs/locale.c: Little adjustment for better usage of
argp.
1997-02-20 20:07 Greg McGary <gkm@eng.ascend.com>
* Makeconfig: Add rules for libc with bounded pointers.
* Makerules: Likewise.
* config.make.in: Likewise.
* configure.in: Likewise.
1997-02-21 10:41 Miles Bader <miles@gnu.ai.mit.edu>
* argp.h (OPTION_NO_USAGE): New macro.
* argp-help.c (usage_long_opt, usage_argful_short_opt,
add_argless_short_opt): Implement OPTION_NO_USAGE.
1997-02-20 16:41 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* malloc/obstack.h: Fix typo.
1997-02-20 15:56 Miles Bader <miles@gnu.ai.mit.edu>
* argp-fmtstream.c (__argp_fmtstream_update): Account for case
where NEXTLINE points one past the end of the active buffer.
* argp-help.c <stddef.h>: New include.
(__argp_failure): Only exit if STATE says it's ok.
(print_header, hol_entry_help): Use UPARAMS fields rather than
constants.
(_help): Call fill_in_uparams if necessary.
(struct hol_help_state): New type.
(struct pentry_state): Add hhstate field. Remove prev_entry &
sep_groups fields.
(hol_entry_help): Add HHSTATE parameter. Remove prev_entry &
sep_groups parameters.
Suppress duplicate arguments if requested, and note the fact.
(print_header, comma): Use PEST->hhstate fields.
(hol_help): Add HHSTATE variable & pass to hol_entry_help.
Remove LAST_ENTRY & SEP_GROUPS variables.
If any suplicate arguments were suppressed, print explanatory note.
(filter_doc): Replace PEST parameter with STATE.
(struct uparams): New type.
(uparams): New variable.
(struct uparam_name): New type.
(uparam_names): New variable.
(fill_in_uparams): New function.
(__argp_failure, __argp_error, __argp_state_help): Make STATE
parameter const.
* argp.h (argp_state_help, __argp_state_help, argp_usage,
__argp_usage, argp_error, __argp_error, argp_failure,
__argp_failure): Make STATE parameter const.
(ARGP_KEY_HELP_DUP_ARGS_NOTE): New macro.
* argp.h (argp_program_bug_address): Make const.
1997-02-20 19:20 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/unix/mman/syscalls.list: Explain msync interface.
1997-02-19 01:37 Erik Troan <ewt@redhat.com>
* shadow/sgetspent_r.c: Accept empty third, fourth and fifth fields.
1997-02-20 14:44 Andreas Jaeger <aj@arthur.pfalz.de>
* stdio-common/test-fseek.c: Remove temporary file, add
copyright.
1997-02-20 17:51 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/generic/netinet/in.h: Protect contents using
__BEGIN/END_DECLS. Reported by a sun <asun@zoology.washington.edu>.
* inet/net/ethernet.h: Move to sysdeps/unix/sysv/linux/net.
* inet/Makefile (headers): Remove net/ethernet.h.
* sysdeps/unix/sysv/linux/Makefile: Install net/ethernet.h.
* sysdeps/unix/sysv/linux/Dist: Distribute net/ethernet.h.
1997-02-20 15:23 Thorsten Kukuk <kukuk@weber.uni-paderborn.de>
* nss/nsswitch.c (__nss_configure_lookup): Use correct test when
searching in sorted array.
1997-02-20 01:24 Philip Blundell <pjb27@cam.ac.uk>
* inet/getnameinfo.c: Change to use reentrant getXXbyYY functions
and protect modification of global data.
1997-02-19 18:48 Miles Bader <miles@gnu.ai.mit.edu>
* argp-parse.c (argp_default_parser): Set STATE->name for OPT_PROGNAME.
(parser_init): Use the basename for PARSER->state.name.
* argp-help.c (__argp_error, __argp_failure, __argp_state_help):
Use PROGRAM_INVOCATION_SHORT_NAME instead of PROGRAM_INVOCATION_NAME.
* argp-parse.c (parser_init): Set PARSER->state.flags.
Make check whether PARSER has the prog name in argv[0] at the
proper place.
1997-02-19 23:34 Ulrich Drepper <drepper@cygnus.com>
* locale/programs/ld-time.c (time_finish): t_fmt_ampm is optional.
Use default value instead of printing a warning.
* nss/XXX-lookup.c: Add misssing explanation.
1997-02-19 19:14 Andreas Jaeger <aj@arthur.pfalz.de>
* inet/in6_addr.c: Add missing braces.
* inet/getnameinfo.c: Include <arpa/inet.h>.
* sysdeps/posix/getaddrinfo.c: Include <arpa/inet.h>.
1997-02-19 11:46 Ulrich Drepper <drepper@cygnus.com>
* string/strxfrm.c (STRCOLL): Correct handling of `position'
levels with no non-IGNOREd element and handling of NUL byte.
* string/strcoll.c (STRXFRM): Likewise.
* locale/weight.h: Likewise.
* shadow/sgetspent_r.c (LINE_PARSER): Add missing ')'.
1997-02-22 01:20:46 +00:00
|
|
|
}
|
2015-04-08 18:56:35 +00:00
|
|
|
done:
|
|
|
|
scratch_buffer_free (&tmpbuf);
|
update from main archive 970221
1997-02-22 00:17 Ulrich Drepper <drepper@cygnus.com>
* catgets/gencat.c: Change to use argp.
* db/makedb: Likewise.
* locale/programs/localedef.c: Likewise.
* locale/programs/locale.c: Little adjustment for better usage of
argp.
1997-02-20 20:07 Greg McGary <gkm@eng.ascend.com>
* Makeconfig: Add rules for libc with bounded pointers.
* Makerules: Likewise.
* config.make.in: Likewise.
* configure.in: Likewise.
1997-02-21 10:41 Miles Bader <miles@gnu.ai.mit.edu>
* argp.h (OPTION_NO_USAGE): New macro.
* argp-help.c (usage_long_opt, usage_argful_short_opt,
add_argless_short_opt): Implement OPTION_NO_USAGE.
1997-02-20 16:41 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* malloc/obstack.h: Fix typo.
1997-02-20 15:56 Miles Bader <miles@gnu.ai.mit.edu>
* argp-fmtstream.c (__argp_fmtstream_update): Account for case
where NEXTLINE points one past the end of the active buffer.
* argp-help.c <stddef.h>: New include.
(__argp_failure): Only exit if STATE says it's ok.
(print_header, hol_entry_help): Use UPARAMS fields rather than
constants.
(_help): Call fill_in_uparams if necessary.
(struct hol_help_state): New type.
(struct pentry_state): Add hhstate field. Remove prev_entry &
sep_groups fields.
(hol_entry_help): Add HHSTATE parameter. Remove prev_entry &
sep_groups parameters.
Suppress duplicate arguments if requested, and note the fact.
(print_header, comma): Use PEST->hhstate fields.
(hol_help): Add HHSTATE variable & pass to hol_entry_help.
Remove LAST_ENTRY & SEP_GROUPS variables.
If any suplicate arguments were suppressed, print explanatory note.
(filter_doc): Replace PEST parameter with STATE.
(struct uparams): New type.
(uparams): New variable.
(struct uparam_name): New type.
(uparam_names): New variable.
(fill_in_uparams): New function.
(__argp_failure, __argp_error, __argp_state_help): Make STATE
parameter const.
* argp.h (argp_state_help, __argp_state_help, argp_usage,
__argp_usage, argp_error, __argp_error, argp_failure,
__argp_failure): Make STATE parameter const.
(ARGP_KEY_HELP_DUP_ARGS_NOTE): New macro.
* argp.h (argp_program_bug_address): Make const.
1997-02-20 19:20 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/unix/mman/syscalls.list: Explain msync interface.
1997-02-19 01:37 Erik Troan <ewt@redhat.com>
* shadow/sgetspent_r.c: Accept empty third, fourth and fifth fields.
1997-02-20 14:44 Andreas Jaeger <aj@arthur.pfalz.de>
* stdio-common/test-fseek.c: Remove temporary file, add
copyright.
1997-02-20 17:51 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/generic/netinet/in.h: Protect contents using
__BEGIN/END_DECLS. Reported by a sun <asun@zoology.washington.edu>.
* inet/net/ethernet.h: Move to sysdeps/unix/sysv/linux/net.
* inet/Makefile (headers): Remove net/ethernet.h.
* sysdeps/unix/sysv/linux/Makefile: Install net/ethernet.h.
* sysdeps/unix/sysv/linux/Dist: Distribute net/ethernet.h.
1997-02-20 15:23 Thorsten Kukuk <kukuk@weber.uni-paderborn.de>
* nss/nsswitch.c (__nss_configure_lookup): Use correct test when
searching in sorted array.
1997-02-20 01:24 Philip Blundell <pjb27@cam.ac.uk>
* inet/getnameinfo.c: Change to use reentrant getXXbyYY functions
and protect modification of global data.
1997-02-19 18:48 Miles Bader <miles@gnu.ai.mit.edu>
* argp-parse.c (argp_default_parser): Set STATE->name for OPT_PROGNAME.
(parser_init): Use the basename for PARSER->state.name.
* argp-help.c (__argp_error, __argp_failure, __argp_state_help):
Use PROGRAM_INVOCATION_SHORT_NAME instead of PROGRAM_INVOCATION_NAME.
* argp-parse.c (parser_init): Set PARSER->state.flags.
Make check whether PARSER has the prog name in argv[0] at the
proper place.
1997-02-19 23:34 Ulrich Drepper <drepper@cygnus.com>
* locale/programs/ld-time.c (time_finish): t_fmt_ampm is optional.
Use default value instead of printing a warning.
* nss/XXX-lookup.c: Add misssing explanation.
1997-02-19 19:14 Andreas Jaeger <aj@arthur.pfalz.de>
* inet/in6_addr.c: Add missing braces.
* inet/getnameinfo.c: Include <arpa/inet.h>.
* sysdeps/posix/getaddrinfo.c: Include <arpa/inet.h>.
1997-02-19 11:46 Ulrich Drepper <drepper@cygnus.com>
* string/strxfrm.c (STRCOLL): Correct handling of `position'
levels with no non-IGNOREd element and handling of NUL byte.
* string/strcoll.c (STRXFRM): Likewise.
* locale/weight.h: Likewise.
* shadow/sgetspent_r.c (LINE_PARSER): Add missing ')'.
1997-02-22 01:20:46 +00:00
|
|
|
}
|
1997-02-19 04:43:53 +00:00
|
|
|
|
1997-07-14 21:49:20 +00:00
|
|
|
__libc_lock_unlock (lock);
|
1997-02-19 04:43:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return domain;
|
|
|
|
};
|
|
|
|
|
2016-05-04 12:45:17 +00:00
|
|
|
/* Copy a string to a destination buffer with length checking. Return
|
|
|
|
EAI_OVERFLOW if the buffer is not large enough, and 0 on
|
|
|
|
success. */
|
|
|
|
static int
|
|
|
|
checked_copy (char *dest, size_t destlen, const char *source)
|
|
|
|
{
|
|
|
|
size_t source_length = strlen (source);
|
|
|
|
if (source_length + 1 > destlen)
|
|
|
|
return EAI_OVERFLOW;
|
|
|
|
memcpy (dest, source, source_length + 1);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Helper function for CHECKED_SNPRINTF below. */
|
|
|
|
static int
|
|
|
|
check_sprintf_result (int result, size_t destlen)
|
|
|
|
{
|
|
|
|
if (result < 0)
|
|
|
|
return EAI_SYSTEM;
|
|
|
|
if ((size_t) result >= destlen)
|
|
|
|
/* If ret == destlen, there was no room for the terminating NUL
|
|
|
|
character. */
|
|
|
|
return EAI_OVERFLOW;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Format a string in the destination buffer. Return 0 on success,
|
|
|
|
EAI_OVERFLOW in case the buffer is too small, or EAI_SYSTEM on any
|
|
|
|
other error. */
|
|
|
|
#define CHECKED_SNPRINTF(dest, destlen, format, ...) \
|
|
|
|
check_sprintf_result \
|
|
|
|
(__snprintf (dest, destlen, format, __VA_ARGS__), destlen)
|
|
|
|
|
2016-04-29 15:08:06 +00:00
|
|
|
/* Convert host name, AF_INET/AF_INET6 case, name only. */
|
|
|
|
static int
|
|
|
|
gni_host_inet_name (struct scratch_buffer *tmpbuf,
|
|
|
|
const struct sockaddr *sa, socklen_t addrlen,
|
|
|
|
char *host, socklen_t hostlen, int flags)
|
|
|
|
{
|
|
|
|
int herrno;
|
|
|
|
struct hostent th;
|
|
|
|
struct hostent *h = NULL;
|
|
|
|
if (sa->sa_family == AF_INET6)
|
|
|
|
{
|
2016-05-04 12:35:12 +00:00
|
|
|
const struct sockaddr_in6 *sin6p = (const struct sockaddr_in6 *) sa;
|
|
|
|
while (__gethostbyaddr_r (&sin6p->sin6_addr, sizeof(struct in6_addr),
|
|
|
|
AF_INET6, &th, tmpbuf->data, tmpbuf->length,
|
2016-04-29 15:08:06 +00:00
|
|
|
&h, &herrno))
|
|
|
|
if (herrno == NETDB_INTERNAL && errno == ERANGE)
|
|
|
|
{
|
|
|
|
if (!scratch_buffer_grow (tmpbuf))
|
|
|
|
{
|
|
|
|
__set_h_errno (herrno);
|
|
|
|
return EAI_MEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-05-04 12:35:12 +00:00
|
|
|
const struct sockaddr_in *sinp = (const struct sockaddr_in *) sa;
|
|
|
|
while (__gethostbyaddr_r (&sinp->sin_addr, sizeof(struct in_addr),
|
|
|
|
AF_INET, &th, tmpbuf->data, tmpbuf->length,
|
2016-04-29 15:08:06 +00:00
|
|
|
&h, &herrno))
|
|
|
|
if (herrno == NETDB_INTERNAL && errno == ERANGE)
|
|
|
|
{
|
|
|
|
if (!scratch_buffer_grow (tmpbuf))
|
|
|
|
{
|
|
|
|
__set_h_errno (herrno);
|
|
|
|
return EAI_MEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (h == NULL)
|
|
|
|
{
|
|
|
|
if (herrno == NETDB_INTERNAL)
|
|
|
|
{
|
|
|
|
__set_h_errno (herrno);
|
|
|
|
return EAI_SYSTEM;
|
|
|
|
}
|
|
|
|
if (herrno == TRY_AGAIN)
|
|
|
|
{
|
|
|
|
__set_h_errno (herrno);
|
|
|
|
return EAI_AGAIN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (h)
|
|
|
|
{
|
|
|
|
char *c;
|
|
|
|
if ((flags & NI_NOFQDN)
|
|
|
|
&& (c = nrl_domainname ())
|
|
|
|
&& (c = strstr (h->h_name, c))
|
|
|
|
&& (c != h->h_name) && (*(--c) == '.'))
|
|
|
|
/* Terminate the string after the prefix. */
|
|
|
|
*c = '\0';
|
|
|
|
|
|
|
|
/* If requested, convert from the IDN format. */
|
2018-05-23 13:26:19 +00:00
|
|
|
bool do_idn = flags & NI_IDN;
|
|
|
|
char *h_name;
|
|
|
|
if (do_idn)
|
2016-04-29 15:08:06 +00:00
|
|
|
{
|
2018-05-23 13:26:19 +00:00
|
|
|
int rc = __idna_from_dns_encoding (h->h_name, &h_name);
|
|
|
|
if (rc == EAI_IDN_ENCODE)
|
|
|
|
/* Use the punycode name as a fallback. */
|
|
|
|
do_idn = false;
|
|
|
|
else if (rc != 0)
|
|
|
|
return rc;
|
2016-04-29 15:08:06 +00:00
|
|
|
}
|
2018-05-23 13:26:19 +00:00
|
|
|
if (!do_idn)
|
|
|
|
h_name = h->h_name;
|
2016-04-29 15:08:06 +00:00
|
|
|
|
2018-05-23 13:26:19 +00:00
|
|
|
size_t len = strlen (h_name) + 1;
|
2016-04-29 15:08:06 +00:00
|
|
|
if (len > hostlen)
|
|
|
|
return EAI_OVERFLOW;
|
2018-05-23 13:26:19 +00:00
|
|
|
memcpy (host, h_name, len);
|
2016-04-29 15:08:06 +00:00
|
|
|
|
2018-05-23 13:26:19 +00:00
|
|
|
if (do_idn)
|
|
|
|
free (h_name);
|
2016-04-29 15:08:06 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EAI_NONAME;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert host name, AF_INET/AF_INET6 case, numeric conversion. */
|
|
|
|
static int
|
|
|
|
gni_host_inet_numeric (struct scratch_buffer *tmpbuf,
|
|
|
|
const struct sockaddr *sa, socklen_t addrlen,
|
|
|
|
char *host, socklen_t hostlen, int flags)
|
|
|
|
{
|
|
|
|
if (sa->sa_family == AF_INET6)
|
|
|
|
{
|
2016-05-04 12:35:12 +00:00
|
|
|
const struct sockaddr_in6 *sin6p = (const struct sockaddr_in6 *) sa;
|
2016-05-04 12:35:23 +00:00
|
|
|
if (inet_ntop (AF_INET6, &sin6p->sin6_addr, host, hostlen) == NULL)
|
|
|
|
return EAI_OVERFLOW;
|
|
|
|
|
2016-05-04 12:35:12 +00:00
|
|
|
uint32_t scopeid = sin6p->sin6_scope_id;
|
2016-04-29 15:08:06 +00:00
|
|
|
if (scopeid != 0)
|
|
|
|
{
|
2016-05-04 12:45:17 +00:00
|
|
|
size_t used_hostlen = __strnlen (host, hostlen);
|
|
|
|
/* Location of the scope string in the host buffer. */
|
|
|
|
char *scope_start = host + used_hostlen;
|
|
|
|
size_t scope_length = hostlen - used_hostlen;
|
2016-04-29 15:08:06 +00:00
|
|
|
|
|
|
|
if (IN6_IS_ADDR_LINKLOCAL (&sin6p->sin6_addr)
|
|
|
|
|| IN6_IS_ADDR_MC_LINKLOCAL (&sin6p->sin6_addr))
|
|
|
|
{
|
2016-05-04 12:45:17 +00:00
|
|
|
char scopebuf[IFNAMSIZ];
|
|
|
|
if (if_indextoname (scopeid, scopebuf) != NULL)
|
|
|
|
return CHECKED_SNPRINTF
|
|
|
|
(scope_start, scope_length,
|
|
|
|
"%c%s", SCOPE_DELIMITER, scopebuf);
|
2016-04-29 15:08:06 +00:00
|
|
|
}
|
2016-05-04 12:45:17 +00:00
|
|
|
return CHECKED_SNPRINTF
|
|
|
|
(scope_start, scope_length, "%c%u", SCOPE_DELIMITER, scopeid);
|
2016-04-29 15:08:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2016-05-04 12:35:12 +00:00
|
|
|
{
|
|
|
|
const struct sockaddr_in *sinp = (const struct sockaddr_in *) sa;
|
2016-05-04 12:35:23 +00:00
|
|
|
if (inet_ntop (AF_INET, &sinp->sin_addr, host, hostlen) == NULL)
|
|
|
|
return EAI_OVERFLOW;
|
2016-05-04 12:35:12 +00:00
|
|
|
}
|
2016-04-29 15:08:06 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-05-04 12:35:12 +00:00
|
|
|
/* Convert AF_INET or AF_INET6 socket address, host part. */
|
2016-04-29 15:08:06 +00:00
|
|
|
static int
|
|
|
|
gni_host_inet (struct scratch_buffer *tmpbuf,
|
|
|
|
const struct sockaddr *sa, socklen_t addrlen,
|
|
|
|
char *host, socklen_t hostlen, int flags)
|
|
|
|
{
|
|
|
|
if (!(flags & NI_NUMERICHOST))
|
|
|
|
{
|
|
|
|
int result = gni_host_inet_name
|
|
|
|
(tmpbuf, sa, addrlen, host, hostlen, flags);
|
|
|
|
if (result != EAI_NONAME)
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & NI_NAMEREQD)
|
|
|
|
return EAI_NONAME;
|
|
|
|
else
|
|
|
|
return gni_host_inet_numeric
|
|
|
|
(tmpbuf, sa, addrlen, host, hostlen, flags);
|
|
|
|
}
|
|
|
|
|
2016-05-04 12:35:12 +00:00
|
|
|
/* Convert AF_LOCAL socket address, host part. */
|
2016-04-29 15:08:06 +00:00
|
|
|
static int
|
|
|
|
gni_host_local (struct scratch_buffer *tmpbuf,
|
|
|
|
const struct sockaddr *sa, socklen_t addrlen,
|
|
|
|
char *host, socklen_t hostlen, int flags)
|
|
|
|
{
|
|
|
|
if (!(flags & NI_NUMERICHOST))
|
|
|
|
{
|
|
|
|
struct utsname utsname;
|
2016-05-04 12:45:17 +00:00
|
|
|
if (uname (&utsname) == 0)
|
|
|
|
return checked_copy (host, hostlen, utsname.nodename);
|
2016-04-29 15:08:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & NI_NAMEREQD)
|
|
|
|
return EAI_NONAME;
|
|
|
|
|
2016-05-04 12:45:17 +00:00
|
|
|
return checked_copy (host, hostlen, "localhost");
|
2016-04-29 15:08:06 +00:00
|
|
|
}
|
|
|
|
|
2016-05-04 12:35:12 +00:00
|
|
|
/* Convert the host part of an AF_LOCAK socket address. */
|
2016-04-29 15:08:06 +00:00
|
|
|
static int
|
|
|
|
gni_host (struct scratch_buffer *tmpbuf,
|
|
|
|
const struct sockaddr *sa, socklen_t addrlen,
|
|
|
|
char *host, socklen_t hostlen, int flags)
|
|
|
|
{
|
|
|
|
switch (sa->sa_family)
|
|
|
|
{
|
|
|
|
case AF_INET:
|
|
|
|
case AF_INET6:
|
|
|
|
return gni_host_inet (tmpbuf, sa, addrlen, host, hostlen, flags);
|
|
|
|
|
|
|
|
case AF_LOCAL:
|
|
|
|
return gni_host_local (tmpbuf, sa, addrlen, host, hostlen, flags);
|
|
|
|
|
|
|
|
default:
|
|
|
|
return EAI_FAMILY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert service to string, AF_INET and AF_INET6 variant. */
|
|
|
|
static int
|
|
|
|
gni_serv_inet (struct scratch_buffer *tmpbuf,
|
|
|
|
const struct sockaddr *sa, socklen_t addrlen,
|
|
|
|
char *serv, socklen_t servlen, int flags)
|
|
|
|
{
|
|
|
|
_Static_assert
|
|
|
|
(offsetof (struct sockaddr_in, sin_port)
|
|
|
|
== offsetof (struct sockaddr_in6, sin6_port)
|
|
|
|
&& sizeof (((struct sockaddr_in) {}).sin_port) == sizeof (in_port_t)
|
|
|
|
&& sizeof (((struct sockaddr_in6) {}).sin6_port) == sizeof (in_port_t),
|
|
|
|
"AF_INET and AF_INET6 port consistency");
|
2016-05-04 12:35:12 +00:00
|
|
|
const struct sockaddr_in *sinp = (const struct sockaddr_in *) sa;
|
2016-04-29 15:08:06 +00:00
|
|
|
if (!(flags & NI_NUMERICSERV))
|
|
|
|
{
|
|
|
|
struct servent *s, ts;
|
|
|
|
int e;
|
2016-05-04 12:35:12 +00:00
|
|
|
while ((e = __getservbyport_r (sinp->sin_port,
|
2016-04-29 15:08:06 +00:00
|
|
|
((flags & NI_DGRAM)
|
|
|
|
? "udp" : "tcp"), &ts,
|
|
|
|
tmpbuf->data, tmpbuf->length, &s)))
|
|
|
|
{
|
|
|
|
if (e == ERANGE)
|
|
|
|
{
|
|
|
|
if (!scratch_buffer_grow (tmpbuf))
|
|
|
|
return EAI_MEMORY;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (s)
|
2016-05-04 12:45:17 +00:00
|
|
|
return checked_copy (serv, servlen, s->s_name);
|
2016-04-29 15:08:06 +00:00
|
|
|
/* Fall through to numeric conversion. */
|
|
|
|
}
|
2016-05-04 12:45:17 +00:00
|
|
|
return CHECKED_SNPRINTF (serv, servlen, "%d", ntohs (sinp->sin_port));
|
2016-04-29 15:08:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert service to string, AF_LOCAL variant. */
|
|
|
|
static int
|
|
|
|
gni_serv_local (struct scratch_buffer *tmpbuf,
|
|
|
|
const struct sockaddr *sa, socklen_t addrlen,
|
|
|
|
char *serv, socklen_t servlen, int flags)
|
|
|
|
{
|
2016-05-04 12:45:17 +00:00
|
|
|
return checked_copy
|
|
|
|
(serv, servlen, ((const struct sockaddr_un *) sa)->sun_path);
|
2016-04-29 15:08:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert service to string, dispatching to the implementations
|
|
|
|
above. */
|
|
|
|
static int
|
|
|
|
gni_serv (struct scratch_buffer *tmpbuf,
|
|
|
|
const struct sockaddr *sa, socklen_t addrlen,
|
|
|
|
char *serv, socklen_t servlen, int flags)
|
|
|
|
{
|
|
|
|
switch (sa->sa_family)
|
|
|
|
{
|
|
|
|
case AF_INET:
|
|
|
|
case AF_INET6:
|
|
|
|
return gni_serv_inet (tmpbuf, sa, addrlen, serv, servlen, flags);
|
|
|
|
case AF_LOCAL:
|
|
|
|
return gni_serv_local (tmpbuf, sa, addrlen, serv, servlen, flags);
|
|
|
|
default:
|
|
|
|
return EAI_FAMILY;
|
|
|
|
}
|
|
|
|
}
|
1997-07-14 21:49:20 +00:00
|
|
|
|
|
|
|
int
|
1998-04-10 09:48:20 +00:00
|
|
|
getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host,
|
2001-01-27 02:27:46 +00:00
|
|
|
socklen_t hostlen, char *serv, socklen_t servlen,
|
2011-05-02 01:36:43 +00:00
|
|
|
int flags)
|
1997-02-19 04:43:53 +00:00
|
|
|
{
|
2004-03-13 08:47:19 +00:00
|
|
|
if (flags & ~(NI_NUMERICHOST|NI_NUMERICSERV|NI_NOFQDN|NI_NAMEREQD|NI_DGRAM
|
2018-05-23 13:26:19 +00:00
|
|
|
|NI_IDN|DEPRECATED_NI_IDN))
|
2000-11-10 04:15:55 +00:00
|
|
|
return EAI_BADFLAGS;
|
|
|
|
|
2000-03-22 18:14:48 +00:00
|
|
|
if (sa == NULL || addrlen < sizeof (sa_family_t))
|
2000-11-10 04:15:55 +00:00
|
|
|
return EAI_FAMILY;
|
2000-03-22 18:14:48 +00:00
|
|
|
|
2008-12-09 10:02:20 +00:00
|
|
|
if ((flags & NI_NAMEREQD) && host == NULL && serv == NULL)
|
|
|
|
return EAI_NONAME;
|
|
|
|
|
2000-03-22 18:14:48 +00:00
|
|
|
switch (sa->sa_family)
|
|
|
|
{
|
|
|
|
case AF_LOCAL:
|
2007-03-17 17:09:13 +00:00
|
|
|
if (addrlen < (socklen_t) offsetof (struct sockaddr_un, sun_path))
|
2000-11-10 04:15:55 +00:00
|
|
|
return EAI_FAMILY;
|
Update.
2000-03-24 Andreas Jaeger <aj@suse.de>
* Makefile (postclean): Added soversions.i.
2000-03-24 Scott Bambrough <scottb@netwinder.org>
* sysdeps/arm/fpu/fpu_control.h: Define _FPU_MASK_IM, _FPU_MASK_ZM,
_FPU_MASK_OM, _FPU_MASK_UM, _FPU_MASK_PM, _FPU_MASK_DM, _FPU_DEFAULT,
and _FPU_IEEE. Change _FPU_RESERVED.
2000-03-24 Scott Bambrough <scottb@netwinder.org>
* sysdeps/unix/sysv/linux/arm/sys/ucontext.h: New file.
2000-03-24 Roland McGrath <roland@baalperazim.frob.com>
* sysdeps/posix/getaddrinfo.c: Include <net/if.h> for if_nametoindex.
(gaih_inet): Remove unused duplicate variable.
* inet/getnameinfo.c (getnameinfo): Use IFNAMSIZ, not MAXHOSTNAMELEN.
Don't use __libc_sa_len, which only exists for Linux. Just handle
AF_INET and AF_INET6 directly as well as AF_LOCAL, since those are the
only flavors supported by this function anyway.
2000-03-24 Geoff Clare <gwc@unisoft.com>
* stdlib/strfmon.c: corrected problems with missing signs and
missing or extra spaces; allow for sign strings longer than
one character; add padding to ensure positive and negative
formats are aligned when a left precision is used.
2000-03-26 Ulrich Drepper <drepper@redhat.com>
* stdlib/random_r.c (__setstate_r): Allow RNGs of type 4.
Patch by John Mizel <John.Mizel@msdw.com>.
2000-03-26 18:48:26 +00:00
|
|
|
break;
|
|
|
|
case AF_INET:
|
|
|
|
if (addrlen < sizeof (struct sockaddr_in))
|
2000-11-10 04:15:55 +00:00
|
|
|
return EAI_FAMILY;
|
Update.
2000-03-24 Andreas Jaeger <aj@suse.de>
* Makefile (postclean): Added soversions.i.
2000-03-24 Scott Bambrough <scottb@netwinder.org>
* sysdeps/arm/fpu/fpu_control.h: Define _FPU_MASK_IM, _FPU_MASK_ZM,
_FPU_MASK_OM, _FPU_MASK_UM, _FPU_MASK_PM, _FPU_MASK_DM, _FPU_DEFAULT,
and _FPU_IEEE. Change _FPU_RESERVED.
2000-03-24 Scott Bambrough <scottb@netwinder.org>
* sysdeps/unix/sysv/linux/arm/sys/ucontext.h: New file.
2000-03-24 Roland McGrath <roland@baalperazim.frob.com>
* sysdeps/posix/getaddrinfo.c: Include <net/if.h> for if_nametoindex.
(gaih_inet): Remove unused duplicate variable.
* inet/getnameinfo.c (getnameinfo): Use IFNAMSIZ, not MAXHOSTNAMELEN.
Don't use __libc_sa_len, which only exists for Linux. Just handle
AF_INET and AF_INET6 directly as well as AF_LOCAL, since those are the
only flavors supported by this function anyway.
2000-03-24 Geoff Clare <gwc@unisoft.com>
* stdlib/strfmon.c: corrected problems with missing signs and
missing or extra spaces; allow for sign strings longer than
one character; add padding to ensure positive and negative
formats are aligned when a left precision is used.
2000-03-26 Ulrich Drepper <drepper@redhat.com>
* stdlib/random_r.c (__setstate_r): Allow RNGs of type 4.
Patch by John Mizel <John.Mizel@msdw.com>.
2000-03-26 18:48:26 +00:00
|
|
|
break;
|
|
|
|
case AF_INET6:
|
|
|
|
if (addrlen < sizeof (struct sockaddr_in6))
|
2000-11-10 04:15:55 +00:00
|
|
|
return EAI_FAMILY;
|
2000-03-22 18:14:48 +00:00
|
|
|
break;
|
|
|
|
default:
|
2000-11-10 04:15:55 +00:00
|
|
|
return EAI_FAMILY;
|
2000-03-22 18:14:48 +00:00
|
|
|
}
|
1997-02-19 04:43:53 +00:00
|
|
|
|
2016-04-29 15:08:06 +00:00
|
|
|
struct scratch_buffer tmpbuf;
|
|
|
|
scratch_buffer_init (&tmpbuf);
|
1997-07-14 21:49:20 +00:00
|
|
|
|
2016-04-29 15:08:06 +00:00
|
|
|
if (host != NULL && hostlen > 0)
|
|
|
|
{
|
|
|
|
int result = gni_host (&tmpbuf, sa, addrlen, host, hostlen, flags);
|
|
|
|
if (result != 0)
|
|
|
|
{
|
|
|
|
scratch_buffer_free (&tmpbuf);
|
|
|
|
return result;
|
|
|
|
}
|
1997-07-14 21:49:20 +00:00
|
|
|
}
|
1997-02-19 04:43:53 +00:00
|
|
|
|
|
|
|
if (serv && (servlen > 0))
|
2016-04-29 15:08:06 +00:00
|
|
|
{
|
|
|
|
int result = gni_serv (&tmpbuf, sa, addrlen, serv, servlen, flags);
|
|
|
|
if (result != 0)
|
|
|
|
{
|
|
|
|
scratch_buffer_free (&tmpbuf);
|
|
|
|
return result;
|
|
|
|
}
|
1997-07-14 21:49:20 +00:00
|
|
|
}
|
|
|
|
|
2016-04-29 15:08:06 +00:00
|
|
|
scratch_buffer_free (&tmpbuf);
|
1997-02-19 04:43:53 +00:00
|
|
|
return 0;
|
1997-08-20 03:53:21 +00:00
|
|
|
}
|
2002-08-06 06:09:28 +00:00
|
|
|
libc_hidden_def (getnameinfo)
|