about summary refs log tree commit diff
path: root/resolv
Commit message (Collapse)AuthorAgeFilesLines
* Update copyright dates with scripts/update-copyrightsJoseph Myers2023-01-0695-95/+95
|
* Avoid use of atoi in some places in libcJoseph Myers2022-12-191-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is split out of <https://sourceware.org/pipermail/libc-alpha/2022-December/144122.html>. atoi has undefined behavior on out-of-range input, which makes it problematic to use anywhere in glibc that might be processing input out-of-range for atoi but not specified to produce undefined behavior for the function calling atoi. Change some uses of atoi to call strtol instead; this avoids the undefined behavior, though there is no guarantee that the overflow handling of strtol is really right in those places either. This also serves to avoid localplt test failures given an installed header redirection for strtol (which means that the call from the inline atoi implementation doesn't end up at a hidden alias from libc_hidden_proto). Certainly, the use of atoi is questionable in argp-help.c (shared with gnulib, so shouldn't depend on glibc implementation details, and processing user-provided input), and maybe also in argp-parse.c (I'm not sure what that code in argp-parse.c is meant to be used for). I also changed inet/rexec.c and resolv/res_init.c similarly to use strtol to avoid such localplt failures, although given those files (in those versions) are only used in glibc it's not problematic for them to rely on the specific behavior of glibc's atoi on out-of-range input (in the absence of compiler optimizations based on the undefined behavior) in the same way it's problematic for gnulib code to do so. There may be other uses of atoi (or atol or atoll), in any of glibc's installed code, for which it would also be appropriate to avoid the undefined behavior on out-of-range input; this patch only fixes the specific cases needed to avoid localplt failures. Tested for x86_64.
* configure: Use -Wno-ignored-attributes if compiler warns about multiple aliasesAdhemerval Zanella2022-11-011-0/+1
| | | | | | | | | clang emits an warning when a double alias redirection is used, to warn the the original symbol will be used even when weak definition is overridden. However, this is a common pattern for weak_alias, where multiple alias are set to same symbol. Reviewed-by: Fangrui Song <maskray@google.com>
* resolv: Fix building tst-resolv-invalid-cname for earlier C standardsFlorian Weimer2022-08-301-1/+1
| | | | | | | | | | | | This fixes this compiler error: tst-resolv-invalid-cname.c: In function ‘test_mode_to_string’: tst-resolv-invalid-cname.c:164:10: error: label at end of compound statement case test_mode_num: ^~~~~~~~~~~~~ Fixes commit 9caf782276ecea4bc86fc94fbb52779736f3106d ("resolv: Add new tst-resolv-invalid-cname").
* nss_dns: Rewrite _nss_dns_gethostbyname4_r using current interfacesFlorian Weimer2022-08-301-281/+162
| | | | | | | | Introduce struct alloc_buffer to this function, and use it and struct ns_rr_cursor in gaih_getanswer_slice. Adjust gaih_getanswer and gaih_getanswer_noaaaa accordingly. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* resolv: Add new tst-resolv-invalid-cnameFlorian Weimer2022-08-302-0/+409
| | | | | | | This test checks resolution through CNAME chains that do not contain host names (bug 12154). Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* nss_dns: In gaih_getanswer_slice, skip strange aliases (bug 12154)Florian Weimer2022-08-301-4/+4
| | | | | | | | | | If the name is not a host name, skip adding it to the result, instead of reporting query failure. This fixes bug 12154 for getaddrinfo. This commit still keeps the old parsing code, and only adjusts when a host name is copied. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* nss_dns: Rewrite getanswer_r to match getanswer_ptr (bug 12154, bug 29305)Florian Weimer2022-08-301-298/+180
| | | | | | | | | | | Allocate the pointer arrays only at the end, when their sizes are known. This addresses bug 29305. Skip over invalid names instead of failing lookups. This partially fixes bug 12154 (for gethostbyname, fixing getaddrinfo requires different changes). Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* nss_dns: Remove remnants of IPv6 address mappingFlorian Weimer2022-08-304-201/+9
| | | | | | | res_use_inet6 always returns false since commit 3f8b44be0a658266adff5 ("resolv: Remove support for RES_USE_INET6 and the inet6 option"). Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* nss_dns: Rewrite _nss_dns_gethostbyaddr2_r and getanswer_ptrFlorian Weimer2022-08-301-303/+102
| | | | | | | | The simplification takes advantage of the split from getanswer_r. It fixes various aliases issues, and optimizes NSS buffer usage. The new DNS packet parsing helpers are used, too. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* nss_dns: Split getanswer_ptr from getanswer_rFlorian Weimer2022-08-301-52/+268
| | | | | | | | | | And expand the use of name_ok and qtype in getanswer_ptr (the former also in getanswer_r). After further cleanups, not much code will be shared between the two functions. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* resolv: Add DNS packet parsing helpers geared towards wire formatFlorian Weimer2022-08-304-0/+369
| | | | | | | | | | | | | | | | | | | | The public parser functions around the ns_rr record type produce textual domain names, but usually, this is not what we need while parsing DNS packets within glibc. This commit adds two new helper functions, __ns_rr_cursor_init and __ns_rr_cursor_next, for writing packet parsers, and struct ns_rr_cursor, struct ns_rr_wire as supporting types. In theory, it is possible to avoid copying the owner name into the rname field in __ns_rr_cursor_next, but this would need more functions that work on compressed names. Eventually, __res_context_send could be enhanced to preserve the result of the packet parsing that is necessary for matching the incoming UDP packets, so that this works does not have to be done twice. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* resolv: Add internal __ns_name_length_uncompressed functionFlorian Weimer2022-08-303-0/+212
| | | | | | | This function is useful for checking that the question name is uncompressed (as it should be). Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* resolv: Add the __ns_samebinaryname functionFlorian Weimer2022-08-303-0/+122
| | | | | | | | During packet parsing, only the binary name is available. If the name equality check is performed before conversion to text, we can sometimes skip the last step. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* resolv: Add internal __res_binary_hnok functionFlorian Weimer2022-08-301-5/+9
| | | | | | | | During package parsing, only the binary representation is available, and it is convenient to check that directly for conformance with host name requirements. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* resolv: Add tst-resolv-aliasesFlorian Weimer2022-08-302-0/+256
| | | | Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* resolv: Add tst-resolv-byaddr for testing reverse lookupFlorian Weimer2022-08-303-0/+360
| | | | Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* resolv/tst-resolv-noaaaa: Support building for older C standardsFlorian Weimer2022-06-241-5/+9
| | | | | | | | | | | | This avoids a compilation error: tst-resolv-noaaaa.c: In function 'response': tst-resolv-noaaaa.c:74:11: error: a label can only be part of a statement and a declaration is not a statement char ipv4[4] = {192, 0, 2, i + 1}; ^~~~ tst-resolv-noaaaa.c:79:11: error: a label can only be part of a statement and a declaration is not a statement char *name = xasprintf ("ptr-%d", i); ^~~~
* resolv: Implement no-aaaa stub resolver optionFlorian Weimer2022-06-2411-12/+773
| | | | Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Replace {u}int_fast{16|32} with {u}int32_tNoah Goldstein2022-04-131-1/+1
| | | | | | | | | On 32-bit machines this has no affect. On 64-bit machines {u}int_fast{16|32} are set as {u}int64_t which is often not ideal. Particularly x86_64 this change both saves code size and may save instruction cost. Full xcheck passes on x86_64.
* resolv: Initialize loop variable on tst-resolv-trailingAdhemerval Zanella2022-03-311-1/+1
| | | | Checked on x86_64-linux-gnu and i686-linux-gnu.
* resolv: Fix unaligned accesses to fields in HEADER structJohn David Anglin2022-03-223-14/+21
| | | | | | | | | | | | | | | | The structure HEADER is normally aligned to a word boundary but sometimes it needs to be accessed when aligned on a byte boundary. This change defines a new typedef, UHEADER, with alignment 1. It is used to ensure the fields are accessed with byte loads and stores when necessary. V4: Change to res_mkquery.c deleted. Small whitespace fix. V5: Move UHEADER typedef to resolv/resolv-internal.h. Replace all HEADER usage with UHEADER in resolv/res_send.c. Signed-off-by: John David Anglin <dave.anglin@bell.net> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* resolv: Fix tst-resolv tests for 2.35 ABIs and laterStafford Horne2022-02-241-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | The commit 737e873b30 ("resolv: Do not build libanl.so for ABIs starting at 2.35") disabled building libanl for ports supporting only 2.35 and later like OpenRISC. However, the if statement was not updated quite correctly and the change ends up disabling many tst-resolv* tests. This was not supposed to be done and it causes test dependency errors like: make: Entering directory 'gnu-home/glibc/resolv' make: *** No rule to make target 'gnu-home/build-glibc/resolv/tst-resolv-res_ninit.out', needed by 'gnu-home/build-glibc/resolv/mtrace-tst-resolv-res_ninit.out'. Stop. make: Leaving directory 'gnu-home/glibc/resolv' This patch move the extra-libs += libanl definition and condition down to be closer to other libanl definitions. The $(have-GLIBC_2.34) condition now includes libanl-routines and libanl-shared-only-routines as well. Also, I have added a comment to endif of $(have-thread-library) to help show the bondary of the have-thread-library definitions. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Update copyright dates with scripts/update-copyrightsPaul Eggert2022-01-0182-82/+82
| | | | | | | | | | | | | | | | | | | | | | | I used these shell commands: ../glibc/scripts/update-copyrights $PWD/../gnulib/build-aux/update-copyright (cd ../glibc && git commit -am"[this commit message]") and then ignored the output, which consisted lines saying "FOO: warning: copyright statement not found" for each of 7061 files FOO. I then removed trailing white space from math/tgmath.h, support/tst-support-open-dev-null-range.c, and sysdeps/x86_64/multiarch/strlen-vec.S, to work around the following obscure pre-commit check failure diagnostics from Savannah. I don't know why I run into these diagnostics whereas others evidently do not. remote: *** 912-#endif remote: *** 913: remote: *** 914- remote: *** error: lines with trailing whitespace found ... remote: *** error: sysdeps/unix/sysv/linux/statx_cp.c: trailing lines
* resolv: Do not install libanl.so symbolic linkAdhemerval Zanella2021-12-301-0/+5
|
* resolv: Do not build libanl.so for ABIs starting at 2.35Adhemerval Zanella2021-12-301-1/+5
|
* resolv: Avoid GCC 12 false positive warning [BZ #28439].Martin Sebor2021-10-111-1/+3
| | | | | | Replace a call to sprintf with an equivalent pair of stpcpy/strcpy calls to avoid a GCC 12 -Wformat-overflow false positive due to recent optimizer improvements.
* resolv: make res_randomid use random_bits()Cristian Rodríguez2021-10-081-1/+2
| | | | | | | It is at least "more random" than 0xffff & __getpid (); Signed-off-by: Cristian Rodríguez <crrodriguez@opensuse.org> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Remove "Contributed by" linesSiddhesh Poyarekar2021-09-0312-12/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | We stopped adding "Contributed by" or similar lines in sources in 2012 in favour of git logs and keeping the Contributors section of the glibc manual up to date. Removing these lines makes the license header a bit more consistent across files and also removes the possibility of error in attribution when license blocks or files are copied across since the contributed-by lines don't actually reflect reality in those cases. Move all "Contributed by" and similar lines (Written by, Test by, etc.) into a new file CONTRIBUTED-BY to retain record of these contributions. These contributors are also mentioned in manual/contrib.texi, so we just maintain this additional record as a courtesy to the earlier developers. The following scripts were used to filter a list of files to edit in place and to clean up the CONTRIBUTED-BY file respectively. These were not added to the glibc sources because they're not expected to be of any use in future given that this is a one time task: https://gist.github.com/siddhesh/b5ecac94eabfd72ed2916d6d8157e7dc https://gist.github.com/siddhesh/15ea1f5e435ace9774f485030695ee02 Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Move malloc hooks into a compat DSOSiddhesh Poyarekar2021-07-221-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | Remove all malloc hook uses from core malloc functions and move it into a new library libc_malloc_debug.so. With this, the hooks now no longer have any effect on the core library. libc_malloc_debug.so is a malloc interposer that needs to be preloaded to get hooks functionality back so that the debugging features that depend on the hooks, i.e. malloc-check, mcheck and mtrace work again. Without the preloaded DSO these debugging features will be nops. These features will be ported away from hooks in subsequent patches. Similarly, legacy applications that need hooks functionality need to preload libc_malloc_debug.so. The symbols exported by libc_malloc_debug.so are maintained at exactly the same version as libc.so. Finally, static binaries will no longer be able to use malloc debugging features since they cannot preload the debugging DSO. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* resolv: Do not install libnss_dns.a, libnss_dns.soFlorian Weimer2021-07-201-0/+8
| | | | Fixes commit e1fcf21474c5b522f ("resolv: Move nss_dns into libc").
* nss: Directly load nss_dns, without going through dlsym/dlopenFlorian Weimer2021-07-192-0/+41
| | | | | | | | | | | | | This partially fixes static-only NSS support (bug 27959): The dns module no longer needs dlopen. Support for disabling dlopen altogher remains to be added. This commit introduces module_load_builtin into nss/nss_module.c, which handles the common parts of loading the built-in nss_files and nss_dns modules. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* resolv: Move nss_dns into libcFlorian Weimer2021-07-195-57/+46
| | | | | | | No abilist updates are needed because the symbols were GLIBC_PRIVATE. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* resolv: Move res_query functions into libcFlorian Weimer2021-07-195-52/+76
| | | | | | | | | | | | | | | This switches to public symbols without __ prefixes, due to improved namespace management in glibc. The script was used with --no-new-version to move the symbols __res_nquery, __res_nquerydomain, __res_nsearch, __res_query, __res_querydomain, __res_search, res_query, res_querydomain, res_search. The public symbols res_nquery, res_nquerydomain, res_nsearch, res_ownok, res_query, res_querydomain, res_search were added with make update-all-abi. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* resolv: Move res_mkquery, res_nmkquery into libcFlorian Weimer2021-07-195-28/+40
| | | | | | | | | | | | | This switches to public symbols without __ prefixes, due to improved namespace management in glibc. The symbols res_mkquery, __res_mkquery, __res_nmkquery were moved with the script (using --no-new-version). res_mkquery@@GLIBC_2.34, res_nmkquery@@GLIBC_2.34 were added using make update-all-abi. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* resolv: Move res_send, res_nsend into libcFlorian Weimer2021-07-196-30/+45
| | | | | | | | | | | Switch to public symbols without __ prefix (due to improved namespace management). __res_send, __res_nsend were moved using the script (with --no-new-version). res_send@@GLIBC_2.34 and res_nsend@@GLIBC_2.34 were added using make update-all-abi. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* resolv: Move res_hostalias into its own file, along with hostaliasFlorian Weimer2021-07-193-30/+52
| | | | | | | These deprecated symbols continue to be exported from libresolv. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* resolv: Move __res_context_hostalias into its own file and into libcFlorian Weimer2021-07-195-42/+135
| | | | | | | | And reformat it to GNU style. Remove the unecessary setbuf call. Use __fgets_unlocked for PLT avoidance; no locking is required here. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* resolv: Move res_queriesmatch to its own file and into libcFlorian Weimer2021-07-195-59/+144
| | | | | | | | | | And reformat it to GNU style. The treatment of this function matches res_nameinquery, for the reasons stated there. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* resolv: Move res_nameinquery to its own file and into libcFlorian Weimer2021-07-195-42/+126
| | | | | | | | | | | | And reformat to GNU style. This deprecated function is used in the implementation of the stub resolver (for now). Keep the public symbol in libresolv for now (so that no new symbol version is needed), and add a forwarder to libresolv. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* resolv: Move ns_samename into its own file, and into libcFlorian Weimer2021-07-198-31/+55
| | | | | | | | | | | | But only as an internal symbol, __libc_ns_samename. The libresolv ABI is preserved. This is because the function is deprecated, and it does not make sense to add new symbol versions for deprecated functions. Also reformat the implementation to GNU style. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* resolv: Move ns_makecanon into its own file, and into libcFlorian Weimer2021-07-195-36/+90
| | | | | | | | | | | | But only as an internal symbol, __libc_ns_makecanon. The libresolv ABI is preserved. This is because the function is deprecated, and it does not make sense to add new symbol versions for deprecated functions. Also reformat the implementation to GNU style. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* resolv: Move res_isourserver to its own file and reformat to GNU styleFlorian Weimer2021-07-193-51/+135
| | | | | Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* resolv: Move __res_get_nsaddr to its own file and into libcFlorian Weimer2021-07-195-21/+51
| | | | | | | | | Eliminate the use of the EXT macro from it because it does not add clarity. The function was added to res_send.c in 2015, and the copyright year reflects that. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* resolv: Rename res_comp.c to res-name-checking.c and move into libcFlorian Weimer2021-07-194-27/+41
| | | | | | | | | | | | | | | This reflects what the remaining functions in the file do. The __res_dnok, __res_hnok, __res_mailok, __res_ownok were moved with the script, using --no-new-version, and turned into compat symbols. __libc_res_dnok@@GLIBC_PRIVATE and __libc_res_hnok@@GLIBC_PRIVATE are added for internal use, to avoid accidentally binding to compatibility symbols. The new public symbols res_dnok, res_hnok, res_mailok, res_ownok were added using make update-all-abi. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* resolv: Move dn_skipname to its own file and into libcFlorian Weimer2021-07-197-18/+110
| | | | | | | | | | | | | | | And reformat it to GNU style. dn_skipname is used outside glibc, so do not deprecate it, and export it as dn_skipname (not __dn_skipname). Due to internal users, provide a __libc_dn_skipname alias, and keep __dn_skipname as a pure compatibility symbol. __dn_skipname@GLIBC_2.0 was moved using the script, and dn_skipname@@GLIBC_2.34 was added using make update-all-abi. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* resolv: Move dn_comp to its own file and into libcFlorian Weimer2021-07-195-17/+106
| | | | | | | | | | | | | | | And reformat it to GNU style. dn_comp is used in various programs, so keep it as a non-deprecated symbol. Switch to dn_comp (not __dn_comp) for the ABI name. There are no internal users, so interposition is not a problem. The __dn_comp symbol was moved with scripts/move-symbol-to-libc.py --no-new-version. dn_comp@@GLIBC_2.34 was added with make update-all-abi. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* resolv: Move _getlong, _getshort, __putlong, __putshort to res-putgetFlorian Weimer2021-07-193-15/+113
| | | | | | | And reformat to GNU style. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* resolv: Move dn_expand to its own file and into libcFlorian Weimer2021-07-1911-44/+134
| | | | | | | | | | | | | | | | | | And reformat to GNU style. This switches back to the dn_expand name for the ABI symbol and turns __dn_expand into a compatibility symbol. With the improved namespace management in current glibc, it is no longer necessary to use a private namespace symbol. To avoid old code binding to a GLIBC_PRIVATE symbol by accident, use __libc_dn_expand for the internal symbol name. The symbols dn_expand, __dnexpand were moved using scripts/move-symbol-to-libc.py, followed by an adjustment to make dn_expand the only GLIBC_2.34 symbol. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* resolv: Move ns_name_compress into its own file and into libcFlorian Weimer2021-07-194-28/+54
| | | | | | | | | And reformat to GNU style. The symbol was moved using scripts/move-symbol-to-libc.py. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>