diff options
Diffstat (limited to 'libc/nss')
57 files changed, 324 insertions, 312 deletions
diff --git a/libc/nss/Makefile b/libc/nss/Makefile index b4a504c9b..a66c17100 100644 --- a/libc/nss/Makefile +++ b/libc/nss/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2014 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 diff --git a/libc/nss/Versions b/libc/nss/Versions index d13d57007..f8ababccc 100644 --- a/libc/nss/Versions +++ b/libc/nss/Versions @@ -40,6 +40,7 @@ libnss_files { _nss_files_endhostent; _nss_files_gethostbyaddr_r; _nss_files_gethostbyname2_r; + _nss_files_gethostbyname3_r; _nss_files_gethostbyname4_r; _nss_files_gethostbyname_r; _nss_files_gethostent_r; diff --git a/libc/nss/XXX-lookup.c b/libc/nss/XXX-lookup.c index 757ba1254..83ba6cf89 100644 --- a/libc/nss/XXX-lookup.c +++ b/libc/nss/XXX-lookup.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2013 Free Software Foundation, Inc. +/* Copyright (C) 1996-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/libc/nss/alias-lookup.c b/libc/nss/alias-lookup.c index 3047e2d64..c77185830 100644 --- a/libc/nss/alias-lookup.c +++ b/libc/nss/alias-lookup.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2013 Free Software Foundation, Inc. +/* Copyright (C) 1996-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/libc/nss/databases.def b/libc/nss/databases.def index fc88c141b..0d01581dd 100644 --- a/libc/nss/databases.def +++ b/libc/nss/databases.def @@ -1,5 +1,5 @@ /* List of all databases defined for the NSS in GNU C Library. - Copyright (C) 1996-2013 Free Software Foundation, Inc. + Copyright (C) 1996-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/libc/nss/db-Makefile b/libc/nss/db-Makefile index 26b277d88..d0009d0fa 100644 --- a/libc/nss/db-Makefile +++ b/libc/nss/db-Makefile @@ -1,5 +1,5 @@ # Makefile to (re-)generate db versions of system database files. -# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Copyright (C) 1996-2014 Free Software Foundation, Inc. # This file is part of the GNU C Library. # Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. # diff --git a/libc/nss/digits_dots.c b/libc/nss/digits_dots.c index e007ef47a..0c12bf1f3 100644 --- a/libc/nss/digits_dots.c +++ b/libc/nss/digits_dots.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997-2013 Free Software Foundation, Inc. +/* Copyright (C) 1997-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by H.J. Lu <hjl@gnu.ai.mit.edu>, 1997. diff --git a/libc/nss/ethers-lookup.c b/libc/nss/ethers-lookup.c index 351b90b76..46bd76d87 100644 --- a/libc/nss/ethers-lookup.c +++ b/libc/nss/ethers-lookup.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2013 Free Software Foundation, Inc. +/* Copyright (C) 1996-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/libc/nss/function.def b/libc/nss/function.def index b5599958f..4dfea8555 100644 --- a/libc/nss/function.def +++ b/libc/nss/function.def @@ -1,5 +1,5 @@ /* List of functions defined for static NSS in GNU C Library. - Copyright (C) 1996-2013 Free Software Foundation, Inc. + Copyright (C) 1996-2014 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 diff --git a/libc/nss/getXXbyYY.c b/libc/nss/getXXbyYY.c index e12129f4d..c9c64156a 100644 --- a/libc/nss/getXXbyYY.c +++ b/libc/nss/getXXbyYY.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2013 Free Software Foundation, Inc. +/* Copyright (C) 1996-2014 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 diff --git a/libc/nss/getXXbyYY_r.c b/libc/nss/getXXbyYY_r.c index 33e63d431..edb74db02 100644 --- a/libc/nss/getXXbyYY_r.c +++ b/libc/nss/getXXbyYY_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2013 Free Software Foundation, Inc. +/* Copyright (C) 1996-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/libc/nss/getXXent.c b/libc/nss/getXXent.c index f11adddca..609650e27 100644 --- a/libc/nss/getXXent.c +++ b/libc/nss/getXXent.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2013 Free Software Foundation, Inc. +/* Copyright (C) 1996-2014 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 diff --git a/libc/nss/getXXent_r.c b/libc/nss/getXXent_r.c index af0e6c76c..89acb0903 100644 --- a/libc/nss/getXXent_r.c +++ b/libc/nss/getXXent_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2013 Free Software Foundation, Inc. +/* Copyright (C) 1996-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/libc/nss/getent.c b/libc/nss/getent.c index c01552d36..75fb8c05f 100644 --- a/libc/nss/getent.c +++ b/libc/nss/getent.c @@ -1,4 +1,4 @@ -/* Copyright (c) 1998-2013 Free Software Foundation, Inc. +/* Copyright (c) 1998-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk <kukuk@suse.de>, 1998. @@ -88,7 +88,7 @@ print_version (FILE *stream, struct argp_state *state) Copyright (C) %s Free Software Foundation, Inc.\n\ This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ -"), "2013"); +"), "2014"); fprintf (stream, gettext ("Written by %s.\n"), "Thorsten Kukuk"); } @@ -796,8 +796,12 @@ services_keys (int number, char *key[]) if (proto != NULL) *proto++ = '\0'; - if (isdigit (key[i][0])) - serv = getservbyport (htons (atol (key[i])), proto); + char *endptr; + long port = strtol (key[i], &endptr, 10); + + if (isdigit (key[i][0]) && *endptr == '\0' + && 0 <= port && port <= 65535) + serv = getservbyport (htons (port), proto); else serv = getservbyname (key[i], proto); diff --git a/libc/nss/getnssent.c b/libc/nss/getnssent.c index 5c9de1914..ef05ccfbb 100644 --- a/libc/nss/getnssent.c +++ b/libc/nss/getnssent.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2013 Free Software Foundation, Inc. +/* Copyright (C) 2000-2014 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 diff --git a/libc/nss/getnssent_r.c b/libc/nss/getnssent_r.c index 7316a2aa1..32cfcf7c1 100644 --- a/libc/nss/getnssent_r.c +++ b/libc/nss/getnssent_r.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2013 Free Software Foundation, Inc. +/* Copyright (C) 2000-2014 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 diff --git a/libc/nss/grp-lookup.c b/libc/nss/grp-lookup.c index 64ca941c7..050919406 100644 --- a/libc/nss/grp-lookup.c +++ b/libc/nss/grp-lookup.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2013 Free Software Foundation, Inc. +/* Copyright (C) 1996-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/libc/nss/hosts-lookup.c b/libc/nss/hosts-lookup.c index 96dde63b8..230124209 100644 --- a/libc/nss/hosts-lookup.c +++ b/libc/nss/hosts-lookup.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2013 Free Software Foundation, Inc. +/* Copyright (C) 1996-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/libc/nss/key-lookup.c b/libc/nss/key-lookup.c index e64d78d11..1625ab8a4 100644 --- a/libc/nss/key-lookup.c +++ b/libc/nss/key-lookup.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2013 Free Software Foundation, Inc. +/* Copyright (C) 1996-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/libc/nss/makedb.c b/libc/nss/makedb.c index bfc908442..7c1a766bd 100644 --- a/libc/nss/makedb.c +++ b/libc/nss/makedb.c @@ -1,5 +1,5 @@ /* Create simple DB database from textual input. - Copyright (C) 1996-2013 Free Software Foundation, Inc. + Copyright (C) 1996-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -386,7 +386,7 @@ print_version (FILE *stream, struct argp_state *state) Copyright (C) %s Free Software Foundation, Inc.\n\ This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ -"), "2013"); +"), "2014"); fprintf (stream, gettext ("Written by %s.\n"), "Ulrich Drepper"); } diff --git a/libc/nss/netgrp-lookup.c b/libc/nss/netgrp-lookup.c index 2c2d36f21..b7937fdb8 100644 --- a/libc/nss/netgrp-lookup.c +++ b/libc/nss/netgrp-lookup.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2013 Free Software Foundation, Inc. +/* Copyright (C) 1996-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/libc/nss/network-lookup.c b/libc/nss/network-lookup.c index 5b64b6f63..80004c7f8 100644 --- a/libc/nss/network-lookup.c +++ b/libc/nss/network-lookup.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2013 Free Software Foundation, Inc. +/* Copyright (C) 1996-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/libc/nss/nss.h b/libc/nss/nss.h index 167a8d5f8..6896703c7 100644 --- a/libc/nss/nss.h +++ b/libc/nss/nss.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2013 Free Software Foundation, Inc. +/* Copyright (C) 1996-2014 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 diff --git a/libc/nss/nss_db/db-XXX.c b/libc/nss/nss_db/db-XXX.c index 40b5ce9be..89b1a126c 100644 --- a/libc/nss/nss_db/db-XXX.c +++ b/libc/nss/nss_db/db-XXX.c @@ -1,5 +1,5 @@ /* Common code for DB-based databases in nss_db module. - Copyright (C) 1996-2013 Free Software Foundation, Inc. + Copyright (C) 1996-2014 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 diff --git a/libc/nss/nss_db/db-init.c b/libc/nss/nss_db/db-init.c index 5135691c1..521c45266 100644 --- a/libc/nss/nss_db/db-init.c +++ b/libc/nss/nss_db/db-init.c @@ -1,5 +1,5 @@ /* Initialization in nss_db module. - Copyright (C) 2011-2013 Free Software Foundation, Inc. + Copyright (C) 2011-2014 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 diff --git a/libc/nss/nss_db/db-initgroups.c b/libc/nss/nss_db/db-initgroups.c index d0d73f0af..fb130f9dd 100644 --- a/libc/nss/nss_db/db-initgroups.c +++ b/libc/nss/nss_db/db-initgroups.c @@ -1,5 +1,5 @@ /* Initgroups handling in nss_db module. - Copyright (C) 2011-2013 Free Software Foundation, Inc. + Copyright (C) 2011-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gmail.com>. diff --git a/libc/nss/nss_db/db-netgrp.c b/libc/nss/nss_db/db-netgrp.c index 203529f4c..8c8fbd818 100644 --- a/libc/nss/nss_db/db-netgrp.c +++ b/libc/nss/nss_db/db-netgrp.c @@ -1,5 +1,5 @@ /* Netgroup file parser in nss_db modules. - Copyright (C) 1996-2013 Free Software Foundation, Inc. + Copyright (C) 1996-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/libc/nss/nss_db/db-open.c b/libc/nss/nss_db/db-open.c index 916ed7525..ea867a7a7 100644 --- a/libc/nss/nss_db/db-open.c +++ b/libc/nss/nss_db/db-open.c @@ -1,5 +1,5 @@ /* Common database routines for nss_db. - Copyright (C) 2000-2013 Free Software Foundation, Inc. + Copyright (C) 2000-2014 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 diff --git a/libc/nss/nss_db/nss_db.h b/libc/nss/nss_db/nss_db.h index 9c5dee63a..5c6b46b47 100644 --- a/libc/nss/nss_db/nss_db.h +++ b/libc/nss/nss_db/nss_db.h @@ -1,5 +1,5 @@ /* Common database open/close routines for nss_db. - Copyright (C) 1999-2013 Free Software Foundation, Inc. + Copyright (C) 1999-2014 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 diff --git a/libc/nss/nss_files/files-XXX.c b/libc/nss/nss_files/files-XXX.c index b62208c32..36242f9d4 100644 --- a/libc/nss/nss_files/files-XXX.c +++ b/libc/nss/nss_files/files-XXX.c @@ -1,5 +1,5 @@ /* Common code for file-based databases in nss_files module. - Copyright (C) 1996-2013 Free Software Foundation, Inc. + Copyright (C) 1996-2014 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 diff --git a/libc/nss/nss_files/files-alias.c b/libc/nss/nss_files/files-alias.c index 8e9cd60bb..53088f6a8 100644 --- a/libc/nss/nss_files/files-alias.c +++ b/libc/nss/nss_files/files-alias.c @@ -1,5 +1,5 @@ /* Mail alias file parser in nss_files module. - Copyright (C) 1996-2013 Free Software Foundation, Inc. + Copyright (C) 1996-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/libc/nss/nss_files/files-ethers.c b/libc/nss/nss_files/files-ethers.c index 467430720..3f9ec5744 100644 --- a/libc/nss/nss_files/files-ethers.c +++ b/libc/nss/nss_files/files-ethers.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2013 Free Software Foundation, Inc. +/* Copyright (C) 1996-2014 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 diff --git a/libc/nss/nss_files/files-grp.c b/libc/nss/nss_files/files-grp.c index 2b818714c..36068d446 100644 --- a/libc/nss/nss_files/files-grp.c +++ b/libc/nss/nss_files/files-grp.c @@ -1,5 +1,5 @@ /* Group file parser in nss_files module. - Copyright (C) 1996-2013 Free Software Foundation, Inc. + Copyright (C) 1996-2014 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 diff --git a/libc/nss/nss_files/files-have_o_cloexec.c b/libc/nss/nss_files/files-have_o_cloexec.c index e621b0a48..4a6cd173e 100644 --- a/libc/nss/nss_files/files-have_o_cloexec.c +++ b/libc/nss/nss_files/files-have_o_cloexec.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2013 Free Software Foundation, Inc. +/* Copyright (C) 2007-2014 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 diff --git a/libc/nss/nss_files/files-hosts.c b/libc/nss/nss_files/files-hosts.c index 6db253515..ab64eadab 100644 --- a/libc/nss/nss_files/files-hosts.c +++ b/libc/nss/nss_files/files-hosts.c @@ -1,5 +1,5 @@ /* Hosts file parser in nss_files module. - Copyright (C) 1996-2013 Free Software Foundation, Inc. + Copyright (C) 1996-2014 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 @@ -97,262 +97,12 @@ LINE_PARSER STRING_FIELD (result->h_name, isspace, 1); }) - - -#define HOST_DB_LOOKUP(name, keysize, keypattern, break_if_match, proto...) \ -enum nss_status \ -_nss_files_get##name##_r (proto, \ - struct STRUCTURE *result, char *buffer, \ - size_t buflen, int *errnop H_ERRNO_PROTO) \ -{ \ - uintptr_t pad = -(uintptr_t) buffer % __alignof__ (struct hostent_data); \ - buffer += pad; \ - buflen = buflen > pad ? buflen - pad : 0; \ - \ - __libc_lock_lock (lock); \ - \ - /* Reset file pointer to beginning or open file. */ \ - enum nss_status status = internal_setent (keep_stream); \ - \ - if (status == NSS_STATUS_SUCCESS) \ - { \ - /* Tell getent function that we have repositioned the file pointer. */ \ - last_use = getby; \ - \ - while ((status = internal_getent (result, buffer, buflen, errnop \ - H_ERRNO_ARG EXTRA_ARGS_VALUE)) \ - == NSS_STATUS_SUCCESS) \ - { break_if_match } \ - \ - if (status == NSS_STATUS_SUCCESS \ - && _res_hconf.flags & HCONF_FLAG_MULTI) \ - { \ - /* We have to get all host entries from the file. */ \ - size_t tmp_buflen = MIN (buflen, 4096); \ - char tmp_buffer_stack[tmp_buflen] \ - __attribute__ ((__aligned__ (__alignof__ (struct hostent_data))));\ - char *tmp_buffer = tmp_buffer_stack; \ - struct hostent tmp_result_buf; \ - int naddrs = 1; \ - int naliases = 0; \ - char *bufferend; \ - bool tmp_buffer_malloced = false; \ - \ - while (result->h_aliases[naliases] != NULL) \ - ++naliases; \ - \ - bufferend = (char *) &result->h_aliases[naliases + 1]; \ - \ - again: \ - while ((status = internal_getent (&tmp_result_buf, tmp_buffer, \ - tmp_buflen, errnop H_ERRNO_ARG \ - EXTRA_ARGS_VALUE)) \ - == NSS_STATUS_SUCCESS) \ - { \ - int matches = 1; \ - struct hostent *old_result = result; \ - result = &tmp_result_buf; \ - /* The following piece is a bit clumsy but we want to use the \ - `break_if_match' value. The optimizer should do its \ - job. */ \ - do \ - { \ - break_if_match \ - result = old_result; \ - } \ - while ((matches = 0)); \ - \ - if (matches) \ - { \ - /* We could be very clever and try to recycle a few bytes \ - in the buffer instead of generating new arrays. But \ - we are not doing this here since it's more work than \ - it's worth. Simply let the user provide a bit bigger \ - buffer. */ \ - char **new_h_addr_list; \ - char **new_h_aliases; \ - int newaliases = 0; \ - size_t newstrlen = 0; \ - int cnt; \ - \ - /* Count the new aliases and the length of the strings. */ \ - while (tmp_result_buf.h_aliases[newaliases] != NULL) \ - { \ - char *cp = tmp_result_buf.h_aliases[newaliases]; \ - ++newaliases; \ - newstrlen += strlen (cp) + 1; \ - } \ - /* If the real name is different add it also to the \ - aliases. This means that there is a duplication \ - in the alias list but this is really the user's \ - problem. */ \ - if (strcmp (old_result->h_name, \ - tmp_result_buf.h_name) != 0) \ - { \ - ++newaliases; \ - newstrlen += strlen (tmp_result_buf.h_name) + 1; \ - } \ - \ - /* Make sure bufferend is aligned. */ \ - assert ((bufferend - (char *) 0) % sizeof (char *) == 0); \ - \ - /* Now we can check whether the buffer is large enough. \ - 16 is the maximal size of the IP address. */ \ - if (bufferend + 16 + (naddrs + 2) * sizeof (char *) \ - + roundup (newstrlen, sizeof (char *)) \ - + (naliases + newaliases + 1) * sizeof (char *) \ - >= buffer + buflen) \ - { \ - *errnop = ERANGE; \ - *herrnop = NETDB_INTERNAL; \ - status = NSS_STATUS_TRYAGAIN; \ - goto out; \ - } \ - \ - new_h_addr_list = \ - (char **) (bufferend \ - + roundup (newstrlen, sizeof (char *)) \ - + 16); \ - new_h_aliases = \ - (char **) ((char *) new_h_addr_list \ - + (naddrs + 2) * sizeof (char *)); \ - \ - /* Copy the old data in the new arrays. */ \ - for (cnt = 0; cnt < naddrs; ++cnt) \ - new_h_addr_list[cnt] = old_result->h_addr_list[cnt]; \ - \ - for (cnt = 0; cnt < naliases; ++cnt) \ - new_h_aliases[cnt] = old_result->h_aliases[cnt]; \ - \ - /* Store the new strings. */ \ - cnt = 0; \ - while (tmp_result_buf.h_aliases[cnt] != NULL) \ - { \ - new_h_aliases[naliases++] = bufferend; \ - bufferend = (__stpcpy (bufferend, \ - tmp_result_buf.h_aliases[cnt]) \ - + 1); \ - ++cnt; \ - } \ - \ - if (cnt < newaliases) \ - { \ - new_h_aliases[naliases++] = bufferend; \ - bufferend = __stpcpy (bufferend, \ - tmp_result_buf.h_name) + 1; \ - } \ - \ - /* Final NULL pointer. */ \ - new_h_aliases[naliases] = NULL; \ - \ - /* Round up the buffer end address. */ \ - bufferend += (sizeof (char *) \ - - ((bufferend - (char *) 0) \ - % sizeof (char *))) % sizeof (char *); \ - \ - /* Now the new address. */ \ - new_h_addr_list[naddrs++] = \ - memcpy (bufferend, tmp_result_buf.h_addr, \ - tmp_result_buf.h_length); \ - \ - /* Also here a final NULL pointer. */ \ - new_h_addr_list[naddrs] = NULL; \ - \ - /* Store the new array pointers. */ \ - old_result->h_aliases = new_h_aliases; \ - old_result->h_addr_list = new_h_addr_list; \ - \ - /* Compute the new buffer end. */ \ - bufferend = (char *) &new_h_aliases[naliases + 1]; \ - assert (bufferend <= buffer + buflen); \ - \ - result = old_result; \ - } \ - } \ - \ - if (status == NSS_STATUS_TRYAGAIN) \ - { \ - size_t newsize = 2 * tmp_buflen; \ - if (tmp_buffer_malloced) \ - { \ - char *newp = realloc (tmp_buffer, newsize); \ - if (newp != NULL) \ - { \ - assert ((((uintptr_t) newp) \ - & (__alignof__ (struct hostent_data) - 1)) \ - == 0); \ - tmp_buffer = newp; \ - tmp_buflen = newsize; \ - goto again; \ - } \ - } \ - else if (!__libc_use_alloca (buflen + newsize)) \ - { \ - tmp_buffer = malloc (newsize); \ - if (tmp_buffer != NULL) \ - { \ - assert ((((uintptr_t) tmp_buffer) \ - & (__alignof__ (struct hostent_data) - 1)) \ - == 0); \ - tmp_buffer_malloced = true; \ - tmp_buflen = newsize; \ - goto again; \ - } \ - } \ - else \ - { \ - tmp_buffer \ - = extend_alloca (tmp_buffer, tmp_buflen, \ - newsize \ - + __alignof__ (struct hostent_data)); \ - tmp_buffer = (char *) (((uintptr_t) tmp_buffer \ - + __alignof__ (struct hostent_data) \ - - 1) \ - & ~(__alignof__ (struct hostent_data)\ - - 1)); \ - goto again; \ - } \ - } \ - else \ - status = NSS_STATUS_SUCCESS; \ - out: \ - if (tmp_buffer_malloced) \ - free (tmp_buffer); \ - } \ - \ - \ - if (! keep_stream) \ - internal_endent (); \ - } \ - \ - __libc_lock_unlock (lock); \ - \ - return status; \ -} - - #define EXTRA_ARGS_VALUE \ , ((_res.options & RES_USE_INET6) ? AF_INET6 : AF_INET), \ ((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0) #include "files-XXX.c" -HOST_DB_LOOKUP (hostbyname, ,, - { - LOOKUP_NAME_CASE (h_name, h_aliases) - }, const char *name) #undef EXTRA_ARGS_VALUE - -/* XXX Is using _res to determine whether we want to convert IPv4 addresses - to IPv6 addresses really the right thing to do? */ -#define EXTRA_ARGS_VALUE \ - , af, ((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0) -HOST_DB_LOOKUP (hostbyname2, ,, - { - LOOKUP_NAME_CASE (h_name, h_aliases) - }, const char *name, int af) -#undef EXTRA_ARGS_VALUE - - /* We only need to consider IPv4 mapped addresses if the input to the gethostbyaddr() function is an IPv6 address. */ #define EXTRA_ARGS_VALUE \ @@ -365,6 +115,263 @@ DB_LOOKUP (hostbyaddr, ,,, }, const void *addr, socklen_t len, int af) #undef EXTRA_ARGS_VALUE +enum nss_status +_nss_files_gethostbyname3_r (const char *name, int af, struct hostent *result, + char *buffer, size_t buflen, int *errnop, + int *herrnop, int32_t *ttlp, char **canonp) +{ + uintptr_t pad = -(uintptr_t) buffer % __alignof__ (struct hostent_data); + buffer += pad; + buflen = buflen > pad ? buflen - pad : 0; + + __libc_lock_lock (lock); + + /* Reset file pointer to beginning or open file. */ + enum nss_status status = internal_setent (keep_stream); + + if (status == NSS_STATUS_SUCCESS) + { + /* XXX Is using _res to determine whether we want to convert IPv4 + addresses to IPv6 addresses really the right thing to do? */ + int flags = ((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0); + + /* Tell getent function that we have repositioned the file pointer. */ + last_use = getby; + + while ((status = internal_getent (result, buffer, buflen, errnop, + herrnop, af, flags)) + == NSS_STATUS_SUCCESS) + { + LOOKUP_NAME_CASE (h_name, h_aliases) + } + + if (status == NSS_STATUS_SUCCESS + && _res_hconf.flags & HCONF_FLAG_MULTI) + { + /* We have to get all host entries from the file. */ + size_t tmp_buflen = MIN (buflen, 4096); + char tmp_buffer_stack[tmp_buflen] + __attribute__ ((__aligned__ (__alignof__ (struct hostent_data)))); + char *tmp_buffer = tmp_buffer_stack; + struct hostent tmp_result_buf; + int naddrs = 1; + int naliases = 0; + char *bufferend; + bool tmp_buffer_malloced = false; + + while (result->h_aliases[naliases] != NULL) + ++naliases; + + bufferend = (char *) &result->h_aliases[naliases + 1]; + + again: + while ((status = internal_getent (&tmp_result_buf, tmp_buffer, + tmp_buflen, errnop, herrnop, af, + flags)) + == NSS_STATUS_SUCCESS) + { + int matches = 1; + struct hostent *old_result = result; + result = &tmp_result_buf; + /* The following piece is a bit clumsy but we want to use the + `LOOKUP_NAME_CASE' value. The optimizer should do its + job. */ + do + { + LOOKUP_NAME_CASE (h_name, h_aliases) + result = old_result; + } + while ((matches = 0)); + + if (matches) + { + /* We could be very clever and try to recycle a few bytes + in the buffer instead of generating new arrays. But + we are not doing this here since it's more work than + it's worth. Simply let the user provide a bit bigger + buffer. */ + char **new_h_addr_list; + char **new_h_aliases; + int newaliases = 0; + size_t newstrlen = 0; + int cnt; + + /* Count the new aliases and the length of the strings. */ + while (tmp_result_buf.h_aliases[newaliases] != NULL) + { + char *cp = tmp_result_buf.h_aliases[newaliases]; + ++newaliases; + newstrlen += strlen (cp) + 1; + } + /* If the real name is different add it also to the + aliases. This means that there is a duplication + in the alias list but this is really the user's + problem. */ + if (strcmp (old_result->h_name, + tmp_result_buf.h_name) != 0) + { + ++newaliases; + newstrlen += strlen (tmp_result_buf.h_name) + 1; + } + + /* Make sure bufferend is aligned. */ + assert ((bufferend - (char *) 0) % sizeof (char *) == 0); + + /* Now we can check whether the buffer is large enough. + 16 is the maximal size of the IP address. */ + if (bufferend + 16 + (naddrs + 2) * sizeof (char *) + + roundup (newstrlen, sizeof (char *)) + + (naliases + newaliases + 1) * sizeof (char *) + >= buffer + buflen) + { + *errnop = ERANGE; + *herrnop = NETDB_INTERNAL; + status = NSS_STATUS_TRYAGAIN; + goto out; + } + + new_h_addr_list = + (char **) (bufferend + + roundup (newstrlen, sizeof (char *)) + + 16); + new_h_aliases = + (char **) ((char *) new_h_addr_list + + (naddrs + 2) * sizeof (char *)); + + /* Copy the old data in the new arrays. */ + for (cnt = 0; cnt < naddrs; ++cnt) + new_h_addr_list[cnt] = old_result->h_addr_list[cnt]; + + for (cnt = 0; cnt < naliases; ++cnt) + new_h_aliases[cnt] = old_result->h_aliases[cnt]; + + /* Store the new strings. */ + cnt = 0; + while (tmp_result_buf.h_aliases[cnt] != NULL) + { + new_h_aliases[naliases++] = bufferend; + bufferend = (__stpcpy (bufferend, + tmp_result_buf.h_aliases[cnt]) + + 1); + ++cnt; + } + + if (cnt < newaliases) + { + new_h_aliases[naliases++] = bufferend; + bufferend = __stpcpy (bufferend, + tmp_result_buf.h_name) + 1; + } + + /* Final NULL pointer. */ + new_h_aliases[naliases] = NULL; + + /* Round up the buffer end address. */ + bufferend += (sizeof (char *) + - ((bufferend - (char *) 0) + % sizeof (char *))) % sizeof (char *); + + /* Now the new address. */ + new_h_addr_list[naddrs++] = + memcpy (bufferend, tmp_result_buf.h_addr, + tmp_result_buf.h_length); + + /* Also here a final NULL pointer. */ + new_h_addr_list[naddrs] = NULL; + + /* Store the new array pointers. */ + old_result->h_aliases = new_h_aliases; + old_result->h_addr_list = new_h_addr_list; + + /* Compute the new buffer end. */ + bufferend = (char *) &new_h_aliases[naliases + 1]; + assert (bufferend <= buffer + buflen); + + result = old_result; + } + } + + if (status == NSS_STATUS_TRYAGAIN) + { + size_t newsize = 2 * tmp_buflen; + if (tmp_buffer_malloced) + { + char *newp = realloc (tmp_buffer, newsize); + if (newp != NULL) + { + assert ((((uintptr_t) newp) + & (__alignof__ (struct hostent_data) - 1)) + == 0); + tmp_buffer = newp; + tmp_buflen = newsize; + goto again; + } + } + else if (!__libc_use_alloca (buflen + newsize)) + { + tmp_buffer = malloc (newsize); + if (tmp_buffer != NULL) + { + assert ((((uintptr_t) tmp_buffer) + & (__alignof__ (struct hostent_data) - 1)) + == 0); + tmp_buffer_malloced = true; + tmp_buflen = newsize; + goto again; + } + } + else + { + tmp_buffer + = extend_alloca (tmp_buffer, tmp_buflen, + newsize + + __alignof__ (struct hostent_data)); + tmp_buffer = (char *) (((uintptr_t) tmp_buffer + + __alignof__ (struct hostent_data) + - 1) + & ~(__alignof__ (struct hostent_data) + - 1)); + goto again; + } + } + else + status = NSS_STATUS_SUCCESS; + out: + if (tmp_buffer_malloced) + free (tmp_buffer); + } + + if (! keep_stream) + internal_endent (); + } + + if (canonp && status == NSS_STATUS_SUCCESS) + *canonp = result->h_name; + + __libc_lock_unlock (lock); + + return status; +} + +enum nss_status +_nss_files_gethostbyname_r (const char *name, struct hostent *result, + char *buffer, size_t buflen, int *errnop, + int *herrnop) +{ + int af = ((_res.options & RES_USE_INET6) ? AF_INET6 : AF_INET); + + return _nss_files_gethostbyname3_r (name, af, result, buffer, buflen, + errnop, herrnop, NULL, NULL); +} + +enum nss_status +_nss_files_gethostbyname2_r (const char *name, int af, struct hostent *result, + char *buffer, size_t buflen, int *errnop, + int *herrnop) +{ + return _nss_files_gethostbyname3_r (name, af, result, buffer, buflen, + errnop, herrnop, NULL, NULL); +} enum nss_status _nss_files_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, @@ -392,8 +399,8 @@ _nss_files_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, buflen = buflen > pad ? buflen - pad : 0; struct hostent result; - status = internal_getent (&result, buffer, buflen, errnop - H_ERRNO_ARG, AF_UNSPEC, 0); + status = internal_getent (&result, buffer, buflen, errnop, + herrnop, AF_UNSPEC, 0); if (status != NSS_STATUS_SUCCESS) break; diff --git a/libc/nss/nss_files/files-init.c b/libc/nss/nss_files/files-init.c index a34c49a99..346395c6f 100644 --- a/libc/nss/nss_files/files-init.c +++ b/libc/nss/nss_files/files-init.c @@ -1,5 +1,5 @@ /* Initialization in nss_files module. - Copyright (C) 2011-2013 Free Software Foundation, Inc. + Copyright (C) 2011-2014 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 diff --git a/libc/nss/nss_files/files-initgroups.c b/libc/nss/nss_files/files-initgroups.c index a547b0a38..9249c2493 100644 --- a/libc/nss/nss_files/files-initgroups.c +++ b/libc/nss/nss_files/files-initgroups.c @@ -1,5 +1,5 @@ /* Initgroups handling in nss_files module. - Copyright (C) 2011-2013 Free Software Foundation, Inc. + Copyright (C) 2011-2014 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 diff --git a/libc/nss/nss_files/files-key.c b/libc/nss/nss_files/files-key.c index 4b2cf24ea..561f79b66 100644 --- a/libc/nss/nss_files/files-key.c +++ b/libc/nss/nss_files/files-key.c @@ -1,5 +1,5 @@ /* Public key file parser in nss_files module. - Copyright (C) 1996-2013 Free Software Foundation, Inc. + Copyright (C) 1996-2014 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 diff --git a/libc/nss/nss_files/files-netgrp.c b/libc/nss/nss_files/files-netgrp.c index 9cc678b38..339f704c9 100644 --- a/libc/nss/nss_files/files-netgrp.c +++ b/libc/nss/nss_files/files-netgrp.c @@ -1,5 +1,5 @@ /* Netgroup file parser in nss_files modules. - Copyright (C) 1996-2013 Free Software Foundation, Inc. + Copyright (C) 1996-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/libc/nss/nss_files/files-network.c b/libc/nss/nss_files/files-network.c index f18e9e174..c0ac7bbd0 100644 --- a/libc/nss/nss_files/files-network.c +++ b/libc/nss/nss_files/files-network.c @@ -1,5 +1,5 @@ /* Networks file parser in nss_files module. - Copyright (C) 1996-2013 Free Software Foundation, Inc. + Copyright (C) 1996-2014 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 diff --git a/libc/nss/nss_files/files-parse.c b/libc/nss/nss_files/files-parse.c index 91f32da8b..1da1a6f35 100644 --- a/libc/nss/nss_files/files-parse.c +++ b/libc/nss/nss_files/files-parse.c @@ -1,5 +1,5 @@ /* Common code for file-based database parsers in nss_files module. - Copyright (C) 1996-2013 Free Software Foundation, Inc. + Copyright (C) 1996-2014 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 diff --git a/libc/nss/nss_files/files-proto.c b/libc/nss/nss_files/files-proto.c index 9c5551539..fded57dc2 100644 --- a/libc/nss/nss_files/files-proto.c +++ b/libc/nss/nss_files/files-proto.c @@ -1,5 +1,5 @@ /* Protocols file parser in nss_files module. - Copyright (C) 1996-2013 Free Software Foundation, Inc. + Copyright (C) 1996-2014 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 diff --git a/libc/nss/nss_files/files-pwd.c b/libc/nss/nss_files/files-pwd.c index 3b31817a7..5d3c46be8 100644 --- a/libc/nss/nss_files/files-pwd.c +++ b/libc/nss/nss_files/files-pwd.c @@ -1,5 +1,5 @@ /* User file parser in nss_files module. - Copyright (C) 1996-2013 Free Software Foundation, Inc. + Copyright (C) 1996-2014 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 diff --git a/libc/nss/nss_files/files-rpc.c b/libc/nss/nss_files/files-rpc.c index f42184f64..1cb9b78bd 100644 --- a/libc/nss/nss_files/files-rpc.c +++ b/libc/nss/nss_files/files-rpc.c @@ -1,5 +1,5 @@ /* SunRPC program number file parser in nss_files module. - Copyright (C) 1996-2013 Free Software Foundation, Inc. + Copyright (C) 1996-2014 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 diff --git a/libc/nss/nss_files/files-service.c b/libc/nss/nss_files/files-service.c index c0f9dbacd..2401cb085 100644 --- a/libc/nss/nss_files/files-service.c +++ b/libc/nss/nss_files/files-service.c @@ -1,5 +1,5 @@ /* Services file parser in nss_files module. - Copyright (C) 1996-2013 Free Software Foundation, Inc. + Copyright (C) 1996-2014 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 diff --git a/libc/nss/nss_files/files-sgrp.c b/libc/nss/nss_files/files-sgrp.c index dcbf18a0a..2b2159a4e 100644 --- a/libc/nss/nss_files/files-sgrp.c +++ b/libc/nss/nss_files/files-sgrp.c @@ -1,5 +1,5 @@ /* User file parser in nss_files module. - Copyright (C) 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2009-2014 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 diff --git a/libc/nss/nss_files/files-spwd.c b/libc/nss/nss_files/files-spwd.c index dfa0fa25e..b7e2dddb4 100644 --- a/libc/nss/nss_files/files-spwd.c +++ b/libc/nss/nss_files/files-spwd.c @@ -1,5 +1,5 @@ /* User file parser in nss_files module. - Copyright (C) 1996-2013 Free Software Foundation, Inc. + Copyright (C) 1996-2014 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 diff --git a/libc/nss/nsswitch.c b/libc/nss/nsswitch.c index 65b1d734f..79fab46f5 100644 --- a/libc/nss/nsswitch.c +++ b/libc/nss/nsswitch.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2013 Free Software Foundation, Inc. +/* Copyright (C) 1996-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/libc/nss/nsswitch.h b/libc/nss/nsswitch.h index 1d9783c06..e3c767ca4 100644 --- a/libc/nss/nsswitch.h +++ b/libc/nss/nsswitch.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2013 Free Software Foundation, Inc. +/* Copyright (C) 1996-2014 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 diff --git a/libc/nss/proto-lookup.c b/libc/nss/proto-lookup.c index 0a3bb1bf8..8ccc9da2f 100644 --- a/libc/nss/proto-lookup.c +++ b/libc/nss/proto-lookup.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2013 Free Software Foundation, Inc. +/* Copyright (C) 1996-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/libc/nss/pwd-lookup.c b/libc/nss/pwd-lookup.c index a72603d55..b2c1bc741 100644 --- a/libc/nss/pwd-lookup.c +++ b/libc/nss/pwd-lookup.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2013 Free Software Foundation, Inc. +/* Copyright (C) 1996-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/libc/nss/rpc-lookup.c b/libc/nss/rpc-lookup.c index b22d5c720..6ef66fcf2 100644 --- a/libc/nss/rpc-lookup.c +++ b/libc/nss/rpc-lookup.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2013 Free Software Foundation, Inc. +/* Copyright (C) 1996-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/libc/nss/service-lookup.c b/libc/nss/service-lookup.c index c1da2d877..7f7dcdfb4 100644 --- a/libc/nss/service-lookup.c +++ b/libc/nss/service-lookup.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2013 Free Software Foundation, Inc. +/* Copyright (C) 1996-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/libc/nss/sgrp-lookup.c b/libc/nss/sgrp-lookup.c index 6d079a4b6..ee1782de1 100644 --- a/libc/nss/sgrp-lookup.c +++ b/libc/nss/sgrp-lookup.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2013 Free Software Foundation, Inc. +/* Copyright (C) 2009-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2009. diff --git a/libc/nss/spwd-lookup.c b/libc/nss/spwd-lookup.c index 902ede074..aba1a4cc0 100644 --- a/libc/nss/spwd-lookup.c +++ b/libc/nss/spwd-lookup.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2013 Free Software Foundation, Inc. +/* Copyright (C) 1996-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. diff --git a/libc/nss/test-digits-dots.c b/libc/nss/test-digits-dots.c index 1efa3449a..db6fdb7b3 100644 --- a/libc/nss/test-digits-dots.c +++ b/libc/nss/test-digits-dots.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2013 Free Software Foundation, Inc. +/* Copyright (C) 2013-2014 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 diff --git a/libc/nss/test-netdb.c b/libc/nss/test-netdb.c index 40b2f604a..1620b5b17 100644 --- a/libc/nss/test-netdb.c +++ b/libc/nss/test-netdb.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2013 Free Software Foundation, Inc. +/* Copyright (C) 1998-2014 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Andreas Jaeger <aj@suse.de>, 1998. |