diff --git a/cmake/libraries.cmake b/cmake/libraries.cmake index baf9983197f..862bb75d422 100644 --- a/cmake/libraries.cmake +++ b/cmake/libraries.cmake @@ -19,7 +19,7 @@ set(FLB_PATH_LIB_ONIGMO "lib/onigmo") set(FLB_PATH_LIB_MPACK "lib/mpack-amalgamation-1.1.1") set(FLB_PATH_LIB_MINIZ "lib/miniz") set(FLB_PATH_LIB_TUTF8E "lib/tutf8e") -set(FLB_PATH_LIB_CARES "lib/c-ares-1.31.0") +set(FLB_PATH_LIB_CARES "lib/c-ares-1.32.0") set(FLB_PATH_LIB_SNAPPY "lib/snappy-fef67ac") set(FLB_PATH_LIB_RDKAFKA "lib/librdkafka-2.3.0") set(FLB_PATH_LIB_RING_BUFFER "lib/lwrb") diff --git a/lib/c-ares-1.31.0/RELEASE-NOTES.md b/lib/c-ares-1.31.0/RELEASE-NOTES.md deleted file mode 100644 index eea305a5b6c..00000000000 --- a/lib/c-ares-1.31.0/RELEASE-NOTES.md +++ /dev/null @@ -1,24 +0,0 @@ -## c-ares version 1.31.0 - June 18 2024 - -This is a maintenance and bugfix release. - -Changes: - -* Enable Query Cache by default. [PR #786](https://github.com/c-ares/c-ares/pull/786) - -Bugfixes: - -* Enhance Windows DNS configuration change detection to also detect manual DNS - configuration changes. [PR #785](https://github.com/c-ares/c-ares/issues/785) -* Various legacy MacOS Build fixes. [Issue #782](https://github.com/c-ares/c-ares/issues/782) -* Ndots value of zero in resolv.conf was not being honored. [852a60a](https://github.com/c-ares/c-ares/commit/852a60a) -* Watt-32 build support had been broken for some time. [PR #781](https://github.com/c-ares/c-ares/pull/781) -* Distribute `ares_dns_rec_type_tostr` manpage. [PR #778](https://github.com/c-ares/c-ares/pull/778) - -Thanks go to these friendly people for their efforts and contributions for this -release: - -* Brad House (@bradh352) -* Gregor Jasny (@gjasny) - - diff --git a/lib/c-ares-1.31.0/include/ares_rules.h b/lib/c-ares-1.31.0/include/ares_rules.h deleted file mode 100644 index 450dc8ab2d5..00000000000 --- a/lib/c-ares-1.31.0/include/ares_rules.h +++ /dev/null @@ -1,133 +0,0 @@ -/* MIT License - * - * Copyright (c) 2009 Daniel Stenberg - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * SPDX-License-Identifier: MIT - */ -#ifndef __CARES_RULES_H -#define __CARES_RULES_H - -/* ================================================================ */ -/* COMPILE TIME SANITY CHECKS */ -/* ================================================================ */ - -/* - * NOTE 1: - * ------- - * - * All checks done in this file are intentionally placed in a public - * header file which is pulled by ares.h when an application is - * being built using an already built c-ares library. Additionally - * this file is also included and used when building the library. - * - * If compilation fails on this file it is certainly sure that the - * problem is elsewhere. It could be a problem in the ares_build.h - * header file, or simply that you are using different compilation - * settings than those used to build the library. - * - * Nothing in this file is intended to be modified or adjusted by the - * c-ares library user nor by the c-ares library builder. - * - * Do not deactivate any check, these are done to make sure that the - * library is properly built and used. - * - * You can find further help on the c-ares development mailing list: - * http://lists.haxx.se/listinfo/c-ares/ - * - * NOTE 2 - * ------ - * - * Some of the following compile time checks are based on the fact - * that the dimension of a constant array can not be a negative one. - * In this way if the compile time verification fails, the compilation - * will fail issuing an error. The error description wording is compiler - * dependent but it will be quite similar to one of the following: - * - * "negative subscript or subscript is too large" - * "array must have at least one element" - * "-1 is an illegal array size" - * "size of array is negative" - * - * If you are building an application which tries to use an already - * built c-ares library and you are getting this kind of errors on - * this file, it is a clear indication that there is a mismatch between - * how the library was built and how you are trying to use it for your - * application. Your already compiled or binary library provider is the - * only one who can give you the details you need to properly use it. - */ - -/* - * Verify that some macros are actually defined. - */ - -#ifndef CARES_TYPEOF_ARES_SOCKLEN_T -# error "CARES_TYPEOF_ARES_SOCKLEN_T definition is missing!" -Error Compilation_aborted_CARES_TYPEOF_ARES_SOCKLEN_T_is_missing -#endif - -/* - * Macros private to this header file. - */ - -#define CareschkszEQ(t, s) sizeof(t) == s ? 1 : -1 - -#define CareschkszGE(t1, t2) sizeof(t1) >= sizeof(t2) ? 1 : -1 - - /* - * Verify that the size previously defined and expected for - * ares_socklen_t is actually the same as the one reported - * by sizeof() at compile time. - */ - - typedef char __cares_rule_02__[CareschkszEQ( - ares_socklen_t, sizeof(CARES_TYPEOF_ARES_SOCKLEN_T))]; - -/* - * Verify at compile time that the size of ares_socklen_t as reported - * by sizeof() is greater or equal than the one reported for int for - * the current compilation. - */ - -typedef char __cares_rule_03__[CareschkszGE(ares_socklen_t, int)]; - -/* ================================================================ */ -/* EXTERNALLY AND INTERNALLY VISIBLE DEFINITIONS */ -/* ================================================================ */ - -/* - * Get rid of macros private to this header file. - */ - -#undef CareschkszEQ -#undef CareschkszGE - -/* - * Get rid of macros not intended to exist beyond this point. - */ - -#undef CARES_PULL_WS2TCPIP_H -#undef CARES_PULL_SYS_TYPES_H -#undef CARES_PULL_SYS_SOCKET_H - -#undef CARES_TYPEOF_ARES_SOCKLEN_T - -#endif /* __CARES_RULES_H */ diff --git a/lib/c-ares-1.31.0/src/lib/ares_setup.h b/lib/c-ares-1.31.0/src/lib/ares_setup.h deleted file mode 100644 index ea66b1115bf..00000000000 --- a/lib/c-ares-1.31.0/src/lib/ares_setup.h +++ /dev/null @@ -1,238 +0,0 @@ -/* MIT License - * - * Copyright (c) 2004 Daniel Stenberg - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * SPDX-License-Identifier: MIT - */ -#ifndef HEADER_CARES_SETUP_H -#define HEADER_CARES_SETUP_H - -/* - * Include configuration script results or hand-crafted - * configuration file for platforms which lack config tool. - */ - -#ifdef HAVE_CONFIG_H -# include "ares_config.h" -#else - -# ifdef _WIN32 -# include "config-win32.h" -# endif - -#endif /* HAVE_CONFIG_H */ - -/* ================================================================ */ -/* Definition of preprocessor macros/symbols which modify compiler */ -/* behaviour or generated code characteristics must be done here, */ -/* as appropriate, before any system header file is included. It is */ -/* also possible to have them defined in the config file included */ -/* before this point. As a result of all this we frown inclusion of */ -/* system header files in our config files, avoid this at any cost. */ -/* ================================================================ */ - -/* - * AIX 4.3 and newer needs _THREAD_SAFE defined to build - * proper reentrant code. Others may also need it. - */ - -#ifdef NEED_THREAD_SAFE -# ifndef _THREAD_SAFE -# define _THREAD_SAFE -# endif -#endif - -/* - * Tru64 needs _REENTRANT set for a few function prototypes and - * things to appear in the system header files. Unixware needs it - * to build proper reentrant code. Others may also need it. - */ - -#ifdef NEED_REENTRANT -# ifndef _REENTRANT -# define _REENTRANT -# endif -#endif - -/* ================================================================ */ -/* If you need to include a system header file for your platform, */ -/* please, do it beyond the point further indicated in this file. */ -/* ================================================================ */ - -/* - * c-ares external interface definitions are also used internally, - * and might also include required system header files to define them. - */ - -#include - -/* - * Compile time sanity checks must also be done when building the library. - */ - -#include - -/* ================================================================= */ -/* No system header file shall be included in this file before this */ -/* point. The only allowed ones are those included from ares_build.h */ -/* ================================================================= */ - -/* - * Include header files for windows builds before redefining anything. - * Use this preproessor block only to include or exclude windows.h, - * winsock2.h, ws2tcpip.h or winsock.h. Any other windows thing belongs - * to any other further and independent block. Under Cygwin things work - * just as under linux (e.g. ) and the winsock headers should - * never be included when __CYGWIN__ is defined. configure script takes - * care of this, not defining HAVE_WINDOWS_H, HAVE_WINSOCK_H, HAVE_WINSOCK2_H, - * neither HAVE_WS2TCPIP_H when __CYGWIN__ is defined. - */ - -#ifdef HAVE_WINDOWS_H -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -# endif -# include -# ifdef HAVE_WINSOCK2_H -# include -# ifdef HAVE_WS2TCPIP_H -# include -# endif -# else -# ifdef HAVE_WINSOCK_H -# include -# endif -# endif -#endif - -/* - * Define USE_WINSOCK to 2 if we have and use WINSOCK2 API, else - * define USE_WINSOCK to 1 if we have and use WINSOCK API, else - * undefine USE_WINSOCK. - */ - -#ifdef USE_WINSOCK -# undef USE_WINSOCK -#endif -#ifdef HAVE_WINSOCK2_H -# define USE_WINSOCK 2 -#else -# ifdef HAVE_WINSOCK_H -# define USE_WINSOCK 1 -# endif -#endif - -/* - * Work-arounds for systems without configure support - */ - -#ifndef HAVE_CONFIG_H - -# if !defined(HAVE_SYS_TIME_H) && !defined(_MSC_VER) && !defined(__WATCOMC__) -# define HAVE_SYS_TIME_H -# endif - -# if !defined(HAVE_UNISTD_H) && !defined(_MSC_VER) -# define HAVE_UNISTD_H 1 -# endif - -# if !defined(HAVE_SYS_UIO_H) && !defined(_WIN32) && !defined(MSDOS) -# define HAVE_SYS_UIO_H -# endif - -#endif /* HAVE_CONFIG_H */ - -/* - * Arg 2 type for gethostname in case it hasn't been defined in config file. - */ - -#ifndef GETHOSTNAME_TYPE_ARG2 -# ifdef USE_WINSOCK -# define GETHOSTNAME_TYPE_ARG2 int -# else -# define GETHOSTNAME_TYPE_ARG2 size_t -# endif -#endif - -#ifdef __POCC__ -# include -# include -# define ESRCH 3 -#endif - -/* - * Android does have the arpa/nameser.h header which is detected by configure - * but it appears to be empty with recent NDK r7b / r7c, so we undefine here. - * z/OS does have the arpa/nameser.h header which is detected by configure - * but it is not fully implemented and missing identifiers, so udefine here. - */ -#if (defined(ANDROID) || defined(__ANDROID__) || defined(__MVS__)) && \ - defined(HAVE_ARPA_NAMESER_H) -# undef HAVE_ARPA_NAMESER_H -#endif - -/* - * Recent autoconf versions define these symbols in ares_config.h. We don't - * want them (since they collide with the libcurl ones when we build - * --enable-debug) so we undef them again here. - */ - -#ifdef PACKAGE_STRING -# undef PACKAGE_STRING -#endif -#ifdef PACKAGE_TARNAME -# undef PACKAGE_TARNAME -#endif -#ifdef PACKAGE_VERSION -# undef PACKAGE_VERSION -#endif -#ifdef PACKAGE_BUGREPORT -# undef PACKAGE_BUGREPORT -#endif -#ifdef PACKAGE_NAME -# undef PACKAGE_NAME -#endif -#ifdef VERSION -# undef VERSION -#endif -#ifdef PACKAGE -# undef PACKAGE -#endif - -/* IPv6 compatibility */ -#if !defined(HAVE_AF_INET6) -# if defined(HAVE_PF_INET6) -# define AF_INET6 PF_INET6 -# else -# define AF_INET6 AF_MAX + 1 -# endif -#endif - -/* - * Include macros and defines that should only be processed once. - */ - -#ifndef __SETUP_ONCE_H -# include "setup_once.h" -#endif - -#endif /* HEADER_CARES_SETUP_H */ diff --git a/lib/c-ares-1.31.0/AUTHORS b/lib/c-ares-1.32.0/AUTHORS similarity index 100% rename from lib/c-ares-1.31.0/AUTHORS rename to lib/c-ares-1.32.0/AUTHORS diff --git a/lib/c-ares-1.31.0/CMakeLists.txt b/lib/c-ares-1.32.0/CMakeLists.txt similarity index 99% rename from lib/c-ares-1.31.0/CMakeLists.txt rename to lib/c-ares-1.32.0/CMakeLists.txt index 0f3c77ba0ae..d3da9afc75b 100644 --- a/lib/c-ares-1.31.0/CMakeLists.txt +++ b/lib/c-ares-1.32.0/CMakeLists.txt @@ -12,7 +12,7 @@ INCLUDE (CheckCSourceCompiles) INCLUDE (CheckStructHasMember) INCLUDE (CheckLibraryExists) -PROJECT (c-ares LANGUAGES C VERSION "1.31.0" ) +PROJECT (c-ares LANGUAGES C VERSION "1.32.0" ) # Set this version before release SET (CARES_VERSION "${PROJECT_VERSION}") @@ -30,7 +30,7 @@ INCLUDE (GNUInstallDirs) # include this *AFTER* PROJECT(), otherwise paths are w # For example, a version of 4:0:2 would generate output such as: # libname.so -> libname.so.2 # libname.so.2 -> libname.so.2.2.0 -SET (CARES_LIB_VERSIONINFO "18:0:16") +SET (CARES_LIB_VERSIONINFO "19:0:17") OPTION (CARES_STATIC "Build as a static library" OFF) @@ -62,8 +62,8 @@ ENDIF () INCLUDE (EnableWarnings) -# allow linking against the static runtime library in msvc IF (MSVC) + # allow linking against the static runtime library in msvc OPTION (CARES_MSVC_STATIC_RUNTIME "Link against the static runtime library" OFF) IF (CARES_MSVC_STATIC_RUNTIME) # CMAKE_CONFIGURATION_TYPES is empty on non-IDE generators (Ninja, NMake) @@ -564,7 +564,7 @@ SET (RECVFROM_TYPE_ARG5 "struct sockaddr *") SET (RECV_TYPE_ARG4 int) SET (GETNAMEINFO_TYPE_ARG1 "struct sockaddr *") SET (GETNAMEINFO_TYPE_ARG7 int) -SET (SEND_TYPE_ARG2 "void *") +SET (SEND_TYPE_ARG2 "const void *") SET (SEND_TYPE_ARG4 int) ################################################################################ @@ -663,6 +663,9 @@ ENDIF () IF (HAVE_SYS_SOCKET_H) SET (CARES_HAVE_SYS_SOCKET_H 1) ENDIF() +IF (HAVE_SYS_SELECT_H) + SET (CARES_HAVE_SYS_SELECT_H 1) +ENDIF() IF (HAVE_WS2TCPIP_H) SET (CARES_HAVE_WS2TCPIP_H 1) ENDIF() diff --git a/lib/c-ares-1.31.0/CONTRIBUTING.md b/lib/c-ares-1.32.0/CONTRIBUTING.md similarity index 100% rename from lib/c-ares-1.31.0/CONTRIBUTING.md rename to lib/c-ares-1.32.0/CONTRIBUTING.md diff --git a/lib/c-ares-1.31.0/DEVELOPER-NOTES.md b/lib/c-ares-1.32.0/DEVELOPER-NOTES.md similarity index 100% rename from lib/c-ares-1.31.0/DEVELOPER-NOTES.md rename to lib/c-ares-1.32.0/DEVELOPER-NOTES.md diff --git a/lib/c-ares-1.31.0/INSTALL.md b/lib/c-ares-1.32.0/INSTALL.md similarity index 89% rename from lib/c-ares-1.31.0/INSTALL.md rename to lib/c-ares-1.32.0/INSTALL.md index 268157b7379..dc58ab8c045 100644 --- a/lib/c-ares-1.31.0/INSTALL.md +++ b/lib/c-ares-1.32.0/INSTALL.md @@ -42,7 +42,7 @@ unpacked the source archive): You probably need to be root when doing the last command. If you have checked out the sources from the git repository, read the -[GIT-INFO](GIT_INFO) on how to proceed. +[GIT-INFO](GIT-INFO) on how to proceed. Get a full listing of all available configure options by invoking it like: @@ -307,6 +307,16 @@ first to rebuild every single library your app uses as well as your app using the debug multithreaded dynamic C runtime. +### MSYS + +Building is supported for native windows via both AutoTools and CMake. When +building with autotools, you can only build either a shared version or a static +version (use `--disable-shared` or `--disable-static`). CMake can build both +simultaneously. + +All of the MSYS environments are supported: `MINGW32`, `MINGW64`, `UCRT64`, +`CLANG32`, `CLANG64`, `CLANGARM64`. + ### MingW32 Make sure that MinGW32's bin dir is in the search path, for example: @@ -339,6 +349,26 @@ add `-DCARES_STATICLIB` to your `CFLAGS`. Otherwise the linker will look for dynamic import symbols. +DOS +--- + +c-ares supports building as a 32bit protected mode application via +[DJGPP](https://www.delorie.com/djgpp/). It is recommended to use a DJGPP +cross compiler from [Andrew Wu](https://github.com/andrewwutw/build-djgpp) +as building directly in a DOS environment can be difficult. + +It is required to also have [Watt-32](https://www.watt-32.net/) available +built using the same compiler. It is recommended to build the latest `master` +branch from [GitHub](https://github.com/sezero/watt32/tree/master). + +Finally, the `DJ_PREFIX` and `WATT_ROOT` environment variables must be set +appropriately before calling `make Makefile.dj` to build c-ares. + +Please refer to our CI +[GitHub Actions Workflow](https://github.com/c-ares/c-ares/blob/main/.github/workflows/djgpp.yml) +for a full build example, including building the latest Watt-32 release. + + IBM OS/2 -------- @@ -418,20 +448,25 @@ This is a probably incomplete list of known hardware and operating systems that c-ares has been compiled for. If you know a system c-ares compiles and runs on, that isn't listed, please let us know! - - Alpha Tru64 v5.0 5.1 - - ARM Android 1.5, 2.1, 2.3 - - MIPS IRIX 6.2, 6.5 - - Power AIX 3.2.5, 4.2, 4.3.1, 4.3.2, 5.1, 5.2 - - i386 Linux 1.3, 2.0, 2.2, 2.3, 2.4, 2.6 - - i386 Novell NetWare - - i386 Windows 95, 98, ME, NT, 2000, XP, 2003 - - x86_64 Linux + - Linux (i686, x86_64, AARCH64, and more) + - MacOS 10.4+ + - iOS + - Windows 8+ (i686, x86_64) + - Android (ARM, AARCH64, x86_64) + - FreeBSD + - NetBSD + - OpenBSD + - Solaris (SPARC, x86_64) + - AIX (POWER) + - Tru64 (Alpha) + - IRIX (MIPS) + - Novell NetWare (i386) Useful URLs =========== - c-ares: https://c-ares.org/ - - MingW: http://www.mingw.org/ - MinGW-w64: http://mingw-w64.sourceforge.net/ + - MSYS2: https://msys2.org - OpenWatcom: http://www.openwatcom.org/ diff --git a/lib/c-ares-1.31.0/LICENSE.md b/lib/c-ares-1.32.0/LICENSE.md similarity index 100% rename from lib/c-ares-1.31.0/LICENSE.md rename to lib/c-ares-1.32.0/LICENSE.md diff --git a/lib/c-ares-1.31.0/Makefile.Watcom b/lib/c-ares-1.32.0/Makefile.Watcom similarity index 100% rename from lib/c-ares-1.31.0/Makefile.Watcom rename to lib/c-ares-1.32.0/Makefile.Watcom diff --git a/lib/c-ares-1.31.0/Makefile.am b/lib/c-ares-1.32.0/Makefile.am similarity index 100% rename from lib/c-ares-1.31.0/Makefile.am rename to lib/c-ares-1.32.0/Makefile.am diff --git a/lib/c-ares-1.31.0/Makefile.dj b/lib/c-ares-1.32.0/Makefile.dj similarity index 66% rename from lib/c-ares-1.31.0/Makefile.dj rename to lib/c-ares-1.32.0/Makefile.dj index 2f221888638..c28aefe9e22 100644 --- a/lib/c-ares-1.31.0/Makefile.dj +++ b/lib/c-ares-1.32.0/Makefile.dj @@ -20,10 +20,51 @@ WATT32_LIB = $(WATT32_ROOT)/lib/libwatt.a OBJ_DIR = djgpp CFLAGS = -g -O2 -I./include -I./src/lib \ - -I$(WATT32_ROOT)/inc -Wall \ + -I$(WATT32_ROOT)/inc \ + -Wall \ + -Wextra \ + -Waggregate-return \ + -Wcast-align \ + -Wcast-qual \ + -Wconversion \ + -Wdeclaration-after-statement \ + -Wdouble-promotion \ + -Wfloat-equal \ + -Winit-self \ + -Wjump-misses-init \ + -Wlogical-op \ + -Wmissing-braces \ + -Wmissing-declarations \ + -Wmissing-format-attribute \ + -Wmissing-include-dirs \ + -Wmissing-prototypes \ + -Wnested-externs \ + -Wno-coverage-mismatch \ + -Wold-style-definition \ + -Wpacked \ + -Wpointer-arith \ + -Wshadow \ + -Wsign-conversion \ + -Wstrict-overflow \ + -Wstrict-prototypes \ + -Wtrampolines \ + -Wundef \ + -Wunreachable-code \ + -Wunused \ + -Wvariadic-macros \ + -Wvla \ + -Wwrite-strings \ + -Werror=implicit-int \ + -Werror=implicit-function-declaration \ + -Wno-long-long \ -DWATT32 -DHAVE_CONFIG_H \ + -D_REENTRANT \ + -DCARES_NO_DEPRECATED \ -Dselect=select_s +# Can't enable -Wredundant-decls due to WATT32 issues + + LDFLAGS = -s ifeq ($(OS),Windows_NT) diff --git a/lib/c-ares-1.31.0/Makefile.in b/lib/c-ares-1.32.0/Makefile.in similarity index 100% rename from lib/c-ares-1.31.0/Makefile.in rename to lib/c-ares-1.32.0/Makefile.in diff --git a/lib/c-ares-1.31.0/Makefile.m32 b/lib/c-ares-1.32.0/Makefile.m32 similarity index 96% rename from lib/c-ares-1.31.0/Makefile.m32 rename to lib/c-ares-1.32.0/Makefile.m32 index a01fe235d13..36ae674c635 100644 --- a/lib/c-ares-1.31.0/Makefile.m32 +++ b/lib/c-ares-1.32.0/Makefile.m32 @@ -64,7 +64,6 @@ install: ${INSTALL} -m 444 ${srcdir}/include/ares.h ${DESTDIR}${includedir} ${INSTALL} -m 444 ${srcdir}/include/ares_build.h ${DESTDIR}${includedir} ${INSTALL} -m 444 ${srcdir}/include/ares_dns_record.h ${DESTDIR}${includedir} - ${INSTALL} -m 444 ${srcdir}/include/ares_rules.h ${DESTDIR}${includedir} ${INSTALL} -m 444 ${srcdir}/include/ares_version.h ${DESTDIR}${includedir} (for man in $(MANPAGES); do \ ${INSTALL} -m 444 ${srcdir}/$${man} ${DESTDIR}${mandir}/man3; \ diff --git a/lib/c-ares-1.31.0/Makefile.msvc b/lib/c-ares-1.32.0/Makefile.msvc similarity index 99% rename from lib/c-ares-1.31.0/Makefile.msvc rename to lib/c-ares-1.32.0/Makefile.msvc index 5969ec705aa..4b338f27999 100644 --- a/lib/c-ares-1.31.0/Makefile.msvc +++ b/lib/c-ares-1.32.0/Makefile.msvc @@ -214,7 +214,7 @@ RT_ERROR_CHECKING = /RTCsu CC_CMD_REL = cl.exe /nologo $(RTLIB) /DNDEBUG /O2 CC_CMD_DBG = cl.exe /nologo $(RTLIBD) /D_DEBUG /Od /Zi $(RT_ERROR_CHECKING) -CC_CFLAGS = $(CFLAGS) /I.\src\lib /I.\include /W3 /EHsc /FD +CC_CFLAGS = $(CFLAGS) /D_REENTRANT /I.\src\lib /I.\include /W3 /EHsc /FD RC_CMD_REL = rc.exe /l 0x409 /d "NDEBUG" RC_CMD_DBG = rc.exe /l 0x409 /d "_DEBUG" @@ -440,7 +440,6 @@ install: @copy /y $(CARES_OUTDIR)\*.* "$(INSTALL_DIR_LIB)" >NUL @copy /y $(SRCDIR)\include\ares.h "$(INSTALL_DIR_INC)" >NUL @copy /y $(SRCDIR)\include\ares_build.h "$(INSTALL_DIR_INC)" >NUL - @copy /y $(SRCDIR)\include\ares_rules.h "$(INSTALL_DIR_INC)" >NUL @copy /y $(SRCDIR)\include\ares_version.h "$(INSTALL_DIR_INC)" >NUL @copy /y $(SRCDIR)\include\ares_dns_record.h "$(INSTALL_DIR_INC)" >NUL @echo Installed c-ares $(CFG) diff --git a/lib/c-ares-1.31.0/Makefile.netware b/lib/c-ares-1.32.0/Makefile.netware similarity index 99% rename from lib/c-ares-1.31.0/Makefile.netware rename to lib/c-ares-1.32.0/Makefile.netware index 5ebbc76207d..6cb00a75100 100644 --- a/lib/c-ares-1.31.0/Makefile.netware +++ b/lib/c-ares-1.32.0/Makefile.netware @@ -299,9 +299,8 @@ ifeq ($(LIBARCH),CLIB) @echo $(DL)#define RECVFROM_TYPE_ARG5 struct sockaddr$(DL) >> $@ @echo $(DL)#define RECVFROM_TYPE_ARG6 int$(DL) >> $@ @echo $(DL)#define RECVFROM_TYPE_RETV int$(DL) >> $@ - @echo $(DL)#define SEND_QUAL_ARG2$(DL) >> $@ @echo $(DL)#define SEND_TYPE_ARG1 int$(DL) >> $@ - @echo $(DL)#define SEND_TYPE_ARG2 char *$(DL) >> $@ + @echo $(DL)#define SEND_TYPE_ARG2 const char *$(DL) >> $@ @echo $(DL)#define SEND_TYPE_ARG3 int$(DL) >> $@ @echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@ @echo $(DL)#define SEND_TYPE_RETV int$(DL) >> $@ diff --git a/lib/c-ares-1.31.0/README.md b/lib/c-ares-1.32.0/README.md similarity index 100% rename from lib/c-ares-1.31.0/README.md rename to lib/c-ares-1.32.0/README.md diff --git a/lib/c-ares-1.31.0/README.msvc b/lib/c-ares-1.32.0/README.msvc similarity index 100% rename from lib/c-ares-1.31.0/README.msvc rename to lib/c-ares-1.32.0/README.msvc diff --git a/lib/c-ares-1.32.0/RELEASE-NOTES.md b/lib/c-ares-1.32.0/RELEASE-NOTES.md new file mode 100644 index 00000000000..545e3ca8274 --- /dev/null +++ b/lib/c-ares-1.32.0/RELEASE-NOTES.md @@ -0,0 +1,38 @@ +## c-ares version 1.32.0 - July 4 2024 + +This is a feature and bugfix release. + +Features: + +* Add support for DNS 0x20 to help prevent cache poisoning attacks, enabled + by specifying `ARES_FLAG_DNS0x20`. Disabled by default. [PR #800](https://github.com/c-ares/c-ares/pull/800) +* Rework query timeout logic to automatically adjust timeouts based on network + conditions. The timeout specified now is only used as a hint until there + is enough history to calculate a more valid timeout. [PR #794](https://github.com/c-ares/c-ares/pull/794) + +Changes: + +* DNS RR TXT strings should not be automatically concatenated as there are use + cases outside of RFC 7208. In order to maintain ABI compliance, the ability + to retrieve TXT strings concatenated is retained as well as a new API to + retrieve the individual strings. This restores behavior from c-ares 1.20.0. + [PR #801](https://github.com/c-ares/c-ares/pull/801) +* Clean up header inclusion logic to make hacking on code easier. [PR #797](https://github.com/c-ares/c-ares/pull/797) +* GCC/Clang: Enable even more strict warnings to catch more coding flaws. [253bdee](https://github.com/c-ares/c-ares/commit/253bdee) +* MSVC: Enable `/W4` warning level. [PR #792](https://github.com/c-ares/c-ares/pull/792) + +Bugfixes: + +* Tests: Fix thread race condition in test cases for EventThread. [PR #803](https://github.com/c-ares/c-ares/pull/803) +* Windows: Fix building with UNICODE. [PR #802](https://github.com/c-ares/c-ares/pull/802) +* Thread Saftey: `ares_timeout()` was missing lock. [74a64e4](https://github.com/c-ares/c-ares/commit/74a64e4) +* Fix building with DJGPP (32bit protected mode DOS). [PR #789](https://github.com/c-ares/c-ares/pull/789) + +Thanks go to these friendly people for their efforts and contributions for this +release: + +* Brad House (@bradh352) +* Cheng (@zcbenz) + + + diff --git a/lib/c-ares-1.31.0/SECURITY.md b/lib/c-ares-1.32.0/SECURITY.md similarity index 100% rename from lib/c-ares-1.31.0/SECURITY.md rename to lib/c-ares-1.32.0/SECURITY.md diff --git a/lib/c-ares-1.31.0/aclocal.m4 b/lib/c-ares-1.32.0/aclocal.m4 similarity index 100% rename from lib/c-ares-1.31.0/aclocal.m4 rename to lib/c-ares-1.32.0/aclocal.m4 diff --git a/lib/c-ares-1.31.0/aminclude_static.am b/lib/c-ares-1.32.0/aminclude_static.am similarity index 99% rename from lib/c-ares-1.31.0/aminclude_static.am rename to lib/c-ares-1.32.0/aminclude_static.am index 7cafa3443cd..7c89a366f80 100644 --- a/lib/c-ares-1.31.0/aminclude_static.am +++ b/lib/c-ares-1.32.0/aminclude_static.am @@ -1,6 +1,6 @@ # aminclude_static.am generated automatically by Autoconf -# from AX_AM_MACROS_STATIC on Tue Jun 18 05:51:32 EDT 2024 +# from AX_AM_MACROS_STATIC on Thu Jul 4 07:03:12 EDT 2024 # Code coverage diff --git a/lib/c-ares-1.31.0/buildconf b/lib/c-ares-1.32.0/buildconf similarity index 100% rename from lib/c-ares-1.31.0/buildconf rename to lib/c-ares-1.32.0/buildconf diff --git a/lib/c-ares-1.31.0/buildconf.bat b/lib/c-ares-1.32.0/buildconf.bat similarity index 100% rename from lib/c-ares-1.31.0/buildconf.bat rename to lib/c-ares-1.32.0/buildconf.bat diff --git a/lib/c-ares-1.31.0/c-ares-config.cmake.in b/lib/c-ares-1.32.0/c-ares-config.cmake.in similarity index 100% rename from lib/c-ares-1.31.0/c-ares-config.cmake.in rename to lib/c-ares-1.32.0/c-ares-config.cmake.in diff --git a/lib/c-ares-1.31.0/cmake/EnableWarnings.cmake b/lib/c-ares-1.32.0/cmake/EnableWarnings.cmake similarity index 84% rename from lib/c-ares-1.31.0/cmake/EnableWarnings.cmake rename to lib/c-ares-1.32.0/cmake/EnableWarnings.cmake index a394a8721f7..5bd68ec45c2 100644 --- a/lib/c-ares-1.31.0/cmake/EnableWarnings.cmake +++ b/lib/c-ares-1.32.0/cmake/EnableWarnings.cmake @@ -39,6 +39,121 @@ include(CheckCXXCompilerFlag) get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES) +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# Helper functions + + +# This function can be called in subdirectories, to prune out warnings that they don't want. +# vararg: warning flags to remove from list of enabled warnings. All "no" flags after EXPLICIT_DISABLE +# will be added to C flags. +# +# Ex.: remove_warnings(-Wall -Wdouble-promotion -Wcomment) prunes those warnings flags from the compile command. +function(remove_warnings) + get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES) + set(langs C) + if ("CXX" IN_LIST languages) + list(APPEND langs CXX) + endif () + + foreach(lang ${langs}) + set(toadd) + set(in_explicit_disable FALSE) + foreach (flag ${ARGN}) + if (flag STREQUAL "EXPLICIT_DISABLE") + set(in_explicit_disable TRUE) + elseif (in_explicit_disable) + list(APPEND toadd "${flag}") + else () + string(REGEX REPLACE "${flag}([ \t]+|$)" "" CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS}") + endif () + endforeach () + _int_enable_warnings_set_flags(lang ${toadd}) + string(STRIP "${CMAKE_${lang}_FLAGS}" CMAKE_${lang}_FLAGS) + set(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS}" PARENT_SCOPE) + endforeach() +endfunction() + + +# Explicitly suppress all warnings. As long as this flag is the last warning flag, warnings will be +# suppressed even if earlier flags enabled warnings. +function(remove_all_warnings) + get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES) + set(langs C) + if ("CXX" IN_LIST languages) + list(APPEND langs CXX) + endif () + + foreach(lang ${langs}) + string(REGEX REPLACE "[-/][Ww][^ \t]*([ \t]+|$)" "" CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS}") + if (MSVC) + string(APPEND CMAKE_${lang}_FLAGS " /w") + else () + string(APPEND CMAKE_${lang}_FLAGS " -w") + endif () + string(STRIP "${CMAKE_${lang}_FLAGS}" CMAKE_${lang}_FLAGS) + set(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS}" PARENT_SCOPE) + endforeach() +endfunction() + + +function(remove_all_warnings_from_targets) + foreach (target ${ARGN}) + if (MSVC) + target_compile_options(${target} PRIVATE "/w") + else () + target_compile_options(${target} PRIVATE "-w") + endif () + endforeach() +endfunction() + + +# Save the current warning settings to an internal variable. +function(push_warnings) + get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES) + set(langs C) + if ("CXX" IN_LIST languages) + list(APPEND langs CXX) + endif () + + foreach(lang ${langs}) + if (CMAKE_${lang}_FLAGS MATCHES ";") + message(AUTHOR_WARNING "Cannot push warnings for ${lang}, CMAKE_${lang}_FLAGS contains semicolons") + continue() + endif () + # Add current flags to end of internal list. + list(APPEND _enable_warnings_internal_${lang}_flags_stack "${CMAKE_${lang}_FLAGS}") + # Propagate results up to caller's scope. + set(_enable_warnings_internal_${lang}_flags_stack "${_enable_warnings_internal_${lang}_flags_stack}" PARENT_SCOPE) + endforeach() +endfunction() + + +# Restore the current warning settings from an internal variable. +function(pop_warnings) + get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES) + set(langs C) + if ("CXX" IN_LIST languages) + list(APPEND langs CXX) + endif () + + foreach(lang ${langs}) + if (NOT _enable_warnings_internal_${lang}_flags_stack) + continue() + endif () + # Pop flags off of end of list, overwrite current flags with whatever we popped off. + list(GET _enable_warnings_internal_${lang}_flags_stack -1 CMAKE_${lang}_FLAGS) + list(REMOVE_AT _enable_warnings_internal_${lang}_flags_stack -1) + # Propagate results up to caller's scope. + set(_enable_warnings_internal_${lang}_flags_stack "${_enable_warnings_internal_${lang}_flags_stack}" PARENT_SCOPE) + string(STRIP "${CMAKE_${lang}_FLAGS}" CMAKE_${lang}_FLAGS) + set(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS}" PARENT_SCOPE) + endforeach() +endfunction() + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# Runs when included automatically + # internal helper: _int_enable_warnings_set_flags_ex(langs_var configs_var [warnings flags]) function(_int_enable_warnings_set_flags_ex langs_var configs_var) if (NOT ARGN) @@ -109,17 +224,42 @@ set(_debug_flags_C) set(_debug_flags_CXX) if (MSVC) + # Don't automatically set /W3 + CMAKE_POLICY (SET CMP0092 NEW) + # Visual Studio uses a completely different nomenclature for warnings than gcc/mingw/clang, so none of the # "-W[name]" warnings will work. - # W4 would be better but it produces unnecessary warnings like: - # * warning C4706: assignment within conditional expression - # Triggered when doing "while(1)" - # * warning C4115: 'timeval' : named type definition in parentheses - # * warning C4201: nonstandard extension used : nameless struct/union - # Triggered by system includes (commctrl.h, shtypes.h, Shlobj.h) set(_flags - /W3 + # Enable warnings + /W4 # Baseline reasonable warnings + /w14242 # 'identifier': conversion from 'type1' to 'type2', possible loss of data + /w14254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data + /w14263 # 'function': member function does not override any base class virtual member function + /w14265 # 'classname': class has virtual functions, but destructor is not virtual instances of this class may + # not be destructed correctly + /w14287 # 'operator': unsigned/negative constant mismatch + /we4289 # nonstandard extension used: 'variable': loop control variable declared in the for-loop is used outside + # the for-loop scope + /w14296 # 'operator': expression is always 'boolean_value' + /w14311 # 'variable': pointer truncation from 'type1' to 'type2' + /w14545 # expression before comma evaluates to a function which is missing an argument list + /w14546 # function call before comma missing argument list + /w14547 # 'operator': operator before comma has no effect; expected operator with side-effect + /w14549 # 'operator': operator before comma has no effect; did you intend 'operator'? + /w14555 # expression has no effect; expected expression with side- effect + /w14619 # pragma warning: there is no warning number 'number' + /w14640 # Enable warning on thread un-safe static member initialization + /w14826 # Conversion from 'type1' to 'type2' is sign-extended. This may cause unexpected runtime behavior. + /w14905 # wide string literal cast to 'LPSTR' + /w14906 # string literal cast to 'LPWSTR' + /w14928 # illegal copy-initialization; more than one user-defined conversion has been implicitly applied + + # Disable some warnings + /wd4201 # nonstandard extension used: nameless struct/union. Used in some windows headers, e.g. IO_STATUS_BLOCK, + # disable. + + # Turn some warnings into errors /we4013 # Treat "function undefined, assuming extern returning int" warning as an error. https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4013 ) @@ -157,7 +297,9 @@ else () -Wextra # Enable additional warnings not covered by Wall and Wextra. + -Waggregate-return -Wcast-align + -Wcast-qual -Wconversion -Wdeclaration-after-statement -Wdouble-promotion @@ -175,6 +317,7 @@ else () -Wno-coverage-mismatch -Wold-style-definition -Wpacked + -Wpedantic -Wpointer-arith -Wredundant-decls -Wshadow @@ -183,6 +326,7 @@ else () -Wstrict-prototypes -Wtrampolines -Wundef + -Wunreachable-code -Wunused -Wvariadic-macros -Wvla @@ -201,6 +345,8 @@ else () # Some clang versions might warn if an argument like "-I/path/to/headers" is unused, # silence these. -Qunused-arguments + + -Wno-long-long ) # C++ flags: @@ -285,115 +431,7 @@ foreach(_lang ${languages}) endif () endforeach() - - -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Helper functions - - -# This function can be called in subdirectories, to prune out warnings that they don't want. -# vararg: warning flags to remove from list of enabled warnings. All "no" flags after EXPLICIT_DISABLE -# will be added to C flags. -# -# Ex.: remove_warnings(-Wall -Wdouble-promotion -Wcomment) prunes those warnings flags from the compile command. -function(remove_warnings) - get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES) - set(langs C) - if ("CXX" IN_LIST languages) - list(APPEND langs CXX) - endif () - - foreach(lang ${langs}) - set(toadd) - set(in_explicit_disable FALSE) - foreach (flag ${ARGN}) - if (flag STREQUAL "EXPLICIT_DISABLE") - set(in_explicit_disable TRUE) - elseif (in_explicit_disable) - list(APPEND toadd "${flag}") - else () - string(REGEX REPLACE "${flag}([ \t]+|$)" "" CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS}") - endif () - endforeach () - _int_enable_warnings_set_flags(lang ${toadd}) - string(STRIP "${CMAKE_${lang}_FLAGS}" CMAKE_${lang}_FLAGS) - set(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS}" PARENT_SCOPE) - endforeach() -endfunction() - - -# Explicitly suppress all warnings. As long as this flag is the last warning flag, warnings will be -# suppressed even if earlier flags enabled warnings. -function(remove_all_warnings) - get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES) - set(langs C) - if ("CXX" IN_LIST languages) - list(APPEND langs CXX) - endif () - - foreach(lang ${langs}) - string(REGEX REPLACE "[-/][Ww][^ \t]*([ \t]+|$)" "" CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS}") - if (MSVC) - string(APPEND CMAKE_${lang}_FLAGS " /w") - else () - string(APPEND CMAKE_${lang}_FLAGS " -w") - endif () - string(STRIP "${CMAKE_${lang}_FLAGS}" CMAKE_${lang}_FLAGS) - set(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS}" PARENT_SCOPE) - endforeach() -endfunction() - - -function(remove_all_warnings_from_targets) - foreach (target ${ARGN}) - if (MSVC) - target_compile_options(${target} PRIVATE "/w") - else () - target_compile_options(${target} PRIVATE "-w") - endif () - endforeach() -endfunction() - - -# Save the current warning settings to an internal variable. -function(push_warnings) - get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES) - set(langs C) - if ("CXX" IN_LIST languages) - list(APPEND langs CXX) - endif () - - foreach(lang ${langs}) - if (CMAKE_${lang}_FLAGS MATCHES ";") - message(AUTHOR_WARNING "Cannot push warnings for ${lang}, CMAKE_${lang}_FLAGS contains semicolons") - continue() - endif () - # Add current flags to end of internal list. - list(APPEND _enable_warnings_internal_${lang}_flags_stack "${CMAKE_${lang}_FLAGS}") - # Propagate results up to caller's scope. - set(_enable_warnings_internal_${lang}_flags_stack "${_enable_warnings_internal_${lang}_flags_stack}" PARENT_SCOPE) - endforeach() -endfunction() - - -# Restore the current warning settings from an internal variable. -function(pop_warnings) - get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES) - set(langs C) - if ("CXX" IN_LIST languages) - list(APPEND langs CXX) - endif () - - foreach(lang ${langs}) - if (NOT _enable_warnings_internal_${lang}_flags_stack) - continue() - endif () - # Pop flags off of end of list, overwrite current flags with whatever we popped off. - list(GET _enable_warnings_internal_${lang}_flags_stack -1 CMAKE_${lang}_FLAGS) - list(REMOVE_AT _enable_warnings_internal_${lang}_flags_stack -1) - # Propagate results up to caller's scope. - set(_enable_warnings_internal_${lang}_flags_stack "${_enable_warnings_internal_${lang}_flags_stack}" PARENT_SCOPE) - string(STRIP "${CMAKE_${lang}_FLAGS}" CMAKE_${lang}_FLAGS) - set(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS}" PARENT_SCOPE) - endforeach() -endfunction() +# CMP0092 doesn't appear to really work, really remove the /W3 here. +if (MSVC) + remove_warnings(/W3) +endif () diff --git a/lib/c-ares-1.31.0/config/compile b/lib/c-ares-1.32.0/config/compile similarity index 100% rename from lib/c-ares-1.31.0/config/compile rename to lib/c-ares-1.32.0/config/compile diff --git a/lib/c-ares-1.31.0/config/config.guess b/lib/c-ares-1.32.0/config/config.guess similarity index 100% rename from lib/c-ares-1.31.0/config/config.guess rename to lib/c-ares-1.32.0/config/config.guess diff --git a/lib/c-ares-1.31.0/config/config.sub b/lib/c-ares-1.32.0/config/config.sub similarity index 100% rename from lib/c-ares-1.31.0/config/config.sub rename to lib/c-ares-1.32.0/config/config.sub diff --git a/lib/c-ares-1.31.0/config/depcomp b/lib/c-ares-1.32.0/config/depcomp similarity index 100% rename from lib/c-ares-1.31.0/config/depcomp rename to lib/c-ares-1.32.0/config/depcomp diff --git a/lib/c-ares-1.31.0/config/install-sh b/lib/c-ares-1.32.0/config/install-sh similarity index 100% rename from lib/c-ares-1.31.0/config/install-sh rename to lib/c-ares-1.32.0/config/install-sh diff --git a/lib/c-ares-1.31.0/config/ltmain.sh b/lib/c-ares-1.32.0/config/ltmain.sh similarity index 100% rename from lib/c-ares-1.31.0/config/ltmain.sh rename to lib/c-ares-1.32.0/config/ltmain.sh diff --git a/lib/c-ares-1.31.0/config/missing b/lib/c-ares-1.32.0/config/missing similarity index 100% rename from lib/c-ares-1.31.0/config/missing rename to lib/c-ares-1.32.0/config/missing diff --git a/lib/c-ares-1.31.0/config/test-driver b/lib/c-ares-1.32.0/config/test-driver similarity index 100% rename from lib/c-ares-1.31.0/config/test-driver rename to lib/c-ares-1.32.0/config/test-driver diff --git a/lib/c-ares-1.31.0/configure b/lib/c-ares-1.32.0/configure similarity index 99% rename from lib/c-ares-1.31.0/configure rename to lib/c-ares-1.32.0/configure index a19193e4206..a309badc242 100755 --- a/lib/c-ares-1.31.0/configure +++ b/lib/c-ares-1.32.0/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.72 for c-ares 1.31.0. +# Generated by GNU Autoconf 2.72 for c-ares 1.32.0. # # Report bugs to . # @@ -614,8 +614,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='c-ares' PACKAGE_TARNAME='c-ares' -PACKAGE_VERSION='1.31.0' -PACKAGE_STRING='c-ares 1.31.0' +PACKAGE_VERSION='1.32.0' +PACKAGE_STRING='c-ares 1.32.0' PACKAGE_BUGREPORT='c-ares mailing list: http://lists.haxx.se/listinfo/c-ares' PACKAGE_URL='' @@ -1415,7 +1415,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -'configure' configures c-ares 1.31.0 to adapt to many kinds of systems. +'configure' configures c-ares 1.32.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1486,7 +1486,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of c-ares 1.31.0:";; + short | recursive ) echo "Configuration of c-ares 1.32.0:";; esac cat <<\_ACEOF @@ -1623,7 +1623,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -c-ares configure 1.31.0 +c-ares configure 1.32.0 generated by GNU Autoconf 2.72 Copyright (C) 2023 Free Software Foundation, Inc. @@ -2267,7 +2267,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by c-ares $as_me 1.31.0, which was +It was created by c-ares $as_me 1.32.0, which was generated by GNU Autoconf 2.72. Invocation command line was $ $0$ac_configure_args_raw @@ -3259,7 +3259,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu -CARES_VERSION_INFO="18:0:16" +CARES_VERSION_INFO="19:0:17" @@ -5999,7 +5999,7 @@ fi # Define the identity of the package. PACKAGE='c-ares' - VERSION='1.31.0' + VERSION='1.32.0' printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h @@ -20682,42 +20682,7 @@ fi if test "$enable_warnings" = "yes"; then -for flag in -Wall \ - -Wextra \ - -Wcast-align \ - -Wconversion \ - -Wdeclaration-after-statement \ - -Wdouble-promotion \ - -Wfloat-equal \ - -Wformat-security \ - -Winit-self \ - -Wjump-misses-init \ - -Wlogical-op \ - -Wmissing-braces \ - -Wmissing-declarations \ - -Wmissing-format-attribute \ - -Wmissing-include-dirs \ - -Wmissing-prototypes \ - -Wnested-externs \ - -Wno-coverage-mismatch \ - -Wold-style-definition \ - -Wpacked \ - -Wpointer-arith \ - -Wredundant-decls \ - -Wshadow \ - -Wsign-conversion \ - -Wstrict-overflow \ - -Wstrict-prototypes \ - -Wtrampolines \ - -Wundef \ - -Wunused \ - -Wvariadic-macros \ - -Wvla \ - -Wwrite-strings \ - -Werror=implicit-int \ - -Werror=implicit-function-declaration \ - -Werror=partial-availability \ - ; do +for flag in -std=c90 -Wall -Wextra -Waggregate-return -Wcast-align -Wcast-qual -Wconversion -Wdeclaration-after-statement -Wdouble-promotion -Wfloat-equal -Wformat-security -Winit-self -Wjump-misses-init -Wlogical-op -Wmissing-braces -Wmissing-declarations -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-prototypes -Wnested-externs -Wno-coverage-mismatch -Wold-style-definition -Wpacked -Wpedantic -Wpointer-arith -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow -Wstrict-prototypes -Wtrampolines -Wundef -Wunreachable-code -Wunused -Wvariadic-macros -Wvla -Wwrite-strings -Werror=implicit-int -Werror=implicit-function-declaration -Werror=partial-availability -Wno-long-long ; do as_CACHEVAR=`printf "%s\n" "ax_cv_check_cflags_-Werror_$flag" | sed "$as_sed_sh"` { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5 printf %s "checking whether C compiler accepts $flag... " >&6; } @@ -23002,7 +22967,7 @@ recvfrom_type_arg5="struct sockaddr *" recv_type_arg4=int getnameinfo_type_arg1="struct sockaddr *" getnameinfo_type_arg7=int -send_type_arg2="void *" +send_type_arg2="const void *" send_type_arg4=int @@ -23053,9 +23018,6 @@ printf "%s\n" "#define SEND_TYPE_ARG1 ${send_type_arg1} " >>confdefs.h printf "%s\n" "#define SEND_TYPE_ARG2 ${send_type_arg2} " >>confdefs.h -printf "%s\n" "#define SEND_QUAL_ARG2 " >>confdefs.h - - printf "%s\n" "#define SEND_TYPE_ARG3 ${send_type_arg3} " >>confdefs.h @@ -23286,6 +23248,13 @@ cat >>confdefs.h <<_EOF #define CARES_HAVE_SYS_SOCKET_H 1 _EOF +fi +if test "x$ac_cv_header_sys_select_h" = "xyes" ; then + +cat >>confdefs.h <<_EOF +#define CARES_HAVE_SYS_SELECT_H 1 +_EOF + fi if test "x$ac_cv_header_ws2tcpip_h" = "xyes" ; then @@ -26370,7 +26339,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by c-ares $as_me 1.31.0, which was +This file was extended by c-ares $as_me 1.32.0, which was generated by GNU Autoconf 2.72. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -26438,7 +26407,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ -c-ares config.status 1.31.0 +c-ares config.status 1.32.0 configured by $0, generated by GNU Autoconf 2.72, with options \\"\$ac_cs_config\\" diff --git a/lib/c-ares-1.31.0/configure.ac b/lib/c-ares-1.32.0/configure.ac similarity index 93% rename from lib/c-ares-1.31.0/configure.ac rename to lib/c-ares-1.32.0/configure.ac index 9e21619ae73..d7deb430f8a 100644 --- a/lib/c-ares-1.31.0/configure.ac +++ b/lib/c-ares-1.32.0/configure.ac @@ -2,10 +2,10 @@ dnl Copyright (C) The c-ares project and its contributors dnl SPDX-License-Identifier: MIT AC_PREREQ([2.69]) -AC_INIT([c-ares], [1.31.0], +AC_INIT([c-ares], [1.32.0], [c-ares mailing list: http://lists.haxx.se/listinfo/c-ares]) -CARES_VERSION_INFO="18:0:16" +CARES_VERSION_INFO="19:0:17" dnl This flag accepts an argument of the form current[:revision[:age]]. So, dnl passing -version-info 3:12:1 sets current to 3, revision to 12, and age to dnl 1. @@ -245,42 +245,8 @@ AC_SUBST(CARES_SYMBOL_HIDING_CFLAG) if test "$enable_warnings" = "yes"; then - AX_APPEND_COMPILE_FLAGS([-Wall \ - -Wextra \ - -Wcast-align \ - -Wconversion \ - -Wdeclaration-after-statement \ - -Wdouble-promotion \ - -Wfloat-equal \ - -Wformat-security \ - -Winit-self \ - -Wjump-misses-init \ - -Wlogical-op \ - -Wmissing-braces \ - -Wmissing-declarations \ - -Wmissing-format-attribute \ - -Wmissing-include-dirs \ - -Wmissing-prototypes \ - -Wnested-externs \ - -Wno-coverage-mismatch \ - -Wold-style-definition \ - -Wpacked \ - -Wpointer-arith \ - -Wredundant-decls \ - -Wshadow \ - -Wsign-conversion \ - -Wstrict-overflow \ - -Wstrict-prototypes \ - -Wtrampolines \ - -Wundef \ - -Wunused \ - -Wvariadic-macros \ - -Wvla \ - -Wwrite-strings \ - -Werror=implicit-int \ - -Werror=implicit-function-declaration \ - -Werror=partial-availability \ - ], [AM_CFLAGS], [-Werror]) + AX_APPEND_COMPILE_FLAGS([-std=c90 -Wall -Wextra -Waggregate-return -Wcast-align -Wcast-qual -Wconversion -Wdeclaration-after-statement -Wdouble-promotion -Wfloat-equal -Wformat-security -Winit-self -Wjump-misses-init -Wlogical-op -Wmissing-braces -Wmissing-declarations -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-prototypes -Wnested-externs -Wno-coverage-mismatch -Wold-style-definition -Wpacked -Wpedantic -Wpointer-arith -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow -Wstrict-prototypes -Wtrampolines -Wundef -Wunreachable-code -Wunused -Wvariadic-macros -Wvla -Wwrite-strings -Werror=implicit-int -Werror=implicit-function-declaration -Werror=partial-availability -Wno-long-long ], + [AM_CFLAGS], [-Werror]) fi if test "$ax_cv_c_compiler_vendor" = "intel"; then @@ -294,17 +260,7 @@ if test "$ac_cv_native_windows" = "yes" ; then dnl other headers, AC_CHECK_HEADERS only allows you to specify headers that dnl must be included *before* the header being checked. - AC_CHECK_HEADERS( - windows.h \ - winsock2.h \ - ws2tcpip.h \ - iphlpapi.h \ - netioapi.h \ - ws2ipdef.h \ - winternl.h \ - ntdef.h \ - ntstatus.h \ - mswsock.h, + AC_CHECK_HEADERS([windows.h winsock2.h ws2tcpip.h iphlpapi.h netioapi.h ws2ipdef.h winternl.h ntdef.h ntstatus.h mswsock.h ], [], [], [-]) dnl Windows builds require linking to iphlpapi @@ -406,42 +362,10 @@ AS_HELP_STRING([--enable-libgcc],[use libgcc when linking]), AC_MSG_RESULT(no) ) -dnl check for a few basic system headers we need -AC_CHECK_HEADERS( - malloc.h \ - memory.h \ - AvailabilityMacros.h \ - sys/types.h \ - sys/time.h \ - sys/select.h \ - sys/socket.h \ - sys/filio.h \ - sys/ioctl.h \ - sys/param.h \ - sys/uio.h \ - sys/random.h \ - sys/event.h \ - sys/epoll.h \ - assert.h \ - iphlpapi.h \ - netioapi.h \ - netdb.h \ - netinet/in.h \ - netinet6/in6.h \ - netinet/tcp.h \ - net/if.h \ - ifaddrs.h \ - fcntl.h \ - errno.h \ - socket.h \ - strings.h \ - stdbool.h \ - time.h \ - poll.h \ - limits.h \ - arpa/nameser.h \ - arpa/nameser_compat.h \ - arpa/inet.h, +dnl check for a few basic system headers we need. It would be nice if we could +dnl split these on separate lines, but for some reason autotools on Windows doesn't +dnl allow this, even tried ending lines with a backslash. +AC_CHECK_HEADERS([malloc.h memory.h AvailabilityMacros.h sys/types.h sys/time.h sys/select.h sys/socket.h sys/filio.h sys/ioctl.h sys/param.h sys/uio.h sys/random.h sys/event.h sys/epoll.h assert.h iphlpapi.h netioapi.h netdb.h netinet/in.h netinet6/in6.h netinet/tcp.h net/if.h ifaddrs.h fcntl.h errno.h socket.h strings.h stdbool.h time.h poll.h limits.h arpa/nameser.h arpa/nameser_compat.h arpa/inet.h ], dnl to do if not found [], dnl to do if found @@ -705,7 +629,7 @@ recvfrom_type_arg5="struct sockaddr *" recv_type_arg4=int getnameinfo_type_arg1="struct sockaddr *" getnameinfo_type_arg7=int -send_type_arg2="void *" +send_type_arg2="const void *" send_type_arg4=int AC_DEFINE_UNQUOTED([RECVFROM_TYPE_RETV], [ ${recvfrom_type_retv} ], [ recvfrom() return value ]) @@ -725,7 +649,6 @@ AC_DEFINE_UNQUOTED([RECV_TYPE_ARG4], [ ${recv_type_arg4} ], [ re AC_DEFINE_UNQUOTED([SEND_TYPE_RETV], [ ${send_type_retv} ], [ send() return value ]) AC_DEFINE_UNQUOTED([SEND_TYPE_ARG1], [ ${send_type_arg1} ], [ send() arg1 type ]) AC_DEFINE_UNQUOTED([SEND_TYPE_ARG2], [ ${send_type_arg2} ], [ send() arg2 type ]) -AC_DEFINE_UNQUOTED([SEND_QUAL_ARG2], [ ], [ send() arg2 qualifier ]) AC_DEFINE_UNQUOTED([SEND_TYPE_ARG3], [ ${send_type_arg3} ], [ send() arg3 type ]) AC_DEFINE_UNQUOTED([SEND_TYPE_ARG4], [ ${send_type_arg4} ], [ send() arg4 type ]) @@ -808,6 +731,9 @@ fi if test "x$ac_cv_header_sys_socket_h" = "xyes" ; then CARES_DEFINE_UNQUOTED([CARES_HAVE_SYS_SOCKET_H],[1]) fi +if test "x$ac_cv_header_sys_select_h" = "xyes" ; then + CARES_DEFINE_UNQUOTED([CARES_HAVE_SYS_SELECT_H],[1]) +fi if test "x$ac_cv_header_ws2tcpip_h" = "xyes" ; then CARES_DEFINE_UNQUOTED([CARES_HAVE_WS2TCPIP_H],[1]) fi @@ -902,12 +828,12 @@ AC_SUBST(AM_CPPFLAGS) AC_SUBST(PKGCONFIG_CFLAGS) AC_SUBST(BUILD_SUBDIRS) -AC_CONFIG_FILES([Makefile \ - include/Makefile \ - src/Makefile \ - src/lib/Makefile \ - src/tools/Makefile \ - docs/Makefile \ +AC_CONFIG_FILES([Makefile + include/Makefile + src/Makefile + src/lib/Makefile + src/tools/Makefile + docs/Makefile libcares.pc ]) AM_COND_IF([BUILD_TESTS], [AC_CONFIG_FILES([test/Makefile])]) diff --git a/lib/c-ares-1.31.0/docs/CMakeLists.txt b/lib/c-ares-1.32.0/docs/CMakeLists.txt similarity index 100% rename from lib/c-ares-1.31.0/docs/CMakeLists.txt rename to lib/c-ares-1.32.0/docs/CMakeLists.txt diff --git a/lib/c-ares-1.31.0/docs/Makefile.am b/lib/c-ares-1.32.0/docs/Makefile.am similarity index 100% rename from lib/c-ares-1.31.0/docs/Makefile.am rename to lib/c-ares-1.32.0/docs/Makefile.am diff --git a/lib/c-ares-1.31.0/docs/Makefile.in b/lib/c-ares-1.32.0/docs/Makefile.in similarity index 99% rename from lib/c-ares-1.31.0/docs/Makefile.in rename to lib/c-ares-1.32.0/docs/Makefile.in index d4bb7795a58..6abb0e7f6bd 100644 --- a/lib/c-ares-1.31.0/docs/Makefile.in +++ b/lib/c-ares-1.32.0/docs/Makefile.in @@ -378,6 +378,10 @@ MANPAGES = ares_cancel.3 \ ares_dns_rec_type_tostr.3 \ ares_dns_rec_type_t.3 \ ares_dns_rr.3 \ + ares_dns_rr_add_abin.3 \ + ares_dns_rr_del_abin.3 \ + ares_dns_rr_get_abin.3 \ + ares_dns_rr_get_abin_cnt.3 \ ares_dns_rr_get_addr.3 \ ares_dns_rr_get_addr6.3 \ ares_dns_rr_get_bin.3 \ diff --git a/lib/c-ares-1.31.0/docs/Makefile.inc b/lib/c-ares-1.32.0/docs/Makefile.inc similarity index 97% rename from lib/c-ares-1.31.0/docs/Makefile.inc rename to lib/c-ares-1.32.0/docs/Makefile.inc index 097bf26589b..83d85ebf1d4 100644 --- a/lib/c-ares-1.31.0/docs/Makefile.inc +++ b/lib/c-ares-1.32.0/docs/Makefile.inc @@ -40,6 +40,10 @@ MANPAGES = ares_cancel.3 \ ares_dns_rec_type_tostr.3 \ ares_dns_rec_type_t.3 \ ares_dns_rr.3 \ + ares_dns_rr_add_abin.3 \ + ares_dns_rr_del_abin.3 \ + ares_dns_rr_get_abin.3 \ + ares_dns_rr_get_abin_cnt.3 \ ares_dns_rr_get_addr.3 \ ares_dns_rr_get_addr6.3 \ ares_dns_rr_get_bin.3 \ diff --git a/lib/c-ares-1.31.0/docs/adig.1 b/lib/c-ares-1.32.0/docs/adig.1 similarity index 100% rename from lib/c-ares-1.31.0/docs/adig.1 rename to lib/c-ares-1.32.0/docs/adig.1 diff --git a/lib/c-ares-1.31.0/docs/ahost.1 b/lib/c-ares-1.32.0/docs/ahost.1 similarity index 100% rename from lib/c-ares-1.31.0/docs/ahost.1 rename to lib/c-ares-1.32.0/docs/ahost.1 diff --git a/lib/c-ares-1.31.0/docs/ares_cancel.3 b/lib/c-ares-1.32.0/docs/ares_cancel.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_cancel.3 rename to lib/c-ares-1.32.0/docs/ares_cancel.3 diff --git a/lib/c-ares-1.31.0/docs/ares_create_query.3 b/lib/c-ares-1.32.0/docs/ares_create_query.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_create_query.3 rename to lib/c-ares-1.32.0/docs/ares_create_query.3 diff --git a/lib/c-ares-1.31.0/docs/ares_destroy.3 b/lib/c-ares-1.32.0/docs/ares_destroy.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_destroy.3 rename to lib/c-ares-1.32.0/docs/ares_destroy.3 diff --git a/lib/c-ares-1.31.0/docs/ares_destroy_options.3 b/lib/c-ares-1.32.0/docs/ares_destroy_options.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_destroy_options.3 rename to lib/c-ares-1.32.0/docs/ares_destroy_options.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_class_fromstr.3 b/lib/c-ares-1.32.0/docs/ares_dns_class_fromstr.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_class_fromstr.3 rename to lib/c-ares-1.32.0/docs/ares_dns_class_fromstr.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_class_t.3 b/lib/c-ares-1.32.0/docs/ares_dns_class_t.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_class_t.3 rename to lib/c-ares-1.32.0/docs/ares_dns_class_t.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_class_tostr.3 b/lib/c-ares-1.32.0/docs/ares_dns_class_tostr.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_class_tostr.3 rename to lib/c-ares-1.32.0/docs/ares_dns_class_tostr.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_datatype_t.3 b/lib/c-ares-1.32.0/docs/ares_dns_datatype_t.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_datatype_t.3 rename to lib/c-ares-1.32.0/docs/ares_dns_datatype_t.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_flags_t.3 b/lib/c-ares-1.32.0/docs/ares_dns_flags_t.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_flags_t.3 rename to lib/c-ares-1.32.0/docs/ares_dns_flags_t.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_mapping.3 b/lib/c-ares-1.32.0/docs/ares_dns_mapping.3 similarity index 96% rename from lib/c-ares-1.31.0/docs/ares_dns_mapping.3 rename to lib/c-ares-1.32.0/docs/ares_dns_mapping.3 index 690ad62be23..451839153c5 100644 --- a/lib/c-ares-1.31.0/docs/ares_dns_mapping.3 +++ b/lib/c-ares-1.32.0/docs/ares_dns_mapping.3 @@ -89,6 +89,13 @@ set and \fIares_dns_rr_get_bin(3)\fP to get. - Array of options. 16bit identifier, Binary data. Use \fIares_dns_rr_set_opt(3)\fP to set and \fIares_dns_rr_get_opt(3)\fP to get. .br +.B ARES_DATATYPE_ABINP +- Array of binary data, but likely printable. Guaranteed to have a NULL terminator +for convenience (not included in length). Use \fIares_dns_rr_add_abin(3)\fP to +set and \fIares_dns_rr_get_abin(3)\fP to get. Can also use +\fIares_dns_rr_set_bin(3)\fP and \fIares_dns_rr_get_bin(3)\fP if only concatenated +strings are desired. +.br .RE .B ares_dns_opt_datatype_t - diff --git a/lib/c-ares-1.31.0/docs/ares_dns_opcode_t.3 b/lib/c-ares-1.32.0/docs/ares_dns_opcode_t.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_opcode_t.3 rename to lib/c-ares-1.32.0/docs/ares_dns_opcode_t.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_opcode_tostr.3 b/lib/c-ares-1.32.0/docs/ares_dns_opcode_tostr.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_opcode_tostr.3 rename to lib/c-ares-1.32.0/docs/ares_dns_opcode_tostr.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_opt_datatype_t.3 b/lib/c-ares-1.32.0/docs/ares_dns_opt_datatype_t.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_opt_datatype_t.3 rename to lib/c-ares-1.32.0/docs/ares_dns_opt_datatype_t.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_opt_get_datatype.3 b/lib/c-ares-1.32.0/docs/ares_dns_opt_get_datatype.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_opt_get_datatype.3 rename to lib/c-ares-1.32.0/docs/ares_dns_opt_get_datatype.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_opt_get_name.3 b/lib/c-ares-1.32.0/docs/ares_dns_opt_get_name.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_opt_get_name.3 rename to lib/c-ares-1.32.0/docs/ares_dns_opt_get_name.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_parse.3 b/lib/c-ares-1.32.0/docs/ares_dns_parse.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_parse.3 rename to lib/c-ares-1.32.0/docs/ares_dns_parse.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rcode_t.3 b/lib/c-ares-1.32.0/docs/ares_dns_rcode_t.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rcode_t.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rcode_t.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rcode_tostr.3 b/lib/c-ares-1.32.0/docs/ares_dns_rcode_tostr.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rcode_tostr.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rcode_tostr.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rec_type_fromstr.3 b/lib/c-ares-1.32.0/docs/ares_dns_rec_type_fromstr.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rec_type_fromstr.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rec_type_fromstr.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rec_type_t.3 b/lib/c-ares-1.32.0/docs/ares_dns_rec_type_t.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rec_type_t.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rec_type_t.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rec_type_tostr.3 b/lib/c-ares-1.32.0/docs/ares_dns_rec_type_tostr.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rec_type_tostr.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rec_type_tostr.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_record.3 b/lib/c-ares-1.32.0/docs/ares_dns_record.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_record.3 rename to lib/c-ares-1.32.0/docs/ares_dns_record.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_record_create.3 b/lib/c-ares-1.32.0/docs/ares_dns_record_create.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_record_create.3 rename to lib/c-ares-1.32.0/docs/ares_dns_record_create.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_record_destroy.3 b/lib/c-ares-1.32.0/docs/ares_dns_record_destroy.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_record_destroy.3 rename to lib/c-ares-1.32.0/docs/ares_dns_record_destroy.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_record_duplicate.3 b/lib/c-ares-1.32.0/docs/ares_dns_record_duplicate.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_record_duplicate.3 rename to lib/c-ares-1.32.0/docs/ares_dns_record_duplicate.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_record_get_flags.3 b/lib/c-ares-1.32.0/docs/ares_dns_record_get_flags.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_record_get_flags.3 rename to lib/c-ares-1.32.0/docs/ares_dns_record_get_flags.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_record_get_id.3 b/lib/c-ares-1.32.0/docs/ares_dns_record_get_id.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_record_get_id.3 rename to lib/c-ares-1.32.0/docs/ares_dns_record_get_id.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_record_get_opcode.3 b/lib/c-ares-1.32.0/docs/ares_dns_record_get_opcode.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_record_get_opcode.3 rename to lib/c-ares-1.32.0/docs/ares_dns_record_get_opcode.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_record_get_rcode.3 b/lib/c-ares-1.32.0/docs/ares_dns_record_get_rcode.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_record_get_rcode.3 rename to lib/c-ares-1.32.0/docs/ares_dns_record_get_rcode.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_record_query_add.3 b/lib/c-ares-1.32.0/docs/ares_dns_record_query_add.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_record_query_add.3 rename to lib/c-ares-1.32.0/docs/ares_dns_record_query_add.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_record_query_cnt.3 b/lib/c-ares-1.32.0/docs/ares_dns_record_query_cnt.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_record_query_cnt.3 rename to lib/c-ares-1.32.0/docs/ares_dns_record_query_cnt.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_record_query_get.3 b/lib/c-ares-1.32.0/docs/ares_dns_record_query_get.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_record_query_get.3 rename to lib/c-ares-1.32.0/docs/ares_dns_record_query_get.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_record_query_set_name.3 b/lib/c-ares-1.32.0/docs/ares_dns_record_query_set_name.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_record_query_set_name.3 rename to lib/c-ares-1.32.0/docs/ares_dns_record_query_set_name.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_record_query_set_type.3 b/lib/c-ares-1.32.0/docs/ares_dns_record_query_set_type.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_record_query_set_type.3 rename to lib/c-ares-1.32.0/docs/ares_dns_record_query_set_type.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_record_rr_add.3 b/lib/c-ares-1.32.0/docs/ares_dns_record_rr_add.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_record_rr_add.3 rename to lib/c-ares-1.32.0/docs/ares_dns_record_rr_add.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_record_rr_cnt.3 b/lib/c-ares-1.32.0/docs/ares_dns_record_rr_cnt.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_record_rr_cnt.3 rename to lib/c-ares-1.32.0/docs/ares_dns_record_rr_cnt.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_record_rr_del.3 b/lib/c-ares-1.32.0/docs/ares_dns_record_rr_del.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_record_rr_del.3 rename to lib/c-ares-1.32.0/docs/ares_dns_record_rr_del.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_record_rr_get.3 b/lib/c-ares-1.32.0/docs/ares_dns_record_rr_get.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_record_rr_get.3 rename to lib/c-ares-1.32.0/docs/ares_dns_record_rr_get.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_record_rr_get_const.3 b/lib/c-ares-1.32.0/docs/ares_dns_record_rr_get_const.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_record_rr_get_const.3 rename to lib/c-ares-1.32.0/docs/ares_dns_record_rr_get_const.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr.3 similarity index 88% rename from lib/c-ares-1.31.0/docs/ares_dns_rr.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr.3 index 1294fd55a44..9d5ab37515e 100644 --- a/lib/c-ares-1.31.0/docs/ares_dns_rr.3 +++ b/lib/c-ares-1.32.0/docs/ares_dns_rr.3 @@ -5,12 +5,14 @@ .SH NAME ares_dns_record_rr_add, ares_dns_record_rr_cnt, ares_dns_record_rr_del, ares_dns_record_rr_get, ares_dns_record_rr_get_const, ares_dns_rr_get_addr, -ares_dns_rr_get_addr6, ares_dns_rr_get_bin, ares_dns_rr_get_class, +ares_dns_rr_get_addr6, ares_dns_rr_get_bin, ares_dns_rr_get_abin_cnt, +ares_dns_rr_get_abin, ares_dns_rr_get_class, ares_dns_rr_get_name, ares_dns_rr_get_opt, ares_dns_rr_get_opt_byid, ares_dns_rr_get_opt_cnt, ares_dns_rr_get_str, ares_dns_rr_get_ttl, ares_dns_rr_get_type, ares_dns_rr_get_u16, ares_dns_rr_get_u32, ares_dns_rr_get_u8, ares_dns_rr_key_t, ares_dns_rr_set_addr, -ares_dns_rr_set_addr6, ares_dns_rr_set_bin, ares_dns_rr_set_opt, +ares_dns_rr_set_addr6, ares_dns_rr_set_bin, ares_dns_rr_add_abin, +ares_dns_rr_del_abin, ares_dns_rr_set_opt, ares_dns_rr_set_str, ares_dns_rr_set_u16, ares_dns_rr_set_u32, ares_dns_rr_set_u8, ares_dns_section_t, ares_tlsa_match_t, ares_tlsa_selector_t, ares_tlsa_usage_t \- @@ -79,6 +81,15 @@ ares_status_t ares_dns_rr_set_bin(ares_dns_rr_t *dns_rr, const unsigned char *val, size_t len); +ares_status_t ares_dns_rr_add_abin(ares_dns_rr_t *dns_rr, + ares_dns_rr_key_t key, + const unsigned char *val, + size_t len); + +ares_status_t ares_dns_rr_del_abin(ares_dns_rr_t *dns_rr, + ares_dns_rr_key_t key, + size_t idx); + ares_status_t ares_dns_rr_set_opt(ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key, unsigned short opt, @@ -107,6 +118,13 @@ const unsigned char *ares_dns_rr_get_bin(const ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key, size_t *len); +size_t ares_dns_rr_get_abin_cnt(const ares_dns_rr_t *dns_rr, + ares_dns_rr_key_t key); + +const unsigned char *ares_dns_rr_get_abin(const ares_dns_rr_t *dns_rr, + ares_dns_rr_key_t key, size_t idx, + size_t *len); + size_t ares_dns_rr_get_opt_cnt(const ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key); @@ -188,7 +206,7 @@ Keys used for handling RR record parameters: - MX Record. Exchange, domain. Datatype: \fIARES_DATATYPE_NAME\fP .br .B ARES_RR_TXT_DATA -- TXT Record. Data. Datatype: \fIARES_DATATYPE_BINP\fP +- TXT Record. Data. Datatype: \fIARES_DATATYPE_ABINP\fP .br .B ARES_RR_SIG_TYPE_COVERED - SIG Record. Type Covered. Datatype: \fIARES_DATATYPE_U16\fP @@ -497,7 +515,7 @@ parameter, and the value is provided in the .IR val parameter. -The \fIares_dns_rr_set_bin(3)\fP function is used to set an binary value for the +The \fIares_dns_rr_set_bin(3)\fP function is used to set a binary value for the associated resource record key/parameter when the datatype is \fIARES_DATATYPE_BIN\fP or \fIARES_DATATYPE_BINP\fP. The resource record to be modified is provided in the @@ -510,6 +528,30 @@ parameter. And the associated value length is provided in the .IR len parameter. +The \fIares_dns_rr_add_abin(3)\fP function is used to append a binary value in +the array for the associated resource record key/parameter when the datatype +is \fIARES_DATATYPE_ABINP\fP. +The resource record to be modified is provided in the +.IR dns_rr +parameter, the key/parameter is provided in the +.IR key +parameter, and the value is provided in the +.IR val +parameter. And the associated value length is provided in the +.IR len +parameter. + +The \fIares_dns_rr_del_abin(3)\fP function is used to delete a binary value in +the array for the associated resource record key/parameter when the datatype +is \fIARES_DATATYPE_ABINP\fP. +The resource record to be modified is provided in the +.IR dns_rr +parameter, the key/parameter is provided in the +.IR key +parameter, and the index to remove is provided in the +.IR idx +parameter. + The \fIares_dns_rr_set_opt(3)\fP function is used to set option/parameter keys and values for the resource record when the datatype if \fIARES_DATATYPE_OPT\fP. The resource record to be modified is provided in the @@ -584,6 +626,26 @@ parameter and the key/parameter to retrieve is provided in the parameter, and length is stored into the variable pointed to by .IR len. +The \fIares_dns_rr_get_abin_cnt(3)\fP function is used to retrieve the count +of the array of stored binary values from the resource record when the datatype +is \fIARES_DATATYPE_ABINP\fP. +The resource record is provided in the +.IR dns_rr +parameter and the key/parameter to retrieve is provided in the +.IR key +parameter. + +The \fIares_dns_rr_get_abin(3)\fP function is used to retrive binary data from +the resource record array when the datatype is \fIARES_DATATYPE_ABINP\fP. +The resource record is provided in the +.IR dns_rr +parameter and the key/parameter to retrieve is provided in the +.IR key +parameter, and the index to retrieve from the array is provided by the +.IR idx +parameter, and length is stored into the variable pointed to by +.IR len. + The \fIares_dns_rr_get_opt_cnt(3)\fP function is used to retrieve the count of options/parameters associated with the resource record when the datatype is \fIARES_DATATYPE_OPT\fP. @@ -630,8 +692,9 @@ respective counts. \fIares_dns_rr_set_addr(3)\fP, \fIares_dns_rr_set_addr6(3)\fP, \fIares_dns_rr_set_str(3)\fP, \fIares_dns_rr_set_u8(3)\fP, \fIares_dns_rr_set_u16(3)\fP, \fIares_dns_rr_set_u32(3)\fP, -\fIares_dns_rr_set_bin(3)\fP, and \fIares_dns_rr_set_opt(3)\fP all -return an \fIares_status_t\fP error code. +\fIares_dns_rr_set_bin(3)\fP, \fIares_dns_rr_add_abin(3)\fP, +\fIares_dns_rr_del_abin(3)\fP, +and \fIares_dns_rr_set_opt(3)\fP all return an \fIares_status_t\fP error code. .B ARES_SUCCESS is returned on success, .B ARES_ENOMEM @@ -645,7 +708,8 @@ is returned on misuse. \fIares_dns_rr_get_addr(3)\fP, \fIares_dns_rr_get_addr6(3)\fP, \fIares_dns_rr_get_str(3)\fP, \fIares_dns_rr_get_u8(3)\fP, \fIares_dns_rr_get_u16(3)\fP, \fIares_dns_rr_get_u32(3)\fP, -\fIares_dns_rr_get_bin(3)\fP, \fIares_dns_rr_get_opt(3)\fP all return their +\fIares_dns_rr_get_bin(3)\fP, \fIares_dns_rr_get_abin_cnt(3)\fP, +\fIares_dns_rr_get_abin(3)\fP, \fIares_dns_rr_get_opt(3)\fP all return their prescribed datatype values and in general can't fail except for misuse cases, in which a 0 (or NULL) may be returned, however 0 can also be a valid return value for most of these functions. diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr_get_addr.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_add_abin.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rr_get_addr.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_add_abin.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr_get_addr6.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_del_abin.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rr_get_addr6.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_del_abin.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr_get_bin.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_get_abin.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rr_get_bin.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_get_abin.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr_get_class.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_get_abin_cnt.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rr_get_class.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_get_abin_cnt.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr_get_name.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_get_addr.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rr_get_name.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_get_addr.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr_get_opt.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_get_addr6.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rr_get_opt.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_get_addr6.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr_get_opt_byid.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_get_bin.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rr_get_opt_byid.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_get_bin.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr_get_opt_cnt.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_get_class.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rr_get_opt_cnt.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_get_class.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr_get_keys.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_get_keys.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rr_get_keys.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_get_keys.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr_get_str.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_get_name.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rr_get_str.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_get_name.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr_get_ttl.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_get_opt.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rr_get_ttl.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_get_opt.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr_get_type.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_get_opt_byid.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rr_get_type.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_get_opt_byid.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr_get_u16.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_get_opt_cnt.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rr_get_u16.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_get_opt_cnt.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr_get_u32.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_get_str.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rr_get_u32.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_get_str.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr_get_u8.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_get_ttl.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rr_get_u8.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_get_ttl.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr_key_t.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_get_type.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rr_key_t.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_get_type.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr_set_addr.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_get_u16.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rr_set_addr.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_get_u16.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr_set_addr6.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_get_u32.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rr_set_addr6.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_get_u32.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr_set_bin.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_get_u8.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rr_set_bin.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_get_u8.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr_key_datatype.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_key_datatype.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rr_key_datatype.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_key_datatype.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr_set_opt.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_key_t.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rr_set_opt.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_key_t.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr_key_to_rec_type.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_key_to_rec_type.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rr_key_to_rec_type.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_key_to_rec_type.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr_key_tostr.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_key_tostr.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rr_key_tostr.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_key_tostr.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr_set_str.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_set_addr.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rr_set_str.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_set_addr.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr_set_u16.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_set_addr6.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rr_set_u16.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_set_addr6.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr_set_u32.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_set_bin.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rr_set_u32.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_set_bin.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_rr_set_u8.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_set_opt.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_rr_set_u8.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_set_opt.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_section_t.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_set_str.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_section_t.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_set_str.3 diff --git a/lib/c-ares-1.31.0/docs/ares_tlsa_match_t.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_set_u16.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_tlsa_match_t.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_set_u16.3 diff --git a/lib/c-ares-1.31.0/docs/ares_tlsa_selector_t.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_set_u32.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_tlsa_selector_t.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_set_u32.3 diff --git a/lib/c-ares-1.31.0/docs/ares_tlsa_usage_t.3 b/lib/c-ares-1.32.0/docs/ares_dns_rr_set_u8.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_tlsa_usage_t.3 rename to lib/c-ares-1.32.0/docs/ares_dns_rr_set_u8.3 diff --git a/lib/c-ares-1.32.0/docs/ares_dns_section_t.3 b/lib/c-ares-1.32.0/docs/ares_dns_section_t.3 new file mode 100644 index 00000000000..b93e4cd4e37 --- /dev/null +++ b/lib/c-ares-1.32.0/docs/ares_dns_section_t.3 @@ -0,0 +1,3 @@ +.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" SPDX-License-Identifier: MIT +.so man3/ares_dns_rr.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_section_tostr.3 b/lib/c-ares-1.32.0/docs/ares_dns_section_tostr.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_section_tostr.3 rename to lib/c-ares-1.32.0/docs/ares_dns_section_tostr.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dns_write.3 b/lib/c-ares-1.32.0/docs/ares_dns_write.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dns_write.3 rename to lib/c-ares-1.32.0/docs/ares_dns_write.3 diff --git a/lib/c-ares-1.31.0/docs/ares_dup.3 b/lib/c-ares-1.32.0/docs/ares_dup.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_dup.3 rename to lib/c-ares-1.32.0/docs/ares_dup.3 diff --git a/lib/c-ares-1.31.0/docs/ares_expand_name.3 b/lib/c-ares-1.32.0/docs/ares_expand_name.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_expand_name.3 rename to lib/c-ares-1.32.0/docs/ares_expand_name.3 diff --git a/lib/c-ares-1.31.0/docs/ares_expand_string.3 b/lib/c-ares-1.32.0/docs/ares_expand_string.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_expand_string.3 rename to lib/c-ares-1.32.0/docs/ares_expand_string.3 diff --git a/lib/c-ares-1.31.0/docs/ares_fds.3 b/lib/c-ares-1.32.0/docs/ares_fds.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_fds.3 rename to lib/c-ares-1.32.0/docs/ares_fds.3 diff --git a/lib/c-ares-1.31.0/docs/ares_free_data.3 b/lib/c-ares-1.32.0/docs/ares_free_data.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_free_data.3 rename to lib/c-ares-1.32.0/docs/ares_free_data.3 diff --git a/lib/c-ares-1.31.0/docs/ares_free_hostent.3 b/lib/c-ares-1.32.0/docs/ares_free_hostent.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_free_hostent.3 rename to lib/c-ares-1.32.0/docs/ares_free_hostent.3 diff --git a/lib/c-ares-1.31.0/docs/ares_free_string.3 b/lib/c-ares-1.32.0/docs/ares_free_string.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_free_string.3 rename to lib/c-ares-1.32.0/docs/ares_free_string.3 diff --git a/lib/c-ares-1.31.0/docs/ares_freeaddrinfo.3 b/lib/c-ares-1.32.0/docs/ares_freeaddrinfo.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_freeaddrinfo.3 rename to lib/c-ares-1.32.0/docs/ares_freeaddrinfo.3 diff --git a/lib/c-ares-1.31.0/docs/ares_get_servers.3 b/lib/c-ares-1.32.0/docs/ares_get_servers.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_get_servers.3 rename to lib/c-ares-1.32.0/docs/ares_get_servers.3 diff --git a/lib/c-ares-1.31.0/docs/ares_get_servers_csv.3 b/lib/c-ares-1.32.0/docs/ares_get_servers_csv.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_get_servers_csv.3 rename to lib/c-ares-1.32.0/docs/ares_get_servers_csv.3 diff --git a/lib/c-ares-1.31.0/docs/ares_get_servers_ports.3 b/lib/c-ares-1.32.0/docs/ares_get_servers_ports.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_get_servers_ports.3 rename to lib/c-ares-1.32.0/docs/ares_get_servers_ports.3 diff --git a/lib/c-ares-1.31.0/docs/ares_getaddrinfo.3 b/lib/c-ares-1.32.0/docs/ares_getaddrinfo.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_getaddrinfo.3 rename to lib/c-ares-1.32.0/docs/ares_getaddrinfo.3 diff --git a/lib/c-ares-1.31.0/docs/ares_gethostbyaddr.3 b/lib/c-ares-1.32.0/docs/ares_gethostbyaddr.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_gethostbyaddr.3 rename to lib/c-ares-1.32.0/docs/ares_gethostbyaddr.3 diff --git a/lib/c-ares-1.31.0/docs/ares_gethostbyname.3 b/lib/c-ares-1.32.0/docs/ares_gethostbyname.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_gethostbyname.3 rename to lib/c-ares-1.32.0/docs/ares_gethostbyname.3 diff --git a/lib/c-ares-1.31.0/docs/ares_gethostbyname_file.3 b/lib/c-ares-1.32.0/docs/ares_gethostbyname_file.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_gethostbyname_file.3 rename to lib/c-ares-1.32.0/docs/ares_gethostbyname_file.3 diff --git a/lib/c-ares-1.31.0/docs/ares_getnameinfo.3 b/lib/c-ares-1.32.0/docs/ares_getnameinfo.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_getnameinfo.3 rename to lib/c-ares-1.32.0/docs/ares_getnameinfo.3 diff --git a/lib/c-ares-1.31.0/docs/ares_getsock.3 b/lib/c-ares-1.32.0/docs/ares_getsock.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_getsock.3 rename to lib/c-ares-1.32.0/docs/ares_getsock.3 diff --git a/lib/c-ares-1.31.0/docs/ares_inet_ntop.3 b/lib/c-ares-1.32.0/docs/ares_inet_ntop.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_inet_ntop.3 rename to lib/c-ares-1.32.0/docs/ares_inet_ntop.3 diff --git a/lib/c-ares-1.31.0/docs/ares_inet_pton.3 b/lib/c-ares-1.32.0/docs/ares_inet_pton.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_inet_pton.3 rename to lib/c-ares-1.32.0/docs/ares_inet_pton.3 diff --git a/lib/c-ares-1.31.0/docs/ares_init.3 b/lib/c-ares-1.32.0/docs/ares_init.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_init.3 rename to lib/c-ares-1.32.0/docs/ares_init.3 diff --git a/lib/c-ares-1.31.0/docs/ares_init_options.3 b/lib/c-ares-1.32.0/docs/ares_init_options.3 similarity index 91% rename from lib/c-ares-1.31.0/docs/ares_init_options.3 rename to lib/c-ares-1.32.0/docs/ares_init_options.3 index 3d983ebe6dd..694beb5ed28 100644 --- a/lib/c-ares-1.31.0/docs/ares_init_options.3 +++ b/lib/c-ares-1.32.0/docs/ares_init_options.3 @@ -130,27 +130,35 @@ v1.22, this is on by default if flags are otherwise not set. .B ARES_FLAG_NO_DFLT_SVR Do not attempt to add a default local named server if there are no other servers available. Instead, fail initialization with \fIARES_ENOSERVER\fP. +.TP 23 +.B ARES_FLAG_DNS0x20 +Enable support for DNS 0x20 as per https://datatracker.ietf.org/doc/html/draft-vixie-dnsext-dns0x20-00 +which adds additional entropy to the request by randomizing the case of the +query name. Integrators need to ensure they treat DNS name responses as +case-insensitive. In rare circumstances this may cause the inability to lookup +certain domains if the upstream server or the authoritative server for the +domain is non-compliant. .RE .TP 18 .B ARES_OPT_TIMEOUT .B int \fItimeout\fP; .br The number of seconds each name server is given to respond to a query on the -first try. (After the first try, the timeout algorithm becomes more -complicated, but scales linearly with the value of \fItimeout\fP.) The -default is two seconds. This option is being deprecated by -\fIARES_OPT_TIMEOUTMS\fP starting in c-ares 1.5.2. +first try. See \fIARES_OPT_TIMEOUTMS\fP which this value is converted into. .TP 18 .B ARES_OPT_TIMEOUTMS .B int \fItimeout\fP; .br The number of milliseconds each name server is given to respond to a query on -the first try. (After the first try, the timeout algorithm becomes more -complicated, but scales linearly with the value of \fItimeout\fP.) The -default is two seconds. Note that this option is specified with the same -struct field as the former \fIARES_OPT_TIMEOUT\fP, it is but the option bits -that tell c-ares how to interpret the number. This option was added in c-ares -1.5.2. +the first try of any given server. The default is two seconds, however any +value below 250ms will automatically be set to 250ms (roughly the RTT half-way +around the world). Note that this option is specified with the same struct field +as the former \fIARES_OPT_TIMEOUT\fP, it is but the option bits that tell c-ares +how to interpret the number. This option was added in c-ares 1.5.2. + +As of c-ares 1.32.0, this option is only honored on the first successful query +to any given server, after that the timeout is automatically calculated based +on prior query history. .TP 18 .B ARES_OPT_TRIES .B int \fItries\fP; @@ -227,7 +235,9 @@ The value of .I sock_state_cb_data will be passed as the .I data -argument. +argument. The channel lock is held during this callback, if in a multithreaded +application, care must be taken to ensure lock order is correct to be able to +handle this and avoid deadlocks. Cannot be used with \fBARES_OPT_EVENT_THREAD\fP. .TP 18 diff --git a/lib/c-ares-1.31.0/docs/ares_library_cleanup.3 b/lib/c-ares-1.32.0/docs/ares_library_cleanup.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_library_cleanup.3 rename to lib/c-ares-1.32.0/docs/ares_library_cleanup.3 diff --git a/lib/c-ares-1.31.0/docs/ares_library_init.3 b/lib/c-ares-1.32.0/docs/ares_library_init.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_library_init.3 rename to lib/c-ares-1.32.0/docs/ares_library_init.3 diff --git a/lib/c-ares-1.31.0/docs/ares_library_init_android.3 b/lib/c-ares-1.32.0/docs/ares_library_init_android.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_library_init_android.3 rename to lib/c-ares-1.32.0/docs/ares_library_init_android.3 diff --git a/lib/c-ares-1.31.0/docs/ares_library_initialized.3 b/lib/c-ares-1.32.0/docs/ares_library_initialized.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_library_initialized.3 rename to lib/c-ares-1.32.0/docs/ares_library_initialized.3 diff --git a/lib/c-ares-1.31.0/docs/ares_mkquery.3 b/lib/c-ares-1.32.0/docs/ares_mkquery.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_mkquery.3 rename to lib/c-ares-1.32.0/docs/ares_mkquery.3 diff --git a/lib/c-ares-1.31.0/docs/ares_opt_param_t.3 b/lib/c-ares-1.32.0/docs/ares_opt_param_t.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_opt_param_t.3 rename to lib/c-ares-1.32.0/docs/ares_opt_param_t.3 diff --git a/lib/c-ares-1.31.0/docs/ares_parse_a_reply.3 b/lib/c-ares-1.32.0/docs/ares_parse_a_reply.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_parse_a_reply.3 rename to lib/c-ares-1.32.0/docs/ares_parse_a_reply.3 diff --git a/lib/c-ares-1.31.0/docs/ares_parse_aaaa_reply.3 b/lib/c-ares-1.32.0/docs/ares_parse_aaaa_reply.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_parse_aaaa_reply.3 rename to lib/c-ares-1.32.0/docs/ares_parse_aaaa_reply.3 diff --git a/lib/c-ares-1.31.0/docs/ares_parse_caa_reply.3 b/lib/c-ares-1.32.0/docs/ares_parse_caa_reply.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_parse_caa_reply.3 rename to lib/c-ares-1.32.0/docs/ares_parse_caa_reply.3 diff --git a/lib/c-ares-1.31.0/docs/ares_parse_mx_reply.3 b/lib/c-ares-1.32.0/docs/ares_parse_mx_reply.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_parse_mx_reply.3 rename to lib/c-ares-1.32.0/docs/ares_parse_mx_reply.3 diff --git a/lib/c-ares-1.31.0/docs/ares_parse_naptr_reply.3 b/lib/c-ares-1.32.0/docs/ares_parse_naptr_reply.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_parse_naptr_reply.3 rename to lib/c-ares-1.32.0/docs/ares_parse_naptr_reply.3 diff --git a/lib/c-ares-1.31.0/docs/ares_parse_ns_reply.3 b/lib/c-ares-1.32.0/docs/ares_parse_ns_reply.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_parse_ns_reply.3 rename to lib/c-ares-1.32.0/docs/ares_parse_ns_reply.3 diff --git a/lib/c-ares-1.31.0/docs/ares_parse_ptr_reply.3 b/lib/c-ares-1.32.0/docs/ares_parse_ptr_reply.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_parse_ptr_reply.3 rename to lib/c-ares-1.32.0/docs/ares_parse_ptr_reply.3 diff --git a/lib/c-ares-1.31.0/docs/ares_parse_soa_reply.3 b/lib/c-ares-1.32.0/docs/ares_parse_soa_reply.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_parse_soa_reply.3 rename to lib/c-ares-1.32.0/docs/ares_parse_soa_reply.3 diff --git a/lib/c-ares-1.31.0/docs/ares_parse_srv_reply.3 b/lib/c-ares-1.32.0/docs/ares_parse_srv_reply.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_parse_srv_reply.3 rename to lib/c-ares-1.32.0/docs/ares_parse_srv_reply.3 diff --git a/lib/c-ares-1.31.0/docs/ares_parse_txt_reply.3 b/lib/c-ares-1.32.0/docs/ares_parse_txt_reply.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_parse_txt_reply.3 rename to lib/c-ares-1.32.0/docs/ares_parse_txt_reply.3 diff --git a/lib/c-ares-1.31.0/docs/ares_parse_uri_reply.3 b/lib/c-ares-1.32.0/docs/ares_parse_uri_reply.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_parse_uri_reply.3 rename to lib/c-ares-1.32.0/docs/ares_parse_uri_reply.3 diff --git a/lib/c-ares-1.31.0/docs/ares_process.3 b/lib/c-ares-1.32.0/docs/ares_process.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_process.3 rename to lib/c-ares-1.32.0/docs/ares_process.3 diff --git a/lib/c-ares-1.31.0/docs/ares_query.3 b/lib/c-ares-1.32.0/docs/ares_query.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_query.3 rename to lib/c-ares-1.32.0/docs/ares_query.3 diff --git a/lib/c-ares-1.31.0/docs/ares_query_dnsrec.3 b/lib/c-ares-1.32.0/docs/ares_query_dnsrec.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_query_dnsrec.3 rename to lib/c-ares-1.32.0/docs/ares_query_dnsrec.3 diff --git a/lib/c-ares-1.31.0/docs/ares_queue.3 b/lib/c-ares-1.32.0/docs/ares_queue.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_queue.3 rename to lib/c-ares-1.32.0/docs/ares_queue.3 diff --git a/lib/c-ares-1.31.0/docs/ares_queue_active_queries.3 b/lib/c-ares-1.32.0/docs/ares_queue_active_queries.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_queue_active_queries.3 rename to lib/c-ares-1.32.0/docs/ares_queue_active_queries.3 diff --git a/lib/c-ares-1.31.0/docs/ares_queue_wait_empty.3 b/lib/c-ares-1.32.0/docs/ares_queue_wait_empty.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_queue_wait_empty.3 rename to lib/c-ares-1.32.0/docs/ares_queue_wait_empty.3 diff --git a/lib/c-ares-1.31.0/docs/ares_reinit.3 b/lib/c-ares-1.32.0/docs/ares_reinit.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_reinit.3 rename to lib/c-ares-1.32.0/docs/ares_reinit.3 diff --git a/lib/c-ares-1.31.0/docs/ares_save_options.3 b/lib/c-ares-1.32.0/docs/ares_save_options.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_save_options.3 rename to lib/c-ares-1.32.0/docs/ares_save_options.3 diff --git a/lib/c-ares-1.31.0/docs/ares_search.3 b/lib/c-ares-1.32.0/docs/ares_search.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_search.3 rename to lib/c-ares-1.32.0/docs/ares_search.3 diff --git a/lib/c-ares-1.31.0/docs/ares_search_dnsrec.3 b/lib/c-ares-1.32.0/docs/ares_search_dnsrec.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_search_dnsrec.3 rename to lib/c-ares-1.32.0/docs/ares_search_dnsrec.3 diff --git a/lib/c-ares-1.31.0/docs/ares_send.3 b/lib/c-ares-1.32.0/docs/ares_send.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_send.3 rename to lib/c-ares-1.32.0/docs/ares_send.3 diff --git a/lib/c-ares-1.31.0/docs/ares_send_dnsrec.3 b/lib/c-ares-1.32.0/docs/ares_send_dnsrec.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_send_dnsrec.3 rename to lib/c-ares-1.32.0/docs/ares_send_dnsrec.3 diff --git a/lib/c-ares-1.31.0/docs/ares_set_local_dev.3 b/lib/c-ares-1.32.0/docs/ares_set_local_dev.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_set_local_dev.3 rename to lib/c-ares-1.32.0/docs/ares_set_local_dev.3 diff --git a/lib/c-ares-1.31.0/docs/ares_set_local_ip4.3 b/lib/c-ares-1.32.0/docs/ares_set_local_ip4.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_set_local_ip4.3 rename to lib/c-ares-1.32.0/docs/ares_set_local_ip4.3 diff --git a/lib/c-ares-1.31.0/docs/ares_set_local_ip6.3 b/lib/c-ares-1.32.0/docs/ares_set_local_ip6.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_set_local_ip6.3 rename to lib/c-ares-1.32.0/docs/ares_set_local_ip6.3 diff --git a/lib/c-ares-1.31.0/docs/ares_set_server_state_callback.3 b/lib/c-ares-1.32.0/docs/ares_set_server_state_callback.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_set_server_state_callback.3 rename to lib/c-ares-1.32.0/docs/ares_set_server_state_callback.3 diff --git a/lib/c-ares-1.31.0/docs/ares_set_servers.3 b/lib/c-ares-1.32.0/docs/ares_set_servers.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_set_servers.3 rename to lib/c-ares-1.32.0/docs/ares_set_servers.3 diff --git a/lib/c-ares-1.31.0/docs/ares_set_servers_csv.3 b/lib/c-ares-1.32.0/docs/ares_set_servers_csv.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_set_servers_csv.3 rename to lib/c-ares-1.32.0/docs/ares_set_servers_csv.3 diff --git a/lib/c-ares-1.31.0/docs/ares_set_servers_ports.3 b/lib/c-ares-1.32.0/docs/ares_set_servers_ports.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_set_servers_ports.3 rename to lib/c-ares-1.32.0/docs/ares_set_servers_ports.3 diff --git a/lib/c-ares-1.31.0/docs/ares_set_servers_ports_csv.3 b/lib/c-ares-1.32.0/docs/ares_set_servers_ports_csv.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_set_servers_ports_csv.3 rename to lib/c-ares-1.32.0/docs/ares_set_servers_ports_csv.3 diff --git a/lib/c-ares-1.31.0/docs/ares_set_socket_callback.3 b/lib/c-ares-1.32.0/docs/ares_set_socket_callback.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_set_socket_callback.3 rename to lib/c-ares-1.32.0/docs/ares_set_socket_callback.3 diff --git a/lib/c-ares-1.31.0/docs/ares_set_socket_configure_callback.3 b/lib/c-ares-1.32.0/docs/ares_set_socket_configure_callback.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_set_socket_configure_callback.3 rename to lib/c-ares-1.32.0/docs/ares_set_socket_configure_callback.3 diff --git a/lib/c-ares-1.31.0/docs/ares_set_socket_functions.3 b/lib/c-ares-1.32.0/docs/ares_set_socket_functions.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_set_socket_functions.3 rename to lib/c-ares-1.32.0/docs/ares_set_socket_functions.3 diff --git a/lib/c-ares-1.31.0/docs/ares_set_sortlist.3 b/lib/c-ares-1.32.0/docs/ares_set_sortlist.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_set_sortlist.3 rename to lib/c-ares-1.32.0/docs/ares_set_sortlist.3 diff --git a/lib/c-ares-1.31.0/docs/ares_strerror.3 b/lib/c-ares-1.32.0/docs/ares_strerror.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_strerror.3 rename to lib/c-ares-1.32.0/docs/ares_strerror.3 diff --git a/lib/c-ares-1.31.0/docs/ares_svcb_param_t.3 b/lib/c-ares-1.32.0/docs/ares_svcb_param_t.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_svcb_param_t.3 rename to lib/c-ares-1.32.0/docs/ares_svcb_param_t.3 diff --git a/lib/c-ares-1.31.0/docs/ares_threadsafety.3 b/lib/c-ares-1.32.0/docs/ares_threadsafety.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_threadsafety.3 rename to lib/c-ares-1.32.0/docs/ares_threadsafety.3 diff --git a/lib/c-ares-1.31.0/docs/ares_timeout.3 b/lib/c-ares-1.32.0/docs/ares_timeout.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_timeout.3 rename to lib/c-ares-1.32.0/docs/ares_timeout.3 diff --git a/lib/c-ares-1.32.0/docs/ares_tlsa_match_t.3 b/lib/c-ares-1.32.0/docs/ares_tlsa_match_t.3 new file mode 100644 index 00000000000..b93e4cd4e37 --- /dev/null +++ b/lib/c-ares-1.32.0/docs/ares_tlsa_match_t.3 @@ -0,0 +1,3 @@ +.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" SPDX-License-Identifier: MIT +.so man3/ares_dns_rr.3 diff --git a/lib/c-ares-1.32.0/docs/ares_tlsa_selector_t.3 b/lib/c-ares-1.32.0/docs/ares_tlsa_selector_t.3 new file mode 100644 index 00000000000..b93e4cd4e37 --- /dev/null +++ b/lib/c-ares-1.32.0/docs/ares_tlsa_selector_t.3 @@ -0,0 +1,3 @@ +.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" SPDX-License-Identifier: MIT +.so man3/ares_dns_rr.3 diff --git a/lib/c-ares-1.32.0/docs/ares_tlsa_usage_t.3 b/lib/c-ares-1.32.0/docs/ares_tlsa_usage_t.3 new file mode 100644 index 00000000000..b93e4cd4e37 --- /dev/null +++ b/lib/c-ares-1.32.0/docs/ares_tlsa_usage_t.3 @@ -0,0 +1,3 @@ +.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" SPDX-License-Identifier: MIT +.so man3/ares_dns_rr.3 diff --git a/lib/c-ares-1.31.0/docs/ares_version.3 b/lib/c-ares-1.32.0/docs/ares_version.3 similarity index 100% rename from lib/c-ares-1.31.0/docs/ares_version.3 rename to lib/c-ares-1.32.0/docs/ares_version.3 diff --git a/lib/c-ares-1.31.0/include/CMakeLists.txt b/lib/c-ares-1.32.0/include/CMakeLists.txt similarity index 85% rename from lib/c-ares-1.31.0/include/CMakeLists.txt rename to lib/c-ares-1.32.0/include/CMakeLists.txt index e95a94dda16..e01885ea1f0 100644 --- a/lib/c-ares-1.31.0/include/CMakeLists.txt +++ b/lib/c-ares-1.32.0/include/CMakeLists.txt @@ -5,6 +5,6 @@ CONFIGURE_FILE (ares_build.h.cmake ${PROJECT_BINARY_DIR}/ares_build.h) # Headers installation target IF (CARES_INSTALL) - SET (CARES_HEADERS ares.h ares_version.h "${PROJECT_BINARY_DIR}/ares_build.h" ares_rules.h ares_dns.h ares_dns_record.h ares_nameser.h) + SET (CARES_HEADERS ares.h ares_version.h "${PROJECT_BINARY_DIR}/ares_build.h" ares_dns.h ares_dns_record.h ares_nameser.h) INSTALL (FILES ${CARES_HEADERS} COMPONENT Devel DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) ENDIF () diff --git a/lib/c-ares-1.31.0/include/Makefile.am b/lib/c-ares-1.32.0/include/Makefile.am similarity index 70% rename from lib/c-ares-1.31.0/include/Makefile.am rename to lib/c-ares-1.32.0/include/Makefile.am index e17790da4f4..c2557d208bd 100644 --- a/lib/c-ares-1.31.0/include/Makefile.am +++ b/lib/c-ares-1.32.0/include/Makefile.am @@ -4,6 +4,6 @@ AUTOMAKE_OPTIONS = foreign nostdinc 1.9.6 ACLOCAL_AMFLAGS = -I m4 --install # what headers to install on 'make install': -include_HEADERS = ares.h ares_version.h ares_build.h ares_rules.h ares_dns.h ares_dns_record.h ares_nameser.h +include_HEADERS = ares.h ares_version.h ares_build.h ares_dns.h ares_dns_record.h ares_nameser.h EXTRA_DIST = ares_build.h.cmake ares_build.h.in ares_build.h.dist CMakeLists.txt diff --git a/lib/c-ares-1.31.0/include/Makefile.in b/lib/c-ares-1.32.0/include/Makefile.in similarity index 99% rename from lib/c-ares-1.31.0/include/Makefile.in rename to lib/c-ares-1.32.0/include/Makefile.in index 6e06995bfc5..94e8e640fbe 100644 --- a/lib/c-ares-1.31.0/include/Makefile.in +++ b/lib/c-ares-1.32.0/include/Makefile.in @@ -352,7 +352,7 @@ AUTOMAKE_OPTIONS = foreign nostdinc 1.9.6 ACLOCAL_AMFLAGS = -I m4 --install # what headers to install on 'make install': -include_HEADERS = ares.h ares_version.h ares_build.h ares_rules.h ares_dns.h ares_dns_record.h ares_nameser.h +include_HEADERS = ares.h ares_version.h ares_build.h ares_dns.h ares_dns_record.h ares_nameser.h EXTRA_DIST = ares_build.h.cmake ares_build.h.in ares_build.h.dist CMakeLists.txt all: ares_build.h $(MAKE) $(AM_MAKEFLAGS) all-am diff --git a/lib/c-ares-1.31.0/include/ares.h b/lib/c-ares-1.32.0/include/ares.h similarity index 98% rename from lib/c-ares-1.31.0/include/ares.h rename to lib/c-ares-1.32.0/include/ares.h index 58cac6cd71f..afff1759b39 100644 --- a/lib/c-ares-1.31.0/include/ares.h +++ b/lib/c-ares-1.32.0/include/ares.h @@ -30,9 +30,43 @@ #include "ares_version.h" /* c-ares version defines */ #include "ares_build.h" /* c-ares build definitions */ -#include "ares_rules.h" /* c-ares rules enforcement */ -#include +#if defined(_WIN32) +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif +#endif + +#ifdef CARES_HAVE_SYS_TYPES_H +# include +#endif + +#ifdef CARES_HAVE_SYS_SOCKET_H +# include +#endif + +#ifdef CARES_HAVE_SYS_SELECT_H +# include +#endif + +#ifdef CARES_HAVE_WINSOCK2_H +# include +/* To aid with linking against a static c-ares build, lets tell the microsoft + * compiler to pull in needed dependencies */ +# ifdef _MSC_VER +# pragma comment(lib, "ws2_32") +# pragma comment(lib, "advapi32") +# pragma comment(lib, "iphlpapi") +# endif +#endif + +#ifdef CARES_HAVE_WS2TCPIP_H +# include +#endif + +#ifdef CARES_HAVE_WINDOWS_H +# include +#endif /* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish libc5-based Linux systems. Only include it on system that are known to @@ -43,43 +77,26 @@ defined(__QNXNTO__) || defined(__MVS__) || defined(__HAIKU__) # include #endif + #if (defined(NETWARE) && !defined(__NOVELL_LIBC__)) # include #endif -#if defined(_WIN32) -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -# endif +#if !defined(_WIN32) +# include #endif -#if defined(WATT32) -# include -# include +#ifdef WATT32 # include -#elif defined(_WIN32_WCE) -# include -# include -#elif defined(_WIN32) -# include -# include -# include -/* To aid with linking against a static c-ares build, lets tell the microsoft - * compiler to pull in needed dependencies */ -# ifdef _MSC_VER -# pragma comment(lib, "ws2_32") -# pragma comment(lib, "advapi32") -# pragma comment(lib, "iphlpapi") -# endif -#else -# include -# include #endif #if defined(ANDROID) || defined(__ANDROID__) # include #endif +typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t; +typedef CARES_TYPEOF_ARES_SSIZE_T ares_ssize_t; + #ifdef __cplusplus extern "C" { #endif @@ -221,6 +238,7 @@ typedef enum { #define ARES_FLAG_NOCHECKRESP (1 << 7) #define ARES_FLAG_EDNS (1 << 8) #define ARES_FLAG_NO_DFLT_SVR (1 << 9) +#define ARES_FLAG_DNS0x20 (1 << 10) /* Option mask values */ #define ARES_OPT_FLAGS (1 << 0) diff --git a/lib/c-ares-1.31.0/include/ares_build.h b/lib/c-ares-1.32.0/include/ares_build.h similarity index 82% rename from lib/c-ares-1.31.0/include/ares_build.h rename to lib/c-ares-1.32.0/include/ares_build.h index 0a2b7a711a3..18a92606a81 100644 --- a/lib/c-ares-1.31.0/include/ares_build.h +++ b/lib/c-ares-1.32.0/include/ares_build.h @@ -134,75 +134,61 @@ #elif defined(_WIN32_WCE) # define CARES_TYPEOF_ARES_SOCKLEN_T int -#elif defined(__MINGW32__) -# define CARES_TYPEOF_ARES_SOCKLEN_T int - #elif defined(__VMS) # define CARES_TYPEOF_ARES_SOCKLEN_T unsigned int #elif defined(__OS400__) # if defined(__ILEC400__) # define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t -# define CARES_PULL_SYS_TYPES_H 1 -# define CARES_PULL_SYS_SOCKET_H 1 +# define CARES_HAVE_SYS_TYPES_H 1 +# define CARES_HAVE_SYS_SOCKET_H 1 +# define CARES_HAVE_SYS_SELECT_H 1 # endif #elif defined(__MVS__) # if defined(__IBMC__) || defined(__IBMCPP__) # define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t -# define CARES_PULL_SYS_TYPES_H 1 -# define CARES_PULL_SYS_SOCKET_H 1 +# define CARES_HAVE_SYS_TYPES_H 1 +# define CARES_HAVE_SYS_SOCKET_H 1 +# define CARES_HAVE_SYS_SELECT_H 1 # endif #elif defined(__370__) # if defined(__IBMC__) || defined(__IBMCPP__) # define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t -# define CARES_PULL_SYS_TYPES_H 1 -# define CARES_PULL_SYS_SOCKET_H 1 +# define CARES_HAVE_SYS_TYPES_H 1 +# define CARES_HAVE_SYS_SOCKET_H 1 +# define CARES_HAVE_SYS_SELECT_H 1 # endif #elif defined(TPF) # define CARES_TYPEOF_ARES_SOCKLEN_T int -/* ===================================== */ -/* KEEP MSVC THE PENULTIMATE ENTRY */ -/* ===================================== */ - -#elif defined(_MSC_VER) +#elif defined(_WIN32) +# define WIN32_LEAN_AND_MEAN # define CARES_TYPEOF_ARES_SOCKLEN_T int +# define CARES_HAVE_WINDOWS_H 1 +# define CARES_HAVE_SYS_TYPES_H 1 -/* ===================================== */ -/* KEEP GENERIC GCC THE LAST ENTRY */ -/* ===================================== */ +# if defined(WATT32) +# define CARES_HAVE_SYS_SOCKET_H 1 +# define CARES_HAVE_SYS_SELECT_H 1 +# else +# define CARES_HAVE_WS2TCPIP_H 1 +# define CARES_HAVE_WINSOCK2_H 1 +# endif #elif defined(__GNUC__) # define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t -# define CARES_PULL_SYS_TYPES_H 1 -# define CARES_PULL_SYS_SOCKET_H 1 +# define CARES_HAVE_SYS_TYPES_H 1 +# define CARES_HAVE_SYS_SOCKET_H 1 +# define CARES_HAVE_SYS_SELECT_H 1 #else # error "Unknown non-configure build target!" Error Compilation_aborted_Unknown_non_configure_build_target #endif -/* CARES_PULL_SYS_TYPES_H is defined above when inclusion of header file */ -/* sys/types.h is required here to properly make type definitions below. */ -#ifdef CARES_PULL_SYS_TYPES_H -# include -#endif - -/* CARES_PULL_SYS_SOCKET_H is defined above when inclusion of header file */ -/* sys/socket.h is required here to properly make type definitions below. */ -#ifdef CARES_PULL_SYS_SOCKET_H -# include -#endif - -/* Data type definition of ares_socklen_t. */ - -#ifdef CARES_TYPEOF_ARES_SOCKLEN_T - typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t; -#endif - /* Data type definition of ares_ssize_t. */ #ifdef _WIN32 # ifdef _WIN64 @@ -214,6 +200,4 @@ # define CARES_TYPEOF_ARES_SSIZE_T ssize_t #endif -typedef CARES_TYPEOF_ARES_SSIZE_T ares_ssize_t; - #endif /* __CARES_BUILD_H */ diff --git a/lib/c-ares-1.31.0/include/ares_build.h.cmake b/lib/c-ares-1.32.0/include/ares_build.h.cmake similarity index 88% rename from lib/c-ares-1.31.0/include/ares_build.h.cmake rename to lib/c-ares-1.32.0/include/ares_build.h.cmake index da8a7e064c0..2263c6c87ef 100644 --- a/lib/c-ares-1.31.0/include/ares_build.h.cmake +++ b/lib/c-ares-1.32.0/include/ares_build.h.cmake @@ -13,10 +13,10 @@ * for C-Ares */ #cmakedefine CARES_HAVE_SYS_TYPES_H #cmakedefine CARES_HAVE_SYS_SOCKET_H +#cmakedefine CARES_HAVE_SYS_SELECT_H #cmakedefine CARES_HAVE_WINDOWS_H #cmakedefine CARES_HAVE_WS2TCPIP_H #cmakedefine CARES_HAVE_WINSOCK2_H -#cmakedefine CARES_HAVE_WINDOWS_H #cmakedefine CARES_HAVE_ARPA_NAMESER_H #cmakedefine CARES_HAVE_ARPA_NAMESER_COMPAT_H @@ -28,6 +28,10 @@ # include #endif +#ifdef CARES_HAVE_SYS_SELECT_H +# include +#endif + #ifdef CARES_HAVE_WINSOCK2_H # include #endif @@ -40,8 +44,4 @@ # include #endif - -typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t; -typedef CARES_TYPEOF_ARES_SSIZE_T ares_ssize_t; - #endif /* __CARES_BUILD_H */ diff --git a/lib/c-ares-1.31.0/include/ares_build.h.in b/lib/c-ares-1.32.0/include/ares_build.h.in similarity index 88% rename from lib/c-ares-1.31.0/include/ares_build.h.in rename to lib/c-ares-1.32.0/include/ares_build.h.in index e55b39b0e3e..1327ed6d990 100644 --- a/lib/c-ares-1.31.0/include/ares_build.h.in +++ b/lib/c-ares-1.32.0/include/ares_build.h.in @@ -13,10 +13,10 @@ * for C-Ares */ #undef CARES_HAVE_SYS_TYPES_H #undef CARES_HAVE_SYS_SOCKET_H +#undef CARES_HAVE_SYS_SELECT_H #undef CARES_HAVE_WINDOWS_H #undef CARES_HAVE_WS2TCPIP_H #undef CARES_HAVE_WINSOCK2_H -#undef CARES_HAVE_WINDOWS_H #undef CARES_HAVE_ARPA_NAMESER_H #undef CARES_HAVE_ARPA_NAMESER_COMPAT_H @@ -28,6 +28,10 @@ # include #endif +#ifdef CARES_HAVE_SYS_SELECT_H +# include +#endif + #ifdef CARES_HAVE_WINSOCK2_H # include #endif @@ -40,8 +44,4 @@ # include #endif - -typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t; -typedef CARES_TYPEOF_ARES_SSIZE_T ares_ssize_t; - #endif /* __CARES_BUILD_H */ diff --git a/lib/c-ares-1.31.0/include/ares_dns.h b/lib/c-ares-1.32.0/include/ares_dns.h similarity index 100% rename from lib/c-ares-1.31.0/include/ares_dns.h rename to lib/c-ares-1.32.0/include/ares_dns.h diff --git a/lib/c-ares-1.31.0/include/ares_dns_record.h b/lib/c-ares-1.32.0/include/ares_dns_record.h similarity index 90% rename from lib/c-ares-1.31.0/include/ares_dns_record.h rename to lib/c-ares-1.32.0/include/ares_dns_record.h index 5533929f65f..00b6809f124 100644 --- a/lib/c-ares-1.31.0/include/ares_dns_record.h +++ b/lib/c-ares-1.32.0/include/ares_dns_record.h @@ -94,7 +94,7 @@ typedef enum { ARES_OPCODE_IQUERY = 1, /*!< Inverse query. Obsolete. */ ARES_OPCODE_STATUS = 2, /*!< Name server status query */ ARES_OPCODE_NOTIFY = 4, /*!< Zone change notification (RFC 1996) */ - ARES_OPCODE_UPDATE = 5, /*!< Zone update message (RFC2136) */ + ARES_OPCODE_UPDATE = 5 /*!< Zone update message (RFC2136) */ } ares_dns_opcode_t; /*! DNS Header flags */ @@ -108,7 +108,7 @@ typedef enum { ARES_FLAG_AD = 1 << 5, /*!< RFC 2065. Authentic Data bit indicates in a * response that the data included has been verified by * the server providing it */ - ARES_FLAG_CD = 1 << 6, /*!< RFC 2065. Checking Disabled bit indicates in a + ARES_FLAG_CD = 1 << 6 /*!< RFC 2065. Checking Disabled bit indicates in a * query that non-verified data is acceptable to the * resolver sending the query. */ } ares_dns_flags_t; @@ -152,25 +152,28 @@ typedef enum { ARES_RCODE_BADNAME = 20, /*!< RFC 2930. Duplicate Key Name */ ARES_RCODE_BADALG = 21, /*!< RFC 2930. Algorithm not supported */ ARES_RCODE_BADTRUNC = 22, /*!< RFC 8945. Bad Truncation */ - ARES_RCODE_BADCOOKIE = 23, /*!< RVC 7973. Bad/missing Server Cookie */ + ARES_RCODE_BADCOOKIE = 23 /*!< RVC 7973. Bad/missing Server Cookie */ } ares_dns_rcode_t; /*! Data types used */ typedef enum { - ARES_DATATYPE_INADDR = 1, /*!< struct in_addr * type */ - ARES_DATATYPE_INADDR6 = 2, /*!< struct ares_in6_addr * type */ - ARES_DATATYPE_U8 = 3, /*!< 8bit unsigned integer */ - ARES_DATATYPE_U16 = 4, /*!< 16bit unsigned integer */ - ARES_DATATYPE_U32 = 5, /*!< 32bit unsigned integer */ - ARES_DATATYPE_NAME = 6, /*!< Null-terminated string of a domain name */ - ARES_DATATYPE_STR = 7, /*!< Null-terminated string */ - ARES_DATATYPE_BIN = 8, /*!< Binary data */ - ARES_DATATYPE_BINP = 9, /*!< Officially defined as binary data, but likely - * printable. Guaranteed to have a NULL - * terminator for convenience (not included in - * length) */ - ARES_DATATYPE_OPT = 10, /*!< Array of options. 16bit identifier, BIN - * data. */ + ARES_DATATYPE_INADDR = 1, /*!< struct in_addr * type */ + ARES_DATATYPE_INADDR6 = 2, /*!< struct ares_in6_addr * type */ + ARES_DATATYPE_U8 = 3, /*!< 8bit unsigned integer */ + ARES_DATATYPE_U16 = 4, /*!< 16bit unsigned integer */ + ARES_DATATYPE_U32 = 5, /*!< 32bit unsigned integer */ + ARES_DATATYPE_NAME = 6, /*!< Null-terminated string of a domain name */ + ARES_DATATYPE_STR = 7, /*!< Null-terminated string */ + ARES_DATATYPE_BIN = 8, /*!< Binary data */ + ARES_DATATYPE_BINP = 9, /*!< Officially defined as binary data, but likely + * printable. Guaranteed to have a NULL + * terminator for convenience (not included in + * length) */ + ARES_DATATYPE_OPT = 10, /*!< Array of options. 16bit identifier, BIN + * data. */ + ARES_DATATYPE_ABINP = 11 /*!< Array of binary data, likely printable. + * Guaranteed to have a NULL terminator for + * convenience (not included in length) */ } ares_dns_datatype_t; /*! Keys used for all RR Types. We take the record type and multiply by 100 @@ -207,7 +210,7 @@ typedef enum { ARES_RR_MX_PREFERENCE = (ARES_REC_TYPE_MX * 100) + 1, /*! MX Record. Exchange, domain. Datatype: NAME */ ARES_RR_MX_EXCHANGE = (ARES_REC_TYPE_MX * 100) + 2, - /*! TXT Record. Data. Datatype: BINP */ + /*! TXT Record. Data. Datatype: ABINP */ ARES_RR_TXT_DATA = (ARES_REC_TYPE_TXT * 100) + 1, /*! SIG Record. Type Covered. Datatype: U16 */ ARES_RR_SIG_TYPE_COVERED = (ARES_REC_TYPE_SIG * 100) + 1, @@ -292,7 +295,7 @@ typedef enum { /*! RAW Record. RR Type. Datatype: U16 */ ARES_RR_RAW_RR_TYPE = (ARES_REC_TYPE_RAW_RR * 100) + 1, /*! RAW Record. RR Data. Datatype: BIN */ - ARES_RR_RAW_RR_DATA = (ARES_REC_TYPE_RAW_RR * 100) + 2, + ARES_RR_RAW_RR_DATA = (ARES_REC_TYPE_RAW_RR * 100) + 2 } ares_dns_rr_key_t; /*! TLSA Record ARES_RR_TLSA_CERT_USAGE known values */ @@ -372,7 +375,7 @@ typedef enum { /*! RFC 8145. Signaling Trust Anchor Knowledge in DNSSEC */ ARES_OPT_PARAM_EDNS_KEY_TAG = 14, /*! RFC 8914. Extended ERROR code and message */ - ARES_OPT_PARAM_EXTENDED_DNS_ERROR = 15, + ARES_OPT_PARAM_EXTENDED_DNS_ERROR = 15 } ares_opt_param_t; /*! Data type for option records for keys like ARES_RR_OPT_OPTIONS and @@ -600,6 +603,15 @@ CARES_EXTERN void ares_dns_record_destroy(ares_dns_record_t *dnsrec); CARES_EXTERN unsigned short ares_dns_record_get_id(const ares_dns_record_t *dnsrec); +/*! Overwrite the DNS query id + * + * \param[in] dnsrec Initialized record object + * \param[in] id DNS query id + * \return ARES_TRUE on success, ARES_FALSE on usage error + */ +CARES_EXTERN ares_bool_t + ares_dns_record_set_id(ares_dns_record_t *dnsrec, unsigned short id); + /*! Get the DNS Record Flags * * \param[in] dnsrec Initialized record object @@ -863,6 +875,34 @@ CARES_EXTERN ares_status_t ares_dns_rr_set_bin(ares_dns_rr_t *dns_rr, const unsigned char *val, size_t len); +/*! Add binary array value (ABINP) data for specified resource record and key. + * Can only be used on keys with datatype ARES_DATATYPE_ABINP. The value will + * Be added as the last element in the array. + * + * \param[in] dns_rr Pointer to resource record + * \param[in] key DNS Resource Record Key + * \param[in] val Pointer to binary data. + * \param[in] len Length of binary data + * \return ARES_SUCCESS on success + */ +CARES_EXTERN ares_status_t ares_dns_rr_add_abin(ares_dns_rr_t *dns_rr, + ares_dns_rr_key_t key, + const unsigned char *val, + size_t len); + +/*! Delete binary array value (ABINP) data for specified resource record and + * key by specified index. Can only be used on keys with datatype + * ARES_DATATYPE_ABINP. The value at the index will be deleted. + * + * \param[in] dns_rr Pointer to resource record + * \param[in] key DNS Resource Record Key + * \param[in] idx Index to delete + * \return ARES_SUCCESS on success + */ +CARES_EXTERN ares_status_t ares_dns_rr_del_abin(ares_dns_rr_t *dns_rr, + ares_dns_rr_key_t key, + size_t idx); + /*! Set the option for the RR * * \param[in] dns_rr Pointer to resource record @@ -939,8 +979,9 @@ CARES_EXTERN unsigned int ares_dns_rr_get_u32(const ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key); /*! Retrieve a pointer to the binary data. Can only be used on keys with - * datatype ARES_DATATYPE_BIN or ARES_DATATYPE_BINP. If BINP, the data is - * guaranteed to have a NULL terminator which is NOT included in the length. + * datatype ARES_DATATYPE_BIN, ARES_DATATYPE_BINP, or ARES_DATATYPE_ABINP. + * If BINP or ABINP, the data is guaranteed to have a NULL terminator which + * is NOT included in the length. * * \param[in] dns_rr Pointer to resource record * \param[in] key DNS Resource Record Key @@ -951,6 +992,32 @@ CARES_EXTERN const unsigned char * ares_dns_rr_get_bin(const ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key, size_t *len); +/*! Retrieve the count of the array of stored binary values. Can only be used on + * keys with datatype ARES_DATATYPE_ABINP. + * + * \param[in] dns_rr Pointer to resource record + * \param[in] key DNS Resource Record Key + * \return count of values + */ +CARES_EXTERN size_t ares_dns_rr_get_abin_cnt(const ares_dns_rr_t *dns_rr, + ares_dns_rr_key_t key); + +/*! Retrieve a pointer to the binary array data from the specified index. Can + * only be used on keys with datatype ARES_DATATYPE_ABINP. If ABINP, the data + * is guaranteed to have a NULL terminator which is NOT included in the length. + * If want all array membersconcatenated, may use ares_dns_rr_get_bin() + * instead. + * + * \param[in] dns_rr Pointer to resource record + * \param[in] key DNS Resource Record Key + * \param[in] idx Index of value to retrieve + * \param[out] len Length of binary data returned + * \return pointer binary data or NULL on error + */ +CARES_EXTERN const unsigned char *ares_dns_rr_get_abin( + const ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key, size_t idx, size_t *len); + + /*! Retrieve the number of options stored for the RR. * * \param[in] dns_rr Pointer to resource record diff --git a/lib/c-ares-1.31.0/include/ares_nameser.h b/lib/c-ares-1.32.0/include/ares_nameser.h similarity index 100% rename from lib/c-ares-1.31.0/include/ares_nameser.h rename to lib/c-ares-1.32.0/include/ares_nameser.h diff --git a/lib/c-ares-1.31.0/include/ares_version.h b/lib/c-ares-1.32.0/include/ares_version.h similarity index 85% rename from lib/c-ares-1.31.0/include/ares_version.h rename to lib/c-ares-1.32.0/include/ares_version.h index cd5a2551534..7374767e98f 100644 --- a/lib/c-ares-1.31.0/include/ares_version.h +++ b/lib/c-ares-1.32.0/include/ares_version.h @@ -31,19 +31,14 @@ #define ARES_COPYRIGHT "2004 - 2024 Daniel Stenberg, ." #define ARES_VERSION_MAJOR 1 -#define ARES_VERSION_MINOR 31 +#define ARES_VERSION_MINOR 32 #define ARES_VERSION_PATCH 0 #define ARES_VERSION \ ((ARES_VERSION_MAJOR << 16) | (ARES_VERSION_MINOR << 8) | \ (ARES_VERSION_PATCH)) -#define ARES_VERSION_STR "1.31.0" +#define ARES_VERSION_STR "1.32.0" -#if (ARES_VERSION >= 0x010700) -# define CARES_HAVE_ARES_LIBRARY_INIT 1 -# define CARES_HAVE_ARES_LIBRARY_CLEANUP 1 -#else -# undef CARES_HAVE_ARES_LIBRARY_INIT -# undef CARES_HAVE_ARES_LIBRARY_CLEANUP -#endif +#define CARES_HAVE_ARES_LIBRARY_INIT 1 +#define CARES_HAVE_ARES_LIBRARY_CLEANUP 1 #endif diff --git a/lib/c-ares-1.31.0/libcares.pc.cmake b/lib/c-ares-1.32.0/libcares.pc.cmake similarity index 100% rename from lib/c-ares-1.31.0/libcares.pc.cmake rename to lib/c-ares-1.32.0/libcares.pc.cmake diff --git a/lib/c-ares-1.31.0/libcares.pc.in b/lib/c-ares-1.32.0/libcares.pc.in similarity index 100% rename from lib/c-ares-1.31.0/libcares.pc.in rename to lib/c-ares-1.32.0/libcares.pc.in diff --git a/lib/c-ares-1.31.0/m4/ax_ac_append_to_file.m4 b/lib/c-ares-1.32.0/m4/ax_ac_append_to_file.m4 similarity index 100% rename from lib/c-ares-1.31.0/m4/ax_ac_append_to_file.m4 rename to lib/c-ares-1.32.0/m4/ax_ac_append_to_file.m4 diff --git a/lib/c-ares-1.31.0/m4/ax_ac_print_to_file.m4 b/lib/c-ares-1.32.0/m4/ax_ac_print_to_file.m4 similarity index 100% rename from lib/c-ares-1.31.0/m4/ax_ac_print_to_file.m4 rename to lib/c-ares-1.32.0/m4/ax_ac_print_to_file.m4 diff --git a/lib/c-ares-1.31.0/m4/ax_add_am_macro_static.m4 b/lib/c-ares-1.32.0/m4/ax_add_am_macro_static.m4 similarity index 100% rename from lib/c-ares-1.31.0/m4/ax_add_am_macro_static.m4 rename to lib/c-ares-1.32.0/m4/ax_add_am_macro_static.m4 diff --git a/lib/c-ares-1.31.0/m4/ax_am_macros_static.m4 b/lib/c-ares-1.32.0/m4/ax_am_macros_static.m4 similarity index 100% rename from lib/c-ares-1.31.0/m4/ax_am_macros_static.m4 rename to lib/c-ares-1.32.0/m4/ax_am_macros_static.m4 diff --git a/lib/c-ares-1.31.0/m4/ax_append_compile_flags.m4 b/lib/c-ares-1.32.0/m4/ax_append_compile_flags.m4 similarity index 100% rename from lib/c-ares-1.31.0/m4/ax_append_compile_flags.m4 rename to lib/c-ares-1.32.0/m4/ax_append_compile_flags.m4 diff --git a/lib/c-ares-1.31.0/m4/ax_append_flag.m4 b/lib/c-ares-1.32.0/m4/ax_append_flag.m4 similarity index 100% rename from lib/c-ares-1.31.0/m4/ax_append_flag.m4 rename to lib/c-ares-1.32.0/m4/ax_append_flag.m4 diff --git a/lib/c-ares-1.31.0/m4/ax_append_link_flags.m4 b/lib/c-ares-1.32.0/m4/ax_append_link_flags.m4 similarity index 100% rename from lib/c-ares-1.31.0/m4/ax_append_link_flags.m4 rename to lib/c-ares-1.32.0/m4/ax_append_link_flags.m4 diff --git a/lib/c-ares-1.31.0/m4/ax_check_compile_flag.m4 b/lib/c-ares-1.32.0/m4/ax_check_compile_flag.m4 similarity index 100% rename from lib/c-ares-1.31.0/m4/ax_check_compile_flag.m4 rename to lib/c-ares-1.32.0/m4/ax_check_compile_flag.m4 diff --git a/lib/c-ares-1.31.0/m4/ax_check_gnu_make.m4 b/lib/c-ares-1.32.0/m4/ax_check_gnu_make.m4 similarity index 100% rename from lib/c-ares-1.31.0/m4/ax_check_gnu_make.m4 rename to lib/c-ares-1.32.0/m4/ax_check_gnu_make.m4 diff --git a/lib/c-ares-1.31.0/m4/ax_check_link_flag.m4 b/lib/c-ares-1.32.0/m4/ax_check_link_flag.m4 similarity index 100% rename from lib/c-ares-1.31.0/m4/ax_check_link_flag.m4 rename to lib/c-ares-1.32.0/m4/ax_check_link_flag.m4 diff --git a/lib/c-ares-1.31.0/m4/ax_check_user_namespace.m4 b/lib/c-ares-1.32.0/m4/ax_check_user_namespace.m4 similarity index 100% rename from lib/c-ares-1.31.0/m4/ax_check_user_namespace.m4 rename to lib/c-ares-1.32.0/m4/ax_check_user_namespace.m4 diff --git a/lib/c-ares-1.31.0/m4/ax_check_uts_namespace.m4 b/lib/c-ares-1.32.0/m4/ax_check_uts_namespace.m4 similarity index 100% rename from lib/c-ares-1.31.0/m4/ax_check_uts_namespace.m4 rename to lib/c-ares-1.32.0/m4/ax_check_uts_namespace.m4 diff --git a/lib/c-ares-1.31.0/m4/ax_code_coverage.m4 b/lib/c-ares-1.32.0/m4/ax_code_coverage.m4 similarity index 100% rename from lib/c-ares-1.31.0/m4/ax_code_coverage.m4 rename to lib/c-ares-1.32.0/m4/ax_code_coverage.m4 diff --git a/lib/c-ares-1.31.0/m4/ax_compiler_vendor.m4 b/lib/c-ares-1.32.0/m4/ax_compiler_vendor.m4 similarity index 100% rename from lib/c-ares-1.31.0/m4/ax_compiler_vendor.m4 rename to lib/c-ares-1.32.0/m4/ax_compiler_vendor.m4 diff --git a/lib/c-ares-1.31.0/m4/ax_cxx_compile_stdcxx.m4 b/lib/c-ares-1.32.0/m4/ax_cxx_compile_stdcxx.m4 similarity index 100% rename from lib/c-ares-1.31.0/m4/ax_cxx_compile_stdcxx.m4 rename to lib/c-ares-1.32.0/m4/ax_cxx_compile_stdcxx.m4 diff --git a/lib/c-ares-1.31.0/m4/ax_cxx_compile_stdcxx_14.m4 b/lib/c-ares-1.32.0/m4/ax_cxx_compile_stdcxx_14.m4 similarity index 100% rename from lib/c-ares-1.31.0/m4/ax_cxx_compile_stdcxx_14.m4 rename to lib/c-ares-1.32.0/m4/ax_cxx_compile_stdcxx_14.m4 diff --git a/lib/c-ares-1.31.0/m4/ax_file_escapes.m4 b/lib/c-ares-1.32.0/m4/ax_file_escapes.m4 similarity index 100% rename from lib/c-ares-1.31.0/m4/ax_file_escapes.m4 rename to lib/c-ares-1.32.0/m4/ax_file_escapes.m4 diff --git a/lib/c-ares-1.31.0/m4/ax_pthread.m4 b/lib/c-ares-1.32.0/m4/ax_pthread.m4 similarity index 100% rename from lib/c-ares-1.31.0/m4/ax_pthread.m4 rename to lib/c-ares-1.32.0/m4/ax_pthread.m4 diff --git a/lib/c-ares-1.31.0/m4/ax_require_defined.m4 b/lib/c-ares-1.32.0/m4/ax_require_defined.m4 similarity index 100% rename from lib/c-ares-1.31.0/m4/ax_require_defined.m4 rename to lib/c-ares-1.32.0/m4/ax_require_defined.m4 diff --git a/lib/c-ares-1.31.0/m4/libtool.m4 b/lib/c-ares-1.32.0/m4/libtool.m4 similarity index 100% rename from lib/c-ares-1.31.0/m4/libtool.m4 rename to lib/c-ares-1.32.0/m4/libtool.m4 diff --git a/lib/c-ares-1.31.0/m4/ltoptions.m4 b/lib/c-ares-1.32.0/m4/ltoptions.m4 similarity index 100% rename from lib/c-ares-1.31.0/m4/ltoptions.m4 rename to lib/c-ares-1.32.0/m4/ltoptions.m4 diff --git a/lib/c-ares-1.31.0/m4/ltsugar.m4 b/lib/c-ares-1.32.0/m4/ltsugar.m4 similarity index 100% rename from lib/c-ares-1.31.0/m4/ltsugar.m4 rename to lib/c-ares-1.32.0/m4/ltsugar.m4 diff --git a/lib/c-ares-1.31.0/m4/ltversion.m4 b/lib/c-ares-1.32.0/m4/ltversion.m4 similarity index 100% rename from lib/c-ares-1.31.0/m4/ltversion.m4 rename to lib/c-ares-1.32.0/m4/ltversion.m4 diff --git a/lib/c-ares-1.31.0/m4/lt~obsolete.m4 b/lib/c-ares-1.32.0/m4/lt~obsolete.m4 similarity index 100% rename from lib/c-ares-1.31.0/m4/lt~obsolete.m4 rename to lib/c-ares-1.32.0/m4/lt~obsolete.m4 diff --git a/lib/c-ares-1.31.0/m4/pkg.m4 b/lib/c-ares-1.32.0/m4/pkg.m4 similarity index 100% rename from lib/c-ares-1.31.0/m4/pkg.m4 rename to lib/c-ares-1.32.0/m4/pkg.m4 diff --git a/lib/c-ares-1.31.0/msvc_ver.inc b/lib/c-ares-1.32.0/msvc_ver.inc similarity index 100% rename from lib/c-ares-1.31.0/msvc_ver.inc rename to lib/c-ares-1.32.0/msvc_ver.inc diff --git a/lib/c-ares-1.31.0/src/CMakeLists.txt b/lib/c-ares-1.32.0/src/CMakeLists.txt similarity index 100% rename from lib/c-ares-1.31.0/src/CMakeLists.txt rename to lib/c-ares-1.32.0/src/CMakeLists.txt diff --git a/lib/c-ares-1.31.0/src/Makefile.am b/lib/c-ares-1.32.0/src/Makefile.am similarity index 100% rename from lib/c-ares-1.31.0/src/Makefile.am rename to lib/c-ares-1.32.0/src/Makefile.am diff --git a/lib/c-ares-1.31.0/src/Makefile.in b/lib/c-ares-1.32.0/src/Makefile.in similarity index 100% rename from lib/c-ares-1.31.0/src/Makefile.in rename to lib/c-ares-1.32.0/src/Makefile.in diff --git a/lib/c-ares-1.31.0/src/lib/CMakeLists.txt b/lib/c-ares-1.32.0/src/lib/CMakeLists.txt similarity index 100% rename from lib/c-ares-1.31.0/src/lib/CMakeLists.txt rename to lib/c-ares-1.32.0/src/lib/CMakeLists.txt diff --git a/lib/c-ares-1.31.0/src/lib/Makefile.am b/lib/c-ares-1.32.0/src/lib/Makefile.am similarity index 100% rename from lib/c-ares-1.31.0/src/lib/Makefile.am rename to lib/c-ares-1.32.0/src/lib/Makefile.am diff --git a/lib/c-ares-1.31.0/src/lib/Makefile.in b/lib/c-ares-1.32.0/src/lib/Makefile.in similarity index 96% rename from lib/c-ares-1.31.0/src/lib/Makefile.in rename to lib/c-ares-1.32.0/src/lib/Makefile.in index f9e7b7ea1ce..38e278a6d30 100644 --- a/lib/c-ares-1.31.0/src/lib/Makefile.in +++ b/lib/c-ares-1.32.0/src/lib/Makefile.in @@ -15,7 +15,7 @@ @SET_MAKE@ # aminclude_static.am generated automatically by Autoconf -# from AX_AM_MACROS_STATIC on Tue Jun 18 05:51:32 EDT 2024 +# from AX_AM_MACROS_STATIC on Thu Jul 4 07:03:12 EDT 2024 # Copyright (C) The c-ares project and its contributors # SPDX-License-Identifier: MIT @@ -175,6 +175,7 @@ am__objects_1 = libcares_la-ares__addrinfo2hostent.lo \ libcares_la-ares__timeval.lo libcares_la-ares_android.lo \ libcares_la-ares_cancel.lo libcares_la-ares_data.lo \ libcares_la-ares_destroy.lo libcares_la-ares_dns_mapping.lo \ + libcares_la-ares_dns_multistring.lo \ libcares_la-ares_dns_name.lo libcares_la-ares_dns_parse.lo \ libcares_la-ares_dns_record.lo libcares_la-ares_dns_write.lo \ libcares_la-ares_event_configchg.lo \ @@ -195,8 +196,9 @@ am__objects_1 = libcares_la-ares__addrinfo2hostent.lo \ libcares_la-ares_gethostbyname.lo \ libcares_la-ares_getnameinfo.lo libcares_la-ares_getsock.lo \ libcares_la-ares_init.lo libcares_la-ares_library_init.lo \ - libcares_la-ares_math.lo libcares_la-ares_create_query.lo \ - libcares_la-ares_options.lo libcares_la-ares_parse_a_reply.lo \ + libcares_la-ares_math.lo libcares_la-ares_metrics.lo \ + libcares_la-ares_create_query.lo libcares_la-ares_options.lo \ + libcares_la-ares_parse_a_reply.lo \ libcares_la-ares_parse_aaaa_reply.lo \ libcares_la-ares_parse_caa_reply.lo \ libcares_la-ares_parse_mx_reply.lo \ @@ -214,7 +216,8 @@ am__objects_1 = libcares_la-ares__addrinfo2hostent.lo \ libcares_la-ares_str.lo libcares_la-ares_strerror.lo \ libcares_la-ares_strsplit.lo libcares_la-ares_sysconfig.lo \ libcares_la-ares_sysconfig_files.lo \ - libcares_la-ares_sysconfig_mac.lo libcares_la-ares_timeout.lo \ + libcares_la-ares_sysconfig_mac.lo \ + libcares_la-ares_sysconfig_win.lo libcares_la-ares_timeout.lo \ libcares_la-ares_update_servers.lo libcares_la-ares_version.lo \ libcares_la-inet_net_pton.lo libcares_la-inet_ntop.lo \ libcares_la-windows_port.lo @@ -268,6 +271,7 @@ am__depfiles_remade = \ ./$(DEPDIR)/libcares_la-ares_data.Plo \ ./$(DEPDIR)/libcares_la-ares_destroy.Plo \ ./$(DEPDIR)/libcares_la-ares_dns_mapping.Plo \ + ./$(DEPDIR)/libcares_la-ares_dns_multistring.Plo \ ./$(DEPDIR)/libcares_la-ares_dns_name.Plo \ ./$(DEPDIR)/libcares_la-ares_dns_parse.Plo \ ./$(DEPDIR)/libcares_la-ares_dns_record.Plo \ @@ -295,6 +299,7 @@ am__depfiles_remade = \ ./$(DEPDIR)/libcares_la-ares_init.Plo \ ./$(DEPDIR)/libcares_la-ares_library_init.Plo \ ./$(DEPDIR)/libcares_la-ares_math.Plo \ + ./$(DEPDIR)/libcares_la-ares_metrics.Plo \ ./$(DEPDIR)/libcares_la-ares_options.Plo \ ./$(DEPDIR)/libcares_la-ares_parse_a_reply.Plo \ ./$(DEPDIR)/libcares_la-ares_parse_aaaa_reply.Plo \ @@ -321,6 +326,7 @@ am__depfiles_remade = \ ./$(DEPDIR)/libcares_la-ares_sysconfig.Plo \ ./$(DEPDIR)/libcares_la-ares_sysconfig_files.Plo \ ./$(DEPDIR)/libcares_la-ares_sysconfig_mac.Plo \ + ./$(DEPDIR)/libcares_la-ares_sysconfig_win.Plo \ ./$(DEPDIR)/libcares_la-ares_timeout.Plo \ ./$(DEPDIR)/libcares_la-ares_update_servers.Plo \ ./$(DEPDIR)/libcares_la-ares_version.Plo \ @@ -624,7 +630,7 @@ CSOURCES = ares__addrinfo2hostent.c \ ares__addrinfo_localhost.c \ ares__buf.c \ ares__close_sockets.c \ - ares__hosts_file.c \ + ares__hosts_file.c \ ares__htable.c \ ares__htable_asvp.c \ ares__htable_strvp.c \ @@ -643,11 +649,12 @@ CSOURCES = ares__addrinfo2hostent.c \ ares_data.c \ ares_destroy.c \ ares_dns_mapping.c \ + ares_dns_multistring.c \ ares_dns_name.c \ ares_dns_parse.c \ ares_dns_record.c \ ares_dns_write.c \ - ares_event_configchg.c \ + ares_event_configchg.c \ ares_event_epoll.c \ ares_event_kqueue.c \ ares_event_poll.c \ @@ -669,7 +676,8 @@ CSOURCES = ares__addrinfo2hostent.c \ ares_getsock.c \ ares_init.c \ ares_library_init.c \ - ares_math.c \ + ares_math.c \ + ares_metrics.c \ ares_create_query.c \ ares_options.c \ ares_parse_a_reply.c \ @@ -685,7 +693,7 @@ CSOURCES = ares__addrinfo2hostent.c \ ares_parse_uri_reply.c \ ares_platform.c \ ares_process.c \ - ares_qcache.c \ + ares_qcache.c \ ares_query.c \ ares_rand.c \ ares_search.c \ @@ -694,11 +702,12 @@ CSOURCES = ares__addrinfo2hostent.c \ ares_str.c \ ares_strerror.c \ ares_strsplit.c \ - ares_sysconfig.c \ - ares_sysconfig_files.c \ - ares_sysconfig_mac.c \ + ares_sysconfig.c \ + ares_sysconfig_files.c \ + ares_sysconfig_mac.c \ + ares_sysconfig_win.c \ ares_timeout.c \ - ares_update_servers.c \ + ares_update_servers.c \ ares_version.c \ inet_net_pton.c \ inet_ntop.c \ @@ -716,6 +725,7 @@ HHEADERS = ares__buf.h \ ares__threads.h \ ares_android.h \ ares_data.h \ + ares_dns_multistring.h \ ares_dns_private.h \ ares_event.h \ ares_event_win32.h \ @@ -728,7 +738,6 @@ HHEADERS = ares__buf.h \ ares_str.h \ ares_strsplit.h \ ares_setup.h \ - setup_once.h \ thirdparty/apple/dnsinfo.h @@ -853,6 +862,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_data.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_destroy.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_dns_mapping.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_dns_multistring.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_dns_name.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_dns_parse.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_dns_record.Plo@am__quote@ # am--include-marker @@ -880,6 +890,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_init.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_library_init.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_math.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_metrics.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_options.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_parse_a_reply.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_parse_aaaa_reply.Plo@am__quote@ # am--include-marker @@ -906,6 +917,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_sysconfig.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_sysconfig_files.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_sysconfig_mac.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_sysconfig_win.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_timeout.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_update_servers.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcares_la-ares_version.Plo@am__quote@ # am--include-marker @@ -1104,6 +1116,13 @@ libcares_la-ares_dns_mapping.lo: ares_dns_mapping.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_dns_mapping.lo `test -f 'ares_dns_mapping.c' || echo '$(srcdir)/'`ares_dns_mapping.c +libcares_la-ares_dns_multistring.lo: ares_dns_multistring.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_dns_multistring.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_dns_multistring.Tpo -c -o libcares_la-ares_dns_multistring.lo `test -f 'ares_dns_multistring.c' || echo '$(srcdir)/'`ares_dns_multistring.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_dns_multistring.Tpo $(DEPDIR)/libcares_la-ares_dns_multistring.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_dns_multistring.c' object='libcares_la-ares_dns_multistring.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_dns_multistring.lo `test -f 'ares_dns_multistring.c' || echo '$(srcdir)/'`ares_dns_multistring.c + libcares_la-ares_dns_name.lo: ares_dns_name.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_dns_name.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_dns_name.Tpo -c -o libcares_la-ares_dns_name.lo `test -f 'ares_dns_name.c' || echo '$(srcdir)/'`ares_dns_name.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_dns_name.Tpo $(DEPDIR)/libcares_la-ares_dns_name.Plo @@ -1293,6 +1312,13 @@ libcares_la-ares_math.lo: ares_math.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_math.lo `test -f 'ares_math.c' || echo '$(srcdir)/'`ares_math.c +libcares_la-ares_metrics.lo: ares_metrics.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_metrics.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_metrics.Tpo -c -o libcares_la-ares_metrics.lo `test -f 'ares_metrics.c' || echo '$(srcdir)/'`ares_metrics.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_metrics.Tpo $(DEPDIR)/libcares_la-ares_metrics.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_metrics.c' object='libcares_la-ares_metrics.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_metrics.lo `test -f 'ares_metrics.c' || echo '$(srcdir)/'`ares_metrics.c + libcares_la-ares_create_query.lo: ares_create_query.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_create_query.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_create_query.Tpo -c -o libcares_la-ares_create_query.lo `test -f 'ares_create_query.c' || echo '$(srcdir)/'`ares_create_query.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_create_query.Tpo $(DEPDIR)/libcares_la-ares_create_query.Plo @@ -1482,6 +1508,13 @@ libcares_la-ares_sysconfig_mac.lo: ares_sysconfig_mac.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_sysconfig_mac.lo `test -f 'ares_sysconfig_mac.c' || echo '$(srcdir)/'`ares_sysconfig_mac.c +libcares_la-ares_sysconfig_win.lo: ares_sysconfig_win.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_sysconfig_win.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_sysconfig_win.Tpo -c -o libcares_la-ares_sysconfig_win.lo `test -f 'ares_sysconfig_win.c' || echo '$(srcdir)/'`ares_sysconfig_win.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_sysconfig_win.Tpo $(DEPDIR)/libcares_la-ares_sysconfig_win.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ares_sysconfig_win.c' object='libcares_la-ares_sysconfig_win.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -c -o libcares_la-ares_sysconfig_win.lo `test -f 'ares_sysconfig_win.c' || echo '$(srcdir)/'`ares_sysconfig_win.c + libcares_la-ares_timeout.lo: ares_timeout.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcares_la_CPPFLAGS) $(CPPFLAGS) $(libcares_la_CFLAGS) $(CFLAGS) -MT libcares_la-ares_timeout.lo -MD -MP -MF $(DEPDIR)/libcares_la-ares_timeout.Tpo -c -o libcares_la-ares_timeout.lo `test -f 'ares_timeout.c' || echo '$(srcdir)/'`ares_timeout.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcares_la-ares_timeout.Tpo $(DEPDIR)/libcares_la-ares_timeout.Plo @@ -1755,6 +1788,7 @@ distclean: distclean-recursive -rm -f ./$(DEPDIR)/libcares_la-ares_data.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_destroy.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_dns_mapping.Plo + -rm -f ./$(DEPDIR)/libcares_la-ares_dns_multistring.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_dns_name.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_dns_parse.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_dns_record.Plo @@ -1782,6 +1816,7 @@ distclean: distclean-recursive -rm -f ./$(DEPDIR)/libcares_la-ares_init.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_library_init.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_math.Plo + -rm -f ./$(DEPDIR)/libcares_la-ares_metrics.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_options.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_parse_a_reply.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_parse_aaaa_reply.Plo @@ -1808,6 +1843,7 @@ distclean: distclean-recursive -rm -f ./$(DEPDIR)/libcares_la-ares_sysconfig.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_sysconfig_files.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_sysconfig_mac.Plo + -rm -f ./$(DEPDIR)/libcares_la-ares_sysconfig_win.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_timeout.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_update_servers.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_version.Plo @@ -1883,6 +1919,7 @@ maintainer-clean: maintainer-clean-recursive -rm -f ./$(DEPDIR)/libcares_la-ares_data.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_destroy.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_dns_mapping.Plo + -rm -f ./$(DEPDIR)/libcares_la-ares_dns_multistring.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_dns_name.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_dns_parse.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_dns_record.Plo @@ -1910,6 +1947,7 @@ maintainer-clean: maintainer-clean-recursive -rm -f ./$(DEPDIR)/libcares_la-ares_init.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_library_init.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_math.Plo + -rm -f ./$(DEPDIR)/libcares_la-ares_metrics.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_options.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_parse_a_reply.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_parse_aaaa_reply.Plo @@ -1936,6 +1974,7 @@ maintainer-clean: maintainer-clean-recursive -rm -f ./$(DEPDIR)/libcares_la-ares_sysconfig.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_sysconfig_files.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_sysconfig_mac.Plo + -rm -f ./$(DEPDIR)/libcares_la-ares_sysconfig_win.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_timeout.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_update_servers.Plo -rm -f ./$(DEPDIR)/libcares_la-ares_version.Plo diff --git a/lib/c-ares-1.31.0/src/lib/Makefile.inc b/lib/c-ares-1.32.0/src/lib/Makefile.inc similarity index 89% rename from lib/c-ares-1.31.0/src/lib/Makefile.inc rename to lib/c-ares-1.32.0/src/lib/Makefile.inc index a3e2453a04f..a1f39609edc 100644 --- a/lib/c-ares-1.31.0/src/lib/Makefile.inc +++ b/lib/c-ares-1.32.0/src/lib/Makefile.inc @@ -5,7 +5,7 @@ CSOURCES = ares__addrinfo2hostent.c \ ares__addrinfo_localhost.c \ ares__buf.c \ ares__close_sockets.c \ - ares__hosts_file.c \ + ares__hosts_file.c \ ares__htable.c \ ares__htable_asvp.c \ ares__htable_strvp.c \ @@ -24,11 +24,12 @@ CSOURCES = ares__addrinfo2hostent.c \ ares_data.c \ ares_destroy.c \ ares_dns_mapping.c \ + ares_dns_multistring.c \ ares_dns_name.c \ ares_dns_parse.c \ ares_dns_record.c \ ares_dns_write.c \ - ares_event_configchg.c \ + ares_event_configchg.c \ ares_event_epoll.c \ ares_event_kqueue.c \ ares_event_poll.c \ @@ -50,7 +51,8 @@ CSOURCES = ares__addrinfo2hostent.c \ ares_getsock.c \ ares_init.c \ ares_library_init.c \ - ares_math.c \ + ares_math.c \ + ares_metrics.c \ ares_create_query.c \ ares_options.c \ ares_parse_a_reply.c \ @@ -66,7 +68,7 @@ CSOURCES = ares__addrinfo2hostent.c \ ares_parse_uri_reply.c \ ares_platform.c \ ares_process.c \ - ares_qcache.c \ + ares_qcache.c \ ares_query.c \ ares_rand.c \ ares_search.c \ @@ -75,11 +77,12 @@ CSOURCES = ares__addrinfo2hostent.c \ ares_str.c \ ares_strerror.c \ ares_strsplit.c \ - ares_sysconfig.c \ - ares_sysconfig_files.c \ - ares_sysconfig_mac.c \ + ares_sysconfig.c \ + ares_sysconfig_files.c \ + ares_sysconfig_mac.c \ + ares_sysconfig_win.c \ ares_timeout.c \ - ares_update_servers.c \ + ares_update_servers.c \ ares_version.c \ inet_net_pton.c \ inet_ntop.c \ @@ -97,6 +100,7 @@ HHEADERS = ares__buf.h \ ares__threads.h \ ares_android.h \ ares_data.h \ + ares_dns_multistring.h \ ares_dns_private.h \ ares_event.h \ ares_event_win32.h \ @@ -109,6 +113,5 @@ HHEADERS = ares__buf.h \ ares_str.h \ ares_strsplit.h \ ares_setup.h \ - setup_once.h \ thirdparty/apple/dnsinfo.h diff --git a/lib/c-ares-1.31.0/src/lib/ares__addrinfo2hostent.c b/lib/c-ares-1.32.0/src/lib/ares__addrinfo2hostent.c similarity index 95% rename from lib/c-ares-1.31.0/src/lib/ares__addrinfo2hostent.c rename to lib/c-ares-1.32.0/src/lib/ares__addrinfo2hostent.c index 3e22bc270f6..9505af7340d 100644 --- a/lib/c-ares-1.31.0/src/lib/ares__addrinfo2hostent.c +++ b/lib/c-ares-1.32.0/src/lib/ares__addrinfo2hostent.c @@ -27,7 +27,7 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_NETINET_IN_H # include @@ -47,8 +47,6 @@ # include #endif -#include "ares.h" -#include "ares_private.h" ares_status_t ares__addrinfo2hostent(const struct ares_addrinfo *ai, int family, struct hostent **host) @@ -165,13 +163,13 @@ ares_status_t ares__addrinfo2hostent(const struct ares_addrinfo *ai, int family, if (family == AF_INET6) { memcpy( (*host)->h_addr_list[i], - &(CARES_INADDR_CAST(struct sockaddr_in6 *, next->ai_addr)->sin6_addr), + &(CARES_INADDR_CAST(const struct sockaddr_in6 *, next->ai_addr)->sin6_addr), (size_t)(*host)->h_length); } if (family == AF_INET) { memcpy( (*host)->h_addr_list[i], - &(CARES_INADDR_CAST(struct sockaddr_in *, next->ai_addr)->sin_addr), + &(CARES_INADDR_CAST(const struct sockaddr_in *, next->ai_addr)->sin_addr), (size_t)(*host)->h_length); } ++i; @@ -195,7 +193,7 @@ ares_status_t ares__addrinfo2hostent(const struct ares_addrinfo *ai, int family, ares_free_hostent(*host); *host = NULL; return ARES_ENOMEM; -/* LCOV_EXCL_STOP */ + /* LCOV_EXCL_STOP */ } ares_status_t ares__addrinfo2addrttl(const struct ares_addrinfo *ai, int family, @@ -256,7 +254,7 @@ ares_status_t ares__addrinfo2addrttl(const struct ares_addrinfo *ai, int family, memcpy( &addr6ttls[*naddrttls].ip6addr, - &(CARES_INADDR_CAST(struct sockaddr_in6 *, next->ai_addr)->sin6_addr), + &(CARES_INADDR_CAST(const struct sockaddr_in6 *, next->ai_addr)->sin6_addr), sizeof(struct ares_in6_addr)); } else { if (next->ai_ttl > cname_ttl) { @@ -266,7 +264,7 @@ ares_status_t ares__addrinfo2addrttl(const struct ares_addrinfo *ai, int family, } memcpy( &addrttls[*naddrttls].ipaddr, - &(CARES_INADDR_CAST(struct sockaddr_in *, next->ai_addr)->sin_addr), + &(CARES_INADDR_CAST(const struct sockaddr_in *, next->ai_addr)->sin_addr), sizeof(struct in_addr)); } (*naddrttls)++; diff --git a/lib/c-ares-1.31.0/src/lib/ares__addrinfo_localhost.c b/lib/c-ares-1.32.0/src/lib/ares__addrinfo_localhost.c similarity index 97% rename from lib/c-ares-1.31.0/src/lib/ares__addrinfo_localhost.c rename to lib/c-ares-1.32.0/src/lib/ares__addrinfo_localhost.c index 89ad35d6ec3..e98dd4e277b 100644 --- a/lib/c-ares-1.31.0/src/lib/ares__addrinfo_localhost.c +++ b/lib/c-ares-1.32.0/src/lib/ares__addrinfo_localhost.c @@ -25,7 +25,7 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_NETINET_IN_H # include @@ -49,10 +49,6 @@ # endif #endif -#include "ares.h" -#include "ares_inet_net_pton.h" -#include "ares_private.h" - ares_status_t ares_append_ai_node(int aftype, unsigned short port, unsigned int ttl, const void *adata, struct ares_addrinfo_node **nodes) @@ -140,7 +136,7 @@ static ares_status_t !defined(__WATCOMC__) PMIB_UNICASTIPADDRESS_TABLE table; unsigned int i; - ares_status_t status; + ares_status_t status = ARES_ENOTFOUND; *nodes = NULL; @@ -208,7 +204,7 @@ ares_status_t ares__addrinfo_localhost(const char *name, unsigned short port, case AF_INET6: case AF_UNSPEC: break; - default: /* LCOV_EXCL_LINE: DefensiveCoding */ + default: /* LCOV_EXCL_LINE: DefensiveCoding */ return ARES_EBADFAMILY; /* LCOV_EXCL_LINE: DefensiveCoding */ } @@ -233,5 +229,5 @@ ares_status_t ares__addrinfo_localhost(const char *name, unsigned short port, ares_free(ai->name); ai->name = NULL; return ARES_ENOMEM; -/* LCOV_EXCL_STOP */ + /* LCOV_EXCL_STOP */ } diff --git a/lib/c-ares-1.31.0/src/lib/ares__buf.c b/lib/c-ares-1.32.0/src/lib/ares__buf.c similarity index 91% rename from lib/c-ares-1.31.0/src/lib/ares__buf.c rename to lib/c-ares-1.32.0/src/lib/ares__buf.c index 4388a7d8918..320a73d6748 100644 --- a/lib/c-ares-1.31.0/src/lib/ares__buf.c +++ b/lib/c-ares-1.32.0/src/lib/ares__buf.c @@ -23,8 +23,6 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" #include "ares_private.h" #include "ares__buf.h" #include @@ -839,7 +837,7 @@ ares_status_t ares__buf_split(ares__buf_t *buf, const unsigned char *delims, } if (flags & ARES_BUF_SPLIT_RTRIM) { - while (len && ares__is_whitespace(ptr[len - 1], ARES_TRUE)) { + while (len > 0 && ares__is_whitespace(ptr[len - 1], ARES_TRUE)) { len--; } } @@ -939,13 +937,13 @@ ares_status_t ares__buf_set_position(ares__buf_t *buf, size_t idx) return ARES_SUCCESS; } -static ares_status_t ares__buf_parse_dns_binstr_int( - ares__buf_t *buf, size_t remaining_len, unsigned char **bin, size_t *bin_len, - ares_bool_t allow_multiple, ares_bool_t validate_printable) +ares_status_t ares__buf_parse_dns_abinstr(ares__buf_t *buf, + size_t remaining_len, + ares__dns_multistring_t **strs, + ares_bool_t validate_printable) { unsigned char len; - ares_status_t status; - ares__buf_t *binbuf = NULL; + ares_status_t status = ARES_EBADRESP; size_t orig_len = ares__buf_len(buf); if (buf == NULL) { @@ -956,9 +954,11 @@ static ares_status_t ares__buf_parse_dns_binstr_int( return ARES_EBADRESP; } - binbuf = ares__buf_create(); - if (binbuf == NULL) { - return ARES_ENOMEM; + if (strs != NULL) { + *strs = ares__dns_multistring_create(); + if (*strs == NULL) { + return ARES_ENOMEM; + } } while (orig_len - ares__buf_len(buf) < remaining_len) { @@ -979,22 +979,88 @@ static ares_status_t ares__buf_parse_dns_binstr_int( } } - if (bin != NULL) { - status = ares__buf_fetch_bytes_into_buf(buf, binbuf, len); + if (strs != NULL) { + unsigned char *data = NULL; + status = ares__buf_fetch_bytes_dup(buf, len, ARES_TRUE, &data); + if (status != ARES_SUCCESS) { + break; + } + status = ares__dns_multistring_add_own(*strs, data, len); + if (status != ARES_SUCCESS) { + ares_free(data); + break; + } } else { status = ares__buf_consume(buf, len); + if (status != ARES_SUCCESS) { + break; + } } - if (status != ARES_SUCCESS) { - break; + } + } + + if (status != ARES_SUCCESS && strs != NULL) { + ares__dns_multistring_destroy(*strs); + *strs = NULL; + } + + return status; +} + +static ares_status_t + ares__buf_parse_dns_binstr_int(ares__buf_t *buf, size_t remaining_len, + unsigned char **bin, size_t *bin_len, + ares_bool_t validate_printable) +{ + unsigned char len; + ares_status_t status = ARES_EBADRESP; + ares__buf_t *binbuf = NULL; + + if (buf == NULL) { + return ARES_EFORMERR; + } + + if (remaining_len == 0) { + return ARES_EBADRESP; + } + + binbuf = ares__buf_create(); + if (binbuf == NULL) { + return ARES_ENOMEM; + } + + status = ares__buf_fetch_bytes(buf, &len, 1); + if (status != ARES_SUCCESS) { + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + } + + remaining_len--; + + if (len > remaining_len) { + status = ARES_EBADRESP; + goto done; + } + + if (len) { + /* When used by the _str() parser, it really needs to be validated to + * be a valid printable ascii string. Do that here */ + if (validate_printable && ares__buf_len(buf) >= len) { + size_t mylen; + const char *data = (const char *)ares__buf_peek(buf, &mylen); + if (!ares__str_isprint(data, len)) { + status = ARES_EBADSTR; + goto done; } } - if (!allow_multiple) { - break; + if (bin != NULL) { + status = ares__buf_fetch_bytes_into_buf(buf, binbuf, len); + } else { + status = ares__buf_consume(buf, len); } } - +done: if (status != ARES_SUCCESS) { ares__buf_destroy(binbuf); } else { @@ -1012,20 +1078,19 @@ static ares_status_t ares__buf_parse_dns_binstr_int( } ares_status_t ares__buf_parse_dns_binstr(ares__buf_t *buf, size_t remaining_len, - unsigned char **bin, size_t *bin_len, - ares_bool_t allow_multiple) + unsigned char **bin, size_t *bin_len) { return ares__buf_parse_dns_binstr_int(buf, remaining_len, bin, bin_len, - allow_multiple, ARES_FALSE); + ARES_FALSE); } ares_status_t ares__buf_parse_dns_str(ares__buf_t *buf, size_t remaining_len, - char **str, ares_bool_t allow_multiple) + char **str) { size_t len; - return ares__buf_parse_dns_binstr_int( - buf, remaining_len, (unsigned char **)str, &len, allow_multiple, ARES_TRUE); + return ares__buf_parse_dns_binstr_int(buf, remaining_len, + (unsigned char **)str, &len, ARES_TRUE); } ares_status_t ares__buf_append_num_dec(ares__buf_t *buf, size_t num, size_t len) @@ -1187,24 +1252,24 @@ ares_status_t ares__buf_load_file(const char *filename, ares__buf_t *buf) /* Get length portably, fstat() is POSIX, not C */ if (fseek(fp, 0, SEEK_END) != 0) { status = ARES_EFILE; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } ftell_len = ftell(fp); if (ftell_len < 0) { status = ARES_EFILE; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } len = (size_t)ftell_len; if (fseek(fp, 0, SEEK_SET) != 0) { status = ARES_EFILE; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (len == 0) { status = ARES_SUCCESS; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* Read entire data into buffer */ @@ -1212,13 +1277,13 @@ ares_status_t ares__buf_load_file(const char *filename, ares__buf_t *buf) ptr = ares__buf_append_start(buf, &ptr_len); if (ptr == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } ptr_len = fread(ptr, 1, len, fp); if (ptr_len != len) { status = ARES_EFILE; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } ares__buf_append_finish(buf, len); diff --git a/lib/c-ares-1.31.0/src/lib/ares__buf.h b/lib/c-ares-1.32.0/src/lib/ares__buf.h similarity index 95% rename from lib/c-ares-1.31.0/src/lib/ares__buf.h rename to lib/c-ares-1.32.0/src/lib/ares__buf.h index a9af6431e0f..cb887aa27ed 100644 --- a/lib/c-ares-1.31.0/src/lib/ares__buf.h +++ b/lib/c-ares-1.32.0/src/lib/ares__buf.h @@ -554,13 +554,31 @@ size_t ares__buf_get_position(const ares__buf_t *buf); * \param[out] name Pointer passed by reference to be filled in with * allocated string of the parsed that must be * ares_free()'d by the caller. - * \param[in] allow_multiple ARES_TRUE if it should attempt to parse multiple - * strings back to back, and will concatenate in - * the returned str. * \return ARES_SUCCESS on success */ ares_status_t ares__buf_parse_dns_str(ares__buf_t *buf, size_t remaining_len, - char **name, ares_bool_t allow_multiple); + char **name); + +/*! Parse an array of character strings as defined in RFC1035, as binary, + * however, for convenience this does guarantee a NULL terminator (that is + * not included in the length for each value). + * + * \param[in] buf initialized buffer object + * \param[in] remaining_len maximum length that should be used for + * parsing the string, this is often less than + * the remaining buffer and is based on the RR + * record length. + * \param[out] strs Pointer passed by reference to be filled in + * with + * the array of values. + * \param[out] validate_printable Validate the strings contain only printable + * data. + * \return ARES_SUCCESS on success + */ +ares_status_t ares__buf_parse_dns_abinstr(ares__buf_t *buf, + size_t remaining_len, + ares__dns_multistring_t **strs, + ares_bool_t validate_printable); /*! Parse a character-string as defined in RFC1035, as binary, however for * convenience this does guarantee a NULL terminator (that is not included @@ -574,14 +592,10 @@ ares_status_t ares__buf_parse_dns_str(ares__buf_t *buf, size_t remaining_len, * allocated string of the parsed that must be * ares_free()'d by the caller. * \param[out] bin_len Length of returned string. - * \param[in] allow_multiple ARES_TRUE if it should attempt to parse multiple - * strings back to back, and will concatenate in - * the returned str. * \return ARES_SUCCESS on success */ ares_status_t ares__buf_parse_dns_binstr(ares__buf_t *buf, size_t remaining_len, - unsigned char **bin, size_t *bin_len, - ares_bool_t allow_multiple); + unsigned char **bin, size_t *bin_len); /*! Load data from specified file path into provided buffer. The entire file * is loaded into memory. diff --git a/lib/c-ares-1.31.0/src/lib/ares__close_sockets.c b/lib/c-ares-1.32.0/src/lib/ares__close_sockets.c similarity index 97% rename from lib/c-ares-1.31.0/src/lib/ares__close_sockets.c rename to lib/c-ares-1.32.0/src/lib/ares__close_sockets.c index 06537a5de75..8d7334b4c4d 100644 --- a/lib/c-ares-1.31.0/src/lib/ares__close_sockets.c +++ b/lib/c-ares-1.32.0/src/lib/ares__close_sockets.c @@ -25,16 +25,15 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" - -#include "ares.h" #include "ares_private.h" #include static void ares__requeue_queries(struct server_connection *conn) { struct query *query; - ares_timeval_t now = ares__tvnow(); + ares_timeval_t now; + + ares__tvnow(&now); while ((query = ares__llist_first_val(conn->queries_to_conn)) != NULL) { ares__requeue_query(query, &now); diff --git a/lib/c-ares-1.31.0/src/lib/ares__hosts_file.c b/lib/c-ares-1.32.0/src/lib/ares__hosts_file.c similarity index 96% rename from lib/c-ares-1.31.0/src/lib/ares__hosts_file.c rename to lib/c-ares-1.32.0/src/lib/ares__hosts_file.c index 0f287576658..271386e7b25 100644 --- a/lib/c-ares-1.31.0/src/lib/ares__hosts_file.c +++ b/lib/c-ares-1.32.0/src/lib/ares__hosts_file.c @@ -23,8 +23,6 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" #include "ares_private.h" #ifdef HAVE_SYS_TYPES_H # include @@ -316,7 +314,7 @@ static ares_status_t ares__hosts_file_add(ares_hosts_file_t *hosts, status = ares__hosts_file_merge_entry(hosts, match, entry, matchtype); if (status != ARES_SUCCESS) { ares__hosts_entry_destroy(entry); /* LCOV_EXCL_LINE: DefensiveCoding */ - return status; /* LCOV_EXCL_LINE: DefensiveCoding */ + return status; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* entry was invalidated above by merging */ entry = match; @@ -617,7 +615,8 @@ static ares_bool_t ares__hosts_expired(const char *filename, /* Expire every 60s if we can't get a time */ if (mod_ts == 0) { - mod_ts = time(NULL) - 60; /* LCOV_EXCL_LINE: only on systems without stat() */ + mod_ts = + time(NULL) - 60; /* LCOV_EXCL_LINE: only on systems without stat() */ } /* If filenames are different, its expired */ @@ -779,7 +778,7 @@ ares_status_t ares__hosts_entry_to_hostent(const ares_hosts_entry_t *entry, *hostent = ares_malloc_zero(sizeof(**hostent)); if (*hostent == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } (*hostent)->h_addrtype = (HOSTENT_ADDRTYPE_TYPE)family; @@ -814,7 +813,7 @@ ares_status_t ares__hosts_entry_to_hostent(const ares_hosts_entry_t *entry, (idx + 2) * sizeof(*(*hostent)->h_addr_list)); if (temp == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } (*hostent)->h_addr_list = temp; @@ -822,7 +821,7 @@ ares_status_t ares__hosts_entry_to_hostent(const ares_hosts_entry_t *entry, (*hostent)->h_addr_list[idx] = ares_malloc(ptr_len); if ((*hostent)->h_addr_list[idx] == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } memcpy((*hostent)->h_addr_list[idx], ptr, ptr_len); @@ -840,7 +839,7 @@ ares_status_t ares__hosts_entry_to_hostent(const ares_hosts_entry_t *entry, (*hostent)->h_name = ares_strdup(ares__llist_first_val(entry->hosts)); if ((*hostent)->h_name == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Copy aliases */ @@ -856,7 +855,7 @@ ares_status_t ares__hosts_entry_to_hostent(const ares_hosts_entry_t *entry, ares_malloc_zero((naliases + 1) * sizeof(*(*hostent)->h_aliases)); if ((*hostent)->h_aliases == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Copy all entries to the alias except the first */ @@ -867,7 +866,7 @@ ares_status_t ares__hosts_entry_to_hostent(const ares_hosts_entry_t *entry, (*hostent)->h_aliases[idx] = ares_strdup(ares__llist_node_val(node)); if ((*hostent)->h_aliases[idx] == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } idx++; @@ -885,7 +884,7 @@ ares_status_t ares__hosts_entry_to_hostent(const ares_hosts_entry_t *entry, ares_free_hostent(*hostent); *hostent = NULL; return status; -/* LCOV_EXCL_STOP */ + /* LCOV_EXCL_STOP */ } static ares_status_t @@ -917,19 +916,19 @@ static ares_status_t cname = ares__append_addrinfo_cname(&cnames); if (cname == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } cname->alias = ares_strdup(host); if (cname->alias == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } cname->name = ares_strdup(primaryhost); if (cname->name == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } node = ares__llist_node_next(node); @@ -940,13 +939,13 @@ static ares_status_t cname = ares__append_addrinfo_cname(&cnames); if (cname == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } cname->name = ares_strdup(primaryhost); if (cname->name == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } status = ARES_SUCCESS; @@ -954,7 +953,7 @@ static ares_status_t done: if (status != ARES_SUCCESS) { ares__freeaddrinfo_cnames(cnames); /* LCOV_EXCL_LINE: DefensiveCoding */ - return status; /* LCOV_EXCL_LINE: DefensiveCoding */ + return status; /* LCOV_EXCL_LINE: DefensiveCoding */ } *cnames_out = cnames; @@ -977,14 +976,14 @@ ares_status_t ares__hosts_entry_to_addrinfo(const ares_hosts_entry_t *entry, case AF_INET6: case AF_UNSPEC: break; - default: /* LCOV_EXCL_LINE: DefensiveCoding */ + default: /* LCOV_EXCL_LINE: DefensiveCoding */ return ARES_EBADFAMILY; /* LCOV_EXCL_LINE: DefensiveCoding */ } ai->name = ares_strdup(name); if (ai->name == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } for (node = ares__llist_node_first(entry->ips); node != NULL; diff --git a/lib/c-ares-1.31.0/src/lib/ares__htable.c b/lib/c-ares-1.32.0/src/lib/ares__htable.c similarity index 98% rename from lib/c-ares-1.31.0/src/lib/ares__htable.c rename to lib/c-ares-1.32.0/src/lib/ares__htable.c index f09c9ea2951..d608d60ce3a 100644 --- a/lib/c-ares-1.31.0/src/lib/ares__htable.c +++ b/lib/c-ares-1.32.0/src/lib/ares__htable.c @@ -23,8 +23,6 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" #include "ares_private.h" #include "ares__llist.h" #include "ares__htable.h" @@ -207,7 +205,7 @@ static ares_bool_t ares__htable_expand(ares__htable_t *htable) * middle, we wouldn't be able to recover. */ buckets = ares_malloc_zero(sizeof(*buckets) * htable->size); if (buckets == NULL) { - goto done; /* LCOV_EXCL_LINE */ + goto done; /* LCOV_EXCL_LINE */ } /* The maximum number of new llists we'll need is the number of collisions @@ -270,7 +268,7 @@ static ares_bool_t ares__htable_expand(ares__htable_t *htable) if (buckets[idx] == NULL) { /* Silence static analysis, this isn't possible but it doesn't know */ if (prealloc_llist == NULL || prealloc_llist_len == 0) { - goto done; /* LCOV_EXCL_LINE */ + goto done; /* LCOV_EXCL_LINE */ } buckets[idx] = prealloc_llist[prealloc_llist_len - 1]; prealloc_llist_len--; @@ -304,7 +302,7 @@ static ares_bool_t ares__htable_expand(ares__htable_t *htable) /* On failure, we need to restore the htable size */ if (rv != ARES_TRUE) { - htable->size = old_size; /* LCOV_EXCL_LINE */ + htable->size = old_size; /* LCOV_EXCL_LINE */ } return rv; @@ -336,7 +334,7 @@ ares_bool_t ares__htable_insert(ares__htable_t *htable, void *bucket) if (htable->num_keys + 1 > (htable->size * ARES__HTABLE_EXPAND_PERCENT) / 100) { if (!ares__htable_expand(htable)) { - return ARES_FALSE; /* LCOV_EXCL_LINE */ + return ARES_FALSE; /* LCOV_EXCL_LINE */ } /* If we expanded, need to calculate a new index */ idx = HASH_IDX(htable, key); diff --git a/lib/c-ares-1.31.0/src/lib/ares__htable.h b/lib/c-ares-1.32.0/src/lib/ares__htable.h similarity index 100% rename from lib/c-ares-1.31.0/src/lib/ares__htable.h rename to lib/c-ares-1.32.0/src/lib/ares__htable.h diff --git a/lib/c-ares-1.31.0/src/lib/ares__htable_asvp.c b/lib/c-ares-1.32.0/src/lib/ares__htable_asvp.c similarity index 98% rename from lib/c-ares-1.31.0/src/lib/ares__htable_asvp.c rename to lib/c-ares-1.32.0/src/lib/ares__htable_asvp.c index 42951712934..4b9267ff6c1 100644 --- a/lib/c-ares-1.31.0/src/lib/ares__htable_asvp.c +++ b/lib/c-ares-1.32.0/src/lib/ares__htable_asvp.c @@ -23,8 +23,6 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" #include "ares_private.h" #include "ares__htable.h" #include "ares__htable_asvp.h" @@ -134,7 +132,7 @@ ares_socket_t *ares__htable_asvp_keys(const ares__htable_asvp_t *htable, out = ares_malloc_zero(sizeof(*out) * cnt); if (out == NULL) { ares_free(buckets); /* LCOV_EXCL_LINE: OutOfMemory */ - return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ + return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ } for (i = 0; i < cnt; i++) { diff --git a/lib/c-ares-1.31.0/src/lib/ares__htable_asvp.h b/lib/c-ares-1.32.0/src/lib/ares__htable_asvp.h similarity index 100% rename from lib/c-ares-1.31.0/src/lib/ares__htable_asvp.h rename to lib/c-ares-1.32.0/src/lib/ares__htable_asvp.h diff --git a/lib/c-ares-1.31.0/src/lib/ares__htable_strvp.c b/lib/c-ares-1.32.0/src/lib/ares__htable_strvp.c similarity index 99% rename from lib/c-ares-1.31.0/src/lib/ares__htable_strvp.c rename to lib/c-ares-1.32.0/src/lib/ares__htable_strvp.c index bfae4c36228..d73a1928a75 100644 --- a/lib/c-ares-1.31.0/src/lib/ares__htable_strvp.c +++ b/lib/c-ares-1.32.0/src/lib/ares__htable_strvp.c @@ -23,8 +23,6 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" #include "ares_private.h" #include "ares__htable.h" #include "ares__htable_strvp.h" diff --git a/lib/c-ares-1.31.0/src/lib/ares__htable_strvp.h b/lib/c-ares-1.32.0/src/lib/ares__htable_strvp.h similarity index 100% rename from lib/c-ares-1.31.0/src/lib/ares__htable_strvp.h rename to lib/c-ares-1.32.0/src/lib/ares__htable_strvp.h diff --git a/lib/c-ares-1.31.0/src/lib/ares__htable_szvp.c b/lib/c-ares-1.32.0/src/lib/ares__htable_szvp.c similarity index 99% rename from lib/c-ares-1.31.0/src/lib/ares__htable_szvp.c rename to lib/c-ares-1.32.0/src/lib/ares__htable_szvp.c index 33d8ed3a8df..b3e88d8b9a4 100644 --- a/lib/c-ares-1.31.0/src/lib/ares__htable_szvp.c +++ b/lib/c-ares-1.32.0/src/lib/ares__htable_szvp.c @@ -23,8 +23,6 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" #include "ares_private.h" #include "ares__htable.h" #include "ares__htable_szvp.h" diff --git a/lib/c-ares-1.31.0/src/lib/ares__htable_szvp.h b/lib/c-ares-1.32.0/src/lib/ares__htable_szvp.h similarity index 100% rename from lib/c-ares-1.31.0/src/lib/ares__htable_szvp.h rename to lib/c-ares-1.32.0/src/lib/ares__htable_szvp.h diff --git a/lib/c-ares-1.31.0/src/lib/ares__htable_vpvp.c b/lib/c-ares-1.32.0/src/lib/ares__htable_vpvp.c similarity index 98% rename from lib/c-ares-1.31.0/src/lib/ares__htable_vpvp.c rename to lib/c-ares-1.32.0/src/lib/ares__htable_vpvp.c index e0c009a6401..9042c48dd7f 100644 --- a/lib/c-ares-1.31.0/src/lib/ares__htable_vpvp.c +++ b/lib/c-ares-1.32.0/src/lib/ares__htable_vpvp.c @@ -23,8 +23,6 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" #include "ares_private.h" #include "ares__htable.h" #include "ares__htable_vpvp.h" @@ -114,7 +112,7 @@ ares__htable_vpvp_t * ares_free(htable); } return NULL; -/* LCOV_EXCL_STOP */ + /* LCOV_EXCL_STOP */ } ares_bool_t ares__htable_vpvp_insert(ares__htable_vpvp_t *htable, void *key, diff --git a/lib/c-ares-1.31.0/src/lib/ares__htable_vpvp.h b/lib/c-ares-1.32.0/src/lib/ares__htable_vpvp.h similarity index 100% rename from lib/c-ares-1.31.0/src/lib/ares__htable_vpvp.h rename to lib/c-ares-1.32.0/src/lib/ares__htable_vpvp.h diff --git a/lib/c-ares-1.31.0/src/lib/ares__iface_ips.c b/lib/c-ares-1.32.0/src/lib/ares__iface_ips.c similarity index 98% rename from lib/c-ares-1.31.0/src/lib/ares__iface_ips.c rename to lib/c-ares-1.32.0/src/lib/ares__iface_ips.c index bc120c70393..6c983cabb1c 100644 --- a/lib/c-ares-1.31.0/src/lib/ares__iface_ips.c +++ b/lib/c-ares-1.32.0/src/lib/ares__iface_ips.c @@ -23,8 +23,7 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" - +#include "ares_private.h" #ifdef USE_WINSOCK # include @@ -55,9 +54,10 @@ #ifdef HAVE_NETINET_IN_H # include #endif +#ifdef HAVE_NETDB_H +# include +#endif -#include "ares.h" -#include "ares_private.h" static ares_status_t ares__iface_ips_enumerate(ares__iface_ips_t *ips, const char *name); @@ -89,7 +89,7 @@ static ares__iface_ips_t *ares__iface_ips_alloc(ares__iface_ip_flags_t flags) ips->ips = ares_malloc_zero(ips->alloc_size * sizeof(*ips->ips)); if (ips->ips == NULL) { ares_free(ips); /* LCOV_EXCL_LINE: OutOfMemory */ - return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ + return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ } ips->enum_flags = flags; return ips; @@ -215,8 +215,8 @@ static ares_status_t /* Add */ idx = ips->cnt++; - ips->ips[idx].flags = flags; - ips->ips[idx].netmask = netmask; + ips->ips[idx].flags = flags; + ips->ips[idx].netmask = netmask; if (flags & ARES_IFACE_IP_LINKLOCAL) { ips->ips[idx].ll_scope = ll_scope; } @@ -526,8 +526,9 @@ static ares_status_t ares__iface_ips_enumerate(ares__iface_ips_t *ips, unsigned int ares__if_nametoindex(const char *name) { #ifdef HAVE_IF_NAMETOINDEX - if (name == NULL) + if (name == NULL) { return 0; + } return if_nametoindex(name); #else ares_status_t status; @@ -535,8 +536,9 @@ unsigned int ares__if_nametoindex(const char *name) size_t i; unsigned int index = 0; - if (name == NULL) + if (name == NULL) { return 0; + } status = ares__iface_ips(&ips, ARES_IFACE_IP_V6 | ARES_IFACE_IP_LINKLOCAL, name); diff --git a/lib/c-ares-1.31.0/src/lib/ares__iface_ips.h b/lib/c-ares-1.32.0/src/lib/ares__iface_ips.h similarity index 100% rename from lib/c-ares-1.31.0/src/lib/ares__iface_ips.h rename to lib/c-ares-1.32.0/src/lib/ares__iface_ips.h diff --git a/lib/c-ares-1.31.0/src/lib/ares__llist.c b/lib/c-ares-1.32.0/src/lib/ares__llist.c similarity index 94% rename from lib/c-ares-1.31.0/src/lib/ares__llist.c rename to lib/c-ares-1.32.0/src/lib/ares__llist.c index a094889d687..96936c1abe7 100644 --- a/lib/c-ares-1.31.0/src/lib/ares__llist.c +++ b/lib/c-ares-1.32.0/src/lib/ares__llist.c @@ -23,8 +23,6 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" #include "ares_private.h" #include "ares__llist.h" @@ -186,6 +184,26 @@ ares__llist_node_t *ares__llist_node_first(ares__llist_t *list) return list->head; } +ares__llist_node_t *ares__llist_node_idx(ares__llist_t *list, size_t idx) +{ + ares__llist_node_t *node; + size_t cnt; + + if (list == NULL) { + return NULL; + } + if (idx >= list->cnt) { + return NULL; + } + + node = list->head; + for (cnt = 0; node != NULL && cnt < idx; cnt++) { + node = node->next; + } + + return node; +} + ares__llist_node_t *ares__llist_node_last(ares__llist_t *list) { if (list == NULL) { @@ -323,7 +341,7 @@ void ares__llist_node_replace(ares__llist_node_t *node, void *val) node->data = val; } -void ares__llist_destroy(ares__llist_t *list) +void ares__llist_clear(ares__llist_t *list) { ares__llist_node_t *node; @@ -334,6 +352,14 @@ void ares__llist_destroy(ares__llist_t *list) while ((node = ares__llist_node_first(list)) != NULL) { ares__llist_node_destroy(node); } +} + +void ares__llist_destroy(ares__llist_t *list) +{ + if (list == NULL) { + return; + } + ares__llist_clear(list); ares_free(list); } diff --git a/lib/c-ares-1.31.0/src/lib/ares__llist.h b/lib/c-ares-1.32.0/src/lib/ares__llist.h similarity index 93% rename from lib/c-ares-1.31.0/src/lib/ares__llist.h rename to lib/c-ares-1.32.0/src/lib/ares__llist.h index 7d57bdab3b0..213f54134bc 100644 --- a/lib/c-ares-1.31.0/src/lib/ares__llist.h +++ b/lib/c-ares-1.32.0/src/lib/ares__llist.h @@ -122,6 +122,14 @@ ares__llist_node_t *ares__llist_node_first(ares__llist_t *list); */ ares__llist_node_t *ares__llist_node_last(ares__llist_t *list); +/*! Obtain a node based on its index. This is an O(n) operation. + * + * \param[in] list Initialized list object + * \param[in] idx Index of node to retrieve + * \return node at index or NULL if invalid index + */ +ares__llist_node_t *ares__llist_node_idx(ares__llist_t *list, size_t idx); + /*! Obtain next node in respect to specified node * * \param[in] node Node referenced @@ -136,6 +144,7 @@ ares__llist_node_t *ares__llist_node_next(ares__llist_node_t *node); */ ares__llist_node_t *ares__llist_node_prev(ares__llist_node_t *node); + /*! Obtain value from node * * \param[in] node Node referenced @@ -150,6 +159,12 @@ void *ares__llist_node_val(ares__llist_node_t *node); */ size_t ares__llist_len(const ares__llist_t *list); +/*! Clear all entries in the list, but don't destroy the list object. + * + * \param[in] list Initialized list object + */ +void ares__llist_clear(ares__llist_t *list); + /*! Obtain list object from referenced node * * \param[in] node Node referenced diff --git a/lib/c-ares-1.31.0/src/lib/ares__parse_into_addrinfo.c b/lib/c-ares-1.32.0/src/lib/ares__parse_into_addrinfo.c similarity index 95% rename from lib/c-ares-1.31.0/src/lib/ares__parse_into_addrinfo.c rename to lib/c-ares-1.32.0/src/lib/ares__parse_into_addrinfo.c index e886585d06a..65c94c04014 100644 --- a/lib/c-ares-1.31.0/src/lib/ares__parse_into_addrinfo.c +++ b/lib/c-ares-1.32.0/src/lib/ares__parse_into_addrinfo.c @@ -24,7 +24,7 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_NETINET_IN_H # include @@ -44,8 +44,6 @@ # include #endif -#include "ares.h" -#include "ares_private.h" ares_status_t ares__parse_into_addrinfo(const ares_dns_record_t *dnsrec, ares_bool_t cname_only_is_enodata, @@ -108,18 +106,18 @@ ares_status_t ares__parse_into_addrinfo(const ares_dns_record_t *dnsrec, cname = ares__append_addrinfo_cname(&cnames); if (cname == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } cname->ttl = (int)ares_dns_rr_get_ttl(rr); cname->alias = ares_strdup(ares_dns_rr_get_name(rr)); if (cname->alias == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } cname->name = ares_strdup(hostname); if (cname->name == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } else if (rtype == ARES_REC_TYPE_A) { got_a = ARES_TRUE; @@ -154,7 +152,7 @@ ares_status_t ares__parse_into_addrinfo(const ares_dns_record_t *dnsrec, ai->name = ares_strdup(hostname); if (ai->name == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } diff --git a/lib/c-ares-1.31.0/src/lib/ares__slist.c b/lib/c-ares-1.32.0/src/lib/ares__slist.c similarity index 99% rename from lib/c-ares-1.31.0/src/lib/ares__slist.c rename to lib/c-ares-1.32.0/src/lib/ares__slist.c index 0c92b552ecb..f0e3f8b14a9 100644 --- a/lib/c-ares-1.31.0/src/lib/ares__slist.c +++ b/lib/c-ares-1.32.0/src/lib/ares__slist.c @@ -23,8 +23,6 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" #include "ares_private.h" #include "ares__slist.h" @@ -254,7 +252,7 @@ ares__slist_node_t *ares__slist_insert(ares__slist_t *list, void *val) ares_free(node); } return NULL; -/* LCOV_EXCL_STOP */ + /* LCOV_EXCL_STOP */ } static void ares__slist_node_pop(ares__slist_node_t *node) diff --git a/lib/c-ares-1.31.0/src/lib/ares__slist.h b/lib/c-ares-1.32.0/src/lib/ares__slist.h similarity index 100% rename from lib/c-ares-1.31.0/src/lib/ares__slist.h rename to lib/c-ares-1.32.0/src/lib/ares__slist.h diff --git a/lib/c-ares-1.31.0/src/lib/ares__socket.c b/lib/c-ares-1.32.0/src/lib/ares__socket.c similarity index 98% rename from lib/c-ares-1.31.0/src/lib/ares__socket.c rename to lib/c-ares-1.32.0/src/lib/ares__socket.c index 7c19574e9f7..7796ab2cbef 100644 --- a/lib/c-ares-1.31.0/src/lib/ares__socket.c +++ b/lib/c-ares-1.32.0/src/lib/ares__socket.c @@ -24,7 +24,7 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_SYS_UIO_H # include @@ -56,8 +56,6 @@ #include #include -#include "ares.h" -#include "ares_private.h" ares_ssize_t ares__socket_recvfrom(ares_channel_t *channel, ares_socket_t s, void *data, size_t data_len, int flags, @@ -305,7 +303,7 @@ ares_status_t ares__open_connection(ares_channel_t *channel, setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (void *)&opt, sizeof(opt)) == -1) { ares__close_socket(channel, s); /* LCOV_EXCL_LINE: UntestablePath */ - return ARES_ECONNREFUSED; /* LCOV_EXCL_LINE: UntestablePath */ + return ARES_ECONNREFUSED; /* LCOV_EXCL_LINE: UntestablePath */ } } #endif @@ -339,7 +337,7 @@ ares_status_t ares__open_connection(ares_channel_t *channel, conn = ares_malloc(sizeof(*conn)); if (conn == NULL) { ares__close_socket(channel, s); /* LCOV_EXCL_LINE: OutOfMemory */ - return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } memset(conn, 0, sizeof(*conn)); conn->fd = s; diff --git a/lib/c-ares-1.31.0/src/lib/ares__sortaddrinfo.c b/lib/c-ares-1.32.0/src/lib/ares__sortaddrinfo.c similarity index 99% rename from lib/c-ares-1.31.0/src/lib/ares__sortaddrinfo.c rename to lib/c-ares-1.32.0/src/lib/ares__sortaddrinfo.c index 155cc8caf44..e9bca4e386d 100644 --- a/lib/c-ares-1.31.0/src/lib/ares__sortaddrinfo.c +++ b/lib/c-ares-1.32.0/src/lib/ares__sortaddrinfo.c @@ -36,7 +36,7 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_NETINET_IN_H # include @@ -51,8 +51,6 @@ #include #include -#include "ares.h" -#include "ares_private.h" struct addrinfo_sort_elem { struct ares_addrinfo_node *ai; diff --git a/lib/c-ares-1.31.0/src/lib/ares__threads.c b/lib/c-ares-1.32.0/src/lib/ares__threads.c similarity index 95% rename from lib/c-ares-1.31.0/src/lib/ares__threads.c rename to lib/c-ares-1.32.0/src/lib/ares__threads.c index efa0e09ef27..ae3a66cc31b 100644 --- a/lib/c-ares-1.31.0/src/lib/ares__threads.c +++ b/lib/c-ares-1.32.0/src/lib/ares__threads.c @@ -23,8 +23,6 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" #include "ares_private.h" #ifdef CARES_THREADS @@ -219,34 +217,22 @@ struct ares__thread_mutex { ares__thread_mutex_t *ares__thread_mutex_create(void) { - pthread_mutexattr_t attr; ares__thread_mutex_t *mut = ares_malloc_zero(sizeof(*mut)); if (mut == NULL) { return NULL; } - if (pthread_mutexattr_init(&attr) != 0) { - ares_free(mut); /* LCOV_EXCL_LINE: UntestablePath */ - return NULL; /* LCOV_EXCL_LINE: UntestablePath */ - } - - if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) != 0) { - goto fail; /* LCOV_EXCL_LINE: UntestablePath */ - } - - if (pthread_mutex_init(&mut->mutex, &attr) != 0) { + if (pthread_mutex_init(&mut->mutex, NULL) != 0) { goto fail; /* LCOV_EXCL_LINE: UntestablePath */ } - pthread_mutexattr_destroy(&attr); return mut; /* LCOV_EXCL_START: UntestablePath */ fail: - pthread_mutexattr_destroy(&attr); ares_free(mut); return NULL; -/* LCOV_EXCL_STOP */ + /* LCOV_EXCL_STOP */ } void ares__thread_mutex_destroy(ares__thread_mutex_t *mut) @@ -384,7 +370,7 @@ ares_status_t ares__thread_create(ares__thread_t **thread, return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } if (pthread_create(&thr->thread, NULL, func, arg) != 0) { - ares_free(thr); /* LCOV_EXCL_LINE: UntestablePath */ + ares_free(thr); /* LCOV_EXCL_LINE: UntestablePath */ return ARES_ESERVFAIL; /* LCOV_EXCL_LINE: UntestablePath */ } @@ -564,7 +550,7 @@ ares_status_t ares_queue_wait_empty(ares_channel_t *channel, int timeout_ms) } if (timeout_ms >= 0) { - tout = ares__tvnow(); + ares__tvnow(&tout); tout.sec += (ares_int64_t)(timeout_ms / 1000); tout.usec += (unsigned int)(timeout_ms % 1000) * 1000; } @@ -575,9 +561,10 @@ ares_status_t ares_queue_wait_empty(ares_channel_t *channel, int timeout_ms) ares__thread_cond_wait(channel->cond_empty, channel->lock); } else { ares_timeval_t tv_remaining; - ares_timeval_t tv_now = ares__tvnow(); + ares_timeval_t tv_now; unsigned long tms; + ares__tvnow(&tv_now); ares__timeval_remaining(&tv_remaining, &tv_now, &tout); tms = (unsigned long)((tv_remaining.sec * 1000) + (tv_remaining.usec / 1000)); diff --git a/lib/c-ares-1.31.0/src/lib/ares__threads.h b/lib/c-ares-1.32.0/src/lib/ares__threads.h similarity index 100% rename from lib/c-ares-1.31.0/src/lib/ares__threads.h rename to lib/c-ares-1.32.0/src/lib/ares__threads.h diff --git a/lib/c-ares-1.31.0/src/lib/ares__timeval.c b/lib/c-ares-1.32.0/src/lib/ares__timeval.c similarity index 79% rename from lib/c-ares-1.31.0/src/lib/ares__timeval.c rename to lib/c-ares-1.32.0/src/lib/ares__timeval.c index a41c70631bb..9c175a82a06 100644 --- a/lib/c-ares-1.31.0/src/lib/ares__timeval.c +++ b/lib/c-ares-1.32.0/src/lib/ares__timeval.c @@ -24,64 +24,55 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" #include "ares_private.h" #if defined(_WIN32) && !defined(MSDOS) -ares_timeval_t ares__tvnow(void) +void ares__tvnow(ares_timeval_t *now) { /* GetTickCount64() is available on Windows Vista and higher */ - ares_timeval_t now; ULONGLONG milliseconds = GetTickCount64(); - now.sec = (ares_int64_t)milliseconds / 1000; - now.usec = (unsigned int)(milliseconds % 1000) * 1000; - return now; + now->sec = (ares_int64_t)milliseconds / 1000; + now->usec = (unsigned int)(milliseconds % 1000) * 1000; } #elif defined(HAVE_CLOCK_GETTIME_MONOTONIC) -ares_timeval_t ares__tvnow(void) +void ares__tvnow(ares_timeval_t *now) { /* clock_gettime() is guaranteed to be increased monotonically when the * monotonic clock is queried. Time starting point is unspecified, it * could be the system start-up time, the Epoch, or something else, * in any case the time starting point does not change once that the * system has started up. */ - ares_timeval_t now; struct timespec tsnow; if (clock_gettime(CLOCK_MONOTONIC, &tsnow) == 0) { - now.sec = (ares_int64_t)tsnow.tv_sec; - now.usec = (unsigned int)(tsnow.tv_nsec / 1000); + now->sec = (ares_int64_t)tsnow.tv_sec; + now->usec = (unsigned int)(tsnow.tv_nsec / 1000); } else { /* LCOV_EXCL_START: FallbackCode */ struct timeval tv; (void)gettimeofday(&tv, NULL); - now.sec = (ares_int64_t)tv.tv_sec; - now.usec = (unsigned int)tv.tv_usec; + now->sec = (ares_int64_t)tv.tv_sec; + now->usec = (unsigned int)tv.tv_usec; /* LCOV_EXCL_STOP */ } - return now; } #elif defined(HAVE_GETTIMEOFDAY) -ares_timeval_t ares__tvnow(void) +void ares__tvnow(ares_timeval_t *now) { /* gettimeofday() is not granted to be increased monotonically, due to * clock drifting and external source time synchronization it can jump * forward or backward in time. */ - ares_timeval_t now; struct timeval tv; (void)gettimeofday(&tv, NULL); - now.sec = (ares_int64_t)tv.tv_sec; - now.usec = (unsigned int)tv.tv_usec; - - return now; + now->sec = (ares_int64_t)tv.tv_sec; + now->usec = (unsigned int)tv.tv_usec; } #else diff --git a/lib/c-ares-1.31.0/src/lib/ares_android.c b/lib/c-ares-1.32.0/src/lib/ares_android.c similarity index 99% rename from lib/c-ares-1.31.0/src/lib/ares_android.c rename to lib/c-ares-1.32.0/src/lib/ares_android.c index 778d4d10607..67a9482d72e 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_android.c +++ b/lib/c-ares-1.32.0/src/lib/ares_android.c @@ -24,13 +24,8 @@ * SPDX-License-Identifier: MIT */ #if defined(ANDROID) || defined(__ANDROID__) - -# include - -# include "ares_setup.h" -# include "ares.h" -# include "ares_android.h" # include "ares_private.h" +# include static JavaVM *android_jvm = NULL; static jobject android_connectivity_manager = NULL; diff --git a/lib/c-ares-1.31.0/src/lib/ares_android.h b/lib/c-ares-1.32.0/src/lib/ares_android.h similarity index 100% rename from lib/c-ares-1.31.0/src/lib/ares_android.h rename to lib/c-ares-1.32.0/src/lib/ares_android.h diff --git a/lib/c-ares-1.31.0/src/lib/ares_cancel.c b/lib/c-ares-1.32.0/src/lib/ares_cancel.c similarity index 96% rename from lib/c-ares-1.31.0/src/lib/ares_cancel.c rename to lib/c-ares-1.32.0/src/lib/ares_cancel.c index 8686c366594..c47bdd8a2b7 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_cancel.c +++ b/lib/c-ares-1.32.0/src/lib/ares_cancel.c @@ -24,10 +24,6 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include - -#include "ares.h" #include "ares_private.h" /* @@ -58,7 +54,7 @@ void ares_cancel(ares_channel_t *channel) * can't report to caller */ if (channel->all_queries == NULL) { channel->all_queries = list_copy; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } node = ares__llist_node_first(list_copy); diff --git a/lib/c-ares-1.31.0/src/lib/ares_config.h.cmake b/lib/c-ares-1.32.0/src/lib/ares_config.h.cmake similarity index 97% rename from lib/c-ares-1.31.0/src/lib/ares_config.h.cmake rename to lib/c-ares-1.32.0/src/lib/ares_config.h.cmake index ffe4adf25ae..cafdadd9bbc 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_config.h.cmake +++ b/lib/c-ares-1.32.0/src/lib/ares_config.h.cmake @@ -377,12 +377,6 @@ /* Define to 1 if you have the __system_property_get function */ #cmakedefine HAVE___SYSTEM_PROPERTY_GET 1 -/* Define to 1 if you need the malloc.h header file even with stdlib.h */ -#cmakedefine NEED_MALLOC_H 1 - -/* Define to 1 if you need the memory.h header file even with stdlib.h */ -#cmakedefine NEED_MEMORY_H 1 - /* Define if have arc4random_buf() */ #cmakedefine HAVE_ARC4RANDOM_BUF 1 @@ -443,9 +437,6 @@ /* Define to the function return type for recv. */ #define RECV_TYPE_RETV @RECV_TYPE_RETV@ -/* Define to the type qualifier of arg 2 for send. */ -#define SEND_QUAL_ARG2 @SEND_QUAL_ARG2@ - /* Define to the type of arg 1 for send. */ #define SEND_TYPE_ARG1 @SEND_TYPE_ARG1@ diff --git a/lib/c-ares-1.31.0/src/lib/ares_config.h.in b/lib/c-ares-1.32.0/src/lib/ares_config.h.in similarity index 99% rename from lib/c-ares-1.31.0/src/lib/ares_config.h.in rename to lib/c-ares-1.32.0/src/lib/ares_config.h.in index b75beb44dd6..0a4aa069580 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_config.h.in +++ b/lib/c-ares-1.32.0/src/lib/ares_config.h.in @@ -451,9 +451,6 @@ /* recv() return value */ #undef RECV_TYPE_RETV -/* send() arg2 qualifier */ -#undef SEND_QUAL_ARG2 - /* send() arg1 type */ #undef SEND_TYPE_ARG1 diff --git a/lib/c-ares-1.31.0/src/lib/ares_create_query.c b/lib/c-ares-1.32.0/src/lib/ares_create_query.c similarity index 98% rename from lib/c-ares-1.31.0/src/lib/ares_create_query.c rename to lib/c-ares-1.32.0/src/lib/ares_create_query.c index a2f2caac6e9..f71a71c9513 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_create_query.c +++ b/lib/c-ares-1.32.0/src/lib/ares_create_query.c @@ -24,8 +24,6 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" #include "ares_private.h" static int ares_create_query_int(const char *name, int dnsclass, int type, diff --git a/lib/c-ares-1.31.0/src/lib/ares_data.c b/lib/c-ares-1.32.0/src/lib/ares_data.c similarity index 99% rename from lib/c-ares-1.31.0/src/lib/ares_data.c rename to lib/c-ares-1.32.0/src/lib/ares_data.c index e37088283ba..d25c3fafff5 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_data.c +++ b/lib/c-ares-1.32.0/src/lib/ares_data.c @@ -24,14 +24,10 @@ * SPDX-License-Identifier: MIT */ - -#include "ares_setup.h" - +#include "ares_private.h" #include - -#include "ares.h" +#include #include "ares_data.h" -#include "ares_private.h" /* ** ares_free_data() - c-ares external API function. diff --git a/lib/c-ares-1.31.0/src/lib/ares_data.h b/lib/c-ares-1.32.0/src/lib/ares_data.h similarity index 100% rename from lib/c-ares-1.31.0/src/lib/ares_data.h rename to lib/c-ares-1.32.0/src/lib/ares_data.h diff --git a/lib/c-ares-1.31.0/src/lib/ares_destroy.c b/lib/c-ares-1.32.0/src/lib/ares_destroy.c similarity index 99% rename from lib/c-ares-1.31.0/src/lib/ares_destroy.c rename to lib/c-ares-1.32.0/src/lib/ares_destroy.c index a19e6d0d97c..ade986df6fd 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_destroy.c +++ b/lib/c-ares-1.32.0/src/lib/ares_destroy.c @@ -25,13 +25,9 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" - -#include - -#include "ares.h" #include "ares_private.h" #include "ares_event.h" +#include void ares_destroy(ares_channel_t *channel) { diff --git a/lib/c-ares-1.31.0/src/lib/ares_dns_mapping.c b/lib/c-ares-1.32.0/src/lib/ares_dns_mapping.c similarity index 96% rename from lib/c-ares-1.31.0/src/lib/ares_dns_mapping.c rename to lib/c-ares-1.32.0/src/lib/ares_dns_mapping.c index 6c4362f000b..738d2f3795a 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_dns_mapping.c +++ b/lib/c-ares-1.32.0/src/lib/ares_dns_mapping.c @@ -23,8 +23,6 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" #include "ares_private.h" ares_bool_t ares_dns_opcode_isvalid(ares_dns_opcode_t opcode) @@ -518,9 +516,11 @@ ares_dns_datatype_t ares_dns_rr_key_datatype(ares_dns_rr_key_t key) return ARES_DATATYPE_U8; case ARES_RR_CAA_VALUE: - case ARES_RR_TXT_DATA: return ARES_DATATYPE_BINP; + case ARES_RR_TXT_DATA: + return ARES_DATATYPE_ABINP; + case ARES_RR_SIG_SIGNATURE: case ARES_RR_TLSA_DATA: case ARES_RR_RAW_RR_DATA: @@ -548,18 +548,14 @@ static const ares_dns_rr_key_t rr_hinfo_keys[] = { ARES_RR_HINFO_CPU, ARES_RR_HINFO_OS }; static const ares_dns_rr_key_t rr_mx_keys[] = { ARES_RR_MX_PREFERENCE, ARES_RR_MX_EXCHANGE }; -static const ares_dns_rr_key_t rr_sig_keys[] = { ARES_RR_SIG_TYPE_COVERED, - ARES_RR_SIG_ALGORITHM, - ARES_RR_SIG_LABELS, - ARES_RR_SIG_ORIGINAL_TTL, - ARES_RR_SIG_EXPIRATION, - ARES_RR_SIG_INCEPTION, - ARES_RR_SIG_KEY_TAG, - ARES_RR_SIG_SIGNERS_NAME, - ARES_RR_SIG_SIGNATURE }; -static const ares_dns_rr_key_t rr_txt_keys[] = { ARES_RR_TXT_DATA }; -static const ares_dns_rr_key_t rr_aaaa_keys[] = { ARES_RR_AAAA_ADDR }; -static const ares_dns_rr_key_t rr_srv_keys[] = { +static const ares_dns_rr_key_t rr_sig_keys[] = { + ARES_RR_SIG_TYPE_COVERED, ARES_RR_SIG_ALGORITHM, ARES_RR_SIG_LABELS, + ARES_RR_SIG_ORIGINAL_TTL, ARES_RR_SIG_EXPIRATION, ARES_RR_SIG_INCEPTION, + ARES_RR_SIG_KEY_TAG, ARES_RR_SIG_SIGNERS_NAME, ARES_RR_SIG_SIGNATURE +}; +static const ares_dns_rr_key_t rr_txt_keys[] = { ARES_RR_TXT_DATA }; +static const ares_dns_rr_key_t rr_aaaa_keys[] = { ARES_RR_AAAA_ADDR }; +static const ares_dns_rr_key_t rr_srv_keys[] = { ARES_RR_SRV_PRIORITY, ARES_RR_SRV_WEIGHT, ARES_RR_SRV_PORT, ARES_RR_SRV_TARGET }; static const ares_dns_rr_key_t rr_naptr_keys[] = { diff --git a/lib/c-ares-1.32.0/src/lib/ares_dns_multistring.c b/lib/c-ares-1.32.0/src/lib/ares_dns_multistring.c new file mode 100644 index 00000000000..b81c46c0eee --- /dev/null +++ b/lib/c-ares-1.32.0/src/lib/ares_dns_multistring.c @@ -0,0 +1,207 @@ +/* MIT License + * + * Copyright (c) 2024 Brad House + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * SPDX-License-Identifier: MIT + */ +#include "ares_private.h" +#include "ares_dns_private.h" + +typedef struct { + unsigned char *data; + size_t len; +} multistring_data_t; + +struct ares__dns_multistring { + /*! whether or not cached concatenated string is valid */ + ares_bool_t cache_invalidated; + /*! combined/concatenated string cache */ + unsigned char *cache_str; + /*! length of combined/concatenated string */ + size_t cache_str_len; + /*! Data making up strings */ + multistring_data_t *strs; + size_t cnt; + size_t alloc; +}; + +ares__dns_multistring_t *ares__dns_multistring_create(void) +{ + return ares_malloc_zero(sizeof(ares__dns_multistring_t)); +} + +void ares__dns_multistring_clear(ares__dns_multistring_t *strs) +{ + size_t i; + + if (strs == NULL) { + return; + } + + for (i = 0; i < strs->cnt; i++) { + ares_free(strs->strs[i].data); + memset(&strs->strs[i], 0, sizeof(strs->strs[i])); + } + strs->cnt = 0; +} + +void ares__dns_multistring_destroy(ares__dns_multistring_t *strs) +{ + if (strs == NULL) { + return; + } + ares__dns_multistring_clear(strs); + ares_free(strs->strs); + ares_free(strs->cache_str); + ares_free(strs); +} + +ares_status_t ares__dns_multistring_replace_own(ares__dns_multistring_t *strs, + size_t idx, unsigned char *str, + size_t len) +{ + if (strs == NULL || str == NULL || len == 0 || idx >= strs->cnt) { + return ARES_EFORMERR; + } + + strs->cache_invalidated = ARES_TRUE; + ares_free(strs->strs[idx].data); + strs->strs[idx].data = str; + strs->strs[idx].len = len; + return ARES_SUCCESS; +} + +ares_status_t ares__dns_multistring_del(ares__dns_multistring_t *strs, + size_t idx) +{ + size_t move_cnt; + + if (strs == NULL || idx >= strs->cnt) { + return ARES_EFORMERR; + } + + strs->cache_invalidated = ARES_TRUE; + + ares_free(strs->strs[idx].data); + + move_cnt = strs->cnt - idx - 1; + if (move_cnt) { + memmove(&strs->strs[idx], &strs->strs[idx + 1], + sizeof(*strs->strs) * move_cnt); + } + + strs->cnt--; + return ARES_SUCCESS; +} + +ares_status_t ares__dns_multistring_add_own(ares__dns_multistring_t *strs, + unsigned char *str, size_t len) +{ + if (strs == NULL) { + return ARES_EFORMERR; + } + + strs->cache_invalidated = ARES_TRUE; + + /* NOTE: its ok to have an empty string added */ + if (str == NULL && len != 0) { + return ARES_EFORMERR; + } + + if (strs->alloc < strs->cnt + 1) { + size_t newalloc = (strs->alloc == 0) ? 1 : (strs->alloc << 1); + void *ptr = ares_realloc_zero(strs->strs, strs->alloc * sizeof(*strs->strs), + (newalloc) * sizeof(*strs->strs)); + if (ptr == NULL) { + return ARES_ENOMEM; + } + strs->strs = ptr; + strs->alloc = newalloc; + } + + strs->strs[strs->cnt].data = str; + strs->strs[strs->cnt].len = len; + strs->cnt++; + + return ARES_SUCCESS; +} + +size_t ares__dns_multistring_cnt(const ares__dns_multistring_t *strs) +{ + if (strs == NULL) { + return 0; + } + return strs->cnt; +} + +const unsigned char *ares__dns_multistring_get( + const ares__dns_multistring_t *strs, size_t idx, size_t *len) +{ + if (strs == NULL || idx >= strs->cnt || len == NULL) { + return NULL; + } + + *len = strs->strs[idx].len; + return strs->strs[idx].data; +} + +const unsigned char * + ares__dns_multistring_get_combined(ares__dns_multistring_t *strs, size_t *len) +{ + ares__buf_t *buf = NULL; + size_t i; + + if (strs == NULL || len == NULL) { + return NULL; + } + + *len = 0; + + /* Return cache if possible */ + if (!strs->cache_invalidated) { + *len = strs->cache_str_len; + return strs->cache_str; + } + + /* Clear cache */ + ares_free(strs->cache_str); + strs->cache_str = NULL; + strs->cache_str_len = 0; + + buf = ares__buf_create(); + + for (i = 0; i < strs->cnt; i++) { + if (ares__buf_append(buf, strs->strs[i].data, strs->strs[i].len) != + ARES_SUCCESS) { + ares__buf_destroy(buf); + return NULL; + } + } + + strs->cache_str = + (unsigned char *)ares__buf_finish_str(buf, &strs->cache_str_len); + if (strs->cache_str != NULL) { + strs->cache_invalidated = ARES_FALSE; + } + *len = strs->cache_str_len; + return strs->cache_str; +} diff --git a/lib/c-ares-1.32.0/src/lib/ares_dns_multistring.h b/lib/c-ares-1.32.0/src/lib/ares_dns_multistring.h new file mode 100644 index 00000000000..3588f5615c3 --- /dev/null +++ b/lib/c-ares-1.32.0/src/lib/ares_dns_multistring.h @@ -0,0 +1,49 @@ +/* MIT License + * + * Copyright (c) 2024 Brad House + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * SPDX-License-Identifier: MIT + */ +#ifndef __ARES_DNS_MULTISTRING_H +#define __ARES_DNS_MULTISTRING_H + +struct ares__dns_multistring; +typedef struct ares__dns_multistring ares__dns_multistring_t; + +ares__dns_multistring_t *ares__dns_multistring_create(void); +void ares__dns_multistring_clear(ares__dns_multistring_t *strs); +void ares__dns_multistring_destroy(ares__dns_multistring_t *strs); +ares_status_t ares__dns_multistring_replace_own(ares__dns_multistring_t *strs, + size_t idx, unsigned char *str, + size_t len); +ares_status_t ares__dns_multistring_del(ares__dns_multistring_t *strs, + size_t idx); +ares_status_t ares__dns_multistring_add_own(ares__dns_multistring_t *strs, + unsigned char *str, size_t len); +size_t ares__dns_multistring_cnt(const ares__dns_multistring_t *strs); +const unsigned char *ares__dns_multistring_get( + const ares__dns_multistring_t *strs, size_t idx, size_t *len); +const unsigned char * + ares__dns_multistring_get_combined(ares__dns_multistring_t *strs, + size_t *len); + +#endif diff --git a/lib/c-ares-1.31.0/src/lib/ares_dns_name.c b/lib/c-ares-1.32.0/src/lib/ares_dns_name.c similarity index 96% rename from lib/c-ares-1.31.0/src/lib/ares_dns_name.c rename to lib/c-ares-1.32.0/src/lib/ares_dns_name.c index 754f9fadd2b..076d26643eb 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_dns_name.c +++ b/lib/c-ares-1.32.0/src/lib/ares_dns_name.c @@ -23,8 +23,6 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" #include "ares_private.h" typedef struct { @@ -59,7 +57,7 @@ static ares_status_t ares__nameoffset_create(ares__llist_t **list, } if (*list == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } off = ares_malloc_zero(sizeof(*off)); @@ -73,7 +71,7 @@ static ares_status_t ares__nameoffset_create(ares__llist_t **list, if (ares__llist_insert_last(*list, off) == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } return ARES_SUCCESS; @@ -82,7 +80,7 @@ static ares_status_t ares__nameoffset_create(ares__llist_t **list, fail: ares__nameoffset_free(off); return status; -/* LCOV_EXCL_STOP */ + /* LCOV_EXCL_STOP */ } static const ares_nameoffset_t *ares__nameoffset_find(ares__llist_t *list, @@ -113,7 +111,10 @@ static const ares_nameoffset_t *ares__nameoffset_find(ares__llist_t *list, prefix_len = name_len - val->name_len; - if (strcasecmp(val->name, name + prefix_len) != 0) { + /* Due to DNS 0x20, lets not inadvertently mangle things, use case-sensitive + * matching instead of case-insensitive. This may result in slightly + * larger DNS queries overall. */ + if (strcmp(val->name, name + prefix_len) != 0) { continue; } @@ -269,7 +270,7 @@ static ares_status_t ares_split_dns_name(ares_dns_labels_t *labels, namebuf = ares__buf_create(); if (namebuf == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } if (*name != '\0') { @@ -284,7 +285,7 @@ static ares_status_t ares_split_dns_name(ares_dns_labels_t *labels, label = ares_dns_labels_add(labels); if (label == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } while (ares__buf_fetch_bytes(namebuf, &c, 1) == ARES_SUCCESS) { @@ -293,7 +294,7 @@ static ares_status_t ares_split_dns_name(ares_dns_labels_t *labels, label = ares_dns_labels_add(labels); if (label == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } continue; } @@ -663,7 +664,7 @@ ares_status_t ares__dns_name_parse(ares__buf_t *buf, char **name, *name = ares__buf_finish_str(namebuf, NULL); if (*name == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } } diff --git a/lib/c-ares-1.31.0/src/lib/ares_dns_parse.c b/lib/c-ares-1.32.0/src/lib/ares_dns_parse.c similarity index 96% rename from lib/c-ares-1.31.0/src/lib/ares_dns_parse.c rename to lib/c-ares-1.32.0/src/lib/ares_dns_parse.c index 765f70ce636..57cb0f714e1 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_dns_parse.c +++ b/lib/c-ares-1.32.0/src/lib/ares_dns_parse.c @@ -23,8 +23,6 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" #include "ares_private.h" #include #ifdef HAVE_STDINT_H @@ -62,14 +60,16 @@ static ares_status_t ares_dns_parse_and_set_dns_name(ares__buf_t *buf, return ARES_SUCCESS; } -static ares_status_t ares_dns_parse_and_set_dns_str( - ares__buf_t *buf, size_t max_len, ares_bool_t allow_multiple, - ares_dns_rr_t *rr, ares_dns_rr_key_t key, ares_bool_t blank_allowed) +static ares_status_t ares_dns_parse_and_set_dns_str(ares__buf_t *buf, + size_t max_len, + ares_dns_rr_t *rr, + ares_dns_rr_key_t key, + ares_bool_t blank_allowed) { ares_status_t status; char *str = NULL; - status = ares__buf_parse_dns_str(buf, max_len, &str, allow_multiple); + status = ares__buf_parse_dns_str(buf, max_len, &str); if (status != ARES_SUCCESS) { return status; } @@ -88,23 +88,21 @@ static ares_status_t ares_dns_parse_and_set_dns_str( } static ares_status_t - ares_dns_parse_and_set_dns_binstr(ares__buf_t *buf, size_t max_len, - ares_bool_t allow_multiple, - ares_dns_rr_t *rr, ares_dns_rr_key_t key) + ares_dns_parse_and_set_dns_abin(ares__buf_t *buf, size_t max_len, + ares_dns_rr_t *rr, ares_dns_rr_key_t key, + ares_bool_t validate_printable) { - ares_status_t status; - unsigned char *bin = NULL; - size_t bin_len = 0; + ares_status_t status; + ares__dns_multistring_t *strs = NULL; - status = - ares__buf_parse_dns_binstr(buf, max_len, &bin, &bin_len, allow_multiple); + status = ares__buf_parse_dns_abinstr(buf, max_len, &strs, validate_printable); if (status != ARES_SUCCESS) { return status; } - status = ares_dns_rr_set_bin_own(rr, key, bin, bin_len); + status = ares_dns_rr_set_abin_own(rr, key, strs); if (status != ARES_SUCCESS) { - ares_free(bin); + ares__dns_multistring_destroy(strs); return status; } return ARES_SUCCESS; @@ -257,7 +255,7 @@ static ares_status_t ares_dns_parse_rr_hinfo(ares__buf_t *buf, /* CPU */ status = ares_dns_parse_and_set_dns_str( - buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), ARES_FALSE, rr, + buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), rr, ARES_RR_HINFO_CPU, ARES_TRUE); if (status != ARES_SUCCESS) { return status; @@ -265,7 +263,7 @@ static ares_status_t ares_dns_parse_rr_hinfo(ares__buf_t *buf, /* OS */ status = ares_dns_parse_and_set_dns_str( - buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), ARES_FALSE, rr, + buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), rr, ARES_RR_HINFO_OS, ARES_TRUE); return status; @@ -292,8 +290,8 @@ static ares_status_t ares_dns_parse_rr_mx(ares__buf_t *buf, ares_dns_rr_t *rr, static ares_status_t ares_dns_parse_rr_txt(ares__buf_t *buf, ares_dns_rr_t *rr, size_t rdlength) { - return ares_dns_parse_and_set_dns_binstr(buf, rdlength, ARES_TRUE, rr, - ARES_RR_TXT_DATA); + return ares_dns_parse_and_set_dns_abin(buf, rdlength, rr, ARES_RR_TXT_DATA, + ARES_FALSE); } static ares_status_t ares_dns_parse_rr_sig(ares__buf_t *buf, ares_dns_rr_t *rr, @@ -430,7 +428,7 @@ static ares_status_t ares_dns_parse_rr_naptr(ares__buf_t *buf, /* FLAGS */ status = ares_dns_parse_and_set_dns_str( - buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), ARES_FALSE, rr, + buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), rr, ARES_RR_NAPTR_FLAGS, ARES_TRUE); if (status != ARES_SUCCESS) { return status; @@ -438,7 +436,7 @@ static ares_status_t ares_dns_parse_rr_naptr(ares__buf_t *buf, /* SERVICES */ status = ares_dns_parse_and_set_dns_str( - buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), ARES_FALSE, rr, + buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), rr, ARES_RR_NAPTR_SERVICES, ARES_TRUE); if (status != ARES_SUCCESS) { return status; @@ -446,7 +444,7 @@ static ares_status_t ares_dns_parse_rr_naptr(ares__buf_t *buf, /* REGEXP */ status = ares_dns_parse_and_set_dns_str( - buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), ARES_FALSE, rr, + buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), rr, ARES_RR_NAPTR_REGEXP, ARES_TRUE); if (status != ARES_SUCCESS) { return status; @@ -731,7 +729,7 @@ static ares_status_t ares_dns_parse_rr_caa(ares__buf_t *buf, ares_dns_rr_t *rr, /* Tag */ status = ares_dns_parse_and_set_dns_str( - buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), ARES_FALSE, rr, + buf, ares_dns_rr_remaining_len(buf, orig_len, rdlength), rr, ARES_RR_CAA_TAG, ARES_FALSE); if (status != ARES_SUCCESS) { return status; diff --git a/lib/c-ares-1.31.0/src/lib/ares_dns_private.h b/lib/c-ares-1.32.0/src/lib/ares_dns_private.h similarity index 97% rename from lib/c-ares-1.31.0/src/lib/ares_dns_private.h rename to lib/c-ares-1.32.0/src/lib/ares_dns_private.h index e8e783d559c..c82fb6a9abe 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_dns_private.h +++ b/lib/c-ares-1.32.0/src/lib/ares_dns_private.h @@ -41,6 +41,9 @@ ares_status_t ares_dns_rr_set_str_own(ares_dns_rr_t *dns_rr, ares_status_t ares_dns_rr_set_bin_own(ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key, unsigned char *val, size_t len); +ares_status_t ares_dns_rr_set_abin_own(ares_dns_rr_t *dns_rr, + ares_dns_rr_key_t key, + ares__dns_multistring_t *strs); ares_status_t ares_dns_rr_set_opt_own(ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key, unsigned short opt, unsigned char *val, size_t val_len); @@ -120,8 +123,7 @@ typedef struct { } ares__dns_mx_t; typedef struct { - char *data; - size_t data_len; + ares__dns_multistring_t *strs; } ares__dns_txt_t; typedef struct { diff --git a/lib/c-ares-1.31.0/src/lib/ares_dns_record.c b/lib/c-ares-1.32.0/src/lib/ares_dns_record.c similarity index 88% rename from lib/c-ares-1.31.0/src/lib/ares_dns_record.c rename to lib/c-ares-1.32.0/src/lib/ares_dns_record.c index 5d109999946..0131743e462 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_dns_record.c +++ b/lib/c-ares-1.32.0/src/lib/ares_dns_record.c @@ -23,8 +23,6 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" #include "ares_private.h" #include #ifdef HAVE_STDINT_H @@ -68,6 +66,15 @@ unsigned short ares_dns_record_get_id(const ares_dns_record_t *dnsrec) return dnsrec->id; } +ares_bool_t ares_dns_record_set_id(ares_dns_record_t *dnsrec, unsigned short id) +{ + if (dnsrec == NULL) { + return ARES_FALSE; + } + dnsrec->id = id; + return ARES_TRUE; +} + unsigned short ares_dns_record_get_flags(const ares_dns_record_t *dnsrec) { if (dnsrec == NULL) { @@ -145,7 +152,7 @@ static void ares__dns_rr_free(ares_dns_rr_t *rr) break; case ARES_REC_TYPE_TXT: - ares_free(rr->r.txt.data); + ares__dns_multistring_destroy(rr->r.txt.strs); break; case ARES_REC_TYPE_SIG: @@ -293,7 +300,7 @@ ares_status_t ares_dns_record_query_set_name(ares_dns_record_t *dnsrec, dnsrec->qd[idx].name = ares_strdup(name); if (dnsrec->qd[idx].name == NULL) { dnsrec->qd[idx].name = orig_name; /* LCOV_EXCL_LINE: OutOfMemory */ - return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } ares_free(orig_name); @@ -664,11 +671,7 @@ static void *ares_dns_rr_data_ptr(ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key, return &dns_rr->r.sig.signature; case ARES_RR_TXT_DATA: - if (lenptr == NULL) { - return NULL; - } - *lenptr = &dns_rr->r.txt.data_len; - return &dns_rr->r.txt.data; + return &dns_rr->r.txt.strs; case ARES_RR_SRV_PRIORITY: return &dns_rr->r.srv.priority; @@ -883,26 +886,138 @@ const unsigned char *ares_dns_rr_get_bin(const ares_dns_rr_t *dns_rr, size_t const *bin_len = NULL; if ((ares_dns_rr_key_datatype(key) != ARES_DATATYPE_BIN && - ares_dns_rr_key_datatype(key) != ARES_DATATYPE_BINP) || + ares_dns_rr_key_datatype(key) != ARES_DATATYPE_BINP && + ares_dns_rr_key_datatype(key) != ARES_DATATYPE_ABINP) || len == NULL) { return NULL; } + /* Array of strings, return concatenated version */ + if (ares_dns_rr_key_datatype(key) == ARES_DATATYPE_ABINP) { + ares__dns_multistring_t * const *strs = + ares_dns_rr_data_ptr_const(dns_rr, key, NULL); + + if (strs == NULL) { + return NULL; + } + + return ares__dns_multistring_get_combined(*strs, len); + } + + /* Not a multi-string, just straight binary data */ bin = ares_dns_rr_data_ptr_const(dns_rr, key, &bin_len); if (bin == NULL) { - return 0; + return NULL; } /* Shouldn't be possible */ if (bin_len == NULL) { return NULL; } - *len = *bin_len; return *bin; } +size_t ares_dns_rr_get_abin_cnt(const ares_dns_rr_t *dns_rr, + ares_dns_rr_key_t key) +{ + ares__dns_multistring_t * const *strs; + + if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_ABINP) { + return 0; + } + + strs = ares_dns_rr_data_ptr_const(dns_rr, key, NULL); + if (strs == NULL) { + return 0; + } + + return ares__dns_multistring_cnt(*strs); +} + +const unsigned char *ares_dns_rr_get_abin(const ares_dns_rr_t *dns_rr, + ares_dns_rr_key_t key, size_t idx, + size_t *len) +{ + ares__dns_multistring_t * const *strs; + + if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_ABINP) { + return NULL; + } + + strs = ares_dns_rr_data_ptr_const(dns_rr, key, NULL); + if (strs == NULL) { + return NULL; + } + + return ares__dns_multistring_get(*strs, idx, len); +} + +ares_status_t ares_dns_rr_del_abin(ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key, + size_t idx) +{ + ares__dns_multistring_t **strs; + + if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_ABINP) { + return ARES_EFORMERR; + } + + strs = ares_dns_rr_data_ptr(dns_rr, key, NULL); + if (strs == NULL) { + return ARES_EFORMERR; + } + + return ares__dns_multistring_del(*strs, idx); +} + +ares_status_t ares_dns_rr_add_abin(ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key, + const unsigned char *val, size_t len) +{ + ares_status_t status; + ares_dns_datatype_t datatype = ares_dns_rr_key_datatype(key); + ares_bool_t is_nullterm = + (datatype == ARES_DATATYPE_ABINP) ? ARES_TRUE : ARES_FALSE; + size_t alloclen = is_nullterm ? len + 1 : len; + unsigned char *temp; + ares__dns_multistring_t **strs; + + if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_ABINP) { + return ARES_EFORMERR; + } + + strs = ares_dns_rr_data_ptr(dns_rr, key, NULL); + if (strs == NULL) { + return ARES_EFORMERR; + } + + if (*strs == NULL) { + *strs = ares__dns_multistring_create(); + if (*strs == NULL) { + return ARES_ENOMEM; + } + } + + temp = ares_malloc(alloclen); + if (temp == NULL) { + return ARES_ENOMEM; + } + + memcpy(temp, val, len); + + /* NULL-term ABINP */ + if (is_nullterm) { + temp[len] = 0; + } + + status = ares__dns_multistring_add_own(*strs, temp, len); + if (status != ARES_SUCCESS) { + ares_free(temp); + } + + return status; +} + const char *ares_dns_rr_get_str(const ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key) { @@ -1115,10 +1230,30 @@ ares_status_t ares_dns_rr_set_bin_own(ares_dns_rr_t *dns_rr, size_t *bin_len = NULL; if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_BIN && - ares_dns_rr_key_datatype(key) != ARES_DATATYPE_BINP) { + ares_dns_rr_key_datatype(key) != ARES_DATATYPE_BINP && + ares_dns_rr_key_datatype(key) != ARES_DATATYPE_ABINP) { return ARES_EFORMERR; } + if (ares_dns_rr_key_datatype(key) == ARES_DATATYPE_ABINP) { + ares__dns_multistring_t **strs = ares_dns_rr_data_ptr(dns_rr, key, NULL); + if (strs == NULL) { + return ARES_EFORMERR; + } + + if (*strs == NULL) { + *strs = ares__dns_multistring_create(); + if (*strs == NULL) { + return ARES_ENOMEM; + } + } + + /* Clear all existing entries as this is an override */ + ares__dns_multistring_clear(*strs); + + return ares__dns_multistring_add_own(*strs, val, len); + } + bin = ares_dns_rr_data_ptr(dns_rr, key, &bin_len); if (bin == NULL || bin_len == NULL) { return ARES_EFORMERR; @@ -1138,7 +1273,11 @@ ares_status_t ares_dns_rr_set_bin(ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key, { ares_status_t status; ares_dns_datatype_t datatype = ares_dns_rr_key_datatype(key); - size_t alloclen = (datatype == ARES_DATATYPE_BINP) ? len + 1 : len; + ares_bool_t is_nullterm = + (datatype == ARES_DATATYPE_BINP || datatype == ARES_DATATYPE_ABINP) + ? ARES_TRUE + : ARES_FALSE; + size_t alloclen = is_nullterm ? len + 1 : len; unsigned char *temp = ares_malloc(alloclen); if (temp == NULL) { @@ -1148,7 +1287,7 @@ ares_status_t ares_dns_rr_set_bin(ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key, memcpy(temp, val, len); /* NULL-term BINP */ - if (datatype == ARES_DATATYPE_BINP) { + if (is_nullterm) { temp[len] = 0; } @@ -1204,6 +1343,29 @@ ares_status_t ares_dns_rr_set_str(ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key, return status; } +ares_status_t ares_dns_rr_set_abin_own(ares_dns_rr_t *dns_rr, + ares_dns_rr_key_t key, + ares__dns_multistring_t *strs) +{ + ares__dns_multistring_t **strs_ptr; + + if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_ABINP) { + return ARES_EFORMERR; + } + + strs_ptr = ares_dns_rr_data_ptr(dns_rr, key, NULL); + if (strs_ptr == NULL) { + return ARES_EFORMERR; + } + + if (*strs_ptr != NULL) { + ares__dns_multistring_destroy(*strs_ptr); + } + *strs_ptr = strs; + + return ARES_SUCCESS; +} + ares_status_t ares_dns_rr_set_opt_own(ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key, unsigned short opt, unsigned char *val, size_t val_len) diff --git a/lib/c-ares-1.31.0/src/lib/ares_dns_write.c b/lib/c-ares-1.32.0/src/lib/ares_dns_write.c similarity index 96% rename from lib/c-ares-1.31.0/src/lib/ares_dns_write.c rename to lib/c-ares-1.32.0/src/lib/ares_dns_write.c index 6cf15bf4e61..60bbd702889 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_dns_write.c +++ b/lib/c-ares-1.32.0/src/lib/ares_dns_write.c @@ -23,8 +23,6 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" #include "ares_private.h" #include #ifdef HAVE_STDINT_H @@ -220,20 +218,14 @@ static ares_status_t ares_dns_write_rr_str(ares__buf_t *buf, return ares__buf_append(buf, (const unsigned char *)str, len); } -static ares_status_t ares_dns_write_rr_binstrs(ares__buf_t *buf, - const ares_dns_rr_t *rr, - ares_dns_rr_key_t key) +static ares_status_t ares_dns_write_binstr(ares__buf_t *buf, + const unsigned char *bin, + size_t bin_len) { - const unsigned char *bin; const unsigned char *ptr; - size_t bin_len; size_t ptr_len; ares_status_t status; - bin = ares_dns_rr_get_bin(rr, key, &bin_len); - if (bin == NULL) { - return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ - } /* split into possible multiple 255-byte or less length strings */ ptr = bin; ptr_len = bin_len; @@ -264,6 +256,33 @@ static ares_status_t ares_dns_write_rr_binstrs(ares__buf_t *buf, return ARES_SUCCESS; } +static ares_status_t ares_dns_write_rr_abin(ares__buf_t *buf, + const ares_dns_rr_t *rr, + ares_dns_rr_key_t key) +{ + ares_status_t status = ARES_EFORMERR; + size_t i; + size_t cnt = ares_dns_rr_get_abin_cnt(rr, key); + + if (cnt == 0) { + return ARES_EFORMERR; + } + + for (i = 0; i < cnt; i++) { + const unsigned char *bin; + size_t bin_len; + + bin = ares_dns_rr_get_abin(rr, key, i, &bin_len); + + status = ares_dns_write_binstr(buf, bin, bin_len); + if (status != ARES_SUCCESS) { + break; + } + } + + return status; +} + static ares_status_t ares_dns_write_rr_be32(ares__buf_t *buf, const ares_dns_rr_t *rr, ares_dns_rr_key_t key) @@ -421,7 +440,7 @@ static ares_status_t ares_dns_write_rr_txt(ares__buf_t *buf, ares__llist_t **namelist) { (void)namelist; - return ares_dns_write_rr_binstrs(buf, rr, ARES_RR_TXT_DATA); + return ares_dns_write_rr_abin(buf, rr, ARES_RR_TXT_DATA); } static ares_status_t ares_dns_write_rr_sig(ares__buf_t *buf, @@ -589,6 +608,12 @@ static ares_status_t ares_dns_write_rr_opt(ares__buf_t *buf, (void)namelist; + /* Coverity reports on this even though its not possible when taken + * into context */ + if (len == 0) { + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ + } + /* We need to go back and overwrite the class and ttl that were emitted as * the OPT record overloads them for its own use (yes, very strange!) */ status = ares__buf_set_length(buf, len - 2 /* RDLENGTH */ @@ -865,6 +890,12 @@ static ares_status_t ares_dns_write_rr_raw_rr(ares__buf_t *buf, (void)namelist; + /* Coverity reports on this even though its not possible when taken + * into context */ + if (len == 0) { + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ + } + /* We need to go back and overwrite the type that was emitted by the parent * function */ status = ares__buf_set_length(buf, len - 2 /* RDLENGTH */ diff --git a/lib/c-ares-1.31.0/src/lib/ares_event.h b/lib/c-ares-1.32.0/src/lib/ares_event.h similarity index 99% rename from lib/c-ares-1.31.0/src/lib/ares_event.h rename to lib/c-ares-1.32.0/src/lib/ares_event.h index f5d044d2a6c..317731fc428 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_event.h +++ b/lib/c-ares-1.32.0/src/lib/ares_event.h @@ -26,8 +26,6 @@ #ifndef __ARES__EVENT_H #define __ARES__EVENT_H -#include "ares_setup.h" - struct ares_event; typedef struct ares_event ares_event_t; diff --git a/lib/c-ares-1.31.0/src/lib/ares_event_configchg.c b/lib/c-ares-1.32.0/src/lib/ares_event_configchg.c similarity index 89% rename from lib/c-ares-1.31.0/src/lib/ares_event_configchg.c rename to lib/c-ares-1.32.0/src/lib/ares_event_configchg.c index b7c5ad8c75b..efdfc0409d6 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_event_configchg.c +++ b/lib/c-ares-1.32.0/src/lib/ares_event_configchg.c @@ -23,8 +23,6 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" #include "ares_private.h" #include "ares_event.h" @@ -149,7 +147,7 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, c->inotify_fd = inotify_init1(IN_NONBLOCK | IN_CLOEXEC); if (c->inotify_fd == -1) { status = ARES_ESERVFAIL; /* LCOV_EXCL_LINE: UntestablePath */ - goto done; /* LCOV_EXCL_LINE: UntestablePath */ + goto done; /* LCOV_EXCL_LINE: UntestablePath */ } /* We need to monitor /etc/resolv.conf, /etc/nsswitch.conf */ @@ -157,7 +155,7 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, IN_CREATE | IN_MODIFY | IN_MOVED_TO | IN_ONLYDIR) == -1) { status = ARES_ESERVFAIL; /* LCOV_EXCL_LINE: UntestablePath */ - goto done; /* LCOV_EXCL_LINE: UntestablePath */ + goto done; /* LCOV_EXCL_LINE: UntestablePath */ } status = @@ -250,32 +248,29 @@ static void ares_event_configchg_ip_cb(PVOID CallerContext, } # endif -static ares_bool_t ares_event_configchg_regnotify(ares_event_configchg_t *configchg) +static ares_bool_t + ares_event_configchg_regnotify(ares_event_configchg_t *configchg) { # if defined(__WATCOMC__) && !defined(REG_NOTIFY_THREAD_AGNOSTIC) # define REG_NOTIFY_THREAD_AGNOSTIC 0x10000000L # endif - DWORD flags = - REG_NOTIFY_CHANGE_NAME|REG_NOTIFY_CHANGE_LAST_SET|REG_NOTIFY_THREAD_AGNOSTIC; + DWORD flags = REG_NOTIFY_CHANGE_NAME | REG_NOTIFY_CHANGE_LAST_SET | + REG_NOTIFY_THREAD_AGNOSTIC; - if (RegNotifyChangeKeyValue(configchg->regip4, TRUE, - flags, - configchg->regip4_event, - TRUE) != ERROR_SUCCESS) { + if (RegNotifyChangeKeyValue(configchg->regip4, TRUE, flags, + configchg->regip4_event, TRUE) != ERROR_SUCCESS) { return ARES_FALSE; } - if (RegNotifyChangeKeyValue(configchg->regip6, TRUE, - flags, - configchg->regip6_event, - TRUE) != ERROR_SUCCESS) { + if (RegNotifyChangeKeyValue(configchg->regip6, TRUE, flags, + configchg->regip6_event, TRUE) != ERROR_SUCCESS) { return ARES_FALSE; } return ARES_TRUE; } -static VOID CALLBACK ares_event_configchg_reg_cb(PVOID lpParameter, +static VOID CALLBACK ares_event_configchg_reg_cb(PVOID lpParameter, BOOLEAN TimerOrWaitFired) { ares_event_configchg_t *configchg = lpParameter; @@ -301,7 +296,7 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, c->e = e; -#ifndef __WATCOMC__ +# ifndef __WATCOMC__ /* NOTE: If a user goes into the control panel and changes the network * adapter DNS addresses manually, this will NOT trigger a notification. * We've also tried listening on NotifyUnicastIpAddressChange(), but @@ -313,20 +308,22 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, status = ARES_ESERVFAIL; goto done; } -#endif +# endif /* Monitor HKLM\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\Interfaces * and HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces * for changes via RegNotifyChangeKeyValue() */ - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, - "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces", - 0, KEY_NOTIFY, &c->regip4) != ERROR_SUCCESS) { + if (RegOpenKeyExW( + HKEY_LOCAL_MACHINE, + L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces", 0, + KEY_NOTIFY, &c->regip4) != ERROR_SUCCESS) { status = ARES_ESERVFAIL; goto done; } - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, - "SYSTEM\\CurrentControlSet\\Services\\Tcpip6\\Parameters\\Interfaces", + if (RegOpenKeyExW( + HKEY_LOCAL_MACHINE, + L"SYSTEM\\CurrentControlSet\\Services\\Tcpip6\\Parameters\\Interfaces", 0, KEY_NOTIFY, &c->regip6) != ERROR_SUCCESS) { status = ARES_ESERVFAIL; goto done; @@ -345,13 +342,15 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, } if (!RegisterWaitForSingleObject(&c->regip4_wait, c->regip4_event, - ares_event_configchg_reg_cb, c, INFINITE, WT_EXECUTEDEFAULT)) { + ares_event_configchg_reg_cb, c, INFINITE, + WT_EXECUTEDEFAULT)) { status = ARES_ESERVFAIL; goto done; } if (!RegisterWaitForSingleObject(&c->regip6_wait, c->regip6_event, - ares_event_configchg_reg_cb, c, INFINITE, WT_EXECUTEDEFAULT)) { + ares_event_configchg_reg_cb, c, INFINITE, + WT_EXECUTEDEFAULT)) { status = ARES_ESERVFAIL; goto done; } @@ -446,15 +445,16 @@ static void ares_event_configchg_cb(ares_event_thread_t *e, ares_socket_t fd, ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, ares_event_thread_t *e) { - ares_status_t status = ARES_SUCCESS; - void *handle = NULL; - const char *(*pdns_configuration_notify_key)(void) = NULL; - const char *notify_key = NULL; - int flags; - size_t i; - const char *searchlibs[] = { + ares_status_t status = ARES_SUCCESS; + void *handle = NULL; + const char *(*pdns_configuration_notify_key)(void) = NULL; + const char *notify_key = NULL; + int flags; + size_t i; + const char *searchlibs[] = { "/usr/lib/libSystem.dylib", - "/System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration", + "/System/Library/Frameworks/SystemConfiguration.framework/" + "SystemConfiguration", NULL }; @@ -464,14 +464,15 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, } /* Load symbol as it isn't normally public */ - for (i=0; searchlibs[i] != NULL; i++) { + for (i = 0; searchlibs[i] != NULL; i++) { handle = dlopen(searchlibs[i], RTLD_LAZY); if (handle == NULL) { /* Fail, loop! */ continue; } - pdns_configuration_notify_key = dlsym(handle, "dns_configuration_notify_key"); + pdns_configuration_notify_key = (const char *(*)(void)) + dlsym(handle, "dns_configuration_notify_key"); if (pdns_configuration_notify_key != NULL) { break; } @@ -548,10 +549,15 @@ static ares_status_t config_change_check(ares__htable_strvp_t *filestat, const char *resolvconf_path) { size_t i; - const char *configfiles[] = { resolvconf_path, "/etc/nsswitch.conf", - "/etc/netsvc.conf", "/etc/svc.conf", NULL }; + const char *configfiles[5]; ares_bool_t changed = ARES_FALSE; + configfiles[0] = resolvconf_path; + configfiles[1] = "/etc/nsswitch.conf"; + configfiles[2] = "/etc/netsvc.conf"; + configfiles[3] = "/etc/svc.conf"; + configfiles[4] = NULL; + for (i = 0; configfiles[i] != NULL; i++) { fileinfo_t *fi = ares__htable_strvp_get_direct(filestat, configfiles[i]); struct stat st; diff --git a/lib/c-ares-1.31.0/src/lib/ares_event_epoll.c b/lib/c-ares-1.32.0/src/lib/ares_event_epoll.c similarity index 95% rename from lib/c-ares-1.31.0/src/lib/ares_event_epoll.c rename to lib/c-ares-1.32.0/src/lib/ares_event_epoll.c index 9ebd87c05c2..5eb25cccc9e 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_event_epoll.c +++ b/lib/c-ares-1.32.0/src/lib/ares_event_epoll.c @@ -23,8 +23,6 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" #include "ares_private.h" #include "ares_event.h" @@ -73,20 +71,16 @@ static ares_bool_t ares_evsys_epoll_init(ares_event_thread_t *e) e->ev_sys_data = ep; - ep->epoll_fd = epoll_create1(0); + ep->epoll_fd = epoll_create1(EPOLL_CLOEXEC); if (ep->epoll_fd == -1) { ares_evsys_epoll_destroy(e); /* LCOV_EXCL_LINE: UntestablePath */ - return ARES_FALSE; /* LCOV_EXCL_LINE: UntestablePath */ + return ARES_FALSE; /* LCOV_EXCL_LINE: UntestablePath */ } -# ifdef FD_CLOEXEC - fcntl(ep->epoll_fd, F_SETFD, FD_CLOEXEC); -# endif - e->ev_signal = ares_pipeevent_create(e); if (e->ev_signal == NULL) { ares_evsys_epoll_destroy(e); /* LCOV_EXCL_LINE: UntestablePath */ - return ARES_FALSE; /* LCOV_EXCL_LINE: UntestablePath */ + return ARES_FALSE; /* LCOV_EXCL_LINE: UntestablePath */ } return ARES_TRUE; diff --git a/lib/c-ares-1.31.0/src/lib/ares_event_kqueue.c b/lib/c-ares-1.32.0/src/lib/ares_event_kqueue.c similarity index 99% rename from lib/c-ares-1.31.0/src/lib/ares_event_kqueue.c rename to lib/c-ares-1.32.0/src/lib/ares_event_kqueue.c index 7e2c60abf51..585033e05ae 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_event_kqueue.c +++ b/lib/c-ares-1.32.0/src/lib/ares_event_kqueue.c @@ -23,8 +23,6 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" #include "ares_private.h" #include "ares_event.h" diff --git a/lib/c-ares-1.31.0/src/lib/ares_event_poll.c b/lib/c-ares-1.32.0/src/lib/ares_event_poll.c similarity index 98% rename from lib/c-ares-1.31.0/src/lib/ares_event_poll.c rename to lib/c-ares-1.32.0/src/lib/ares_event_poll.c index bcaac791994..42ffd912e95 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_event_poll.c +++ b/lib/c-ares-1.32.0/src/lib/ares_event_poll.c @@ -23,8 +23,6 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" #include "ares_private.h" #include "ares_event.h" #ifdef HAVE_POLL_H diff --git a/lib/c-ares-1.31.0/src/lib/ares_event_select.c b/lib/c-ares-1.32.0/src/lib/ares_event_select.c similarity index 99% rename from lib/c-ares-1.31.0/src/lib/ares_event_select.c rename to lib/c-ares-1.32.0/src/lib/ares_event_select.c index 89b399b92ac..980652002c3 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_event_select.c +++ b/lib/c-ares-1.32.0/src/lib/ares_event_select.c @@ -29,8 +29,6 @@ * anyhow */ #define FD_SETSIZE 4096 -#include "ares_setup.h" -#include "ares.h" #include "ares_private.h" #include "ares_event.h" #ifdef HAVE_SYS_SELECT_H diff --git a/lib/c-ares-1.31.0/src/lib/ares_event_thread.c b/lib/c-ares-1.32.0/src/lib/ares_event_thread.c similarity index 94% rename from lib/c-ares-1.31.0/src/lib/ares_event_thread.c rename to lib/c-ares-1.32.0/src/lib/ares_event_thread.c index e87313f6296..48aacdedd57 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_event_thread.c +++ b/lib/c-ares-1.32.0/src/lib/ares_event_thread.c @@ -23,8 +23,6 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" #include "ares_private.h" #include "ares_event.h" @@ -128,7 +126,7 @@ ares_status_t ares_event_update(ares_event_t **event, ares_event_thread_t *e, } if (ares__llist_insert_last(e->ev_updates, ev) == NULL) { - ares_free(ev); /* LCOV_EXCL_LINE: OutOfMemory */ + ares_free(ev); /* LCOV_EXCL_LINE: OutOfMemory */ return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -274,16 +272,19 @@ static void *ares_event_thread(void *arg) const struct timeval *tvout; unsigned long timeout_ms = 0; /* 0 = unlimited */ + ares_event_process_updates(e); + + /* Don't hold a mutex while waiting on events or calling into anything + * that might require a c-ares channel lock since a callback could be + * triggered cross-thread */ + ares__thread_mutex_unlock(e->mutex); + tvout = ares_timeout(e->channel, NULL, &tv); if (tvout != NULL) { timeout_ms = (unsigned long)((tvout->tv_sec * 1000) + (tvout->tv_usec / 1000) + 1); } - ares_event_process_updates(e); - - /* Don't hold a mutex while waiting on events */ - ares__thread_mutex_unlock(e->mutex); e->ev_sys->wait(e, timeout_ms); /* Each iteration should do timeout processing */ @@ -391,22 +392,23 @@ static const ares_event_sys_t *ares_event_fetch_sys(ares_evsys_t evsys) /* case ARES_EVSYS_DEFAULT: */ default: + break; + } + + /* default */ #if defined(USE_WINSOCK) - return &ares_evsys_win32; + return &ares_evsys_win32; #elif defined(HAVE_KQUEUE) - return &ares_evsys_kqueue; + return &ares_evsys_kqueue; #elif defined(HAVE_EPOLL) - return &ares_evsys_epoll; + return &ares_evsys_epoll; #elif defined(HAVE_POLL) - return &ares_evsys_poll; + return &ares_evsys_poll; #elif defined(HAVE_PIPE) - return &ares_evsys_select; + return &ares_evsys_select; #else - break; -#endif - } - return NULL; +#endif } ares_status_t ares_event_thread_init(ares_channel_t *channel) @@ -421,25 +423,25 @@ ares_status_t ares_event_thread_init(ares_channel_t *channel) e->mutex = ares__thread_mutex_create(); if (e->mutex == NULL) { ares_event_thread_destroy_int(e); /* LCOV_EXCL_LINE: OutOfMemory */ - return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } e->ev_updates = ares__llist_create(NULL); if (e->ev_updates == NULL) { ares_event_thread_destroy_int(e); /* LCOV_EXCL_LINE: OutOfMemory */ - return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } e->ev_sock_handles = ares__htable_asvp_create(ares_event_destroy_cb); if (e->ev_sock_handles == NULL) { ares_event_thread_destroy_int(e); /* LCOV_EXCL_LINE: OutOfMemory */ - return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } e->ev_cust_handles = ares__htable_vpvp_create(NULL, ares_event_destroy_cb); if (e->ev_cust_handles == NULL) { ares_event_thread_destroy_int(e); /* LCOV_EXCL_LINE: OutOfMemory */ - return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } e->channel = channel; @@ -447,7 +449,7 @@ ares_status_t ares_event_thread_init(ares_channel_t *channel) e->ev_sys = ares_event_fetch_sys(channel->evsys); if (e->ev_sys == NULL) { ares_event_thread_destroy_int(e); /* LCOV_EXCL_LINE: UntestablePath */ - return ARES_ENOTIMP; /* LCOV_EXCL_LINE: UntestablePath */ + return ARES_ENOTIMP; /* LCOV_EXCL_LINE: UntestablePath */ } channel->sock_state_cb = ares_event_thread_sockstate_cb; diff --git a/lib/c-ares-1.31.0/src/lib/ares_event_wake_pipe.c b/lib/c-ares-1.32.0/src/lib/ares_event_wake_pipe.c similarity index 96% rename from lib/c-ares-1.31.0/src/lib/ares_event_wake_pipe.c rename to lib/c-ares-1.32.0/src/lib/ares_event_wake_pipe.c index c0aa70b5dea..282d013dc62 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_event_wake_pipe.c +++ b/lib/c-ares-1.32.0/src/lib/ares_event_wake_pipe.c @@ -23,8 +23,6 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" #include "ares_private.h" #include "ares_event.h" #ifdef HAVE_UNISTD_H @@ -69,7 +67,7 @@ static ares_pipeevent_t *ares_pipeevent_init(void) # ifdef HAVE_PIPE2 if (pipe2(p->filedes, O_NONBLOCK | O_CLOEXEC) != 0) { ares_pipeevent_destroy(p); /* LCOV_EXCL_LINE: UntestablePath */ - return NULL; /* LCOV_EXCL_LINE: UntestablePath */ + return NULL; /* LCOV_EXCL_LINE: UntestablePath */ } # else if (pipe(p->filedes) != 0) { @@ -157,7 +155,7 @@ ares_event_t *ares_pipeevent_create(ares_event_thread_t *e) ares_pipeevent_signal); if (status != ARES_SUCCESS) { ares_pipeevent_destroy(p); /* LCOV_EXCL_LINE: DefensiveCoding */ - return NULL; /* LCOV_EXCL_LINE: DefensiveCoding */ + return NULL; /* LCOV_EXCL_LINE: DefensiveCoding */ } return event; diff --git a/lib/c-ares-1.31.0/src/lib/ares_event_win32.c b/lib/c-ares-1.32.0/src/lib/ares_event_win32.c similarity index 96% rename from lib/c-ares-1.31.0/src/lib/ares_event_win32.c rename to lib/c-ares-1.32.0/src/lib/ares_event_win32.c index fa84864b4be..4e4b9c53c33 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_event_win32.c +++ b/lib/c-ares-1.32.0/src/lib/ares_event_win32.c @@ -24,8 +24,12 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" +/* Uses an anonymous union */ +#if defined(__clang__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wc11-extensions" +#endif + #include "ares_private.h" #include "ares_event.h" #include "ares_event_win32.h" @@ -254,12 +258,28 @@ static ares_bool_t ares_evsys_win32_init(ares_event_thread_t *e) goto fail; } +#ifdef __GNUC__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wpedantic" +/* Without the (void *) cast we get: + * warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'NTSTATUS (*)(...)'} [-Wcast-function-type] + * but with it we get: + * warning: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic] + * look unsolvable short of killing the warning. + */ +#endif + + /* Load Internal symbols not typically accessible */ ew->NtDeviceIoControlFile = (NtDeviceIoControlFile_t)(void *)GetProcAddress( ntdll, "NtDeviceIoControlFile"); ew->NtCancelIoFileEx = (NtCancelIoFileEx_t)(void *)GetProcAddress(ntdll, "NtCancelIoFileEx"); +#ifdef __GNUC__ +# pragma GCC diagnostic pop +#endif + if (ew->NtCancelIoFileEx == NULL || ew->NtDeviceIoControlFile == NULL) { goto fail; } @@ -365,8 +385,6 @@ static ares_bool_t ares_evsys_win32_afd_enqueue(ares_event_t *event, IOCTL_AFD_POLL, &ed->afd_poll_info, sizeof(ed->afd_poll_info), &ed->afd_poll_info, sizeof(ed->afd_poll_info)); if (status != STATUS_SUCCESS && status != STATUS_PENDING) { - printf("%s(): failed to perform IOCTL_AFD_POLL operation\n", __FUNCTION__); - fflush(stdout); return ARES_FALSE; } @@ -441,8 +459,6 @@ static ares_bool_t ares_evsys_win32_event_add(ares_event_t *event) ed->base_socket = ares_evsys_win32_basesocket(ed->socket); if (ed->base_socket == ARES_SOCKET_BAD) { - fprintf(stderr, "%s(): could not determine base socket for fd %d\n", - __FUNCTION__, (int)event->fd); ares_evsys_win32_eventdata_destroy(ed); return ARES_FALSE; } @@ -451,9 +467,6 @@ static ares_bool_t ares_evsys_win32_event_add(ares_event_t *event) * socket handle */ if (WSADuplicateSocketW(ed->base_socket, GetCurrentProcessId(), &protocol_info) != 0) { - fprintf(stderr, - "%s(): could not retrieve protocol info for creating peer socket\n", - __FUNCTION__); ares_evsys_win32_eventdata_destroy(ed); return ARES_FALSE; } @@ -462,7 +475,6 @@ static ares_bool_t ares_evsys_win32_event_add(ares_event_t *event) WSASocketW(protocol_info.iAddressFamily, protocol_info.iSocketType, protocol_info.iProtocol, &protocol_info, 0, WSA_FLAG_OVERLAPPED); if (ed->peer_socket == ARES_SOCKET_BAD) { - fprintf(stderr, "%s(): could not create peer socket\n", __FUNCTION__); ares_evsys_win32_eventdata_destroy(ed); return ARES_FALSE; } @@ -471,7 +483,6 @@ static ares_bool_t ares_evsys_win32_event_add(ares_event_t *event) if (CreateIoCompletionPort((HANDLE)ed->peer_socket, ew->iocp_handle, (ULONG_PTR)ed, 0) == NULL) { - fprintf(stderr, "%s(): failed to bind peer socket to IOCP\n", __FUNCTION__); ares_evsys_win32_eventdata_destroy(ed); return ARES_FALSE; } @@ -599,3 +610,7 @@ const ares_event_sys_t ares_evsys_win32 = { "win32", ares_evsys_win32_event_mod, ares_evsys_win32_wait }; #endif + +#if defined(__clang__) +# pragma GCC diagnostic pop +#endif diff --git a/lib/c-ares-1.31.0/src/lib/ares_event_win32.h b/lib/c-ares-1.32.0/src/lib/ares_event_win32.h similarity index 100% rename from lib/c-ares-1.31.0/src/lib/ares_event_win32.h rename to lib/c-ares-1.32.0/src/lib/ares_event_win32.h diff --git a/lib/c-ares-1.31.0/src/lib/ares_expand_name.c b/lib/c-ares-1.32.0/src/lib/ares_expand_name.c similarity index 97% rename from lib/c-ares-1.31.0/src/lib/ares_expand_name.c rename to lib/c-ares-1.32.0/src/lib/ares_expand_name.c index 8f6728dedd3..63bd6451668 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_expand_name.c +++ b/lib/c-ares-1.32.0/src/lib/ares_expand_name.c @@ -25,7 +25,7 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_NETINET_IN_H # include @@ -33,9 +33,6 @@ #include "ares_nameser.h" -#include "ares.h" -#include "ares_private.h" /* for the memdebug */ - ares_status_t ares__expand_name_validated(const unsigned char *encoded, const unsigned char *abuf, size_t alen, char **s, size_t *enclen, diff --git a/lib/c-ares-1.31.0/src/lib/ares_expand_string.c b/lib/c-ares-1.32.0/src/lib/ares_expand_string.c similarity index 95% rename from lib/c-ares-1.31.0/src/lib/ares_expand_string.c rename to lib/c-ares-1.32.0/src/lib/ares_expand_string.c index 502125a8af5..570ccd917a3 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_expand_string.c +++ b/lib/c-ares-1.32.0/src/lib/ares_expand_string.c @@ -25,7 +25,7 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_NETINET_IN_H # include @@ -33,9 +33,6 @@ #include "ares_nameser.h" -#include "ares.h" -#include "ares_private.h" /* for the memdebug */ - /* Simply decodes a length-encoded character string. The first byte of the * input is the length of the string to be returned and the bytes thereafter * are the characters of the string. The returned result will be NULL @@ -78,7 +75,7 @@ ares_status_t ares_expand_string_ex(const unsigned char *encoded, start_len = ares__buf_len(buf); status = - ares__buf_parse_dns_binstr(buf, ares__buf_len(buf), s, &len, ARES_FALSE); + ares__buf_parse_dns_binstr(buf, ares__buf_len(buf), s, &len); /* hrm, no way to pass back 'len' with the prototype */ if (status != ARES_SUCCESS) { goto done; diff --git a/lib/c-ares-1.31.0/src/lib/ares_fds.c b/lib/c-ares-1.32.0/src/lib/ares_fds.c similarity index 98% rename from lib/c-ares-1.31.0/src/lib/ares_fds.c rename to lib/c-ares-1.32.0/src/lib/ares_fds.c index e39823304a7..0502e71182a 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_fds.c +++ b/lib/c-ares-1.32.0/src/lib/ares_fds.c @@ -25,9 +25,6 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" - -#include "ares.h" #include "ares_private.h" int ares_fds(const ares_channel_t *channel, fd_set *read_fds, fd_set *write_fds) diff --git a/lib/c-ares-1.31.0/src/lib/ares_free_hostent.c b/lib/c-ares-1.32.0/src/lib/ares_free_hostent.c similarity index 95% rename from lib/c-ares-1.31.0/src/lib/ares_free_hostent.c rename to lib/c-ares-1.32.0/src/lib/ares_free_hostent.c index a088c1b15cd..bf2037238b5 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_free_hostent.c +++ b/lib/c-ares-1.32.0/src/lib/ares_free_hostent.c @@ -24,16 +24,12 @@ * * SPDX-License-Identifier: MIT */ - -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_NETDB_H # include #endif -#include "ares.h" -#include "ares_private.h" /* for memdebug */ - void ares_free_hostent(struct hostent *host) { char **p; diff --git a/lib/c-ares-1.31.0/src/lib/ares_free_string.c b/lib/c-ares-1.32.0/src/lib/ares_free_string.c similarity index 96% rename from lib/c-ares-1.31.0/src/lib/ares_free_string.c rename to lib/c-ares-1.32.0/src/lib/ares_free_string.c index 39773067bd2..048ad5d2ae2 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_free_string.c +++ b/lib/c-ares-1.32.0/src/lib/ares_free_string.c @@ -25,9 +25,6 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" - -#include "ares.h" #include "ares_private.h" void ares_free_string(void *str) diff --git a/lib/c-ares-1.31.0/src/lib/ares_freeaddrinfo.c b/lib/c-ares-1.32.0/src/lib/ares_freeaddrinfo.c similarity index 97% rename from lib/c-ares-1.31.0/src/lib/ares_freeaddrinfo.c rename to lib/c-ares-1.32.0/src/lib/ares_freeaddrinfo.c index 45d931a3f86..2a49f57531e 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_freeaddrinfo.c +++ b/lib/c-ares-1.32.0/src/lib/ares_freeaddrinfo.c @@ -25,15 +25,12 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_NETDB_H # include #endif -#include "ares.h" -#include "ares_private.h" - void ares__freeaddrinfo_cnames(struct ares_addrinfo_cname *head) { struct ares_addrinfo_cname *current; diff --git a/lib/c-ares-1.31.0/src/lib/ares_getaddrinfo.c b/lib/c-ares-1.32.0/src/lib/ares_getaddrinfo.c similarity index 97% rename from lib/c-ares-1.31.0/src/lib/ares_getaddrinfo.c rename to lib/c-ares-1.32.0/src/lib/ares_getaddrinfo.c index 51463402e2f..8a195ed0220 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_getaddrinfo.c +++ b/lib/c-ares-1.32.0/src/lib/ares_getaddrinfo.c @@ -26,7 +26,7 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_GETSERVBYNAME_R # if !defined(GETSERVBYNAME_R_ARGS) || (GETSERVBYNAME_R_ARGS < 4) || \ @@ -56,8 +56,6 @@ # include #endif -#include "ares.h" -#include "ares_private.h" #include "ares_dns.h" #ifdef _WIN32 @@ -254,7 +252,7 @@ static ares_bool_t fake_addrinfo(const char *name, unsigned short port, ares_bool_t valid = ARES_TRUE; const char *p; for (p = name; *p; p++) { - if (!ISDIGIT(*p) && *p != '.') { + if (!isdigit(*p) && *p != '.') { valid = ARES_FALSE; break; } else if (*p == '.') { @@ -275,7 +273,7 @@ static ares_bool_t fake_addrinfo(const char *name, unsigned short port, status = ares_append_ai_node(AF_INET, port, 0, &addr4, &ai->nodes); if (status != ARES_SUCCESS) { callback(arg, (int)status, 0, NULL); /* LCOV_EXCL_LINE: OutOfMemory */ - return ARES_TRUE; /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_TRUE; /* LCOV_EXCL_LINE: OutOfMemory */ } } } @@ -289,7 +287,7 @@ static ares_bool_t fake_addrinfo(const char *name, unsigned short port, status = ares_append_ai_node(AF_INET6, port, 0, &addr6, &ai->nodes); if (status != ARES_SUCCESS) { callback(arg, (int)status, 0, NULL); /* LCOV_EXCL_LINE: OutOfMemory */ - return ARES_TRUE; /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_TRUE; /* LCOV_EXCL_LINE: OutOfMemory */ } } } @@ -674,20 +672,20 @@ static ares_bool_t next_dns_lookup(struct host_query *hquery) switch (hquery->hints.ai_family) { case AF_INET: hquery->remaining += 1; - ares_query_dnsrec(hquery->channel, name, ARES_CLASS_IN, ARES_REC_TYPE_A, + ares_query_nolock(hquery->channel, name, ARES_CLASS_IN, ARES_REC_TYPE_A, host_callback, hquery, &hquery->qid_a); break; case AF_INET6: hquery->remaining += 1; - ares_query_dnsrec(hquery->channel, name, ARES_CLASS_IN, + ares_query_nolock(hquery->channel, name, ARES_CLASS_IN, ARES_REC_TYPE_AAAA, host_callback, hquery, &hquery->qid_aaaa); break; case AF_UNSPEC: hquery->remaining += 2; - ares_query_dnsrec(hquery->channel, name, ARES_CLASS_IN, ARES_REC_TYPE_A, + ares_query_nolock(hquery->channel, name, ARES_CLASS_IN, ARES_REC_TYPE_A, host_callback, hquery, &hquery->qid_a); - ares_query_dnsrec(hquery->channel, name, ARES_CLASS_IN, + ares_query_nolock(hquery->channel, name, ARES_CLASS_IN, ARES_REC_TYPE_AAAA, host_callback, hquery, &hquery->qid_aaaa); break; diff --git a/lib/c-ares-1.31.0/src/lib/ares_getenv.c b/lib/c-ares-1.32.0/src/lib/ares_getenv.c similarity index 98% rename from lib/c-ares-1.31.0/src/lib/ares_getenv.c rename to lib/c-ares-1.32.0/src/lib/ares_getenv.c index 08601a61e54..4f471673b9d 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_getenv.c +++ b/lib/c-ares-1.32.0/src/lib/ares_getenv.c @@ -25,7 +25,7 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #include "ares_getenv.h" #ifndef HAVE_GETENV diff --git a/lib/c-ares-1.31.0/src/lib/ares_getenv.h b/lib/c-ares-1.32.0/src/lib/ares_getenv.h similarity index 98% rename from lib/c-ares-1.31.0/src/lib/ares_getenv.h rename to lib/c-ares-1.32.0/src/lib/ares_getenv.h index d8bd3a2195b..490097fc8d3 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_getenv.h +++ b/lib/c-ares-1.32.0/src/lib/ares_getenv.h @@ -27,8 +27,6 @@ #ifndef HEADER_CARES_GETENV_H #define HEADER_CARES_GETENV_H -#include "ares_setup.h" - #ifndef HAVE_GETENV extern char *ares_getenv(const char *name); #endif diff --git a/lib/c-ares-1.31.0/src/lib/ares_gethostbyaddr.c b/lib/c-ares-1.32.0/src/lib/ares_gethostbyaddr.c similarity index 93% rename from lib/c-ares-1.31.0/src/lib/ares_gethostbyaddr.c rename to lib/c-ares-1.32.0/src/lib/ares_gethostbyaddr.c index 9676e17edfb..1db81ec2b48 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_gethostbyaddr.c +++ b/lib/c-ares-1.32.0/src/lib/ares_gethostbyaddr.c @@ -25,7 +25,7 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_NETINET_IN_H # include @@ -38,11 +38,8 @@ #endif #include "ares_nameser.h" - -#include "ares.h" #include "ares_inet_net_pton.h" #include "ares_platform.h" -#include "ares_private.h" struct addr_query { /* Arguments passed to ares_gethostbyaddr() */ @@ -64,9 +61,9 @@ static ares_status_t file_lookup(ares_channel_t *channel, const struct ares_addr *addr, struct hostent **host); -static void ares_gethostbyaddr_int(ares_channel_t *channel, const void *addr, - int addrlen, int family, - ares_host_callback callback, void *arg) +void ares_gethostbyaddr_nolock(ares_channel_t *channel, const void *addr, + int addrlen, int family, + ares_host_callback callback, void *arg) { struct addr_query *aquery; @@ -116,7 +113,7 @@ void ares_gethostbyaddr(ares_channel_t *channel, const void *addr, int addrlen, return; } ares__channel_lock(channel); - ares_gethostbyaddr_int(channel, addr, addrlen, family, callback, arg); + ares_gethostbyaddr_nolock(channel, addr, addrlen, family, callback, arg); ares__channel_unlock(channel); } @@ -132,11 +129,12 @@ static void next_lookup(struct addr_query *aquery) case 'b': name = ares_dns_addr_to_ptr(&aquery->addr); if (name == NULL) { - end_aquery(aquery, ARES_ENOMEM, NULL); /* LCOV_EXCL_LINE: OutOfMemory */ - return; /* LCOV_EXCL_LINE: OutOfMemory */ + end_aquery(aquery, ARES_ENOMEM, + NULL); /* LCOV_EXCL_LINE: OutOfMemory */ + return; /* LCOV_EXCL_LINE: OutOfMemory */ } aquery->remaining_lookups = p + 1; - ares_query_dnsrec(aquery->channel, name, ARES_CLASS_IN, + ares_query_nolock(aquery->channel, name, ARES_CLASS_IN, ARES_REC_TYPE_PTR, addr_callback, aquery, NULL); ares_free(name); return; diff --git a/lib/c-ares-1.31.0/src/lib/ares_gethostbyname.c b/lib/c-ares-1.32.0/src/lib/ares_gethostbyname.c similarity index 97% rename from lib/c-ares-1.31.0/src/lib/ares_gethostbyname.c rename to lib/c-ares-1.32.0/src/lib/ares_gethostbyname.c index 2a8ec555d4e..6db86e0eed1 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_gethostbyname.c +++ b/lib/c-ares-1.32.0/src/lib/ares_gethostbyname.c @@ -25,7 +25,7 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_NETINET_IN_H # include @@ -43,10 +43,8 @@ # include #endif -#include "ares.h" #include "ares_inet_net_pton.h" #include "ares_platform.h" -#include "ares_private.h" static void sort_addresses(const struct hostent *host, const struct apattern *sortlist, size_t nsort); @@ -102,13 +100,17 @@ static void ares_gethostbyname_callback(void *arg, int status, int timeouts, void ares_gethostbyname(ares_channel_t *channel, const char *name, int family, ares_host_callback callback, void *arg) { - const struct ares_addrinfo_hints hints = { ARES_AI_CANONNAME, family, 0, 0 }; - struct host_query *ghbn_arg; + struct ares_addrinfo_hints hints; + struct host_query *ghbn_arg; if (!callback) { return; } + memset(&hints, 0, sizeof(hints)); + hints.ai_flags = ARES_AI_CANONNAME; + hints.ai_family = family; + ghbn_arg = ares_malloc(sizeof(*ghbn_arg)); if (!ghbn_arg) { callback(arg, ARES_ENOMEM, 0, NULL); @@ -249,7 +251,7 @@ static ares_status_t ares__hostent_localhost(const char *name, int family, ai = ares_malloc_zero(sizeof(*ai)); if (ai == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ares__addrinfo_localhost(name, 0, &hints, ai); diff --git a/lib/c-ares-1.31.0/src/lib/ares_getnameinfo.c b/lib/c-ares-1.32.0/src/lib/ares_getnameinfo.c similarity index 94% rename from lib/c-ares-1.31.0/src/lib/ares_getnameinfo.c rename to lib/c-ares-1.32.0/src/lib/ares_getnameinfo.c index 57c6ddaf999..622c1adb1c7 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_getnameinfo.c +++ b/lib/c-ares-1.32.0/src/lib/ares_getnameinfo.c @@ -23,7 +23,7 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_GETSERVBYPORT_R # if !defined(GETSERVBYPORT_R_ARGS) || (GETSERVBYPORT_R_ARGS < 4) || \ @@ -51,9 +51,7 @@ # include #endif -#include "ares.h" #include "ares_ipv6.h" -#include "ares_private.h" struct nameinfo_query { ares_nameinfo_callback callback; @@ -81,8 +79,8 @@ static void nameinfo_callback(void *arg, int status, int timeouts, static char *lookup_service(unsigned short port, unsigned int flags, char *buf, size_t buflen); #ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID -static void append_scopeid(const struct sockaddr_in6 *addr6, - unsigned int flags, char *buf, size_t buflen); +static void append_scopeid(const struct sockaddr_in6 *addr6, unsigned int flags, + char *buf, size_t buflen); #endif static char *ares_striendstr(const char *s1, const char *s2); @@ -100,11 +98,11 @@ static void ares_getnameinfo_int(ares_channel_t *channel, /* Validate socket address family and length */ if (sa && sa->sa_family == AF_INET && salen >= (ares_socklen_t)sizeof(struct sockaddr_in)) { - addr = CARES_INADDR_CAST(struct sockaddr_in *, sa); + addr = CARES_INADDR_CAST(const struct sockaddr_in *, sa); port = addr->sin_port; } else if (sa && sa->sa_family == AF_INET6 && salen >= (ares_socklen_t)sizeof(struct sockaddr_in6)) { - addr6 = CARES_INADDR_CAST(struct sockaddr_in6 *, sa); + addr6 = CARES_INADDR_CAST(const struct sockaddr_in6 *, sa); port = addr6->sin6_port; } else { callback(arg, ARES_ENOTIMP, 0, NULL, NULL); @@ -173,14 +171,15 @@ static void ares_getnameinfo_int(ares_channel_t *channel, if (sa->sa_family == AF_INET) { niquery->family = AF_INET; memcpy(&niquery->addr.addr4, addr, sizeof(niquery->addr.addr4)); - ares_gethostbyaddr(channel, &addr->sin_addr, sizeof(struct in_addr), - AF_INET, nameinfo_callback, niquery); + ares_gethostbyaddr_nolock(channel, &addr->sin_addr, + sizeof(struct in_addr), AF_INET, + nameinfo_callback, niquery); } else { niquery->family = AF_INET6; memcpy(&niquery->addr.addr6, addr6, sizeof(niquery->addr.addr6)); - ares_gethostbyaddr(channel, &addr6->sin6_addr, - sizeof(struct ares_in6_addr), AF_INET6, - nameinfo_callback, niquery); + ares_gethostbyaddr_nolock(channel, &addr6->sin6_addr, + sizeof(struct ares_in6_addr), AF_INET6, + nameinfo_callback, niquery); } } } @@ -411,8 +410,8 @@ static char *ares_striendstr(const char *s1, const char *s2) c1 = c1_begin; c2 = s2; while (c2 < s2 + s2_len) { - lo1 = TOLOWER(*c1); - lo2 = TOLOWER(*c2); + lo1 = ares__tolower((unsigned char)*c1); + lo2 = ares__tolower((unsigned char)*c2); if (lo1 != lo2) { return NULL; } else { diff --git a/lib/c-ares-1.31.0/src/lib/ares_getsock.c b/lib/c-ares-1.32.0/src/lib/ares_getsock.c similarity index 98% rename from lib/c-ares-1.31.0/src/lib/ares_getsock.c rename to lib/c-ares-1.32.0/src/lib/ares_getsock.c index b64c075572d..836d9b973ed 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_getsock.c +++ b/lib/c-ares-1.32.0/src/lib/ares_getsock.c @@ -24,9 +24,6 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" - -#include "ares.h" #include "ares_private.h" int ares_getsock(const ares_channel_t *channel, ares_socket_t *socks, diff --git a/lib/c-ares-1.31.0/src/lib/ares_inet_net_pton.h b/lib/c-ares-1.32.0/src/lib/ares_inet_net_pton.h similarity index 100% rename from lib/c-ares-1.31.0/src/lib/ares_inet_net_pton.h rename to lib/c-ares-1.32.0/src/lib/ares_inet_net_pton.h diff --git a/lib/c-ares-1.31.0/src/lib/ares_init.c b/lib/c-ares-1.32.0/src/lib/ares_init.c similarity index 98% rename from lib/c-ares-1.31.0/src/lib/ares_init.c rename to lib/c-ares-1.32.0/src/lib/ares_init.c index be3cfacf581..5456444ae49 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_init.c +++ b/lib/c-ares-1.32.0/src/lib/ares_init.c @@ -25,7 +25,7 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_SYS_PARAM_H # include @@ -61,10 +61,8 @@ # include #endif -#include "ares.h" #include "ares_inet_net_pton.h" #include "ares_platform.h" -#include "ares_private.h" #include "ares_event.h" int ares_init(ares_channel_t **channelptr) @@ -197,7 +195,7 @@ static ares_status_t init_by_defaults(ares_channel_t *channel) hostname = ares_malloc(len); if (!hostname) { rc = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto error; /* LCOV_EXCL_LINE: OutOfMemory */ + goto error; /* LCOV_EXCL_LINE: OutOfMemory */ } do { @@ -210,7 +208,7 @@ static ares_status_t init_by_defaults(ares_channel_t *channel) p = ares_realloc(hostname, len); if (!p) { rc = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto error; /* LCOV_EXCL_LINE: OutOfMemory */ + goto error; /* LCOV_EXCL_LINE: OutOfMemory */ } hostname = p; continue; @@ -229,12 +227,12 @@ static ares_status_t init_by_defaults(ares_channel_t *channel) channel->domains = ares_malloc(sizeof(char *)); if (!channel->domains) { rc = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto error; /* LCOV_EXCL_LINE: OutOfMemory */ + goto error; /* LCOV_EXCL_LINE: OutOfMemory */ } channel->domains[0] = ares_strdup(dot + 1); if (!channel->domains[0]) { rc = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto error; /* LCOV_EXCL_LINE: OutOfMemory */ + goto error; /* LCOV_EXCL_LINE: OutOfMemory */ } channel->ndomains = 1; } @@ -488,7 +486,6 @@ int ares_dup(ares_channel_t **dest, const ares_channel_t *src) *dest = NULL; /* in case of failure return NULL explicitly */ - ares__channel_lock(src); /* First get the options supported by the old ares_save_options() function, which is most of them */ rc = (ares_status_t)ares_save_options(src, &opts, &optmask); @@ -507,6 +504,7 @@ int ares_dup(ares_channel_t **dest, const ares_channel_t *src) goto done; } + ares__channel_lock(src); /* Now clone the options that ares_save_options() doesn't support, but are * user-provided */ (*dest)->sock_create_cb = src->sock_create_cb; @@ -522,7 +520,7 @@ int ares_dup(ares_channel_t **dest, const ares_channel_t *src) sizeof((*dest)->local_dev_name)); (*dest)->local_ip4 = src->local_ip4; memcpy((*dest)->local_ip6, src->local_ip6, sizeof(src->local_ip6)); - + ares__channel_unlock(src); /* Servers are a bit unique as ares_init_options() only allows ipv4 servers * and not a port per server, but there are other user specified ways, that @@ -558,7 +556,6 @@ int ares_dup(ares_channel_t **dest, const ares_channel_t *src) rc = ARES_SUCCESS; done: - ares__channel_unlock(src); return (int)rc; /* everything went fine */ } diff --git a/lib/c-ares-1.31.0/src/lib/ares_ipv6.h b/lib/c-ares-1.32.0/src/lib/ares_ipv6.h similarity index 100% rename from lib/c-ares-1.31.0/src/lib/ares_ipv6.h rename to lib/c-ares-1.32.0/src/lib/ares_ipv6.h diff --git a/lib/c-ares-1.31.0/src/lib/ares_library_init.c b/lib/c-ares-1.32.0/src/lib/ares_library_init.c similarity index 98% rename from lib/c-ares-1.31.0/src/lib/ares_library_init.c rename to lib/c-ares-1.32.0/src/lib/ares_library_init.c index 1d98acc403e..6c2f7c0f8ce 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_library_init.c +++ b/lib/c-ares-1.32.0/src/lib/ares_library_init.c @@ -25,9 +25,6 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" - -#include "ares.h" #include "ares_private.h" /* library-private global and unique instance vars */ diff --git a/lib/c-ares-1.31.0/src/lib/ares_math.c b/lib/c-ares-1.32.0/src/lib/ares_math.c similarity index 93% rename from lib/c-ares-1.31.0/src/lib/ares_math.c rename to lib/c-ares-1.32.0/src/lib/ares_math.c index eaefd6c5de7..45999bdeaba 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_math.c +++ b/lib/c-ares-1.32.0/src/lib/ares_math.c @@ -23,8 +23,7 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" + #include "ares_private.h" /* Uses public domain code snippets from @@ -57,9 +56,23 @@ static ares_int64_t ares__round_up_pow2_u64(ares_int64_t n) return n; } +ares_bool_t ares__is_64bit(void) +{ +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable : 4127) +#endif + + return (sizeof(size_t) == 4) ? ARES_FALSE : ARES_TRUE; + +#ifdef _MSC_VER +# pragma warning(pop) +#endif +} + size_t ares__round_up_pow2(size_t n) { - if (sizeof(size_t) > 4) { + if (ares__is_64bit()) { return (size_t)ares__round_up_pow2_u64((ares_int64_t)n); } @@ -79,7 +92,7 @@ size_t ares__log2(size_t n) 56, 45, 25, 31, 35, 16, 9, 12, 44, 24, 15, 8, 23, 7, 6, 5 }; - if (sizeof(size_t) == 4) { + if (!ares__is_64bit()) { return tab32[(n * 0x077CB531) >> 27]; } diff --git a/lib/c-ares-1.32.0/src/lib/ares_metrics.c b/lib/c-ares-1.32.0/src/lib/ares_metrics.c new file mode 100644 index 00000000000..4b40677239f --- /dev/null +++ b/lib/c-ares-1.32.0/src/lib/ares_metrics.c @@ -0,0 +1,262 @@ +/* MIT License + * + * Copyright (c) 2024 Brad House + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * SPDX-License-Identifier: MIT + */ + + +/* IMPLEMENTATION NOTES + * ==================== + * + * With very little effort we should be able to determine fairly proper timeouts + * we can use based on prior query history. We track in order to be able to + * auto-scale when network conditions change (e.g. maybe there is a provider + * failover and timings change due to that). Apple appears to do this within + * their system resolver in MacOS. Obviously we should have a minimum, maximum, + * and initial value to make sure the algorithm doesn't somehow go off the + * rails. + * + * Values: + * - Minimum Timeout: 250ms (approximate RTT half-way around the globe) + * - Maximum Timeout: 5000ms (Recommended timeout in RFC 1123), can be reduced + * by ARES_OPT_MAXTIMEOUTMS, but otherwise the bound specified by the option + * caps the retry timeout. + * - Initial Timeout: User-specified via configuration or ARES_OPT_TIMEOUTMS + * - Average latency multiplier: 5x (a local DNS server returning a cached value + * will be quicker than if it needs to recurse so we need to account for this) + * - Minimum Count for Average: 3. This is the minimum number of queries we + * need to form an average for the bucket. + * + * Per-server buckets for tracking latency over time (these are ephemeral + * meaning they don't persist once a channel is destroyed). We record both the + * current timespan for the bucket and the immediate preceding timespan in case + * of roll-overs we can still maintain recent metrics for calculations: + * - 1 minute + * - 15 minutes + * - 1 hr + * - 1 day + * - since inception + * + * Each bucket would contain: + * - timestamp (divided by interval) + * - minimum latency + * - maximum latency + * - total time + * - count + * NOTE: average latency is (total time / count), we will calculate this + * dynamically when needed + * + * Basic algorithm for calculating timeout to use would be: + * - Scan from most recent bucket to least recent + * - Check timestamp of bucket, if doesn't match current time, continue to next + * bucket + * - Check count of bucket, if its not at least the "Minimum Count for Average", + * check the previous bucket, otherwise continue to next bucket + * - If we reached the end with no bucket match, use "Initial Timeout" + * - If bucket is selected, take ("total time" / count) as Average latency, + * multiply by "Average Latency Multiplier", bound by "Minimum Timeout" and + * "Maximum Timeout" + * NOTE: The timeout calculated may not be the timeout used. If we are retrying + * the query on the same server another time, then it will use a larger value + * + * On each query reply where the response is legitimate (proper response or + * NXDOMAIN) and not something like a server error: + * - Cycle through each bucket in order + * - Check timestamp of bucket against current timestamp, if out of date + * overwrite previous entry with values, clear current values + * - Compare current minimum and maximum recorded latency against query time and + * adjust if necessary + * - Increment "count" by 1 and "total time" by the query time + * + * Other Notes: + * - This is always-on, the only user-configurable value is the initial + * timeout which will simply re-uses the current option. + * - Minimum and Maximum latencies for a bucket are currently unused but are + * there in case we find a need for them in the future. + */ + +#include "ares_private.h" + +/*! Minimum timeout value. Chosen due to it being approximately RTT half-way + * around the world */ +#define MIN_TIMEOUT_MS 250 + +/*! Multiplier to apply to average latency to come up with an initial timeout */ +#define AVG_TIMEOUT_MULTIPLIER 5 + +/*! Upper timeout bounds, only used if channel->maxtimeout not set */ +#define MAX_TIMEOUT_MS 5000 + +/*! Minimum queries required to form an average */ +#define MIN_COUNT_FOR_AVERAGE 3 + +static time_t ares_metric_timestamp(ares_server_bucket_t bucket, + const ares_timeval_t *now, + ares_bool_t is_previous) +{ + time_t divisor = 1; /* Silence bogus MSVC warning by setting default value */ + + switch (bucket) { + case ARES_METRIC_1MINUTE: + divisor = 60; + break; + case ARES_METRIC_15MINUTES: + divisor = 15 * 60; + break; + case ARES_METRIC_1HOUR: + divisor = 60 * 60; + break; + case ARES_METRIC_1DAY: + divisor = 24 * 60 * 60; + break; + case ARES_METRIC_INCEPTION: + return is_previous ? 0 : 1; + case ARES_METRIC_COUNT: + return 0; /* Invalid! */ + } + + if (is_previous) { + if (divisor >= now->sec) { + return 0; + } + return (time_t)((now->sec - divisor) / divisor); + } + + return (time_t)(now->sec / divisor); +} + +void ares_metrics_record(const struct query *query, struct server_state *server, + ares_status_t status, const ares_dns_record_t *dnsrec) +{ + ares_timeval_t now; + ares_timeval_t tvdiff; + unsigned int query_ms; + ares_dns_rcode_t rcode; + ares_server_bucket_t i; + + if (status != ARES_SUCCESS) { + return; + } + + if (server == NULL) { + return; + } + + ares__tvnow(&now); + + rcode = ares_dns_record_get_rcode(dnsrec); + if (rcode != ARES_RCODE_NOERROR && rcode != ARES_RCODE_NXDOMAIN) { + return; + } + + ares__timeval_diff(&tvdiff, &query->ts, &now); + query_ms = (unsigned int)(tvdiff.sec + (tvdiff.usec / 1000)); + if (query_ms == 0) { + query_ms = 1; + } + + /* Place in each bucket */ + for (i = 0; i < ARES_METRIC_COUNT; i++) { + time_t ts = ares_metric_timestamp(i, &now, ARES_FALSE); + + /* Copy metrics to prev and clear */ + if (ts != server->metrics[i].ts) { + server->metrics[i].prev_ts = server->metrics[i].ts; + server->metrics[i].prev_total_ms = server->metrics[i].total_ms; + server->metrics[i].prev_total_count = server->metrics[i].total_count; + server->metrics[i].ts = ts; + server->metrics[i].latency_min_ms = 0; + server->metrics[i].latency_max_ms = 0; + server->metrics[i].total_ms = 0; + server->metrics[i].total_count = 0; + } + + if (server->metrics[i].latency_min_ms == 0 || + server->metrics[i].latency_min_ms > query_ms) { + server->metrics[i].latency_min_ms = query_ms; + } + + if (query_ms > server->metrics[i].latency_max_ms) { + server->metrics[i].latency_min_ms = query_ms; + } + + server->metrics[i].total_count++; + server->metrics[i].total_ms += (ares_uint64_t)query_ms; + } +} + +size_t ares_metrics_server_timeout(const struct server_state *server, + const ares_timeval_t *now) +{ + const ares_channel_t *channel = server->channel; + ares_server_bucket_t i; + size_t timeout_ms = 0; + + + for (i = 0; i < ARES_METRIC_COUNT; i++) { + time_t ts = ares_metric_timestamp(i, now, ARES_FALSE); + + /* This ts has been invalidated, see if we should use the previous + * time period */ + if (ts != server->metrics[i].ts || + server->metrics[i].total_count < MIN_COUNT_FOR_AVERAGE) { + time_t prev_ts = ares_metric_timestamp(i, now, ARES_TRUE); + if (prev_ts != server->metrics[i].prev_ts || + server->metrics[i].prev_total_count < MIN_COUNT_FOR_AVERAGE) { + /* Move onto next bucket */ + continue; + } + /* Calculate average time for previous bucket */ + timeout_ms = (size_t)(server->metrics[i].prev_total_ms / + server->metrics[i].prev_total_count); + } else { + /* Calculate average time for current bucket*/ + timeout_ms = + (size_t)(server->metrics[i].total_ms / server->metrics[i].total_count); + } + + /* Multiply average by constant to get timeout value */ + timeout_ms *= AVG_TIMEOUT_MULTIPLIER; + break; + } + + /* If we're here, that means its the first query for the server, so we just + * use the initial default timeout */ + if (timeout_ms == 0) { + timeout_ms = channel->timeout; + } + + /* don't go below lower bounds */ + if (timeout_ms < MIN_TIMEOUT_MS) { + timeout_ms = MIN_TIMEOUT_MS; + } + + /* don't go above upper bounds */ + if (channel->maxtimeout && timeout_ms > channel->maxtimeout) { + timeout_ms = channel->maxtimeout; + } else if (timeout_ms > MAX_TIMEOUT_MS) { + timeout_ms = MAX_TIMEOUT_MS; + } + + return timeout_ms; +} diff --git a/lib/c-ares-1.31.0/src/lib/ares_options.c b/lib/c-ares-1.32.0/src/lib/ares_options.c similarity index 99% rename from lib/c-ares-1.31.0/src/lib/ares_options.c rename to lib/c-ares-1.32.0/src/lib/ares_options.c index 959c4f7a8c9..19ddf6d8ca1 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_options.c +++ b/lib/c-ares-1.32.0/src/lib/ares_options.c @@ -25,16 +25,14 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_ARPA_INET_H # include #endif -#include "ares.h" #include "ares_data.h" #include "ares_inet_net_pton.h" -#include "ares_private.h" void ares_destroy_options(struct ares_options *options) { @@ -464,8 +462,8 @@ ares_status_t ares__init_by_options(ares_channel_t *channel, /* qcache_max_ttl is unsigned unlike the others */ channel->qcache_max_ttl = options->qcache_max_ttl; } else { - optmask |= ARES_OPT_QUERY_CACHE; - channel->qcache_max_ttl = 3600; + optmask |= ARES_OPT_QUERY_CACHE; + channel->qcache_max_ttl = 3600; } /* Initialize the ipv4 servers if provided */ diff --git a/lib/c-ares-1.31.0/src/lib/ares_parse_a_reply.c b/lib/c-ares-1.32.0/src/lib/ares_parse_a_reply.c similarity index 97% rename from lib/c-ares-1.31.0/src/lib/ares_parse_a_reply.c rename to lib/c-ares-1.32.0/src/lib/ares_parse_a_reply.c index 2b7b0e6be28..0981b90eeaf 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_parse_a_reply.c +++ b/lib/c-ares-1.32.0/src/lib/ares_parse_a_reply.c @@ -25,7 +25,7 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_NETINET_IN_H # include @@ -37,8 +37,6 @@ # include #endif -#include "ares_nameser.h" - #ifdef HAVE_STRINGS_H # include #endif @@ -47,10 +45,6 @@ # include #endif -#include "ares.h" -#include "ares_dns.h" -#include "ares_private.h" - int ares_parse_a_reply(const unsigned char *abuf, int alen, struct hostent **host, struct ares_addrttl *addrttls, int *naddrttls) diff --git a/lib/c-ares-1.31.0/src/lib/ares_parse_aaaa_reply.c b/lib/c-ares-1.32.0/src/lib/ares_parse_aaaa_reply.c similarity index 97% rename from lib/c-ares-1.31.0/src/lib/ares_parse_aaaa_reply.c rename to lib/c-ares-1.32.0/src/lib/ares_parse_aaaa_reply.c index 6e2a466482a..3f6932643b2 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_parse_aaaa_reply.c +++ b/lib/c-ares-1.32.0/src/lib/ares_parse_aaaa_reply.c @@ -26,7 +26,7 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_NETINET_IN_H # include @@ -38,8 +38,6 @@ # include #endif -#include "ares_nameser.h" - #ifdef HAVE_STRINGS_H # include #endif @@ -48,10 +46,7 @@ # include #endif -#include "ares.h" -#include "ares_dns.h" #include "ares_inet_net_pton.h" -#include "ares_private.h" int ares_parse_aaaa_reply(const unsigned char *abuf, int alen, struct hostent **host, struct ares_addr6ttl *addrttls, diff --git a/lib/c-ares-1.31.0/src/lib/ares_parse_caa_reply.c b/lib/c-ares-1.32.0/src/lib/ares_parse_caa_reply.c similarity index 92% rename from lib/c-ares-1.31.0/src/lib/ares_parse_caa_reply.c rename to lib/c-ares-1.32.0/src/lib/ares_parse_caa_reply.c index 42f2525697d..f74358f4566 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_parse_caa_reply.c +++ b/lib/c-ares-1.32.0/src/lib/ares_parse_caa_reply.c @@ -24,10 +24,8 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" -#include "ares_data.h" #include "ares_private.h" +#include "ares_data.h" int ares_parse_caa_reply(const unsigned char *abuf, int alen_int, struct ares_caa_reply **caa_out) @@ -67,7 +65,7 @@ int ares_parse_caa_reply(const unsigned char *abuf, int alen_int, if (rr == NULL) { /* Shouldn't be possible */ status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* XXX: Why do we allow Chaos class? */ @@ -85,7 +83,7 @@ int ares_parse_caa_reply(const unsigned char *abuf, int alen_int, caa_curr = ares_malloc_data(ARES_DATATYPE_CAA_REPLY); if (caa_curr == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Link in the record */ @@ -101,7 +99,7 @@ int ares_parse_caa_reply(const unsigned char *abuf, int alen_int, (unsigned char *)ares_strdup(ares_dns_rr_get_str(rr, ARES_RR_CAA_TAG)); if (caa_curr->property == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - break; /* LCOV_EXCL_LINE: OutOfMemory */ + break; /* LCOV_EXCL_LINE: OutOfMemory */ } /* RFC6844 says this can only be ascii, so not sure why we're recording a * length */ @@ -110,14 +108,14 @@ int ares_parse_caa_reply(const unsigned char *abuf, int alen_int, ptr = ares_dns_rr_get_bin(rr, ARES_RR_CAA_VALUE, &ptr_len); if (ptr == NULL) { status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* Wants NULL termination for some reason */ caa_curr->value = ares_malloc(ptr_len + 1); if (caa_curr->value == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } memcpy(caa_curr->value, ptr, ptr_len); caa_curr->value[ptr_len] = 0; diff --git a/lib/c-ares-1.31.0/src/lib/ares_parse_mx_reply.c b/lib/c-ares-1.32.0/src/lib/ares_parse_mx_reply.c similarity index 94% rename from lib/c-ares-1.31.0/src/lib/ares_parse_mx_reply.c rename to lib/c-ares-1.32.0/src/lib/ares_parse_mx_reply.c index f9e5f025a8f..480074f670c 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_parse_mx_reply.c +++ b/lib/c-ares-1.32.0/src/lib/ares_parse_mx_reply.c @@ -24,10 +24,8 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" -#include "ares_data.h" #include "ares_private.h" +#include "ares_data.h" int ares_parse_mx_reply(const unsigned char *abuf, int alen_int, struct ares_mx_reply **mx_out) @@ -65,7 +63,7 @@ int ares_parse_mx_reply(const unsigned char *abuf, int alen_int, if (rr == NULL) { /* Shouldn't be possible */ status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (ares_dns_rr_get_class(rr) != ARES_CLASS_IN || @@ -77,7 +75,7 @@ int ares_parse_mx_reply(const unsigned char *abuf, int alen_int, mx_curr = ares_malloc_data(ARES_DATATYPE_MX_REPLY); if (mx_curr == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Link in the record */ @@ -93,7 +91,7 @@ int ares_parse_mx_reply(const unsigned char *abuf, int alen_int, if (mx_curr->host == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } diff --git a/lib/c-ares-1.31.0/src/lib/ares_parse_naptr_reply.c b/lib/c-ares-1.32.0/src/lib/ares_parse_naptr_reply.c similarity index 91% rename from lib/c-ares-1.31.0/src/lib/ares_parse_naptr_reply.c rename to lib/c-ares-1.32.0/src/lib/ares_parse_naptr_reply.c index 51ee6f38a5a..c00ce710666 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_parse_naptr_reply.c +++ b/lib/c-ares-1.32.0/src/lib/ares_parse_naptr_reply.c @@ -23,10 +23,8 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" -#include "ares_data.h" #include "ares_private.h" +#include "ares_data.h" int ares_parse_naptr_reply(const unsigned char *abuf, int alen_int, struct ares_naptr_reply **naptr_out) @@ -64,7 +62,7 @@ int ares_parse_naptr_reply(const unsigned char *abuf, int alen_int, if (rr == NULL) { /* Shouldn't be possible */ status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (ares_dns_rr_get_class(rr) != ARES_CLASS_IN || @@ -76,7 +74,7 @@ int ares_parse_naptr_reply(const unsigned char *abuf, int alen_int, naptr_curr = ares_malloc_data(ARES_DATATYPE_NAPTR_REPLY); if (naptr_curr == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Link in the record */ @@ -95,27 +93,27 @@ int ares_parse_naptr_reply(const unsigned char *abuf, int alen_int, ares_dns_rr_get_str(rr, ARES_RR_NAPTR_FLAGS)); if (naptr_curr->flags == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* XXX: Why is this unsigned char * ? */ naptr_curr->service = (unsigned char *)ares_strdup( ares_dns_rr_get_str(rr, ARES_RR_NAPTR_SERVICES)); if (naptr_curr->service == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* XXX: Why is this unsigned char * ? */ naptr_curr->regexp = (unsigned char *)ares_strdup( ares_dns_rr_get_str(rr, ARES_RR_NAPTR_REGEXP)); if (naptr_curr->regexp == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } naptr_curr->replacement = ares_strdup(ares_dns_rr_get_str(rr, ARES_RR_NAPTR_REPLACEMENT)); if (naptr_curr->replacement == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } diff --git a/lib/c-ares-1.31.0/src/lib/ares_parse_ns_reply.c b/lib/c-ares-1.32.0/src/lib/ares_parse_ns_reply.c similarity index 91% rename from lib/c-ares-1.31.0/src/lib/ares_parse_ns_reply.c rename to lib/c-ares-1.32.0/src/lib/ares_parse_ns_reply.c index 762353964e2..fc9ab9219d3 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_parse_ns_reply.c +++ b/lib/c-ares-1.32.0/src/lib/ares_parse_ns_reply.c @@ -24,7 +24,7 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_NETINET_IN_H # include @@ -36,9 +36,6 @@ # include #endif -#include "ares.h" -#include "ares_private.h" - int ares_parse_ns_reply(const unsigned char *abuf, int alen_int, struct hostent **host) { @@ -74,7 +71,7 @@ int ares_parse_ns_reply(const unsigned char *abuf, int alen_int, hostent = ares_malloc(sizeof(*hostent)); if (hostent == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } memset(hostent, 0, sizeof(*hostent)); @@ -82,7 +79,7 @@ int ares_parse_ns_reply(const unsigned char *abuf, int alen_int, hostent->h_addr_list = ares_malloc(sizeof(*hostent->h_addr_list)); if (hostent->h_addr_list == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } hostent->h_addr_list[0] = NULL; hostent->h_addrtype = AF_INET; @@ -96,14 +93,14 @@ int ares_parse_ns_reply(const unsigned char *abuf, int alen_int, hostent->h_name = ares_strdup(hostname); if (hostent->h_name == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Preallocate the maximum number + 1 */ hostent->h_aliases = ares_malloc((ancount + 1) * sizeof(*hostent->h_aliases)); if (hostent->h_aliases == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } memset(hostent->h_aliases, 0, (ancount + 1) * sizeof(*hostent->h_aliases)); @@ -114,7 +111,7 @@ int ares_parse_ns_reply(const unsigned char *abuf, int alen_int, if (rr == NULL) { /* Shouldn't be possible */ status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (ares_dns_rr_get_class(rr) != ARES_CLASS_IN || @@ -125,7 +122,7 @@ int ares_parse_ns_reply(const unsigned char *abuf, int alen_int, hostname = ares_dns_rr_get_str(rr, ARES_RR_NS_NSDNAME); if (hostname == NULL) { status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } hostent->h_aliases[nscount] = ares_strdup(hostname); diff --git a/lib/c-ares-1.31.0/src/lib/ares_parse_ptr_reply.c b/lib/c-ares-1.32.0/src/lib/ares_parse_ptr_reply.c similarity index 95% rename from lib/c-ares-1.31.0/src/lib/ares_parse_ptr_reply.c rename to lib/c-ares-1.32.0/src/lib/ares_parse_ptr_reply.c index 3f8cc122b0c..56a7b5f94eb 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_parse_ptr_reply.c +++ b/lib/c-ares-1.32.0/src/lib/ares_parse_ptr_reply.c @@ -24,7 +24,7 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_NETINET_IN_H # include @@ -33,8 +33,6 @@ # include #endif -#include "ares.h" -#include "ares_private.h" ares_status_t ares_parse_ptr_reply_dnsrec(const ares_dns_record_t *dnsrec, const void *addr, int addrlen, @@ -106,7 +104,7 @@ ares_status_t ares_parse_ptr_reply_dnsrec(const ares_dns_record_t *dnsrec, if (rr == NULL) { /* Shouldn't be possible */ status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (ares_dns_rr_get_class(rr) != ARES_CLASS_IN) { @@ -118,7 +116,7 @@ ares_status_t ares_parse_ptr_reply_dnsrec(const ares_dns_record_t *dnsrec, ptrname = ares_dns_rr_get_str(rr, ARES_RR_CNAME_CNAME); if (ptrname == NULL) { status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } } @@ -146,7 +144,7 @@ ares_status_t ares_parse_ptr_reply_dnsrec(const ares_dns_record_t *dnsrec, hostname = ares_dns_rr_get_str(rr, ARES_RR_PTR_DNAME); if (hostname == NULL) { status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* Append as an alias */ @@ -169,7 +167,7 @@ ares_status_t ares_parse_ptr_reply_dnsrec(const ares_dns_record_t *dnsrec, hostent->h_name = ares_strdup(hostname); if (hostent->h_name == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } done: diff --git a/lib/c-ares-1.31.0/src/lib/ares_parse_soa_reply.c b/lib/c-ares-1.32.0/src/lib/ares_parse_soa_reply.c similarity index 93% rename from lib/c-ares-1.31.0/src/lib/ares_parse_soa_reply.c rename to lib/c-ares-1.32.0/src/lib/ares_parse_soa_reply.c index d471471aad8..46b40dedc4d 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_parse_soa_reply.c +++ b/lib/c-ares-1.32.0/src/lib/ares_parse_soa_reply.c @@ -24,10 +24,8 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" -#include "ares_data.h" #include "ares_private.h" +#include "ares_data.h" int ares_parse_soa_reply(const unsigned char *abuf, int alen_int, struct ares_soa_reply **soa_out) @@ -63,7 +61,7 @@ int ares_parse_soa_reply(const unsigned char *abuf, int alen_int, if (rr == NULL) { /* Shouldn't be possible */ status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (ares_dns_rr_get_class(rr) != ARES_CLASS_IN || @@ -75,7 +73,7 @@ int ares_parse_soa_reply(const unsigned char *abuf, int alen_int, soa = ares_malloc_data(ARES_DATATYPE_SOA_REPLY); if (soa == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } soa->serial = ares_dns_rr_get_u32(rr, ARES_RR_SOA_SERIAL); @@ -86,12 +84,12 @@ int ares_parse_soa_reply(const unsigned char *abuf, int alen_int, soa->nsname = ares_strdup(ares_dns_rr_get_str(rr, ARES_RR_SOA_MNAME)); if (soa->nsname == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } soa->hostmaster = ares_strdup(ares_dns_rr_get_str(rr, ARES_RR_SOA_RNAME)); if (soa->hostmaster == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } break; } diff --git a/lib/c-ares-1.31.0/src/lib/ares_parse_srv_reply.c b/lib/c-ares-1.32.0/src/lib/ares_parse_srv_reply.c similarity index 94% rename from lib/c-ares-1.31.0/src/lib/ares_parse_srv_reply.c rename to lib/c-ares-1.32.0/src/lib/ares_parse_srv_reply.c index 438737b79ac..3f9fd95ebf6 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_parse_srv_reply.c +++ b/lib/c-ares-1.32.0/src/lib/ares_parse_srv_reply.c @@ -24,10 +24,8 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" -#include "ares_data.h" #include "ares_private.h" +#include "ares_data.h" int ares_parse_srv_reply(const unsigned char *abuf, int alen_int, struct ares_srv_reply **srv_out) @@ -65,7 +63,7 @@ int ares_parse_srv_reply(const unsigned char *abuf, int alen_int, if (rr == NULL) { /* Shouldn't be possible */ status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (ares_dns_rr_get_class(rr) != ARES_CLASS_IN || @@ -77,7 +75,7 @@ int ares_parse_srv_reply(const unsigned char *abuf, int alen_int, srv_curr = ares_malloc_data(ARES_DATATYPE_SRV_REPLY); if (srv_curr == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Link in the record */ @@ -97,7 +95,7 @@ int ares_parse_srv_reply(const unsigned char *abuf, int alen_int, if (srv_curr->host == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } diff --git a/lib/c-ares-1.31.0/src/lib/ares_parse_txt_reply.c b/lib/c-ares-1.32.0/src/lib/ares_parse_txt_reply.c similarity index 71% rename from lib/c-ares-1.31.0/src/lib/ares_parse_txt_reply.c rename to lib/c-ares-1.32.0/src/lib/ares_parse_txt_reply.c index 2555734c7df..cd280332d23 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_parse_txt_reply.c +++ b/lib/c-ares-1.32.0/src/lib/ares_parse_txt_reply.c @@ -24,10 +24,8 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" -#include "ares_data.h" #include "ares_private.h" +#include "ares_data.h" static int ares__parse_txt_reply(const unsigned char *abuf, size_t alen, ares_bool_t ex, void **txt_out) @@ -54,13 +52,14 @@ static int ares__parse_txt_reply(const unsigned char *abuf, size_t alen, for (i = 0; i < ares_dns_record_rr_cnt(dnsrec, ARES_SECTION_ANSWER); i++) { const ares_dns_rr_t *rr = ares_dns_record_rr_get(dnsrec, ARES_SECTION_ANSWER, i); - const unsigned char *ptr; - size_t ptr_len; + size_t j; + size_t cnt; + if (rr == NULL) { /* Shouldn't be possible */ status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* XXX: Why Chaos? */ @@ -70,37 +69,44 @@ static int ares__parse_txt_reply(const unsigned char *abuf, size_t alen, continue; } - /* Allocate storage for this TXT answer appending it to the list */ - txt_curr = - ares_malloc_data(ex ? ARES_DATATYPE_TXT_EXT : ARES_DATATYPE_TXT_REPLY); - if (txt_curr == NULL) { - status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ - } - - /* Link in the record */ - if (txt_last) { - txt_last->next = txt_curr; - } else { - txt_head = txt_curr; - } - txt_last = txt_curr; - - /* These days, records are joined, always tag as start */ - if (ex) { - txt_curr->record_start = 1; - } - - ptr = ares_dns_rr_get_bin(rr, ARES_RR_TXT_DATA, &ptr_len); - - txt_curr->txt = ares_malloc(ptr_len + 1); - if (txt_curr->txt == NULL) { - status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + cnt = ares_dns_rr_get_abin_cnt(rr, ARES_RR_TXT_DATA); + + for (j=0; jnext = txt_curr; + } else { + txt_head = txt_curr; + } + txt_last = txt_curr; + + /* Tag start on first for each TXT record */ + if (ex && j == 0) { + txt_curr->record_start = 1; + } + + ptr = ares_dns_rr_get_abin(rr, ARES_RR_TXT_DATA, j, &ptr_len); + + txt_curr->txt = ares_malloc(ptr_len + 1); + if (txt_curr->txt == NULL) { + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + } + memcpy(txt_curr->txt, ptr, ptr_len); + txt_curr->txt[ptr_len] = 0; + txt_curr->length = ptr_len; } - memcpy(txt_curr->txt, ptr, ptr_len); - txt_curr->txt[ptr_len] = 0; - txt_curr->length = ptr_len; } done: diff --git a/lib/c-ares-1.31.0/src/lib/ares_parse_uri_reply.c b/lib/c-ares-1.32.0/src/lib/ares_parse_uri_reply.c similarity index 95% rename from lib/c-ares-1.31.0/src/lib/ares_parse_uri_reply.c rename to lib/c-ares-1.32.0/src/lib/ares_parse_uri_reply.c index 5966b946969..317e204d5d8 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_parse_uri_reply.c +++ b/lib/c-ares-1.32.0/src/lib/ares_parse_uri_reply.c @@ -24,10 +24,8 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" -#include "ares_data.h" #include "ares_private.h" +#include "ares_data.h" int ares_parse_uri_reply(const unsigned char *abuf, int alen_int, struct ares_uri_reply **uri_out) @@ -65,7 +63,7 @@ int ares_parse_uri_reply(const unsigned char *abuf, int alen_int, if (rr == NULL) { /* Shouldn't be possible */ status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ - goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (ares_dns_rr_get_class(rr) != ARES_CLASS_IN || @@ -77,7 +75,7 @@ int ares_parse_uri_reply(const unsigned char *abuf, int alen_int, uri_curr = ares_malloc_data(ARES_DATATYPE_URI_REPLY); if (uri_curr == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Link in the record */ diff --git a/lib/c-ares-1.31.0/src/lib/ares_platform.c b/lib/c-ares-1.32.0/src/lib/ares_platform.c similarity index 99% rename from lib/c-ares-1.31.0/src/lib/ares_platform.c rename to lib/c-ares-1.32.0/src/lib/ares_platform.c index cd1470f832f..8f0a1dbffb8 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_platform.c +++ b/lib/c-ares-1.32.0/src/lib/ares_platform.c @@ -25,11 +25,8 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" - -#include "ares.h" -#include "ares_platform.h" #include "ares_private.h" +#include "ares_platform.h" #if defined(_WIN32) && !defined(MSDOS) diff --git a/lib/c-ares-1.31.0/src/lib/ares_platform.h b/lib/c-ares-1.32.0/src/lib/ares_platform.h similarity index 98% rename from lib/c-ares-1.31.0/src/lib/ares_platform.h rename to lib/c-ares-1.32.0/src/lib/ares_platform.h index df07f77a493..768eaddddd9 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_platform.h +++ b/lib/c-ares-1.32.0/src/lib/ares_platform.h @@ -27,8 +27,6 @@ #ifndef HEADER_CARES_PLATFORM_H #define HEADER_CARES_PLATFORM_H -#include "ares_setup.h" - #if defined(_WIN32) && !defined(MSDOS) typedef enum { diff --git a/lib/c-ares-1.31.0/src/lib/ares_private.h b/lib/c-ares-1.32.0/src/lib/ares_private.h similarity index 85% rename from lib/c-ares-1.31.0/src/lib/ares_private.h rename to lib/c-ares-1.32.0/src/lib/ares_private.h index 1fc4fda045b..3b5f627bd16 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_private.h +++ b/lib/c-ares-1.32.0/src/lib/ares_private.h @@ -27,15 +27,19 @@ #ifndef __ARES_PRIVATE_H #define __ARES_PRIVATE_H +/* ============================================================================ + * NOTE: All c-ares source files should include ares_private.h as the first + * header. + * ============================================================================ + */ + +#include "ares_setup.h" +#include "ares.h" + #ifdef HAVE_NETINET_IN_H # include #endif -#ifdef WATT32 -# include -# include -#endif - #define DEFAULT_TIMEOUT 2000 /* milliseconds */ #define DEFAULT_TRIES 3 #ifndef INADDR_NONE @@ -46,7 +50,7 @@ * warning: cast from 'const struct sockaddr *' to 'const struct sockaddr_in6 *' * increases required alignment from 1 to 4 [-Wcast-align] */ -#define CARES_INADDR_CAST(type, var) ((type)((void *)var)) +#define CARES_INADDR_CAST(type, var) ((type)((const void *)var)) #if defined(USE_WINSOCK) @@ -107,6 +111,7 @@ typedef struct ares_rand_state ares_rand_state; #include "ares__htable_szvp.h" #include "ares__htable_asvp.h" #include "ares__htable_vpvp.h" +#include "ares_dns_multistring.h" #include "ares__buf.h" #include "ares_dns_private.h" #include "ares__iface_ips.h" @@ -175,6 +180,30 @@ typedef struct { unsigned int usec; /*!< Microseconds. Can't be negative. */ } ares_timeval_t; +/*! Various buckets for grouping history */ +typedef enum { + ARES_METRIC_1MINUTE = 0, /*!< Bucket for tracking over the last minute */ + ARES_METRIC_15MINUTES, /*!< Bucket for tracking over the last 15 minutes */ + ARES_METRIC_1HOUR, /*!< Bucket for tracking over the last hour */ + ARES_METRIC_1DAY, /*!< Bucket for tracking over the last day */ + ARES_METRIC_INCEPTION, /*!< Bucket for tracking since inception */ + ARES_METRIC_COUNT /*!< Count of buckets, not a real bucket */ +} ares_server_bucket_t; + +/*! Data metrics collected for each bucket */ +typedef struct { + time_t ts; /*!< Timestamp divided by bucket divisor */ + unsigned int latency_min_ms; /*!< Minimum latency for queries */ + unsigned int latency_max_ms; /*!< Maximum latency for queries */ + ares_uint64_t total_ms; /*!< Cumulative query time for bucket */ + ares_uint64_t total_count; /*!< Number of queries for bucket */ + + time_t prev_ts; /*!< Previous period bucket timestamp */ + ares_uint64_t + prev_total_ms; /*!< Previous period bucket cumulative query time */ + ares_uint64_t prev_total_count; /*!< Previous period bucket query count */ +} ares_server_metrics_t; + struct server_state { /* Configuration */ size_t idx; /* index for server in system configuration */ @@ -200,6 +229,9 @@ struct server_state { /* TCP output queue */ ares__buf_t *tcp_send; + /*! Buckets for collecting metrics about the server */ + ares_server_metrics_t metrics[ARES_METRIC_COUNT]; + /* Link back to owning channel */ ares_channel_t *channel; }; @@ -208,6 +240,7 @@ struct server_state { struct query { /* Query ID from qbuf, for faster lookup, and current timeout */ unsigned short qid; /* host byte order */ + ares_timeval_t ts; /*!< Timestamp query was sent */ ares_timeval_t timeout; ares_channel_t *channel; @@ -222,9 +255,8 @@ struct query { /* connection handle query is associated with */ struct server_connection *conn; - /* Arguments passed to ares_send() */ - unsigned char *qbuf; - size_t qlen; + /* Query */ + ares_dns_record_t *query; ares_callback_dnsrec callback; void *arg; @@ -411,22 +443,24 @@ void ares__destroy_rand_state(ares_rand_state *state); void ares__rand_bytes(ares_rand_state *state, unsigned char *buf, size_t len); unsigned short ares__generate_new_id(ares_rand_state *state); -ares_timeval_t ares__tvnow(void); +void ares__tvnow(ares_timeval_t *now); void ares__timeval_remaining(ares_timeval_t *remaining, const ares_timeval_t *now, const ares_timeval_t *tout); -ares_status_t ares__expand_name_validated(const unsigned char *encoded, - const unsigned char *abuf, - size_t alen, char **s, size_t *enclen, - ares_bool_t is_hostname); -ares_status_t ares_expand_string_ex(const unsigned char *encoded, - const unsigned char *abuf, size_t alen, - unsigned char **s, size_t *enclen); -ares_status_t ares__init_servers_state(ares_channel_t *channel); -ares_status_t ares__init_by_options(ares_channel_t *channel, - const struct ares_options *options, - int optmask); -ares_status_t ares__init_by_sysconfig(ares_channel_t *channel); +void ares__timeval_diff(ares_timeval_t *tvdiff, const ares_timeval_t *tvstart, + const ares_timeval_t *tvstop); +ares_status_t ares__expand_name_validated(const unsigned char *encoded, + const unsigned char *abuf, + size_t alen, char **s, size_t *enclen, + ares_bool_t is_hostname); +ares_status_t ares_expand_string_ex(const unsigned char *encoded, + const unsigned char *abuf, size_t alen, + unsigned char **s, size_t *enclen); +ares_status_t ares__init_servers_state(ares_channel_t *channel); +ares_status_t ares__init_by_options(ares_channel_t *channel, + const struct ares_options *options, + int optmask); +ares_status_t ares__init_by_sysconfig(ares_channel_t *channel); typedef struct { ares__llist_t *sconfig; @@ -452,6 +486,9 @@ ares_status_t ares__init_sysconfig_files(const ares_channel_t *channel, #ifdef __APPLE__ ares_status_t ares__init_sysconfig_macos(ares_sysconfig_t *sysconfig); #endif +#ifdef USE_WINSOCK +ares_status_t ares__init_sysconfig_windows(ares_sysconfig_t *sysconfig); +#endif ares_status_t ares__parse_sortlist(struct apattern **sortlist, size_t *nsort, const char *str); @@ -560,6 +597,26 @@ ares_status_t ares__hosts_entry_to_addrinfo(const ares_hosts_entry_t *entry, ares_bool_t want_cnames, struct ares_addrinfo *ai); +/* Same as ares_query_dnsrec() except does not take a channel lock. Use this + * if a channel lock is already held */ +ares_status_t ares_query_nolock(ares_channel_t *channel, const char *name, + ares_dns_class_t dnsclass, + ares_dns_rec_type_t type, + ares_callback_dnsrec callback, void *arg, + unsigned short *qid); + +/* Same as ares_send_dnsrec() except does not take a channel lock. Use this + * if a channel lock is already held */ +ares_status_t ares_send_nolock(ares_channel_t *channel, + const ares_dns_record_t *dnsrec, + ares_callback_dnsrec callback, + void *arg, unsigned short *qid); + +/* Same as ares_gethostbyaddr() except does not take a channel lock. Use this + * if a channel lock is already held */ +void ares_gethostbyaddr_nolock(ares_channel_t *channel, const void *addr, + int addrlen, int family, + ares_host_callback callback, void *arg); /*! Parse a compressed DNS name as defined in RFC1035 starting at the current * offset within the buffer. @@ -609,13 +666,6 @@ ares_status_t ares__dns_name_write(ares__buf_t *buf, ares__llist_t **list, void ares_queue_notify_empty(ares_channel_t *channel); -#define ARES_SWAP_BYTE(a, b) \ - do { \ - unsigned char swapByte = *(a); \ - *(a) = *(b); \ - *(b) = swapByte; \ - } while (0) - #define SOCK_STATE_CALLBACK(c, s, r, w) \ do { \ if ((c)->sock_state_cb) { \ @@ -632,6 +682,7 @@ ares_bool_t ares__subnet_match(const struct ares_addr *addr, unsigned char netmask); ares_bool_t ares__addr_is_linklocal(const struct ares_addr *addr); +ares_bool_t ares__is_64bit(void); size_t ares__round_up_pow2(size_t n); size_t ares__log2(size_t n); size_t ares__pow(size_t x, size_t y); @@ -652,6 +703,11 @@ ares_status_t ares_qcache_fetch(ares_channel_t *channel, const ares_dns_record_t *dnsrec, const ares_dns_record_t **dnsrec_resp); +void ares_metrics_record(const struct query *query, struct server_state *server, + ares_status_t status, const ares_dns_record_t *dnsrec); +size_t ares_metrics_server_timeout(const struct server_state *server, + const ares_timeval_t *now); + ares_status_t ares__channel_threading_init(ares_channel_t *channel); void ares__channel_threading_destroy(ares_channel_t *channel); void ares__channel_lock(const ares_channel_t *channel); diff --git a/lib/c-ares-1.31.0/src/lib/ares_process.c b/lib/c-ares-1.32.0/src/lib/ares_process.c similarity index 89% rename from lib/c-ares-1.31.0/src/lib/ares_process.c rename to lib/c-ares-1.32.0/src/lib/ares_process.c index 6e50902b71d..562d6b5e1b1 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_process.c +++ b/lib/c-ares-1.32.0/src/lib/ares_process.c @@ -25,8 +25,7 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" - +#include "ares_private.h" #ifdef HAVE_STRINGS_H # include @@ -45,10 +44,6 @@ #include #include -#include "ares.h" -#include "ares_private.h" -#include "ares_nameser.h" -#include "ares_dns.h" static void timeadd(ares_timeval_t *now, size_t millisecs); static ares_bool_t try_again(int errnum); @@ -65,16 +60,17 @@ static ares_status_t process_answer(ares_channel_t *channel, static void handle_conn_error(struct server_connection *conn, ares_bool_t critical_failure); -static ares_bool_t same_questions(const ares_dns_record_t *qrec, +static ares_bool_t same_questions(const struct query *query, const ares_dns_record_t *arec); static ares_bool_t same_address(const struct sockaddr *sa, const struct ares_addr *aa); -static void end_query(ares_channel_t *channel, struct query *query, - ares_status_t status, const ares_dns_record_t *dnsrec); +static void end_query(ares_channel_t *channel, struct server_state *server, + struct query *query, ares_status_t status, + const ares_dns_record_t *dnsrec); /* Invoke the server state callback after a success or failure */ -static void invoke_server_state_cb(const struct server_state *server, - ares_bool_t success, int flags) +static void invoke_server_state_cb(const struct server_state *server, + ares_bool_t success, int flags) { const ares_channel_t *channel = server->channel; ares__buf_t *buf; @@ -93,7 +89,7 @@ static void invoke_server_state_cb(const struct server_state *server, status = ares_get_server_addr(server, buf); if (status != ARES_SUCCESS) { ares__buf_destroy(buf); /* LCOV_EXCL_LINE: OutOfMemory */ - return; /* LCOV_EXCL_LINE: OutOfMemory */ + return; /* LCOV_EXCL_LINE: OutOfMemory */ } server_string = ares__buf_finish_str(buf, NULL); @@ -122,7 +118,7 @@ static void server_increment_failures(struct server_state *server, server->consec_failures++; ares__slist_node_reinsert(node); - next_retry_time = ares__tvnow(); + ares__tvnow(&next_retry_time); timeadd(&next_retry_time, channel->server_retry_delay); server->next_retry_time = next_retry_time; @@ -200,7 +196,7 @@ static void processfds(ares_channel_t *channel, fd_set *read_fds, ares__channel_lock(channel); - now = ares__tvnow(); + ares__tvnow(&now); read_packets(channel, read_fds, read_fd, &now); process_timeouts(channel, &now); /* Write last as the other 2 operations might have triggered writes */ @@ -380,7 +376,7 @@ static void read_tcp_data(ares_channel_t *channel, /* Can't fail except for misuse */ data = ares__buf_tag_fetch(server->tcp_parser, &data_len); - if (data == NULL) { + if (data == NULL || data_len < 2) { ares__buf_tag_clear(server->tcp_parser); break; } @@ -623,22 +619,19 @@ static void process_timeouts(ares_channel_t *channel, const ares_timeval_t *now) } } -static ares_status_t rewrite_without_edns(ares_dns_record_t *qdnsrec, - struct query *query) +static ares_status_t rewrite_without_edns(struct query *query) { - ares_status_t status; + ares_status_t status = ARES_SUCCESS; size_t i; ares_bool_t found_opt_rr = ARES_FALSE; - unsigned char *msg = NULL; - size_t msglen = 0; /* Find and remove the OPT RR record */ - for (i = 0; i < ares_dns_record_rr_cnt(qdnsrec, ARES_SECTION_ADDITIONAL); + for (i = 0; i < ares_dns_record_rr_cnt(query->query, ARES_SECTION_ADDITIONAL); i++) { const ares_dns_rr_t *rr; - rr = ares_dns_record_rr_get(qdnsrec, ARES_SECTION_ADDITIONAL, i); + rr = ares_dns_record_rr_get(query->query, ARES_SECTION_ADDITIONAL, i); if (ares_dns_rr_get_type(rr) == ARES_REC_TYPE_OPT) { - ares_dns_record_rr_del(qdnsrec, ARES_SECTION_ADDITIONAL, i); + ares_dns_record_rr_del(query->query, ARES_SECTION_ADDITIONAL, i); found_opt_rr = ARES_TRUE; break; } @@ -649,16 +642,6 @@ static ares_status_t rewrite_without_edns(ares_dns_record_t *qdnsrec, goto done; } - /* Rewrite the DNS message */ - status = ares_dns_write(qdnsrec, &msg, &msglen); - if (status != ARES_SUCCESS) { - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ - } - - ares_free(query->qbuf); - query->qbuf = msg; - query->qlen = msglen; - done: return status; } @@ -676,7 +659,6 @@ static ares_status_t process_answer(ares_channel_t *channel, * invalidating the connection all-together */ struct server_state *server = conn->server; ares_dns_record_t *rdnsrec = NULL; - ares_dns_record_t *qdnsrec = NULL; ares_status_t status; ares_bool_t is_cached = ARES_FALSE; @@ -699,16 +681,9 @@ static ares_status_t process_answer(ares_channel_t *channel, goto cleanup; } - /* Parse the question we sent as we use it to compare */ - status = ares_dns_parse(query->qbuf, query->qlen, 0, &qdnsrec); - if (status != ARES_SUCCESS) { - end_query(channel, query, status, NULL); - goto cleanup; - } - /* Both the query id and the questions must be the same. We will drop any * replies that aren't for the same query as this is considered invalid. */ - if (!same_questions(qdnsrec, rdnsrec)) { + if (!same_questions(query, rdnsrec)) { /* Possible qid conflict due to delayed response, that's ok */ status = ARES_SUCCESS; goto cleanup; @@ -725,10 +700,10 @@ static ares_status_t process_answer(ares_channel_t *channel, * protocol extension is not understood by the responder. We must retry the * query without EDNS enabled. */ if (ares_dns_record_get_rcode(rdnsrec) == ARES_RCODE_FORMERR && - ares_dns_has_opt_rr(qdnsrec) && !ares_dns_has_opt_rr(rdnsrec)) { - status = rewrite_without_edns(qdnsrec, query); + ares_dns_has_opt_rr(query->query) && !ares_dns_has_opt_rr(rdnsrec)) { + status = rewrite_without_edns(query); if (status != ARES_SUCCESS) { - end_query(channel, query, status, NULL); + end_query(channel, server, query, status, NULL); goto cleanup; } @@ -787,7 +762,7 @@ static ares_status_t process_answer(ares_channel_t *channel, } server_set_good(server, query->using_tcp); - end_query(channel, query, ARES_SUCCESS, rdnsrec); + end_query(channel, server, query, ARES_SUCCESS, rdnsrec); status = ARES_SUCCESS; @@ -797,7 +772,6 @@ static ares_status_t process_answer(ares_channel_t *channel, ares_dns_record_destroy(rdnsrec); } - ares_dns_record_destroy(qdnsrec); return status; } @@ -833,7 +807,7 @@ ares_status_t ares__requeue_query(struct query *query, query->error_status = ARES_ETIMEOUT; } - end_query(channel, query, query->error_status, NULL); + end_query(channel, NULL, query, query->error_status, NULL); return ARES_ETIMEOUT; } @@ -916,8 +890,10 @@ static struct server_state *ares__failover_server(ares_channel_t *channel) ares__rand_bytes(channel->rand_state, (unsigned char *)&r, sizeof(r)); if (r % channel->server_retry_chance == 0) { /* Select a suitable failed server to retry. */ - ares_timeval_t now = ares__tvnow(); + ares_timeval_t now; ares__slist_node_t *node; + + ares__tvnow(&now); for (node = ares__slist_node_first(channel->servers); node != NULL; node = ares__slist_node_next(node)) { struct server_state *node_val = ares__slist_node_val(node); @@ -936,18 +912,58 @@ static ares_status_t ares__append_tcpbuf(struct server_state *server, const struct query *query) { ares_status_t status; + unsigned char *qbuf = NULL; + size_t qbuf_len = 0; + + status = ares_dns_write(query->query, &qbuf, &qbuf_len); + if (status != ARES_SUCCESS) { + goto done; + } + + status = ares__buf_append_be16(server->tcp_send, (unsigned short)qbuf_len); + if (status != ARES_SUCCESS) { + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + } + + status = ares__buf_append(server->tcp_send, qbuf, qbuf_len); + +done: + ares_free(qbuf); + return status; +} + + +static ares_status_t ares__write_udpbuf(ares_channel_t *channel, + ares_socket_t fd, + const struct query *query) +{ + ares_status_t status; + unsigned char *qbuf = NULL; + size_t qbuf_len = 0; - status = ares__buf_append_be16(server->tcp_send, (unsigned short)query->qlen); + status = ares_dns_write(query->query, &qbuf, &qbuf_len); if (status != ARES_SUCCESS) { - return status; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; } - return ares__buf_append(server->tcp_send, query->qbuf, query->qlen); + + if (ares__socket_write(channel, fd, qbuf, qbuf_len) == -1) { + status = ARES_ESERVFAIL; + } else { + status = ARES_SUCCESS; + } + +done: + ares_free(qbuf); + return status; } -static size_t ares__calc_query_timeout(const struct query *query) +static size_t ares__calc_query_timeout(const struct query *query, + const struct server_state *server, + const ares_timeval_t *now) { const ares_channel_t *channel = query->channel; - size_t timeplus = channel->timeout; + size_t timeout = ares_metrics_server_timeout(server, now); + size_t timeplus = timeout; size_t rounds; size_t num_servers = ares__slist_len(channel->servers); @@ -986,8 +1002,8 @@ static size_t ares__calc_query_timeout(const struct query *query) /* We want explicitly guarantee that timeplus is greater or equal to timeout * specified in channel options. */ - if (timeplus < channel->timeout) { - timeplus = channel->timeout; + if (timeplus < timeout) { + timeplus = timeout; } return timeplus; @@ -1014,7 +1030,7 @@ ares_status_t ares__send_query(struct query *query, const ares_timeval_t *now) } if (server == NULL) { - end_query(channel, query, ARES_ENOSERVER /* ? */, NULL); + end_query(channel, server, query, ARES_ENOSERVER /* ? */, NULL); return ARES_ENOSERVER; } @@ -1041,7 +1057,7 @@ ares_status_t ares__send_query(struct query *query, const ares_timeval_t *now) /* Anything else is not retryable, likely ENOMEM */ default: - end_query(channel, query, status, NULL); + end_query(channel, server, query, status, NULL); return status; } } @@ -1052,7 +1068,7 @@ ares_status_t ares__send_query(struct query *query, const ares_timeval_t *now) status = ares__append_tcpbuf(server, query); if (status != ARES_SUCCESS) { - end_query(channel, query, status, NULL); + end_query(channel, server, query, status, NULL); /* Only safe to kill connection if it was new, otherwise it should be * cleaned up by another process later */ @@ -1100,14 +1116,22 @@ ares_status_t ares__send_query(struct query *query, const ares_timeval_t *now) /* Anything else is not retryable, likely ENOMEM */ default: - end_query(channel, query, status, NULL); + end_query(channel, server, query, status, NULL); return status; } node = ares__llist_node_first(server->connections); } conn = ares__llist_node_val(node); - if (ares__socket_write(channel, conn->fd, query->qbuf, query->qlen) == -1) { + + status = ares__write_udpbuf(channel, conn->fd, query); + if (status != ARES_SUCCESS) { + if (status == ARES_ENOMEM) { + /* Not retryable */ + end_query(channel, server, query, status, NULL); + return status; + } + /* FIXME: Handle EAGAIN here since it likely can happen. */ server_increment_failures(server, query->using_tcp); status = ares__requeue_query(query, now); @@ -1122,18 +1146,19 @@ ares_status_t ares__send_query(struct query *query, const ares_timeval_t *now) } } - timeplus = ares__calc_query_timeout(query); + timeplus = ares__calc_query_timeout(query, server, now); /* Keep track of queries bucketed by timeout, so we can process * timeout events quickly. */ ares__slist_node_destroy(query->node_queries_by_timeout); + query->ts = *now; query->timeout = *now; timeadd(&query->timeout, timeplus); query->node_queries_by_timeout = ares__slist_insert(channel->queries_by_timeout, query); if (!query->node_queries_by_timeout) { /* LCOV_EXCL_START: OutOfMemory */ - end_query(channel, query, ARES_ENOMEM, NULL); + end_query(channel, server, query, ARES_ENOMEM, NULL); /* Only safe to kill connection if it was new, otherwise it should be * cleaned up by another process later */ if (new_connection) { @@ -1151,7 +1176,7 @@ ares_status_t ares__send_query(struct query *query, const ares_timeval_t *now) if (query->node_queries_to_conn == NULL) { /* LCOV_EXCL_START: OutOfMemory */ - end_query(channel, query, ARES_ENOMEM, NULL); + end_query(channel, server, query, ARES_ENOMEM, NULL); /* Only safe to kill connection if it was new, otherwise it should be * cleaned up by another process later */ if (new_connection) { @@ -1166,11 +1191,13 @@ ares_status_t ares__send_query(struct query *query, const ares_timeval_t *now) return ARES_SUCCESS; } -static ares_bool_t same_questions(const ares_dns_record_t *qrec, +static ares_bool_t same_questions(const struct query *query, const ares_dns_record_t *arec) { - size_t i; - ares_bool_t rv = ARES_FALSE; + size_t i; + ares_bool_t rv = ARES_FALSE; + const ares_dns_record_t *qrec = query->query; + const ares_channel_t *channel = query->channel; if (ares_dns_record_query_cnt(qrec) != ares_dns_record_query_cnt(arec)) { @@ -1196,9 +1223,26 @@ static ares_bool_t same_questions(const ares_dns_record_t *qrec, aname == NULL) { goto done; } - if (strcasecmp(qname, aname) != 0 || qtype != atype || qclass != aclass) { + + if (qtype != atype || qclass != aclass) { goto done; } + + if (channel->flags & ARES_FLAG_DNS0x20 && !query->using_tcp) { + /* NOTE: for DNS 0x20, part of the protection is to use a case-sensitive + * comparison of the DNS query name. This expects the upstream DNS + * server to preserve the case of the name in the response packet. + * https://datatracker.ietf.org/doc/html/draft-vixie-dnsext-dns0x20-00 + */ + if (strcmp(qname, aname) != 0) { + goto done; + } + } else { + /* without DNS0x20 use case-insensitive matching */ + if (strcasecmp(qname, aname) != 0) { + goto done; + } + } } rv = ARES_TRUE; @@ -1217,14 +1261,14 @@ static ares_bool_t same_address(const struct sockaddr *sa, switch (aa->family) { case AF_INET: addr1 = &aa->addr.addr4; - addr2 = &(CARES_INADDR_CAST(struct sockaddr_in *, sa))->sin_addr; + addr2 = &(CARES_INADDR_CAST(const struct sockaddr_in *, sa))->sin_addr; if (memcmp(addr1, addr2, sizeof(aa->addr.addr4)) == 0) { return ARES_TRUE; /* match */ } break; case AF_INET6: addr1 = &aa->addr.addr6; - addr2 = &(CARES_INADDR_CAST(struct sockaddr_in6 *, sa))->sin6_addr; + addr2 = &(CARES_INADDR_CAST(const struct sockaddr_in6 *, sa))->sin6_addr; if (memcmp(addr1, addr2, sizeof(aa->addr.addr6)) == 0) { return ARES_TRUE; /* match */ } @@ -1248,9 +1292,12 @@ static void ares_detach_query(struct query *query) query->node_all_queries = NULL; } -static void end_query(ares_channel_t *channel, struct query *query, - ares_status_t status, const ares_dns_record_t *dnsrec) +static void end_query(ares_channel_t *channel, struct server_state *server, + struct query *query, ares_status_t status, + const ares_dns_record_t *dnsrec) { + ares_metrics_record(query, server, status, dnsrec); + /* Invoke the callback. */ query->callback(query->arg, status, query->timeouts, dnsrec); ares__free_query(query); @@ -1270,7 +1317,7 @@ void ares__free_query(struct query *query) query->callback = NULL; query->arg = NULL; /* Deallocate the memory associated with the query */ - ares_free(query->qbuf); + ares_dns_record_destroy(query->query); ares_free(query); } diff --git a/lib/c-ares-1.31.0/src/lib/ares_qcache.c b/lib/c-ares-1.32.0/src/lib/ares_qcache.c similarity index 88% rename from lib/c-ares-1.31.0/src/lib/ares_qcache.c rename to lib/c-ares-1.32.0/src/lib/ares_qcache.c index e03d0692226..2d9919fd104 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_qcache.c +++ b/lib/c-ares-1.32.0/src/lib/ares_qcache.c @@ -23,8 +23,6 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" #include "ares_private.h" struct ares__qcache { @@ -135,7 +133,7 @@ static char *ares__qcache_calc_key(const ares_dns_record_t *dnsrec) fail: ares__buf_destroy(buf); return NULL; -/* LCOV_EXCL_STOP */ + /* LCOV_EXCL_STOP */ } static void ares__qcache_expire(ares__qcache_t *cache, @@ -214,20 +212,20 @@ ares_status_t ares__qcache_create(ares_rand_state *rand_state, cache = ares_malloc_zero(sizeof(*cache)); if (cache == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } cache->cache = ares__htable_strvp_create(NULL); if (cache->cache == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } cache->expire = ares__slist_create(rand_state, ares__qcache_entry_sort_cb, ares__qcache_entry_destroy_cb); if (cache->expire == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } cache->max_ttl = max_ttl; @@ -301,37 +299,18 @@ static unsigned int ares__qcache_soa_minimum(ares_dns_record_t *dnsrec) return 0; } -static char *ares__qcache_calc_key_frombuf(const unsigned char *qbuf, - size_t qlen) -{ - ares_status_t status; - ares_dns_record_t *dnsrec = NULL; - char *key = NULL; - - status = ares_dns_parse(qbuf, qlen, 0, &dnsrec); - if (status != ARES_SUCCESS) { - goto done; - } - - key = ares__qcache_calc_key(dnsrec); - -done: - ares_dns_record_destroy(dnsrec); - return key; -} - /* On success, takes ownership of dnsrec */ -static ares_status_t ares__qcache_insert(ares__qcache_t *qcache, - ares_dns_record_t *dnsrec, - const unsigned char *qbuf, size_t qlen, - const ares_timeval_t *now) +static ares_status_t ares__qcache_insert(ares__qcache_t *qcache, + ares_dns_record_t *qresp, + const ares_dns_record_t *qreq, + const ares_timeval_t *now) { ares__qcache_entry_t *entry; unsigned int ttl; - ares_dns_rcode_t rcode = ares_dns_record_get_rcode(dnsrec); - ares_dns_flags_t flags = ares_dns_record_get_flags(dnsrec); + ares_dns_rcode_t rcode = ares_dns_record_get_rcode(qresp); + ares_dns_flags_t flags = ares_dns_record_get_flags(qresp); - if (qcache == NULL || dnsrec == NULL) { + if (qcache == NULL || qresp == NULL) { return ARES_EFORMERR; } @@ -347,9 +326,9 @@ static ares_status_t ares__qcache_insert(ares__qcache_t *qcache, /* Look at SOA for NXDOMAIN for minimum */ if (rcode == ARES_RCODE_NXDOMAIN) { - ttl = ares__qcache_soa_minimum(dnsrec); + ttl = ares__qcache_soa_minimum(qresp); } else { - ttl = ares__qcache_calc_minttl(dnsrec); + ttl = ares__qcache_calc_minttl(qresp); } if (ttl > qcache->max_ttl) { @@ -366,7 +345,7 @@ static ares_status_t ares__qcache_insert(ares__qcache_t *qcache, goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } - entry->dnsrec = dnsrec; + entry->dnsrec = qresp; entry->expire_ts = now->sec + (time_t)ttl; entry->insert_ts = now->sec; @@ -374,7 +353,7 @@ static ares_status_t ares__qcache_insert(ares__qcache_t *qcache, * request had, so we have to re-parse the request in order to generate the * key for caching, but we'll only do this once we know for sure we really * want to cache it */ - entry->key = ares__qcache_calc_key_frombuf(qbuf, qlen); + entry->key = ares__qcache_calc_key(qreq); if (entry->key == NULL) { goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } @@ -397,7 +376,7 @@ static ares_status_t ares__qcache_insert(ares__qcache_t *qcache, ares_free(entry); } return ARES_ENOMEM; -/* LCOV_EXCL_STOP */ + /* LCOV_EXCL_STOP */ } ares_status_t ares_qcache_fetch(ares_channel_t *channel, @@ -422,7 +401,7 @@ ares_status_t ares_qcache_fetch(ares_channel_t *channel, key = ares__qcache_calc_key(dnsrec); if (key == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } entry = ares__htable_strvp_get_direct(channel->qcache->cache, key); @@ -446,6 +425,6 @@ ares_status_t ares_qcache_insert(ares_channel_t *channel, const struct query *query, ares_dns_record_t *dnsrec) { - return ares__qcache_insert(channel->qcache, dnsrec, query->qbuf, query->qlen, + return ares__qcache_insert(channel->qcache, dnsrec, query->query, now); } diff --git a/lib/c-ares-1.31.0/src/lib/ares_query.c b/lib/c-ares-1.32.0/src/lib/ares_query.c similarity index 86% rename from lib/c-ares-1.31.0/src/lib/ares_query.c rename to lib/c-ares-1.32.0/src/lib/ares_query.c index 35214bc4a5b..4d0861a5f52 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_query.c +++ b/lib/c-ares-1.32.0/src/lib/ares_query.c @@ -25,18 +25,12 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_NETINET_IN_H # include #endif -#include "ares_nameser.h" - -#include "ares.h" -#include "ares_dns.h" -#include "ares_private.h" - typedef struct { ares_callback_dnsrec callback; void *arg; @@ -64,11 +58,11 @@ static void ares_query_dnsrec_cb(void *arg, ares_status_t status, ares_free(qquery); } -static ares_status_t ares_query_int(ares_channel_t *channel, const char *name, - ares_dns_class_t dnsclass, - ares_dns_rec_type_t type, - ares_callback_dnsrec callback, void *arg, - unsigned short *qid) +ares_status_t ares_query_nolock(ares_channel_t *channel, const char *name, + ares_dns_class_t dnsclass, + ares_dns_rec_type_t type, + ares_callback_dnsrec callback, void *arg, + unsigned short *qid) { ares_status_t status; ares_dns_record_t *dnsrec = NULL; @@ -94,7 +88,7 @@ static ares_status_t ares_query_int(ares_channel_t *channel, const char *name, (size_t)(channel->flags & ARES_FLAG_EDNS) ? channel->ednspsz : 0); if (status != ARES_SUCCESS) { callback(arg, status, 0, NULL); /* LCOV_EXCL_LINE: OutOfMemory */ - return status; /* LCOV_EXCL_LINE: OutOfMemory */ + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } qquery = ares_malloc(sizeof(*qquery)); @@ -111,7 +105,7 @@ static ares_status_t ares_query_int(ares_channel_t *channel, const char *name, qquery->arg = arg; /* Send it off. qcallback will be called when we get an answer. */ - status = ares_send_dnsrec(channel, dnsrec, ares_query_dnsrec_cb, qquery, qid); + status = ares_send_nolock(channel, dnsrec, ares_query_dnsrec_cb, qquery, qid); ares_dns_record_destroy(dnsrec); return status; @@ -130,7 +124,7 @@ ares_status_t ares_query_dnsrec(ares_channel_t *channel, const char *name, } ares__channel_lock(channel); - status = ares_query_int(channel, name, dnsclass, type, callback, arg, qid); + status = ares_query_nolock(channel, name, dnsclass, type, callback, arg, qid); ares__channel_unlock(channel); return status; } @@ -147,7 +141,7 @@ void ares_query(ares_channel_t *channel, const char *name, int dnsclass, carg = ares__dnsrec_convert_arg(callback, arg); if (carg == NULL) { callback(arg, ARES_ENOMEM, 0, NULL, 0); /* LCOV_EXCL_LINE: OutOfMemory */ - return; /* LCOV_EXCL_LINE: OutOfMemory */ + return; /* LCOV_EXCL_LINE: OutOfMemory */ } ares_query_dnsrec(channel, name, (ares_dns_class_t)dnsclass, diff --git a/lib/c-ares-1.31.0/src/lib/ares_rand.c b/lib/c-ares-1.32.0/src/lib/ares_rand.c similarity index 95% rename from lib/c-ares-1.31.0/src/lib/ares_rand.c rename to lib/c-ares-1.32.0/src/lib/ares_rand.c index e36cbc67d70..c57bb706e68 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_rand.c +++ b/lib/c-ares-1.32.0/src/lib/ares_rand.c @@ -24,8 +24,6 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" #include "ares_private.h" #include @@ -43,7 +41,7 @@ typedef enum { ARES_RAND_OS = 1 << 0, /* OS-provided such as RtlGenRandom or arc4random */ ARES_RAND_FILE = 1 << 1, /* OS file-backed random number generator */ - ARES_RAND_RC4 = 1 << 2, /* Internal RC4 based PRNG */ + ARES_RAND_RC4 = 1 << 2 /* Internal RC4 based PRNG */ } ares_rand_backend; #define ARES_RC4_KEY_LEN 32 /* 256 bits */ @@ -57,7 +55,7 @@ typedef struct ares_rand_rc4 { static unsigned int ares_u32_from_ptr(void *addr) { /* LCOV_EXCL_START: FallbackCode */ - if (sizeof(void *) == 8) { + if (ares__is_64bit()) { return (unsigned int)((((ares_uint64_t)addr >> 32) & 0xFFFFFFFF) | ((ares_uint64_t)addr & 0xFFFFFFFF)); } @@ -91,7 +89,7 @@ static void ares_rc4_generate_key(ares_rand_rc4 *rc4_state, unsigned char *key, memcpy(key + len, &data, sizeof(data)); len += sizeof(data); - tv = ares__tvnow(); + ares__tvnow(&tv); data = (unsigned int)((tv.sec | tv.usec) & 0xFFFFFFFF); memcpy(key + len, &data, sizeof(data)); len += sizeof(data); @@ -105,6 +103,13 @@ static void ares_rc4_generate_key(ares_rand_rc4 *rc4_state, unsigned char *key, /* LCOV_EXCL_STOP */ } +#define ARES_SWAP_BYTE(a, b) \ + do { \ + unsigned char swapByte = *(a); \ + *(a) = *(b); \ + *(b) = swapByte; \ + } while (0) + static void ares_rc4_init(ares_rand_rc4 *rc4_state) { /* LCOV_EXCL_START: FallbackCode */ @@ -229,7 +234,7 @@ ares_rand_state *ares__init_rand_state(void) if (!ares__init_rand_engine(state)) { ares_free(state); /* LCOV_EXCL_LINE: UntestablePath */ - return NULL; /* LCOV_EXCL_LINE: UntestablePath */ + return NULL; /* LCOV_EXCL_LINE: UntestablePath */ } return state; @@ -250,7 +255,7 @@ static void ares__clear_rand_state(ares_rand_state *state) break; case ARES_RAND_RC4: break; - /* LCOV_EXCL_STOP */ + /* LCOV_EXCL_STOP */ } } @@ -313,7 +318,7 @@ static void ares__rand_bytes_fetch(ares_rand_state *state, unsigned char *buf, break; #endif - /* LCOV_EXCL_START: FallbackCode */ + /* LCOV_EXCL_START: FallbackCode */ case ARES_RAND_FILE: while (1) { @@ -334,8 +339,7 @@ static void ares__rand_bytes_fetch(ares_rand_state *state, unsigned char *buf, ares_rc4_prng(&state->state.rc4, buf, len); return; - /* LCOV_EXCL_STOP */ - + /* LCOV_EXCL_STOP */ } /* If we didn't return before we got here, that means we had a critical rand diff --git a/lib/c-ares-1.31.0/src/lib/ares_search.c b/lib/c-ares-1.32.0/src/lib/ares_search.c similarity index 96% rename from lib/c-ares-1.31.0/src/lib/ares_search.c rename to lib/c-ares-1.32.0/src/lib/ares_search.c index 7403de1674d..ae98df39a80 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_search.c +++ b/lib/c-ares-1.32.0/src/lib/ares_search.c @@ -25,16 +25,12 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_STRINGS_H # include #endif -#include "ares.h" -#include "ares_private.h" -#include "ares_dns.h" - struct search_query { /* Arguments passed to ares_search_dnsrec() */ ares_channel_t *channel; @@ -97,7 +93,7 @@ static ares_status_t ares_search_next(ares_channel_t *channel, } status = - ares_send_dnsrec(channel, squery->dnsrec, search_callback, squery, NULL); + ares_send_nolock(channel, squery->dnsrec, search_callback, squery, NULL); if (status != ARES_EFORMERR) { *skip_cleanup = ARES_TRUE; @@ -201,7 +197,7 @@ ares_status_t ares__search_name_list(const ares_channel_t *channel, list = ares_malloc_zero(sizeof(*list) * list_len); if (list == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } list[0] = alias; alias = NULL; @@ -216,7 +212,7 @@ ares_status_t ares__search_name_list(const ares_channel_t *channel, list = ares_malloc_zero(sizeof(*list) * list_len); if (list == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } list[0] = ares_strdup(name); if (list[0] == NULL) { @@ -323,7 +319,7 @@ static ares_status_t ares_search_int(ares_channel_t *channel, squery = ares_malloc_zero(sizeof(*squery)); if (squery == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } squery->channel = channel; @@ -332,7 +328,7 @@ static ares_status_t ares_search_int(ares_channel_t *channel, squery->dnsrec = ares_dns_record_duplicate(dnsrec); if (squery->dnsrec == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } squery->callback = callback; @@ -456,7 +452,7 @@ ares_status_t ares_search_dnsrec(ares_channel_t *channel, ares_status_t status; if (channel == NULL || dnsrec == NULL || callback == NULL) { - return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } ares__channel_lock(channel); @@ -498,7 +494,7 @@ ares_status_t ares__lookup_hostaliases(const ares_channel_t *channel, ares__llist_node_t *node; if (channel == NULL || name == NULL || alias == NULL) { - return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } *alias = NULL; @@ -521,8 +517,8 @@ ares_status_t ares__lookup_hostaliases(const ares_channel_t *channel, buf = ares__buf_create(); if (buf == NULL) { - status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ares__buf_load_file(hostaliases, buf); @@ -581,8 +577,8 @@ ares_status_t ares__lookup_hostaliases(const ares_channel_t *channel, *alias = ares_strdup(fqdn); if (*alias == NULL) { - status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Good! */ diff --git a/lib/c-ares-1.31.0/src/lib/ares_send.c b/lib/c-ares-1.32.0/src/lib/ares_send.c similarity index 67% rename from lib/c-ares-1.31.0/src/lib/ares_send.c rename to lib/c-ares-1.32.0/src/lib/ares_send.c index 800edce63dc..94e7e12b42d 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_send.c +++ b/lib/c-ares-1.32.0/src/lib/ares_send.c @@ -25,18 +25,13 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_NETINET_IN_H # include #endif - #include "ares_nameser.h" -#include "ares.h" -#include "ares_dns.h" -#include "ares_private.h" - static unsigned short generate_unique_qid(ares_channel_t *channel) { unsigned short id; @@ -48,18 +43,79 @@ static unsigned short generate_unique_qid(ares_channel_t *channel) return id; } -static ares_status_t ares_send_dnsrec_int(ares_channel_t *channel, - const ares_dns_record_t *dnsrec, - ares_callback_dnsrec callback, - void *arg, unsigned short *qid) + +/* https://datatracker.ietf.org/doc/html/draft-vixie-dnsext-dns0x20-00 */ +static ares_status_t ares_apply_dns0x20(ares_channel_t *channel, + ares_dns_record_t *dnsrec) +{ + ares_status_t status = ARES_SUCCESS; + const char *name = NULL; + char dns0x20name[256]; + unsigned char randdata[256 / 8]; + size_t len; + size_t remaining_bits; + size_t total_bits; + size_t i; + + status = ares_dns_record_query_get(dnsrec, 0, &name, NULL, NULL); + if (status != ARES_SUCCESS) { + goto done; + } + + len = ares_strlen(name); + if (len == 0 || len >= sizeof(dns0x20name)) { + status = ARES_EBADNAME; + goto done; + } + + memset(dns0x20name, 0, sizeof(dns0x20name)); + + /* Fetch the minimum amount of random data we'd need for the string, which + * is 1 bit per byte */ + total_bits = ((len + 7) / 8) * 8; + remaining_bits = total_bits; + ares__rand_bytes(channel->rand_state, randdata, total_bits / 8); + + /* Randomly apply 0x20 to name */ + for (i=0; iservers) == 0) { callback(arg, ARES_ENOSERVER, 0, NULL); return ARES_ENOSERVER; @@ -78,26 +134,36 @@ static ares_status_t ares_send_dnsrec_int(ares_channel_t *channel, query = ares_malloc(sizeof(struct query)); if (!query) { callback(arg, ARES_ENOMEM, 0, NULL); /* LCOV_EXCL_LINE: OutOfMemory */ - return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } memset(query, 0, sizeof(*query)); - query->channel = channel; - - status = ares_dns_write(dnsrec, &query->qbuf, &query->qlen); - if (status != ARES_SUCCESS) { - ares_free(query); - callback(arg, status, 0, NULL); - return status; - } - + query->channel = channel; query->qid = id; query->timeout.sec = 0; query->timeout.usec = 0; + query->using_tcp = (channel->flags & ARES_FLAG_USEVC)?ARES_TRUE:ARES_FALSE; + + /* Duplicate Query */ + query->query = ares_dns_record_duplicate(dnsrec); + if (query->query == NULL) { + ares_free(query); + callback(arg, ARES_ENOMEM, 0, NULL); + return ARES_ENOMEM; + } - /* Ignore first 2 bytes, assign our own query id */ - query->qbuf[0] = (unsigned char)((id >> 8) & 0xFF); - query->qbuf[1] = (unsigned char)(id & 0xFF); + ares_dns_record_set_id(query->query, id); + + if (channel->flags & ARES_FLAG_DNS0x20 && !query->using_tcp) { + status = ares_apply_dns0x20(channel, query->query); + if (status != ARES_SUCCESS) { + /* LCOV_EXCL_START: OutOfMemory */ + callback(arg, status, 0, NULL); + ares__free_query(query); + return status; + /* LCOV_EXCL_STOP */ + } + } /* Fill in query arguments. */ query->callback = callback; @@ -106,9 +172,6 @@ static ares_status_t ares_send_dnsrec_int(ares_channel_t *channel, /* Initialize query status. */ query->try_count = 0; - packetsz = (channel->flags & ARES_FLAG_EDNS) ? channel->ednspsz : PACKETSZ; - query->using_tcp = - (channel->flags & ARES_FLAG_USEVC) || query->qlen > packetsz; query->error_status = ARES_SUCCESS; query->timeouts = 0; @@ -161,7 +224,7 @@ ares_status_t ares_send_dnsrec(ares_channel_t *channel, ares__channel_lock(channel); - status = ares_send_dnsrec_int(channel, dnsrec, callback, arg, qid); + status = ares_send_nolock(channel, dnsrec, callback, arg, qid); ares__channel_unlock(channel); diff --git a/lib/c-ares-1.31.0/src/lib/setup_once.h b/lib/c-ares-1.32.0/src/lib/ares_setup.h similarity index 70% rename from lib/c-ares-1.31.0/src/lib/setup_once.h rename to lib/c-ares-1.32.0/src/lib/ares_setup.h index 649d6ac4d61..1b554f1974c 100644 --- a/lib/c-ares-1.31.0/src/lib/setup_once.h +++ b/lib/c-ares-1.32.0/src/lib/ares_setup.h @@ -23,24 +23,77 @@ * * SPDX-License-Identifier: MIT */ -#ifndef __SETUP_ONCE_H -#define __SETUP_ONCE_H +#ifndef __ARES_SETUP_H +#define __ARES_SETUP_H + +/* ============================================================================ + * NOTE: This file is automatically included by ares_private.h and should not + * typically be included directly. + * All c-ares source files should include ares_private.h as the + * first header. + * ============================================================================ + */ + +/* + * Include configuration script results or hand-crafted + * configuration file for platforms which lack config tool. + */ +#ifdef HAVE_CONFIG_H +# include "ares_config.h" +#else +# ifdef _WIN32 +# include "config-win32.h" +# endif +#endif /* HAVE_CONFIG_H */ -/******************************************************************** - * NOTICE * - * ======== * - * * - * Content of header files lib/setup_once.h and ares/setup_once.h * - * must be kept in sync. Modify the other one if you change this. * - * * - ********************************************************************/ +/* + * c-ares external interface definitions are also used internally, + * and might also include required system header files to define them. + */ +#include "ares_build.h" + +/* ================================================================= */ +/* No system header file shall be included in this file before this */ +/* point. The only allowed ones are those included from ares_build.h */ +/* ================================================================= */ /* - * Inclusion of common header files. + * Include header files for windows builds before redefining anything. + * Use this preproessor block only to include or exclude windows.h, + * winsock2.h, ws2tcpip.h or winsock.h. Any other windows thing belongs + * to any other further and independent block. Under Cygwin things work + * just as under linux (e.g. ) and the winsock headers should + * never be included when __CYGWIN__ is defined. configure script takes + * care of this, not defining HAVE_WINDOWS_H, HAVE_WINSOCK_H, HAVE_WINSOCK2_H, + * neither HAVE_WS2TCPIP_H when __CYGWIN__ is defined. */ +#ifdef USE_WINSOCK +# undef USE_WINSOCK +#endif + +#ifdef HAVE_WINDOWS_H +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif +# include +# ifdef HAVE_WINSOCK2_H +# include +# define USE_WINSOCK 2 +# ifdef HAVE_WS2TCPIP_H +# include +# endif +# else +# ifdef HAVE_WINSOCK_H +# include +# define USE_WINSOCK 1 +# endif +# endif +#endif + + #include #include #include @@ -55,14 +108,10 @@ # include #endif -#ifdef NEED_MALLOC_H +#ifdef HAVE_MALLOC_H # include #endif -#ifdef NEED_MEMORY_H -# include -#endif - #ifdef HAVE_SYS_STAT_H # include #endif @@ -79,6 +128,77 @@ # include #endif +#ifdef HAVE_SYS_SOCKET_H +# include +#endif + +/* + * Arg 2 type for gethostname in case it hasn't been defined in config file. + */ + +#ifndef GETHOSTNAME_TYPE_ARG2 +# ifdef USE_WINSOCK +# define GETHOSTNAME_TYPE_ARG2 int +# else +# define GETHOSTNAME_TYPE_ARG2 size_t +# endif +#endif + +#ifdef __POCC__ +# include +# include +# define ESRCH 3 +#endif + +/* + * Android does have the arpa/nameser.h header which is detected by configure + * but it appears to be empty with recent NDK r7b / r7c, so we undefine here. + * z/OS does have the arpa/nameser.h header which is detected by configure + * but it is not fully implemented and missing identifiers, so udefine here. + */ +#if (defined(ANDROID) || defined(__ANDROID__) || defined(__MVS__)) && \ + defined(HAVE_ARPA_NAMESER_H) +# undef HAVE_ARPA_NAMESER_H +#endif + +/* + * Recent autoconf versions define these symbols in ares_config.h. We don't + * want them (since they collide with the libcurl ones when we build + * --enable-debug) so we undef them again here. + */ + +#ifdef PACKAGE_STRING +# undef PACKAGE_STRING +#endif +#ifdef PACKAGE_TARNAME +# undef PACKAGE_TARNAME +#endif +#ifdef PACKAGE_VERSION +# undef PACKAGE_VERSION +#endif +#ifdef PACKAGE_BUGREPORT +# undef PACKAGE_BUGREPORT +#endif +#ifdef PACKAGE_NAME +# undef PACKAGE_NAME +#endif +#ifdef VERSION +# undef VERSION +#endif +#ifdef PACKAGE +# undef PACKAGE +#endif + +/* IPv6 compatibility */ +#if !defined(HAVE_AF_INET6) +# if defined(HAVE_PF_INET6) +# define AF_INET6 PF_INET6 +# else +# define AF_INET6 AF_MAX + 1 +# endif +#endif + + #ifdef __hpux # if !defined(_XOPEN_SOURCE_EXTENDED) || defined(_KERNEL) # ifdef _APP32_64BIT_OFF_T @@ -90,10 +210,6 @@ # endif #endif -#ifdef HAVE_SYS_SOCKET_H -# include -#endif - #ifdef __hpux # if !defined(_XOPEN_SOURCE_EXTENDED) || defined(_KERNEL) # ifdef OLD_APP32_64BIT_OFF_T @@ -152,7 +268,7 @@ struct timeval { * which is used to write outgoing data on a connected socket. * If yours has another name then don't define HAVE_SEND. * - * If HAVE_SEND is defined then SEND_TYPE_ARG1, SEND_QUAL_ARG2, + * If HAVE_SEND is defined then SEND_TYPE_ARG1, * SEND_TYPE_ARG2, SEND_TYPE_ARG3, SEND_TYPE_ARG4 and * SEND_TYPE_RETV must also be defined. */ @@ -184,7 +300,7 @@ Error Missing_definition_of_macro_sread write((SEND_TYPE_ARG1)(x), (SEND_TYPE_ARG2)(y), (SEND_TYPE_ARG3)(z)) #elif defined(HAVE_SEND) -# if !defined(SEND_TYPE_ARG1) || !defined(SEND_QUAL_ARG2) || \ +# if !defined(SEND_TYPE_ARG1) || \ !defined(SEND_TYPE_ARG2) || !defined(SEND_TYPE_ARG3) || \ !defined(SEND_TYPE_ARG4) || !defined(SEND_TYPE_RETV) /* */ @@ -204,42 +320,6 @@ Error Missing_definition_of_macro_sread #endif /* HAVE_SEND */ -#if 0 -# if defined(HAVE_RECVFROM) -/* - * Currently recvfrom is only used on udp sockets. - */ -# if !defined(RECVFROM_TYPE_ARG1) || !defined(RECVFROM_TYPE_ARG2) || \ - !defined(RECVFROM_TYPE_ARG3) || !defined(RECVFROM_TYPE_ARG4) || \ - !defined(RECVFROM_TYPE_ARG5) || !defined(RECVFROM_TYPE_ARG6) || \ - !defined(RECVFROM_TYPE_RETV) - /* */ - Error Missing_definition_of_return_and_arguments_types_of_recvfrom - /* */ -# else -# define sreadfrom(s, b, bl, f, fl) \ - (ares_ssize_t) \ - recvfrom((RECVFROM_TYPE_ARG1)(s), (RECVFROM_TYPE_ARG2 *)(b), \ - (RECVFROM_TYPE_ARG3)(bl), (RECVFROM_TYPE_ARG4)(0), \ - (RECVFROM_TYPE_ARG5 *)(f), (RECVFROM_TYPE_ARG6 *)(fl)) -# endif -# else /* HAVE_RECVFROM */ -# ifndef sreadfrom - /* */ - Error Missing_definition_of_macro_sreadfrom - /* */ -# endif -# endif /* HAVE_RECVFROM */ - - -# ifdef RECVFROM_TYPE_ARG6_IS_VOID -# define RECVFROM_ARG6_T int -# else -# define RECVFROM_ARG6_T RECVFROM_TYPE_ARG6 -# endif -#endif /* if 0 */ - - /* * Function-like macro definition used to close a socket. */ @@ -254,48 +334,6 @@ Error Missing_definition_of_macro_sread # define sclose(x) close((x)) #endif - -/* - * Uppercase macro versions of ANSI/ISO is*() functions/macros which - * avoid negative number inputs with argument byte codes > 127. - */ - -#define ISSPACE(x) (isspace((int)((unsigned char)x))) -#define ISDIGIT(x) (isdigit((int)((unsigned char)x))) -#define ISALNUM(x) (isalnum((int)((unsigned char)x))) -#define ISXDIGIT(x) (isxdigit((int)((unsigned char)x))) -#define ISGRAPH(x) (isgraph((int)((unsigned char)x))) -#define ISALPHA(x) (isalpha((int)((unsigned char)x))) -#define ISPRINT(x) (isprint((int)((unsigned char)x))) -#define ISUPPER(x) (isupper((int)((unsigned char)x))) -#define ISLOWER(x) (islower((int)((unsigned char)x))) -#define ISASCII(x) (((unsigned char)x) <= 127 ? 1 : 0) - -#define ISBLANK(x) \ - (int)((((unsigned char)x) == ' ') || (((unsigned char)x) == '\t')) - -#define TOLOWER(x) (tolower((int)((unsigned char)x))) - - -/* - * Macro WHILE_FALSE may be used to build single-iteration do-while loops, - * avoiding compiler warnings. Mostly intended for other macro definitions. - */ - -#define WHILE_FALSE while (0) - -#if defined(_MSC_VER) && !defined(__POCC__) -# undef WHILE_FALSE -# if (_MSC_VER < 1500) -# define WHILE_FALSE while (1, 0) -# else -# define WHILE_FALSE \ - __pragma(warning(push)) __pragma(warning(disable : 4127)) while (0) \ - __pragma(warning(pop)) -# endif -#endif - - /* * Macro used to include code only in debug builds. */ @@ -305,25 +343,9 @@ Error Missing_definition_of_macro_sread #else # define DEBUGF(x) \ do { \ - } \ - WHILE_FALSE + } while(0) #endif - -/* - * Macro used to include assertion code only in debug builds. - */ - -#if defined(DEBUGBUILD) && defined(HAVE_ASSERT_H) -# define DEBUGASSERT(x) assert(x) -#else -# define DEBUGASSERT(x) \ - do { \ - } \ - WHILE_FALSE -#endif - - /* * Macro SOCKERRNO / SET_SOCKERRNO() returns / sets the *socket-related* errno * (or equivalent) on this platform to hide platform details to code using it. @@ -431,34 +453,4 @@ Error Missing_definition_of_macro_sread # define EREMOTE WSAEREMOTE #endif - -/* - * Actually use __32_getpwuid() on 64-bit VMS builds for getpwuid() - */ - -#if defined(__VMS) && defined(__INITIAL_POINTER_SIZE) && \ - (__INITIAL_POINTER_SIZE == 64) -# define getpwuid __32_getpwuid -#endif - - -/* - * Macro argv_item_t hides platform details to code using it. - */ - -#ifdef __VMS -# define argv_item_t __char_ptr32 -#else -# define argv_item_t char * -#endif - - -/* - * We use this ZERO_NULL to avoid picky compiler warnings, - * when assigning a NULL pointer to a function pointer var. - */ - -#define ZERO_NULL 0 - - -#endif /* __SETUP_ONCE_H */ +#endif /* __ARES_SETUP_H */ diff --git a/lib/c-ares-1.31.0/src/lib/ares_str.c b/lib/c-ares-1.32.0/src/lib/ares_str.c similarity index 99% rename from lib/c-ares-1.31.0/src/lib/ares_str.c rename to lib/c-ares-1.32.0/src/lib/ares_str.c index db0a12bd2fd..ade61041eb9 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_str.c +++ b/lib/c-ares-1.32.0/src/lib/ares_str.c @@ -25,10 +25,8 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares_str.h" -#include "ares.h" #include "ares_private.h" +#include "ares_str.h" #ifdef HAVE_STDINT_H # include diff --git a/lib/c-ares-1.31.0/src/lib/ares_str.h b/lib/c-ares-1.32.0/src/lib/ares_str.h similarity index 98% rename from lib/c-ares-1.31.0/src/lib/ares_str.h rename to lib/c-ares-1.32.0/src/lib/ares_str.h index 526a927a628..81353221407 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_str.h +++ b/lib/c-ares-1.32.0/src/lib/ares_str.h @@ -27,9 +27,6 @@ #ifndef __ARES_STR_H #define __ARES_STR_H -#include "ares_setup.h" -#include "ares.h" - char *ares_strdup(const char *s1); size_t ares_strlen(const char *str); diff --git a/lib/c-ares-1.31.0/src/lib/ares_strcasecmp.c b/lib/c-ares-1.32.0/src/lib/ares_strcasecmp.c similarity index 89% rename from lib/c-ares-1.31.0/src/lib/ares_strcasecmp.c rename to lib/c-ares-1.32.0/src/lib/ares_strcasecmp.c index b91cbbe1544..76b835fd8e9 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_strcasecmp.c +++ b/lib/c-ares-1.32.0/src/lib/ares_strcasecmp.c @@ -25,7 +25,7 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #include "ares_strcasecmp.h" #ifndef HAVE_STRCASECMP @@ -39,8 +39,8 @@ int ares_strcasecmp(const char *a, const char *b) size_t i; for (i = 0; i < (size_t)-1; i++) { - int c1 = ISUPPER(a[i]) ? tolower(a[i]) : a[i]; - int c2 = ISUPPER(b[i]) ? tolower(b[i]) : b[i]; + int c1 = ares__tolower(a[i]); + int c2 = ares__tolower(b[i]); if (c1 != c2) { return c1 - c2; } @@ -64,8 +64,8 @@ int ares_strncasecmp(const char *a, const char *b, size_t n) size_t i; for (i = 0; i < n; i++) { - int c1 = ISUPPER(a[i]) ? tolower(a[i]) : a[i]; - int c2 = ISUPPER(b[i]) ? tolower(b[i]) : b[i]; + int c1 = ares__tolower(a[i]); + int c2 = ares__tolower(b[i]); if (c1 != c2) { return c1 - c2; } diff --git a/lib/c-ares-1.31.0/src/lib/ares_strcasecmp.h b/lib/c-ares-1.32.0/src/lib/ares_strcasecmp.h similarity index 98% rename from lib/c-ares-1.31.0/src/lib/ares_strcasecmp.h rename to lib/c-ares-1.32.0/src/lib/ares_strcasecmp.h index 31a66be7179..a8097d2219e 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_strcasecmp.h +++ b/lib/c-ares-1.32.0/src/lib/ares_strcasecmp.h @@ -27,8 +27,6 @@ #ifndef HEADER_CARES_STRCASECMP_H #define HEADER_CARES_STRCASECMP_H -#include "ares_setup.h" - #ifndef HAVE_STRCASECMP extern int ares_strcasecmp(const char *a, const char *b); #endif diff --git a/lib/c-ares-1.31.0/src/lib/ares_strerror.c b/lib/c-ares-1.32.0/src/lib/ares_strerror.c similarity index 98% rename from lib/c-ares-1.31.0/src/lib/ares_strerror.c rename to lib/c-ares-1.32.0/src/lib/ares_strerror.c index ae94f9619ef..d9f64116202 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_strerror.c +++ b/lib/c-ares-1.32.0/src/lib/ares_strerror.c @@ -25,9 +25,7 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include -#include "ares.h" +#include "ares_private.h" const char *ares_strerror(int code) { diff --git a/lib/c-ares-1.31.0/src/lib/ares_strsplit.c b/lib/c-ares-1.32.0/src/lib/ares_strsplit.c similarity index 94% rename from lib/c-ares-1.31.0/src/lib/ares_strsplit.c rename to lib/c-ares-1.32.0/src/lib/ares_strsplit.c index 432a2d6cebb..dee307d7799 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_strsplit.c +++ b/lib/c-ares-1.32.0/src/lib/ares_strsplit.c @@ -23,13 +23,6 @@ * * SPDX-License-Identifier: MIT */ - -#if defined(__MVS__) -# include -#endif - -#include "ares_setup.h" -#include "ares.h" #include "ares_private.h" void ares__strsplit_free(char **elms, size_t num_elm) @@ -64,7 +57,7 @@ char **ares__strsplit_duplicate(char **elms, size_t num_elm) out[i] = ares_strdup(elms[i]); if (out[i] == NULL) { ares__strsplit_free(out, num_elm); /* LCOV_EXCL_LINE: OutOfMemory */ - return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ + return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -109,7 +102,7 @@ char **ares__strsplit(const char *in, const char *delms, size_t *num_elm) out = ares_malloc_zero(cnt * sizeof(*out)); if (out == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } for (node = ares__llist_node_first(llist); node != NULL; diff --git a/lib/c-ares-1.31.0/src/lib/ares_strsplit.h b/lib/c-ares-1.32.0/src/lib/ares_strsplit.h similarity index 98% rename from lib/c-ares-1.31.0/src/lib/ares_strsplit.h rename to lib/c-ares-1.32.0/src/lib/ares_strsplit.h index af650eee534..ee997804f01 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_strsplit.h +++ b/lib/c-ares-1.32.0/src/lib/ares_strsplit.h @@ -26,8 +26,6 @@ #ifndef HEADER_CARES_STRSPLIT_H #define HEADER_CARES_STRSPLIT_H -#include "ares_setup.h" - /* Split a string on delms skipping empty or duplicate elements. * * param in String to split. diff --git a/lib/c-ares-1.32.0/src/lib/ares_sysconfig.c b/lib/c-ares-1.32.0/src/lib/ares_sysconfig.c new file mode 100644 index 00000000000..2cd3df28235 --- /dev/null +++ b/lib/c-ares-1.32.0/src/lib/ares_sysconfig.c @@ -0,0 +1,542 @@ +/* MIT License + * + * Copyright (c) 1998 Massachusetts Institute of Technology + * Copyright (c) 2007 Daniel Stenberg + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * SPDX-License-Identifier: MIT + */ + +#include "ares_private.h" + +#ifdef HAVE_SYS_PARAM_H +# include +#endif + +#ifdef HAVE_NETINET_IN_H +# include +#endif + +#ifdef HAVE_NETDB_H +# include +#endif + +#ifdef HAVE_ARPA_INET_H +# include +#endif + +#if defined(ANDROID) || defined(__ANDROID__) +# include +# include "ares_android.h" +/* From the Bionic sources */ +# define DNS_PROP_NAME_PREFIX "net.dns" +# define MAX_DNS_PROPERTIES 8 +#endif + +#if defined(CARES_USE_LIBRESOLV) +# include +#endif + +#include "ares_inet_net_pton.h" +#include "ares_platform.h" + + +#if defined(__MVS__) +static ares_status_t ares__init_sysconfig_mvs(ares_sysconfig_t *sysconfig) +{ + struct __res_state *res = 0; + size_t count4; + size_t count6; + int i; + __STATEEXTIPV6 *v6; + arse__llist_t *sconfig = NULL; + ares_status_t status; + + if (0 == res) { + int rc = res_init(); + while (rc == -1 && h_errno == TRY_AGAIN) { + rc = res_init(); + } + if (rc == -1) { + return ARES_ENOMEM; + } + res = __res(); + } + + v6 = res->__res_extIPv6; + if (res->nscount > 0) { + count4 = (size_t)res->nscount; + } + + if (v6 && v6->__stat_nscount > 0) { + count6 = (size_t)v6->__stat_nscount; + } else { + count6 = 0; + } + + for (i = 0; i < count4; i++) { + struct sockaddr_in *addr_in = &(res->nsaddr_list[i]); + struct ares_addr addr; + + addr.addr.addr4.s_addr = addr_in->sin_addr.s_addr; + addr.family = AF_INET; + + status = + ares__sconfig_append(&sysconfig->sconfig, &addr, htons(addr_in->sin_port), + htons(addr_in->sin_port), NULL); + + if (status != ARES_SUCCESS) { + return status; + } + } + + for (i = 0; i < count6; i++) { + struct sockaddr_in6 *addr_in = &(v6->__stat_nsaddr_list[i]); + struct ares_addr addr; + + addr.family = AF_INET6; + memcpy(&(addr.addr.addr6), &(addr_in->sin6_addr), + sizeof(addr_in->sin6_addr)); + + status = + ares__sconfig_append(&sysconfig->sconfig, &addr, htons(addr_in->sin_port), + htons(addr_in->sin_port), NULL); + + if (status != ARES_SUCCESS) { + return status; + } + } + + return ARES_SUCCESS; +} +#endif + +#if defined(__riscos__) +static ares_status_t ares__init_sysconfig_riscos(ares_sysconfig_t *sysconfig) +{ + char *line; + ares_status_t status = ARES_SUCCESS; + + /* Under RISC OS, name servers are listed in the + system variable Inet$Resolvers, space separated. */ + line = getenv("Inet$Resolvers"); + if (line) { + char *resolvers = ares_strdup(line); + char *pos; + char *space; + + if (!resolvers) { + return ARES_ENOMEM; + } + + pos = resolvers; + do { + space = strchr(pos, ' '); + if (space) { + *space = '\0'; + } + status = + ares__sconfig_append_fromstr(&sysconfig->sconfig, pos, ARES_TRUE); + if (status != ARES_SUCCESS) { + break; + } + pos = space + 1; + } while (space); + + ares_free(resolvers); + } + + return status; +} +#endif + +#if defined(WATT32) +static ares_status_t ares__init_sysconfig_watt32(ares_sysconfig_t *sysconfig) +{ + size_t i; + ares_status_t status; + + sock_init(); + + for (i = 0; def_nameservers[i]; i++) { + struct ares_addr addr; + + addr.family = AF_INET; + addr.addr.addr4.s_addr = htonl(def_nameservers[i]); + + status = ares__sconfig_append(&sysconfig->sconfig, &addr, 0, 0, NULL); + + if (status != ARES_SUCCESS) { + return status; + } + } + + return ARES_SUCCESS; +} +#endif + +#if defined(ANDROID) || defined(__ANDROID__) +static ares_status_t ares__init_sysconfig_android(ares_sysconfig_t *sysconfig) +{ + size_t i; + char **dns_servers; + char *domains; + size_t num_servers; + ares_status_t status = ARES_EFILE; + + /* Use the Android connectivity manager to get a list + * of DNS servers. As of Android 8 (Oreo) net.dns# + * system properties are no longer available. Google claims this + * improves privacy. Apps now need the ACCESS_NETWORK_STATE + * permission and must use the ConnectivityManager which + * is Java only. */ + dns_servers = ares_get_android_server_list(MAX_DNS_PROPERTIES, &num_servers); + if (dns_servers != NULL) { + for (i = 0; i < num_servers; i++) { + status = ares__sconfig_append_fromstr(&sysconfig->sconfig, dns_servers[i], + ARES_TRUE); + if (status != ARES_SUCCESS) { + return status; + } + } + for (i = 0; i < num_servers; i++) { + ares_free(dns_servers[i]); + } + ares_free(dns_servers); + } + + domains = ares_get_android_search_domains_list(); + sysconfig->domains = ares__strsplit(domains, ", ", &sysconfig->ndomains); + ares_free(domains); + +# ifdef HAVE___SYSTEM_PROPERTY_GET + /* Old way using the system property still in place as + * a fallback. Older android versions can still use this. + * it's possible for older apps not not have added the new + * permission and we want to try to avoid breaking those. + * + * We'll only run this if we don't have any dns servers + * because this will get the same ones (if it works). */ + if (sysconfig->sconfig == NULL) { + char propname[PROP_NAME_MAX]; + char propvalue[PROP_VALUE_MAX] = ""; + for (i = 1; i <= MAX_DNS_PROPERTIES; i++) { + snprintf(propname, sizeof(propname), "%s%u", DNS_PROP_NAME_PREFIX, i); + if (__system_property_get(propname, propvalue) < 1) { + break; + } + status = + ares__sconfig_append_fromstr(&sysconfig->sconfig, propvalue, ARES_TRUE); + if (status != ARES_SUCCESS) { + return status; + } + } + } +# endif /* HAVE___SYSTEM_PROPERTY_GET */ + + return status; +} +#endif + +#if defined(CARES_USE_LIBRESOLV) +static ares_status_t ares__init_sysconfig_libresolv(ares_sysconfig_t *sysconfig) +{ + struct __res_state res; + ares_status_t status = ARES_SUCCESS; + union res_sockaddr_union addr[MAXNS]; + int nscount; + size_t i; + size_t entries = 0; + ares__buf_t *ipbuf = NULL; + + memset(&res, 0, sizeof(res)); + + if (res_ninit(&res) != 0 || !(res.options & RES_INIT)) { + return ARES_EFILE; + } + + nscount = res_getservers(&res, addr, MAXNS); + + for (i = 0; i < (size_t)nscount; ++i) { + char ipaddr[INET6_ADDRSTRLEN] = ""; + char *ipstr = NULL; + unsigned short port = 0; + unsigned int ll_scope = 0; + + sa_family_t family = addr[i].sin.sin_family; + if (family == AF_INET) { + ares_inet_ntop(family, &addr[i].sin.sin_addr, ipaddr, sizeof(ipaddr)); + port = ntohs(addr[i].sin.sin_port); + } else if (family == AF_INET6) { + ares_inet_ntop(family, &addr[i].sin6.sin6_addr, ipaddr, sizeof(ipaddr)); + port = ntohs(addr[i].sin6.sin6_port); + ll_scope = addr[i].sin6.sin6_scope_id; + } else { + continue; + } + + + /* [ip]:port%iface */ + ipbuf = ares__buf_create(); + if (ipbuf == NULL) { + status = ARES_ENOMEM; + goto done; + } + + status = ares__buf_append_str(ipbuf, "["); + if (status != ARES_SUCCESS) { + goto done; + } + + status = ares__buf_append_str(ipbuf, ipaddr); + if (status != ARES_SUCCESS) { + goto done; + } + + status = ares__buf_append_str(ipbuf, "]"); + if (status != ARES_SUCCESS) { + goto done; + } + + if (port) { + status = ares__buf_append_str(ipbuf, ":"); + if (status != ARES_SUCCESS) { + goto done; + } + status = ares__buf_append_num_dec(ipbuf, port, 0); + if (status != ARES_SUCCESS) { + goto done; + } + } + + if (ll_scope) { + status = ares__buf_append_str(ipbuf, "%"); + if (status != ARES_SUCCESS) { + goto done; + } + status = ares__buf_append_num_dec(ipbuf, ll_scope, 0); + if (status != ARES_SUCCESS) { + goto done; + } + } + + ipstr = ares__buf_finish_str(ipbuf, NULL); + ipbuf = NULL; + if (ipstr == NULL) { + status = ARES_ENOMEM; + goto done; + } + + status = + ares__sconfig_append_fromstr(&sysconfig->sconfig, ipstr, ARES_TRUE); + + ares_free(ipstr); + if (status != ARES_SUCCESS) { + goto done; + } + } + + while ((entries < MAXDNSRCH) && res.dnsrch[entries]) { + entries++; + } + + if (entries) { + sysconfig->domains = ares_malloc_zero(entries * sizeof(char *)); + if (sysconfig->domains == NULL) { + status = ARES_ENOMEM; + goto done; + } else { + sysconfig->ndomains = entries; + for (i = 0; i < sysconfig->ndomains; i++) { + sysconfig->domains[i] = ares_strdup(res.dnsrch[i]); + if (sysconfig->domains[i] == NULL) { + status = ARES_ENOMEM; + goto done; + } + } + } + } + + if (res.ndots >= 0) { + sysconfig->ndots = (size_t)res.ndots; + } +/* Apple does not allow configuration of retry, so this is a static dummy + * value, ignore */ +# ifndef __APPLE__ + if (res.retry > 0) { + sysconfig->tries = (size_t)res.retry; + } +# endif + if (res.options & RES_ROTATE) { + sysconfig->rotate = ARES_TRUE; + } + + if (res.retrans > 0) { +/* Apple does not allow configuration of retrans, so this is a dummy value + * that is extremely high (5s) */ +# ifndef __APPLE__ + if (res.retrans > 0) { + sysconfig->timeout_ms = (unsigned int)res.retrans * 1000; + } +# endif + } + +done: + ares__buf_destroy(ipbuf); + res_ndestroy(&res); + return status; +} +#endif + +static void ares_sysconfig_free(ares_sysconfig_t *sysconfig) +{ + ares__llist_destroy(sysconfig->sconfig); + ares__strsplit_free(sysconfig->domains, sysconfig->ndomains); + ares_free(sysconfig->sortlist); + ares_free(sysconfig->lookups); + memset(sysconfig, 0, sizeof(*sysconfig)); +} + +static ares_status_t ares_sysconfig_apply(ares_channel_t *channel, + const ares_sysconfig_t *sysconfig) +{ + ares_status_t status; + + if (sysconfig->sconfig && !(channel->optmask & ARES_OPT_SERVERS)) { + status = ares__servers_update(channel, sysconfig->sconfig, ARES_FALSE); + if (status != ARES_SUCCESS) { + return status; + } + } + + if (sysconfig->domains && !(channel->optmask & ARES_OPT_DOMAINS)) { + /* Make sure we duplicate first then replace so even if there is + * ARES_ENOMEM, the channel stays in a good state */ + char **temp = + ares__strsplit_duplicate(sysconfig->domains, sysconfig->ndomains); + if (temp == NULL) { + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + } + + ares__strsplit_free(channel->domains, channel->ndomains); + channel->domains = temp; + channel->ndomains = sysconfig->ndomains; + } + + if (sysconfig->lookups && !(channel->optmask & ARES_OPT_LOOKUPS)) { + char *temp = ares_strdup(sysconfig->lookups); + if (temp == NULL) { + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + } + + ares_free(channel->lookups); + channel->lookups = temp; + } + + if (sysconfig->sortlist && !(channel->optmask & ARES_OPT_SORTLIST)) { + struct apattern *temp = + ares_malloc(sizeof(*channel->sortlist) * sysconfig->nsortlist); + if (temp == NULL) { + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + } + memcpy(temp, sysconfig->sortlist, + sizeof(*channel->sortlist) * sysconfig->nsortlist); + + ares_free(channel->sortlist); + channel->sortlist = temp; + channel->nsort = sysconfig->nsortlist; + } + + if (!(channel->optmask & ARES_OPT_NDOTS)) { + channel->ndots = sysconfig->ndots; + } + + if (sysconfig->tries && !(channel->optmask & ARES_OPT_TRIES)) { + channel->tries = sysconfig->tries; + } + + if (sysconfig->timeout_ms && !(channel->optmask & ARES_OPT_TIMEOUTMS)) { + channel->timeout = sysconfig->timeout_ms; + } + + if (!(channel->optmask & (ARES_OPT_ROTATE | ARES_OPT_NOROTATE))) { + channel->rotate = sysconfig->rotate; + } + + if (sysconfig->usevc) { + channel->flags |= ARES_FLAG_USEVC; + } + + return ARES_SUCCESS; +} + +ares_status_t ares__init_by_sysconfig(ares_channel_t *channel) +{ + ares_status_t status; + ares_sysconfig_t sysconfig; + + memset(&sysconfig, 0, sizeof(sysconfig)); + +#if defined(USE_WINSOCK) + status = ares__init_sysconfig_windows(&sysconfig); +#elif defined(__MVS__) + status = ares__init_sysconfig_mvs(&sysconfig); +#elif defined(__riscos__) + status = ares__init_sysconfig_riscos(&sysconfig); +#elif defined(WATT32) + status = ares__init_sysconfig_watt32(&sysconfig); +#elif defined(ANDROID) || defined(__ANDROID__) + status = ares__init_sysconfig_android(&sysconfig); +#elif defined(__APPLE__) + status = ares__init_sysconfig_macos(&sysconfig); +#elif defined(CARES_USE_LIBRESOLV) + status = ares__init_sysconfig_libresolv(&sysconfig); +#else + status = ares__init_sysconfig_files(channel, &sysconfig); +#endif + + if (status != ARES_SUCCESS) { + goto done; + } + + /* Environment is supposed to override sysconfig */ + status = ares__init_by_environment(&sysconfig); + if (status != ARES_SUCCESS) { + goto done; + } + + /* Lock when applying the configuration to the channel. Don't need to + * lock prior to this. */ + + ares__channel_lock(channel); + + status = ares_sysconfig_apply(channel, &sysconfig); + ares__channel_unlock(channel); + + if (status != ARES_SUCCESS) { + goto done; + } + +done: + ares_sysconfig_free(&sysconfig); + + return status; +} diff --git a/lib/c-ares-1.31.0/src/lib/ares_sysconfig_files.c b/lib/c-ares-1.32.0/src/lib/ares_sysconfig_files.c similarity index 99% rename from lib/c-ares-1.31.0/src/lib/ares_sysconfig_files.c rename to lib/c-ares-1.32.0/src/lib/ares_sysconfig_files.c index f71043000a4..7b8bdbe4187 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_sysconfig_files.c +++ b/lib/c-ares-1.32.0/src/lib/ares_sysconfig_files.c @@ -25,7 +25,7 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_SYS_PARAM_H # include @@ -43,8 +43,6 @@ # include #endif -#include "ares_nameser.h" - #if defined(ANDROID) || defined(__ANDROID__) # include # include "ares_android.h" @@ -61,10 +59,8 @@ # include #endif -#include "ares.h" #include "ares_inet_net_pton.h" #include "ares_platform.h" -#include "ares_private.h" static unsigned char ip_natural_mask(const struct ares_addr *addr) { @@ -263,7 +259,7 @@ ares_status_t ares__parse_sortlist(struct apattern **sortlist, size_t *nsort, if (!sortlist_append(sortlist, nsort, &pat)) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } diff --git a/lib/c-ares-1.31.0/src/lib/ares_sysconfig_mac.c b/lib/c-ares-1.32.0/src/lib/ares_sysconfig_mac.c similarity index 91% rename from lib/c-ares-1.31.0/src/lib/ares_sysconfig_mac.c rename to lib/c-ares-1.32.0/src/lib/ares_sysconfig_mac.c index 6ec499e59f5..e2136201f68 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_sysconfig_mac.c +++ b/lib/c-ares-1.32.0/src/lib/ares_sysconfig_mac.c @@ -45,7 +45,14 @@ * private header extracted from: * https://opensource.apple.com/source/configd/configd-1109.140.1/dnsinfo/dnsinfo.h */ -# include "ares_setup.h" + +/* The apple header uses anonymous unions which came with C11 */ +# if defined(__clang__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wc11-extensions" +# endif + +# include "ares_private.h" # include # include # include @@ -56,8 +63,6 @@ # if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 /* MacOS 10.8 */ # include # endif -# include "ares.h" -# include "ares_private.h" typedef struct { void *handle; @@ -80,12 +85,13 @@ static void dnsinfo_destroy(dnsinfo_t *dnsinfo) static ares_status_t dnsinfo_init(dnsinfo_t **dnsinfo_out) { - dnsinfo_t *dnsinfo = NULL; - ares_status_t status = ARES_SUCCESS; + dnsinfo_t *dnsinfo = NULL; + ares_status_t status = ARES_SUCCESS; size_t i; - const char *searchlibs[] = { + const char *searchlibs[] = { "/usr/lib/libSystem.dylib", - "/System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration", + "/System/Library/Frameworks/SystemConfiguration.framework/" + "SystemConfiguration", NULL }; @@ -102,17 +108,17 @@ static ares_status_t dnsinfo_init(dnsinfo_t **dnsinfo_out) goto done; } - for (i=0; searchlibs[i] != NULL; i++) { + for (i = 0; searchlibs[i] != NULL; i++) { dnsinfo->handle = dlopen(searchlibs[i], RTLD_LAZY /* | RTLD_NOLOAD */); if (dnsinfo->handle == NULL) { /* Fail, loop */ continue; } - dnsinfo->dns_configuration_copy = + dnsinfo->dns_configuration_copy = (dns_config_t *(*)(void)) dlsym(dnsinfo->handle, "dns_configuration_copy"); - dnsinfo->dns_configuration_free = + dnsinfo->dns_configuration_free = (void (*)(dns_config_t *)) dlsym(dnsinfo->handle, "dns_configuration_free"); if (dnsinfo->dns_configuration_copy != NULL && @@ -162,7 +168,7 @@ static ares_status_t read_resolver(const dns_resolver_t *resolver, unsigned short port = 0; ares_status_t status = ARES_SUCCESS; -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 /* MacOS 10.8 */ +# if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 /* MacOS 10.8 */ /* XXX: resolver->domain is for domain-specific servers. When we implement * this support, we'll want to use this. But for now, we're going to * skip any servers which set this since we can't properly route. @@ -172,9 +178,9 @@ static ares_status_t read_resolver(const dns_resolver_t *resolver, if (resolver->domain != NULL) { return ARES_SUCCESS; } -#endif +# endif -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 /* MacOS 10.8 */ +# if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 /* MacOS 10.8 */ /* Check to see if DNS server should be used, base this on if the server is * reachable or can be reachable automatically if we send traffic that * direction. */ @@ -183,7 +189,7 @@ static ares_status_t read_resolver(const dns_resolver_t *resolver, kSCNetworkReachabilityFlagsConnectionOnTraffic))) { return ARES_SUCCESS; } -#endif +# endif /* NOTE: it doesn't look like resolver->flags is relevant */ @@ -296,8 +302,8 @@ static ares_status_t read_resolver(const dns_resolver_t *resolver, if_name = ares__if_indextoname(resolver->if_index, if_name_str, sizeof(if_name_str)); - status = ares__sconfig_append(&sysconfig->sconfig, &addr, addrport, - addrport, if_name); + status = ares__sconfig_append(&sysconfig->sconfig, &addr, addrport, + addrport, if_name); if (status != ARES_SUCCESS) { return status; } @@ -365,5 +371,13 @@ ares_status_t ares__init_sysconfig_macos(ares_sysconfig_t *sysconfig) return status; } +# if defined(__clang__) +# pragma GCC diagnostic pop +# endif + +#else + +/* Prevent compiler warnings due to empty translation unit */ +typedef int make_iso_compilers_happy; #endif diff --git a/lib/c-ares-1.31.0/src/lib/ares_sysconfig.c b/lib/c-ares-1.32.0/src/lib/ares_sysconfig_win.c similarity index 59% rename from lib/c-ares-1.31.0/src/lib/ares_sysconfig.c rename to lib/c-ares-1.32.0/src/lib/ares_sysconfig_win.c index 32f8b7f8ba1..5ca7ccb50cf 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_sysconfig.c +++ b/lib/c-ares-1.32.0/src/lib/ares_sysconfig_win.c @@ -25,7 +25,7 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_SYS_PARAM_H # include @@ -43,20 +43,6 @@ # include #endif -#include "ares_nameser.h" - -#if defined(ANDROID) || defined(__ANDROID__) -# include -# include "ares_android.h" -/* From the Bionic sources */ -# define DNS_PROP_NAME_PREFIX "net.dns" -# define MAX_DNS_PROPERTIES 8 -#endif - -#if defined(CARES_USE_LIBRESOLV) -# include -#endif - #if defined(USE_WINSOCK) # if defined(HAVE_IPHLPAPI_H) # include @@ -66,10 +52,8 @@ # endif #endif -#include "ares.h" #include "ares_inet_net_pton.h" #include "ares_platform.h" -#include "ares_private.h" #if defined(USE_WINSOCK) /* @@ -604,7 +588,7 @@ static ares_bool_t get_SuffixList_Windows(char **outptr) return *outptr != NULL ? ARES_TRUE : ARES_FALSE; } -static ares_status_t ares__init_sysconfig_windows(ares_sysconfig_t *sysconfig) +ares_status_t ares__init_sysconfig_windows(ares_sysconfig_t *sysconfig) { char *line = NULL; ares_status_t status = ARES_SUCCESS; @@ -632,485 +616,3 @@ static ares_status_t ares__init_sysconfig_windows(ares_sysconfig_t *sysconfig) return status; } #endif - -#if defined(__MVS__) -static ares_status_t ares__init_sysconfig_mvs(ares_sysconfig_t *sysconfig) -{ - struct __res_state *res = 0; - size_t count4; - size_t count6; - int i; - __STATEEXTIPV6 *v6; - arse__llist_t *sconfig = NULL; - ares_status_t status; - - if (0 == res) { - int rc = res_init(); - while (rc == -1 && h_errno == TRY_AGAIN) { - rc = res_init(); - } - if (rc == -1) { - return ARES_ENOMEM; - } - res = __res(); - } - - v6 = res->__res_extIPv6; - if (res->nscount > 0) { - count4 = (size_t)res->nscount; - } - - if (v6 && v6->__stat_nscount > 0) { - count6 = (size_t)v6->__stat_nscount; - } else { - count6 = 0; - } - - for (i = 0; i < count4; i++) { - struct sockaddr_in *addr_in = &(res->nsaddr_list[i]); - struct ares_addr addr; - - addr.addr.addr4.s_addr = addr_in->sin_addr.s_addr; - addr.family = AF_INET; - - status = - ares__sconfig_append(&sysconfig->sconfig, &addr, htons(addr_in->sin_port), - htons(addr_in->sin_port), NULL); - - if (status != ARES_SUCCESS) { - return status; - } - } - - for (i = 0; i < count6; i++) { - struct sockaddr_in6 *addr_in = &(v6->__stat_nsaddr_list[i]); - struct ares_addr addr; - - addr.family = AF_INET6; - memcpy(&(addr.addr.addr6), &(addr_in->sin6_addr), - sizeof(addr_in->sin6_addr)); - - status = - ares__sconfig_append(&sysconfig->sconfig, &addr, htons(addr_in->sin_port), - htons(addr_in->sin_port), NULL); - - if (status != ARES_SUCCESS) { - return status; - } - } - - return ARES_SUCCESS; -} -#endif - -#if defined(__riscos__) -static ares_status_t ares__init_sysconfig_riscos(ares_sysconfig_t *sysconfig) -{ - char *line; - ares_status_t status = ARES_SUCCESS; - - /* Under RISC OS, name servers are listed in the - system variable Inet$Resolvers, space separated. */ - line = getenv("Inet$Resolvers"); - if (line) { - char *resolvers = ares_strdup(line); - char *pos; - char *space; - - if (!resolvers) { - return ARES_ENOMEM; - } - - pos = resolvers; - do { - space = strchr(pos, ' '); - if (space) { - *space = '\0'; - } - status = - ares__sconfig_append_fromstr(&sysconfig->sconfig, pos, ARES_TRUE); - if (status != ARES_SUCCESS) { - break; - } - pos = space + 1; - } while (space); - - ares_free(resolvers); - } - - return status; -} -#endif - -#if defined(WATT32) -static ares_status_t ares__init_sysconfig_watt32(ares_sysconfig_t *sysconfig) -{ - size_t i; - ares_status_t status; - - sock_init(); - - for (i = 0; def_nameservers[i]; i++) { - struct ares_addr addr; - - addr.family = AF_INET; - addr.addr.addr4.s_addr = htonl(def_nameservers[i]); - - status = ares__sconfig_append(&sysconfig->sconfig, &addr, 0, 0, NULL); - - if (status != ARES_SUCCESS) { - return status; - } - } - - return ARES_SUCCESS; -} -#endif - -#if defined(ANDROID) || defined(__ANDROID__) -static ares_status_t ares__init_sysconfig_android(ares_sysconfig_t *sysconfig) -{ - size_t i; - char **dns_servers; - char *domains; - size_t num_servers; - ares_status_t status = ARES_EFILE; - - /* Use the Android connectivity manager to get a list - * of DNS servers. As of Android 8 (Oreo) net.dns# - * system properties are no longer available. Google claims this - * improves privacy. Apps now need the ACCESS_NETWORK_STATE - * permission and must use the ConnectivityManager which - * is Java only. */ - dns_servers = ares_get_android_server_list(MAX_DNS_PROPERTIES, &num_servers); - if (dns_servers != NULL) { - for (i = 0; i < num_servers; i++) { - status = ares__sconfig_append_fromstr(&sysconfig->sconfig, dns_servers[i], - ARES_TRUE); - if (status != ARES_SUCCESS) { - return status; - } - } - for (i = 0; i < num_servers; i++) { - ares_free(dns_servers[i]); - } - ares_free(dns_servers); - } - - domains = ares_get_android_search_domains_list(); - sysconfig->domains = ares__strsplit(domains, ", ", &sysconfig->ndomains); - ares_free(domains); - -# ifdef HAVE___SYSTEM_PROPERTY_GET - /* Old way using the system property still in place as - * a fallback. Older android versions can still use this. - * it's possible for older apps not not have added the new - * permission and we want to try to avoid breaking those. - * - * We'll only run this if we don't have any dns servers - * because this will get the same ones (if it works). */ - if (sysconfig->sconfig == NULL) { - char propname[PROP_NAME_MAX]; - char propvalue[PROP_VALUE_MAX] = ""; - for (i = 1; i <= MAX_DNS_PROPERTIES; i++) { - snprintf(propname, sizeof(propname), "%s%u", DNS_PROP_NAME_PREFIX, i); - if (__system_property_get(propname, propvalue) < 1) { - break; - } - status = - ares__sconfig_append_fromstr(&sysconfig->sconfig, propvalue, ARES_TRUE); - if (status != ARES_SUCCESS) { - return status; - } - } - } -# endif /* HAVE___SYSTEM_PROPERTY_GET */ - - return status; -} -#endif - -#if defined(CARES_USE_LIBRESOLV) -static ares_status_t ares__init_sysconfig_libresolv(ares_sysconfig_t *sysconfig) -{ - struct __res_state res; - ares_status_t status = ARES_SUCCESS; - union res_sockaddr_union addr[MAXNS]; - int nscount; - size_t i; - size_t entries = 0; - ares__buf_t *ipbuf = NULL; - - memset(&res, 0, sizeof(res)); - - if (res_ninit(&res) != 0 || !(res.options & RES_INIT)) { - return ARES_EFILE; - } - - nscount = res_getservers(&res, addr, MAXNS); - - for (i = 0; i < (size_t)nscount; ++i) { - char ipaddr[INET6_ADDRSTRLEN] = ""; - char *ipstr = NULL; - unsigned short port = 0; - unsigned int ll_scope = 0; - - sa_family_t family = addr[i].sin.sin_family; - if (family == AF_INET) { - ares_inet_ntop(family, &addr[i].sin.sin_addr, ipaddr, sizeof(ipaddr)); - port = ntohs(addr[i].sin.sin_port); - } else if (family == AF_INET6) { - ares_inet_ntop(family, &addr[i].sin6.sin6_addr, ipaddr, sizeof(ipaddr)); - port = ntohs(addr[i].sin6.sin6_port); - ll_scope = addr[i].sin6.sin6_scope_id; - } else { - continue; - } - - - /* [ip]:port%iface */ - ipbuf = ares__buf_create(); - if (ipbuf == NULL) { - status = ARES_ENOMEM; - goto done; - } - - status = ares__buf_append_str(ipbuf, "["); - if (status != ARES_SUCCESS) { - goto done; - } - - status = ares__buf_append_str(ipbuf, ipaddr); - if (status != ARES_SUCCESS) { - goto done; - } - - status = ares__buf_append_str(ipbuf, "]"); - if (status != ARES_SUCCESS) { - goto done; - } - - if (port) { - status = ares__buf_append_str(ipbuf, ":"); - if (status != ARES_SUCCESS) { - goto done; - } - status = ares__buf_append_num_dec(ipbuf, port, 0); - if (status != ARES_SUCCESS) { - goto done; - } - } - - if (ll_scope) { - status = ares__buf_append_str(ipbuf, "%"); - if (status != ARES_SUCCESS) { - goto done; - } - status = ares__buf_append_num_dec(ipbuf, ll_scope, 0); - if (status != ARES_SUCCESS) { - goto done; - } - } - - ipstr = ares__buf_finish_str(ipbuf, NULL); - ipbuf = NULL; - if (ipstr == NULL) { - status = ARES_ENOMEM; - goto done; - } - - status = - ares__sconfig_append_fromstr(&sysconfig->sconfig, ipstr, ARES_TRUE); - - ares_free(ipstr); - if (status != ARES_SUCCESS) { - goto done; - } - } - - while ((entries < MAXDNSRCH) && res.dnsrch[entries]) { - entries++; - } - - if (entries) { - sysconfig->domains = ares_malloc_zero(entries * sizeof(char *)); - if (sysconfig->domains == NULL) { - status = ARES_ENOMEM; - goto done; - } else { - sysconfig->ndomains = entries; - for (i = 0; i < sysconfig->ndomains; i++) { - sysconfig->domains[i] = ares_strdup(res.dnsrch[i]); - if (sysconfig->domains[i] == NULL) { - status = ARES_ENOMEM; - goto done; - } - } - } - } - - if (res.ndots >= 0) { - sysconfig->ndots = (size_t)res.ndots; - } -/* Apple does not allow configuration of retry, so this is a static dummy - * value, ignore */ -# ifndef __APPLE__ - if (res.retry > 0) { - sysconfig->tries = (size_t)res.retry; - } -# endif - if (res.options & RES_ROTATE) { - sysconfig->rotate = ARES_TRUE; - } - - if (res.retrans > 0) { -/* Apple does not allow configuration of retrans, so this is a dummy value - * that is extremely high (5s) */ -# ifndef __APPLE__ - if (res.retrans > 0) { - sysconfig->timeout_ms = (unsigned int)res.retrans * 1000; - } -# endif - } - -done: - ares__buf_destroy(ipbuf); - res_ndestroy(&res); - return status; -} -#endif - -static void ares_sysconfig_free(ares_sysconfig_t *sysconfig) -{ - ares__llist_destroy(sysconfig->sconfig); - ares__strsplit_free(sysconfig->domains, sysconfig->ndomains); - ares_free(sysconfig->sortlist); - ares_free(sysconfig->lookups); - memset(sysconfig, 0, sizeof(*sysconfig)); -} - -static ares_status_t ares_sysconfig_apply(ares_channel_t *channel, - const ares_sysconfig_t *sysconfig) -{ - ares_status_t status; - - if (sysconfig->sconfig && !(channel->optmask & ARES_OPT_SERVERS)) { - status = ares__servers_update(channel, sysconfig->sconfig, ARES_FALSE); - if (status != ARES_SUCCESS) { - return status; - } - } - - if (sysconfig->domains && !(channel->optmask & ARES_OPT_DOMAINS)) { - /* Make sure we duplicate first then replace so even if there is - * ARES_ENOMEM, the channel stays in a good state */ - char **temp = - ares__strsplit_duplicate(sysconfig->domains, sysconfig->ndomains); - if (temp == NULL) { - return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - } - - ares__strsplit_free(channel->domains, channel->ndomains); - channel->domains = temp; - channel->ndomains = sysconfig->ndomains; - } - - if (sysconfig->lookups && !(channel->optmask & ARES_OPT_LOOKUPS)) { - char *temp = ares_strdup(sysconfig->lookups); - if (temp == NULL) { - return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - } - - ares_free(channel->lookups); - channel->lookups = temp; - } - - if (sysconfig->sortlist && !(channel->optmask & ARES_OPT_SORTLIST)) { - struct apattern *temp = - ares_malloc(sizeof(*channel->sortlist) * sysconfig->nsortlist); - if (temp == NULL) { - return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - } - memcpy(temp, sysconfig->sortlist, - sizeof(*channel->sortlist) * sysconfig->nsortlist); - - ares_free(channel->sortlist); - channel->sortlist = temp; - channel->nsort = sysconfig->nsortlist; - } - - if (!(channel->optmask & ARES_OPT_NDOTS)) { - channel->ndots = sysconfig->ndots; - } - - if (sysconfig->tries && !(channel->optmask & ARES_OPT_TRIES)) { - channel->tries = sysconfig->tries; - } - - if (sysconfig->timeout_ms && !(channel->optmask & ARES_OPT_TIMEOUTMS)) { - channel->timeout = sysconfig->timeout_ms; - } - - if (!(channel->optmask & (ARES_OPT_ROTATE | ARES_OPT_NOROTATE))) { - channel->rotate = sysconfig->rotate; - } - - if (sysconfig->usevc) { - channel->flags |= ARES_FLAG_USEVC; - } - - return ARES_SUCCESS; -} - -ares_status_t ares__init_by_sysconfig(ares_channel_t *channel) -{ - ares_status_t status; - ares_sysconfig_t sysconfig; - - memset(&sysconfig, 0, sizeof(sysconfig)); - -#if defined(USE_WINSOCK) - status = ares__init_sysconfig_windows(&sysconfig); -#elif defined(__MVS__) - status = ares__init_sysconfig_mvs(&sysconfig); -#elif defined(__riscos__) - status = ares__init_sysconfig_riscos(&sysconfig); -#elif defined(WATT32) - status = ares__init_sysconfig_watt32(&sysconfig); -#elif defined(ANDROID) || defined(__ANDROID__) - status = ares__init_sysconfig_android(&sysconfig); -#elif defined(__APPLE__) - status = ares__init_sysconfig_macos(&sysconfig); -#elif defined(CARES_USE_LIBRESOLV) - status = ares__init_sysconfig_libresolv(&sysconfig); -#else - status = ares__init_sysconfig_files(channel, &sysconfig); -#endif - - if (status != ARES_SUCCESS) { - goto done; - } - - /* Environment is supposed to override sysconfig */ - status = ares__init_by_environment(&sysconfig); - if (status != ARES_SUCCESS) { - goto done; - } - - /* Lock when applying the configuration to the channel. Don't need to - * lock prior to this. */ - - ares__channel_lock(channel); - - status = ares_sysconfig_apply(channel, &sysconfig); - ares__channel_unlock(channel); - - if (status != ARES_SUCCESS) { - goto done; - } - -done: - ares_sysconfig_free(&sysconfig); - - return status; -} diff --git a/lib/c-ares-1.31.0/src/lib/ares_timeout.c b/lib/c-ares-1.32.0/src/lib/ares_timeout.c similarity index 68% rename from lib/c-ares-1.31.0/src/lib/ares_timeout.c rename to lib/c-ares-1.32.0/src/lib/ares_timeout.c index 3acc66a87fe..dac439b1b43 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_timeout.c +++ b/lib/c-ares-1.32.0/src/lib/ares_timeout.c @@ -25,14 +25,12 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_LIMITS_H # include #endif -#include "ares.h" -#include "ares_private.h" void ares__timeval_remaining(ares_timeval_t *remaining, const ares_timeval_t *now, @@ -55,28 +53,38 @@ void ares__timeval_remaining(ares_timeval_t *remaining, } } -static struct timeval ares_timeval_to_struct_timeval(const ares_timeval_t *atv) +void ares__timeval_diff(ares_timeval_t *tvdiff, const ares_timeval_t *tvstart, + const ares_timeval_t *tvstop) { - struct timeval tv; - - tv.tv_sec = (time_t)atv->sec; - tv.tv_usec = (int)atv->usec; - - return tv; + tvdiff->sec = tvstop->sec - tvstart->sec; + if (tvstop->usec > tvstart->usec) { + tvdiff->usec = tvstop->usec - tvstart->usec; + } else { + tvdiff->sec -= 1; + tvdiff->usec = tvstop->usec + 1000000 - tvstart->usec; + } } -static ares_timeval_t struct_timeval_to_ares_timeval(const struct timeval *tv) +static void ares_timeval_to_struct_timeval(struct timeval *tv, const ares_timeval_t *atv) { - ares_timeval_t atv; +#ifdef USE_WINSOCK + tv->tv_sec = (long)atv->sec; +#else + tv->tv_sec = (time_t)atv->sec; +#endif - atv.sec = (ares_int64_t)tv->tv_sec; - atv.usec = (unsigned int)tv->tv_usec; + tv->tv_usec = (int)atv->usec; +} - return atv; +static void struct_timeval_to_ares_timeval(ares_timeval_t *atv, const struct timeval *tv) +{ + atv->sec = (ares_int64_t)tv->tv_sec; + atv->usec = (unsigned int)tv->tv_usec; } -struct timeval *ares_timeout(const ares_channel_t *channel, - struct timeval *maxtv, struct timeval *tvbuf) +static struct timeval *ares_timeout_int(const ares_channel_t *channel, + struct timeval *maxtv, + struct timeval *tvbuf) { const struct query *query; ares__slist_node_t *node; @@ -94,18 +102,18 @@ struct timeval *ares_timeout(const ares_channel_t *channel, query = ares__slist_node_val(node); - now = ares__tvnow(); + ares__tvnow(&now); ares__timeval_remaining(&atvbuf, &now, &query->timeout); - *tvbuf = ares_timeval_to_struct_timeval(&atvbuf); + ares_timeval_to_struct_timeval(tvbuf, &atvbuf); if (maxtv == NULL) { return tvbuf; } /* Return the minimum time between maxtv and tvbuf */ - amaxtv = struct_timeval_to_ares_timeval(maxtv); + struct_timeval_to_ares_timeval(&amaxtv, maxtv); if (atvbuf.sec > amaxtv.sec) { return maxtv; @@ -121,3 +129,20 @@ struct timeval *ares_timeout(const ares_channel_t *channel, return tvbuf; } + +struct timeval *ares_timeout(const ares_channel_t *channel, + struct timeval *maxtv, struct timeval *tvbuf) +{ + struct timeval *rv; + + if (channel == NULL || tvbuf == NULL) + return NULL; + + ares__channel_lock(channel); + + rv = ares_timeout_int(channel, maxtv, tvbuf); + + ares__channel_unlock(channel); + + return rv; +} diff --git a/lib/c-ares-1.31.0/src/lib/ares_update_servers.c b/lib/c-ares-1.32.0/src/lib/ares_update_servers.c similarity index 97% rename from lib/c-ares-1.31.0/src/lib/ares_update_servers.c rename to lib/c-ares-1.32.0/src/lib/ares_update_servers.c index 77ed7dd2503..455e3001d5c 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_update_servers.c +++ b/lib/c-ares-1.32.0/src/lib/ares_update_servers.c @@ -25,7 +25,7 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_ARPA_INET_H # include @@ -49,10 +49,8 @@ # endif #endif -#include "ares.h" #include "ares_data.h" #include "ares_inet_net_pton.h" -#include "ares_private.h" typedef struct { struct ares_addr addr; @@ -397,7 +395,7 @@ ares_status_t ares__sconfig_append(ares__llist_t **sconfig, *sconfig = ares__llist_create(ares_free); if (*sconfig == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -423,7 +421,7 @@ ares_status_t ares__sconfig_append(ares__llist_t **sconfig, if (ares__llist_insert_last(*sconfig, s) == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } return ARES_SUCCESS; @@ -613,24 +611,24 @@ static ares_status_t ares__server_create(ares_channel_t *channel, server->tcp_parser = ares__buf_create(); if (server->tcp_parser == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } server->tcp_send = ares__buf_create(); if (server->tcp_send == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } server->connections = ares__llist_create(NULL); if (server->connections == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } if (ares__slist_insert(channel->servers, server) == NULL) { status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ - goto done; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ARES_SUCCESS; @@ -711,8 +709,6 @@ ares_status_t ares__servers_update(ares_channel_t *channel, return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } - ares__channel_lock(channel); - /* NOTE: a NULL or zero entry server list is considered valid due to * real-world people needing support for this for their test harnesses */ @@ -781,7 +777,6 @@ ares_status_t ares__servers_update(ares_channel_t *channel, status = ARES_SUCCESS; done: - ares__channel_unlock(channel); return status; } @@ -823,7 +818,7 @@ static ares_status_t if (ares__llist_insert_last(s, sconfig) == NULL) { ares_free(sconfig); /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -834,7 +829,7 @@ static ares_status_t fail: ares__llist_destroy(s); return ARES_ENOMEM; -/* LCOV_EXCL_STOP */ + /* LCOV_EXCL_STOP */ } static ares_status_t ares_addr_port_node_to_server_config_llist( @@ -877,7 +872,7 @@ static ares_status_t ares_addr_port_node_to_server_config_llist( if (ares__llist_insert_last(s, sconfig) == NULL) { ares_free(sconfig); /* LCOV_EXCL_LINE: OutOfMemory */ - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -888,7 +883,7 @@ static ares_status_t ares_addr_port_node_to_server_config_llist( fail: ares__llist_destroy(s); return ARES_ENOMEM; -/* LCOV_EXCL_STOP */ + /* LCOV_EXCL_STOP */ } ares_status_t ares_in_addr_to_server_config_llist(const struct in_addr *servers, @@ -929,7 +924,7 @@ ares_status_t ares_in_addr_to_server_config_llist(const struct in_addr *servers, fail: ares__llist_destroy(s); return ARES_ENOMEM; -/* LCOV_EXCL_STOP */ + /* LCOV_EXCL_STOP */ } /* Write out the details of a server to a buffer */ @@ -1115,8 +1110,9 @@ int ares_set_servers(ares_channel_t *channel, return (int)status; } - /* NOTE: lock is in ares__servers_update() */ + ares__channel_lock(channel); status = ares__servers_update(channel, slist, ARES_TRUE); + ares__channel_unlock(channel); ares__llist_destroy(slist); @@ -1138,8 +1134,9 @@ int ares_set_servers_ports(ares_channel_t *channel, return (int)status; } - /* NOTE: lock is in ares__servers_update() */ + ares__channel_lock(channel); status = ares__servers_update(channel, slist, ARES_TRUE); + ares__channel_unlock(channel); ares__llist_destroy(slist); @@ -1157,11 +1154,12 @@ static ares_status_t set_servers_csv(ares_channel_t *channel, const char *_csv) return ARES_ENODATA; } - /* NOTE: lock is in ares__servers_update() */ - if (ares_strlen(_csv) == 0) { /* blank all servers */ - return ares__servers_update(channel, NULL, ARES_TRUE); + ares__channel_lock(channel); + status = ares__servers_update(channel, NULL, ARES_TRUE); + ares__channel_unlock(channel); + return status; } status = ares__sconfig_append_fromstr(&slist, _csv, ARES_FALSE); @@ -1170,8 +1168,9 @@ static ares_status_t set_servers_csv(ares_channel_t *channel, const char *_csv) return status; } - /* NOTE: lock is in ares__servers_update() */ + ares__channel_lock(channel); status = ares__servers_update(channel, slist, ARES_TRUE); + ares__channel_unlock(channel); ares__llist_destroy(slist); @@ -1181,13 +1180,11 @@ static ares_status_t set_servers_csv(ares_channel_t *channel, const char *_csv) /* We'll go ahead and honor ports anyhow */ int ares_set_servers_csv(ares_channel_t *channel, const char *_csv) { - /* NOTE: lock is in ares__servers_update() */ return (int)set_servers_csv(channel, _csv); } int ares_set_servers_ports_csv(ares_channel_t *channel, const char *_csv) { - /* NOTE: lock is in ares__servers_update() */ return (int)set_servers_csv(channel, _csv); } diff --git a/lib/c-ares-1.31.0/src/lib/ares_version.c b/lib/c-ares-1.32.0/src/lib/ares_version.c similarity index 97% rename from lib/c-ares-1.31.0/src/lib/ares_version.c rename to lib/c-ares-1.32.0/src/lib/ares_version.c index ca15fa77dcf..f50f65b0d61 100644 --- a/lib/c-ares-1.31.0/src/lib/ares_version.c +++ b/lib/c-ares-1.32.0/src/lib/ares_version.c @@ -24,8 +24,7 @@ * * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" -#include "ares.h" +#include "ares_private.h" const char *ares_version(int *version) { diff --git a/lib/c-ares-1.31.0/src/lib/cares.rc b/lib/c-ares-1.32.0/src/lib/cares.rc similarity index 100% rename from lib/c-ares-1.31.0/src/lib/cares.rc rename to lib/c-ares-1.32.0/src/lib/cares.rc diff --git a/lib/c-ares-1.31.0/src/lib/config-dos.h b/lib/c-ares-1.32.0/src/lib/config-dos.h similarity index 63% rename from lib/c-ares-1.31.0/src/lib/config-dos.h rename to lib/c-ares-1.32.0/src/lib/config-dos.h index 6d99bd681c4..db758fcca66 100644 --- a/lib/c-ares-1.31.0/src/lib/config-dos.h +++ b/lib/c-ares-1.32.0/src/lib/config-dos.h @@ -32,14 +32,13 @@ #define HAVE_TIME_H 1 #define HAVE_UNISTD_H 1 #define HAVE_WRITEV 1 - -#define NEED_MALLOC_H 1 +#define HAVE_STAT 1 +#define HAVE_MALLOC_H 1 /* Qualifiers for send(), recv(), recvfrom() and getnameinfo(). */ #define SEND_TYPE_ARG1 int -#define SEND_QUAL_ARG2 const -#define SEND_TYPE_ARG2 void * +#define SEND_TYPE_ARG2 const void * #define SEND_TYPE_ARG3 int #define SEND_TYPE_ARG4 int #define SEND_TYPE_RETV int @@ -73,7 +72,7 @@ # define HAVE_VARIADIC_MACROS_GCC 1 /* Because djgpp <= 2.03 doesn't have snprintf() etc. */ -# if (DJGPP_MINOR < 4) +# if defined(DJGPP_MINOR) && DJGPP_MINOR < 4 # define _MPRINTF_REPLACE # endif @@ -85,30 +84,30 @@ # define strerror(e) strerror_s_((e)) #endif +/* This seems odd, can DOS build without WATT32? */ #ifdef WATT32 -# define HAVE_AF_INET6 1 -# define HAVE_ARPA_INET_H 1 -# define HAVE_ARPA_NAMESER_H 1 -# define HAVE_CLOSE_S 1 -# define HAVE_GETHOSTNAME 1 -# define HAVE_NETDB_H 1 -# define HAVE_NETINET_IN_H 1 -# define HAVE_NETINET_TCP_H 1 -# define HAVE_PF_INET6 1 -# define HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1 -# define HAVE_STRUCT_ADDRINFO 1 -# define HAVE_STRUCT_IN6_ADDR 1 -# define HAVE_STRUCT_SOCKADDR_IN6 1 -# define HAVE_SYS_SOCKET_H 1 -# define HAVE_SYS_UIO_H 1 -# define NS_INADDRSZ 4 -# define HAVE_STRUCT_SOCKADDR_IN6 1 - -# define HAVE_GETSERVBYPORT_R 1 -# define GETSERVBYPORT_R_ARGS 5 +# define HAVE_AF_INET6 1 +# define HAVE_ARPA_INET_H 1 +# define HAVE_ARPA_NAMESER_H 1 +# define HAVE_CLOSE_S 1 +# define HAVE_GETHOSTNAME 1 +# define HAVE_NETDB_H 1 +# define HAVE_NETINET_IN_H 1 +# define HAVE_NETINET_TCP_H 1 +# define HAVE_PF_INET6 1 +# define HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID 1 +# define HAVE_STRUCT_ADDRINFO 1 +# define HAVE_STRUCT_IN6_ADDR 1 +# define HAVE_STRUCT_SOCKADDR_IN6 1 +# define HAVE_SYS_SOCKET_H 1 +# define HAVE_SYS_IOCTL_H 1 +# define HAVE_SYS_UIO_H 1 +# define NS_INADDRSZ 4 +# define HAVE_GETSERVBYPORT_R 1 +# define GETSERVBYPORT_R_ARGS 6 +# define HAVE_WRITEV 1 +# define HAVE_IF_NAMETOINDEX 1 +# define HAVE_IF_INDEXTONAME 1 #endif -#undef word -#undef byte - #endif /* HEADER_CONFIG_DOS_H */ diff --git a/lib/c-ares-1.31.0/src/lib/config-win32.h b/lib/c-ares-1.32.0/src/lib/config-win32.h similarity index 97% rename from lib/c-ares-1.31.0/src/lib/config-win32.h rename to lib/c-ares-1.32.0/src/lib/config-win32.h index a55cf9e2dbb..da5c7483879 100644 --- a/lib/c-ares-1.31.0/src/lib/config-win32.h +++ b/lib/c-ares-1.32.0/src/lib/config-win32.h @@ -190,11 +190,8 @@ /* Define to the type of arg 1 for send. */ #define SEND_TYPE_ARG1 SOCKET -/* Define to the type qualifier of arg 2 for send. */ -#define SEND_QUAL_ARG2 const - /* Define to the type of arg 2 for send. */ -#define SEND_TYPE_ARG2 char * +#define SEND_TYPE_ARG2 const char * /* Define to the type of arg 3 for send. */ #define SEND_TYPE_ARG3 int @@ -212,19 +209,24 @@ # undef SEND_TYPE_ARG1 # define SEND_TYPE_ARG1 int # undef RECVFROM_TYPE_ARG1 -# define RECVFROM_TYPE_ARG1 int +# define RECVFROM_TYPE_ARG1 int # define NS_INADDRSZ 4 # define HAVE_ARPA_NAMESER_H 1 # define HAVE_ARPA_INET_H 1 # define HAVE_NETDB_H 1 # define HAVE_NETINET_IN_H 1 # define HAVE_SYS_SOCKET_H 1 +# define HAVE_SYS_IOCTL_H 1 # define HAVE_NETINET_TCP_H 1 # define HAVE_AF_INET6 1 # define HAVE_PF_INET6 1 # define HAVE_STRUCT_IN6_ADDR 1 # define HAVE_STRUCT_SOCKADDR_IN6 1 # define HAVE_WRITEV 1 +# define HAVE_IF_NAMETOINDEX 1 +# define HAVE_IF_INDEXTONAME 1 +# define HAVE_GETSERVBYPORT_R 1 +# define GETSERVBYPORT_R_ARGS 6 # undef HAVE_WINSOCK_H # undef HAVE_WINSOCK2_H # undef HAVE_WS2TCPIP_H @@ -351,7 +353,7 @@ #endif #if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0600) && \ - !defined(__WATCOMC__) && !defined(WATT32) + !defined(__WATCOMC__) && !defined(WATT32) /* Define if you have if_nametoindex() */ # define HAVE_IF_NAMETOINDEX 1 /* Define if you have if_indextoname() */ diff --git a/lib/c-ares-1.31.0/src/lib/inet_net_pton.c b/lib/c-ares-1.32.0/src/lib/inet_net_pton.c similarity index 97% rename from lib/c-ares-1.31.0/src/lib/inet_net_pton.c rename to lib/c-ares-1.32.0/src/lib/inet_net_pton.c index 19429f205d8..935058da9ce 100644 --- a/lib/c-ares-1.31.0/src/lib/inet_net_pton.c +++ b/lib/c-ares-1.32.0/src/lib/inet_net_pton.c @@ -18,7 +18,7 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_NETINET_IN_H # include @@ -29,11 +29,13 @@ #include "ares_nameser.h" -#include "ares.h" #include "ares_ipv6.h" #include "ares_inet_net_pton.h" -#include "ares_private.h" +#define ISDIGIT(x) (isdigit((int)((unsigned char)x))) +#define ISXDIGIT(x) (isxdigit((int)((unsigned char)x))) +#define ISASCII(x) (((unsigned char)x) <= 127 ? 1 : 0) +#define ISUPPER(x) (isupper((int)((unsigned char)x))) const struct ares_in6_addr ares_in6addr_any = { { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } }; @@ -82,7 +84,7 @@ static int ares_inet_net_pton_ipv4(const char *src, unsigned char *dst, src++; /* skip x or X. */ while ((ch = *src++) != '\0' && ISASCII(ch) && ISXDIGIT(ch)) { if (ISUPPER(ch)) { - ch = tolower(ch); + ch = ares__tolower((unsigned char)ch); } n = (int)(strchr(xdigits, ch) - xdigits); if (dirty == 0) { diff --git a/lib/c-ares-1.31.0/src/lib/inet_ntop.c b/lib/c-ares-1.32.0/src/lib/inet_ntop.c similarity index 86% rename from lib/c-ares-1.31.0/src/lib/inet_ntop.c rename to lib/c-ares-1.32.0/src/lib/inet_ntop.c index 622befa9958..8dee8d69da7 100644 --- a/lib/c-ares-1.31.0/src/lib/inet_ntop.c +++ b/lib/c-ares-1.32.0/src/lib/inet_ntop.c @@ -17,7 +17,7 @@ * SPDX-License-Identifier: MIT */ -#include "ares_setup.h" +#include "ares_private.h" #ifdef HAVE_NETINET_IN_H # include @@ -27,12 +27,7 @@ #endif #include "ares_nameser.h" - -#include "ares.h" #include "ares_ipv6.h" -#include "ares_private.h" - -#ifndef HAVE_INET_NTOP /* * WARNING: Don't even consider trying to compile this on a system where @@ -60,14 +55,14 @@ const char *ares_inet_ntop(int af, const void *src, char *dst, { switch (af) { case AF_INET: - return (inet_ntop4(src, dst, (size_t)size)); + return inet_ntop4(src, dst, (size_t)size); case AF_INET6: - return (inet_ntop6(src, dst, (size_t)size)); + return inet_ntop6(src, dst, (size_t)size); default: - SET_ERRNO(EAFNOSUPPORT); - return (NULL); + break; } - /* NOTREACHED */ + SET_ERRNO(EAFNOSUPPORT); + return NULL; } /* const char * @@ -86,13 +81,18 @@ static const char *inet_ntop4(const unsigned char *src, char *dst, size_t size) static const char fmt[] = "%u.%u.%u.%u"; char tmp[sizeof("255.255.255.255")]; + if (size < sizeof(tmp)) { + SET_ERRNO(ENOSPC); + return NULL; + } + if ((size_t)snprintf(tmp, sizeof(tmp), fmt, src[0], src[1], src[2], src[3]) >= size) { SET_ERRNO(ENOSPC); - return (NULL); + return NULL; } ares_strcpy(dst, tmp, size); - return (dst); + return dst; } /* const char * @@ -114,11 +114,12 @@ static const char *inet_ntop6(const unsigned char *src, char *dst, size_t size) char *tp; struct { - int base, len; + ares_ssize_t base; + size_t len; } best, cur; unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ]; - int i; + size_t i; /* * Preprocess: @@ -136,7 +137,8 @@ static const char *inet_ntop6(const unsigned char *src, char *dst, size_t size) for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) { if (words[i] == 0) { if (cur.base == -1) { - cur.base = i, cur.len = 1; + cur.base = (ares_ssize_t)i; + cur.len = 1; } else { cur.len++; } @@ -164,8 +166,8 @@ static const char *inet_ntop6(const unsigned char *src, char *dst, size_t size) tp = tmp; for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) { /* Are we inside the best run of 0x00's? */ - if (best.base != -1 && i >= best.base && i < (best.base + best.len)) { - if (i == best.base) { + if (best.base != -1 && i >= (size_t)best.base && i < ((size_t)best.base + best.len)) { + if (i == (size_t)best.base) { *tp++ = ':'; } continue; @@ -188,7 +190,7 @@ static const char *inet_ntop6(const unsigned char *src, char *dst, size_t size) } /* Was it a trailing run of 0x00's? */ if (best.base != -1 && - (best.base + best.len) == (NS_IN6ADDRSZ / NS_INT16SZ)) { + ((size_t)best.base + best.len) == (NS_IN6ADDRSZ / NS_INT16SZ)) { *tp++ = ':'; } *tp++ = '\0'; @@ -198,19 +200,9 @@ static const char *inet_ntop6(const unsigned char *src, char *dst, size_t size) */ if ((size_t)(tp - tmp) > size) { SET_ERRNO(ENOSPC); - return (NULL); + return NULL; } ares_strcpy(dst, tmp, size); - return (dst); -} - -#else /* HAVE_INET_NTOP */ - -const char *ares_inet_ntop(int af, const void *src, char *dst, - ares_socklen_t size) -{ - /* just relay this to the underlying function */ - return inet_ntop(af, src, dst, size); + return dst; } -#endif /* HAVE_INET_NTOP */ diff --git a/lib/c-ares-1.31.0/src/lib/thirdparty/apple/dnsinfo.h b/lib/c-ares-1.32.0/src/lib/thirdparty/apple/dnsinfo.h similarity index 100% rename from lib/c-ares-1.31.0/src/lib/thirdparty/apple/dnsinfo.h rename to lib/c-ares-1.32.0/src/lib/thirdparty/apple/dnsinfo.h diff --git a/lib/c-ares-1.31.0/src/lib/windows_port.c b/lib/c-ares-1.32.0/src/lib/windows_port.c similarity index 95% rename from lib/c-ares-1.31.0/src/lib/windows_port.c rename to lib/c-ares-1.32.0/src/lib/windows_port.c index 5395f203601..22f0dc020a0 100644 --- a/lib/c-ares-1.31.0/src/lib/windows_port.c +++ b/lib/c-ares-1.32.0/src/lib/windows_port.c @@ -6,7 +6,7 @@ * SPDX-License-Identifier: MIT * */ -#include "ares_setup.h" +#include "ares_private.h" /* only do the following on windows diff --git a/lib/c-ares-1.31.0/src/tools/CMakeLists.txt b/lib/c-ares-1.32.0/src/tools/CMakeLists.txt similarity index 100% rename from lib/c-ares-1.31.0/src/tools/CMakeLists.txt rename to lib/c-ares-1.32.0/src/tools/CMakeLists.txt diff --git a/lib/c-ares-1.31.0/src/tools/Makefile.am b/lib/c-ares-1.32.0/src/tools/Makefile.am similarity index 100% rename from lib/c-ares-1.31.0/src/tools/Makefile.am rename to lib/c-ares-1.32.0/src/tools/Makefile.am diff --git a/lib/c-ares-1.31.0/src/tools/Makefile.in b/lib/c-ares-1.32.0/src/tools/Makefile.in similarity index 100% rename from lib/c-ares-1.31.0/src/tools/Makefile.in rename to lib/c-ares-1.32.0/src/tools/Makefile.in diff --git a/lib/c-ares-1.31.0/src/tools/Makefile.inc b/lib/c-ares-1.32.0/src/tools/Makefile.inc similarity index 100% rename from lib/c-ares-1.31.0/src/tools/Makefile.inc rename to lib/c-ares-1.32.0/src/tools/Makefile.inc diff --git a/lib/c-ares-1.31.0/src/tools/adig.c b/lib/c-ares-1.32.0/src/tools/adig.c similarity index 94% rename from lib/c-ares-1.31.0/src/tools/adig.c rename to lib/c-ares-1.32.0/src/tools/adig.c index e0d5c915aa5..026340c72bf 100644 --- a/lib/c-ares-1.31.0/src/tools/adig.c +++ b/lib/c-ares-1.32.0/src/tools/adig.c @@ -84,7 +84,9 @@ static const nv_t configflags[] = { { "igntc", ARES_FLAG_IGNTC }, { "norecurse", ARES_FLAG_NORECURSE }, { "stayopen", ARES_FLAG_STAYOPEN }, - { "noaliases", ARES_FLAG_NOALIASES } + { "noaliases", ARES_FLAG_NOALIASES }, + { "edns", ARES_FLAG_EDNS }, + { "dns0x20", ARES_FLAG_DNS0x20 } }; static const size_t nconfigflags = sizeof(configflags) / sizeof(*configflags); @@ -113,35 +115,48 @@ static void free_config(adig_config_t *config) static void print_help(void) { + /* Split due to maximum c89 string literal of 509 bytes */ printf("adig version %s\n\n", ares_version(NULL)); printf( "usage: adig [-h] [-d] [-f flag] [[-s server] ...] [-T|U port] [-c class]\n" - " [-t type] name ...\n\n" - " -h : Display this help and exit.\n" - " -d : Print some extra debugging output.\n" - " -f flag : Add a behavior control flag. Possible values are\n" + " [-t type] name ...\n\n"); + printf( + " -h : Display this help and exit.\n"); + printf( + " -d : Print some extra debugging output.\n"); + printf( + " -f flag : Add a behavior control flag. May be specified more than once\n" + " to add additional flags. Possible values are:\n" " igntc - do not retry a truncated query as TCP, just\n" " return the truncated answer\n" " noaliases - don't honor the HOSTALIASES environment\n" - " variable\n" + " variable\n"); + printf( " norecurse - don't query upstream servers recursively\n" " primary - use the first server\n" " stayopen - don't close the communication sockets\n" " usevc - use TCP only\n" + " edns - use EDNS\n" + " dns0x20 - enable DNS 0x20 support\n"); + printf( " -s server : Connect to the specified DNS server, instead of the\n" " system's default one(s). Servers are tried in round-robin,\n" - " if the previous one failed.\n" - " -T port : Connect to the specified TCP port of DNS server.\n" - " -U port : Connect to the specified UDP port of DNS server.\n" + " if the previous one failed.\n"); + printf( + " -T port : Connect to the specified TCP port of DNS server.\n"); + printf( + " -U port : Connect to the specified UDP port of DNS server.\n"); + printf( " -c class : Set the query class. Possible values for class are:\n" - " ANY, CHAOS, HS and IN (default)\n" + " ANY, CHAOS, HS and IN (default)\n"); + printf( " -t type : Query records of the specified type. Possible values for\n" " type are:\n" " A (default), AAAA, ANY, CNAME, HINFO, MX, NAPTR, NS, PTR,\n" " SOA, SRV, TXT, TLSA, URI, CAA, SVCB, HTTPS\n\n"); } -static ares_bool_t read_cmdline(int argc, const char **argv, +static ares_bool_t read_cmdline(int argc, const char * const * argv, adig_config_t *config) { ares_getopt_state_t state; @@ -613,6 +628,21 @@ static void print_binp(const ares_dns_rr_t *rr, ares_dns_rr_key_t key) print_opt_binp(binp, len); } +static void print_abinp(const ares_dns_rr_t *rr, ares_dns_rr_key_t key) +{ + size_t i; + size_t cnt = ares_dns_rr_get_abin_cnt(rr, key); + + for (i=0; iopterr = 1; diff --git a/lib/c-ares-1.31.0/src/tools/ares_getopt.h b/lib/c-ares-1.32.0/src/tools/ares_getopt.h similarity index 97% rename from lib/c-ares-1.31.0/src/tools/ares_getopt.h rename to lib/c-ares-1.32.0/src/tools/ares_getopt.h index a14f7ab42d4..7ff1fdeeb28 100644 --- a/lib/c-ares-1.31.0/src/tools/ares_getopt.h +++ b/lib/c-ares-1.32.0/src/tools/ares_getopt.h @@ -40,10 +40,10 @@ typedef struct { int optopt; /* character checked for validity */ const char *place; int argc; - const char **argv; + const char * const *argv; } ares_getopt_state_t; -void ares_getopt_init(ares_getopt_state_t *state, int argc, const char **argv); +void ares_getopt_init(ares_getopt_state_t *state, int argc, const char * const * argv); int ares_getopt(ares_getopt_state_t *state, const char *ostr); #endif /* ARES_GETOPT_H */ diff --git a/lib/c-ares-1.31.0/test/CMakeLists.txt b/lib/c-ares-1.32.0/test/CMakeLists.txt similarity index 100% rename from lib/c-ares-1.31.0/test/CMakeLists.txt rename to lib/c-ares-1.32.0/test/CMakeLists.txt diff --git a/lib/c-ares-1.31.0/test/Makefile.am b/lib/c-ares-1.32.0/test/Makefile.am similarity index 100% rename from lib/c-ares-1.31.0/test/Makefile.am rename to lib/c-ares-1.32.0/test/Makefile.am diff --git a/lib/c-ares-1.31.0/test/Makefile.in b/lib/c-ares-1.32.0/test/Makefile.in similarity index 100% rename from lib/c-ares-1.31.0/test/Makefile.in rename to lib/c-ares-1.32.0/test/Makefile.in diff --git a/lib/c-ares-1.31.0/test/Makefile.inc b/lib/c-ares-1.32.0/test/Makefile.inc similarity index 100% rename from lib/c-ares-1.31.0/test/Makefile.inc rename to lib/c-ares-1.32.0/test/Makefile.inc diff --git a/lib/c-ares-1.31.0/test/Makefile.m32 b/lib/c-ares-1.32.0/test/Makefile.m32 similarity index 100% rename from lib/c-ares-1.31.0/test/Makefile.m32 rename to lib/c-ares-1.32.0/test/Makefile.m32 diff --git a/lib/c-ares-1.31.0/test/Makefile.msvc b/lib/c-ares-1.32.0/test/Makefile.msvc similarity index 100% rename from lib/c-ares-1.31.0/test/Makefile.msvc rename to lib/c-ares-1.32.0/test/Makefile.msvc diff --git a/lib/c-ares-1.31.0/test/README.md b/lib/c-ares-1.32.0/test/README.md similarity index 100% rename from lib/c-ares-1.31.0/test/README.md rename to lib/c-ares-1.32.0/test/README.md diff --git a/lib/c-ares-1.31.0/test/ares-fuzz.c b/lib/c-ares-1.32.0/test/ares-fuzz.c similarity index 97% rename from lib/c-ares-1.31.0/test/ares-fuzz.c rename to lib/c-ares-1.32.0/test/ares-fuzz.c index d78a57914b8..8203d48da80 100644 --- a/lib/c-ares-1.31.0/test/ares-fuzz.c +++ b/lib/c-ares-1.32.0/test/ares-fuzz.c @@ -27,10 +27,10 @@ * General driver to allow command-line fuzzer (i.e. afl) to * exercise the libFuzzer entrypoint. */ +#include #include #include -#include #include #include #ifdef WIN32 @@ -75,7 +75,11 @@ int main(int argc, char *argv[]) if (argc == 1) { int count = 0; while (KEEP_FUZZING(count)) { +#ifndef STDIN_FILENO ProcessFile(fileno(stdin)); +#else + ProcessFile(STDIN_FILENO); +#endif count++; } } else { diff --git a/lib/c-ares-1.31.0/test/ares-test-ai.h b/lib/c-ares-1.32.0/test/ares-test-ai.h similarity index 100% rename from lib/c-ares-1.31.0/test/ares-test-ai.h rename to lib/c-ares-1.32.0/test/ares-test-ai.h diff --git a/lib/c-ares-1.31.0/test/ares-test-fuzz-name.c b/lib/c-ares-1.32.0/test/ares-test-fuzz-name.c similarity index 91% rename from lib/c-ares-1.31.0/test/ares-test-fuzz-name.c rename to lib/c-ares-1.32.0/test/ares-test-fuzz-name.c index 1c4c331574f..f32d347b752 100644 --- a/lib/c-ares-1.31.0/test/ares-test-fuzz-name.c +++ b/lib/c-ares-1.32.0/test/ares-test-fuzz-name.c @@ -28,15 +28,15 @@ #include #include "ares.h" -// Include ares internal file for DNS protocol constants +/* Include ares internal file for DNS protocol constants */ #include "ares_nameser.h" int LLVMFuzzerTestOneInput(const unsigned char *data, unsigned long size); -// Entrypoint for Clang's libfuzzer, exercising query creation. +/* Entrypoint for Clang's libfuzzer, exercising query creation. */ int LLVMFuzzerTestOneInput(const unsigned char *data, unsigned long size) { - // Null terminate the data. + /* Null terminate the data. */ char *name = malloc(size + 1); unsigned char *buf = NULL; int buflen = 0; diff --git a/lib/c-ares-1.31.0/test/ares-test-fuzz.c b/lib/c-ares-1.32.0/test/ares-test-fuzz.c similarity index 96% rename from lib/c-ares-1.31.0/test/ares-test-fuzz.c rename to lib/c-ares-1.32.0/test/ares-test-fuzz.c index c66e7037d7f..8746405b9fd 100644 --- a/lib/c-ares-1.31.0/test/ares-test-fuzz.c +++ b/lib/c-ares-1.32.0/test/ares-test-fuzz.c @@ -24,15 +24,15 @@ * SPDX-License-Identifier: MIT */ #include - +#include #include "ares.h" int LLVMFuzzerTestOneInput(const unsigned char *data, unsigned long size); -// Entrypoint for Clang's libfuzzer +/* Entrypoint for Clang's libfuzzer */ int LLVMFuzzerTestOneInput(const unsigned char *data, unsigned long size) { - // Feed the data into each of the ares_parse_*_reply functions. + /* Feed the data into each of the ares_parse_*_reply functions. */ struct hostent *host = NULL; struct ares_addrttl info[5]; struct ares_addr6ttl info6[5]; diff --git a/lib/c-ares-1.31.0/test/ares-test-init.cc b/lib/c-ares-1.32.0/test/ares-test-init.cc similarity index 100% rename from lib/c-ares-1.31.0/test/ares-test-init.cc rename to lib/c-ares-1.32.0/test/ares-test-init.cc diff --git a/lib/c-ares-1.31.0/test/ares-test-internal.cc b/lib/c-ares-1.32.0/test/ares-test-internal.cc similarity index 98% rename from lib/c-ares-1.31.0/test/ares-test-internal.cc rename to lib/c-ares-1.32.0/test/ares-test-internal.cc index d0e7f282fff..74b10d92c07 100644 --- a/lib/c-ares-1.31.0/test/ares-test-internal.cc +++ b/lib/c-ares-1.32.0/test/ares-test-internal.cc @@ -42,11 +42,10 @@ extern "C" { #undef PACKAGE_STRING #undef PACKAGE_TARNAME // ... so we can include the library's config without symbol redefinitions. -#include "ares_setup.h" +#include "ares_private.h" #include "ares_inet_net_pton.h" #include "ares_data.h" #include "ares_strsplit.h" -#include "ares_private.h" #include "ares__htable.h" #ifdef HAVE_ARPA_INET_H @@ -463,10 +462,14 @@ TEST_F(LibraryTest, DNSRecord) { EXPECT_EQ(ARES_SUCCESS, ares_dns_record_rr_add(&rr, dnsrec, ARES_SECTION_ANSWER, "example.com", ARES_REC_TYPE_TXT, ARES_CLASS_IN, 3600)); - const char txt[] = "blah=here blah=there anywhere"; - EXPECT_EQ(ARES_SUCCESS, - ares_dns_rr_set_bin(rr, ARES_RR_TXT_DATA, (unsigned char *)txt, - sizeof(txt))); + const char txt1[] = "blah=here blah=there anywhere"; + const char txt2[] = "some other record"; + EXPECT_EQ(ARES_SUCCESS, + ares_dns_rr_add_abin(rr, ARES_RR_TXT_DATA, (unsigned char *)txt1, + sizeof(txt1)-1)); + EXPECT_EQ(ARES_SUCCESS, + ares_dns_rr_add_abin(rr, ARES_RR_TXT_DATA, (unsigned char *)txt2, + sizeof(txt2)-1)); /* SIG */ EXPECT_EQ(ARES_SUCCESS, ares_dns_record_rr_add(&rr, dnsrec, ARES_SECTION_ANSWER, "example.com", @@ -736,7 +739,7 @@ TEST_F(LibraryTest, DNSRecord) { ares__buf_append_str(printmsg, ares_dns_section_tostr((ares_dns_section_t)i)); ares__buf_append_str(printmsg, " SECTION:\n"); for (size_t j = 0; j < ares_dns_record_rr_cnt(dnsrec, (ares_dns_section_t)i); j++) { - const ares_dns_rr_t *rr = ares_dns_record_rr_get(dnsrec, (ares_dns_section_t)i, j); + rr = ares_dns_record_rr_get(dnsrec, (ares_dns_section_t)i, j); ares__buf_append_str(printmsg, ares_dns_rr_get_name(rr)); ares__buf_append_str(printmsg, ".\t\t\t"); ares__buf_append_str(printmsg, ares_dns_class_tostr(ares_dns_rr_get_class(rr))); @@ -785,6 +788,17 @@ TEST_F(LibraryTest, DNSRecord) { ares__buf_append_str(printmsg, (const char *)ares_dns_rr_get_bin(rr, keys[k], &templen)); ares__buf_append_byte(printmsg, '"'); break; + case ARES_DATATYPE_ABINP: + for (size_t a=0; a reply = { - 0x00, 0x00, // qid - 0x84, // response + query + AA + not-TC + not-RD - 0x00, // not-RA + not-Z + not-AD + not-CD + rc=NoError - 0x00, 0x01, // 1 question - 0x00, 0x01, // 1 answer RRs - 0x00, 0x00, // 0 authority RRs - 0x00, 0x00, // 0 additional RRs - // Question - 0x03, 'w', 'w', 'w', - 0x06, 'g', 'o', 'o', 'g', 'l', 'e', - 0x03, 'c', 'o', 'm', - 0x00, - 0x00, 0x01, // type A - 0x00, 0x01, // class IN - // Answer - 0x03, 'w', 'w', 'w', - 0x06, 'g', 'o', 'o', 'g', 'l', 'e', - 0x03, 'c', 'o', 'm', - 0x00, - 0x00, 0x01, // type A - 0x00, 0x01, // class IN - 0x00, 0x00, 0x01, 0x00, // TTL - 0x00, 0x04, // rdata length - 0x01, 0x02, 0x03, 0x04 - }; - - ON_CALL(server_, OnRequest("www.google.com", T_A)) - .WillByDefault(SetReplyData(&server_, reply)); - - HostResult result; - ares_gethostbyname(channel_, "www.google.com.", AF_INET, HostCallback, &result); - Process(); - EXPECT_TRUE(result.done_); - std::stringstream ss; - ss << result.host_; - EXPECT_EQ("{'www.google.com' aliases=[] addrs=[1.2.3.4]}", ss.str()); -} - // UDP only so mock server doesn't get confused by concatenated requests TEST_P(MockUDPEventThreadTest, GetHostByNameParallelLookups) { DNSPacket rsp1; @@ -142,6 +102,7 @@ TEST_P(MockUDPEventThreadTest, TruncationRetry) { static int sock_cb_count = 0; static int SocketConnectCallback(ares_socket_t fd, int type, void *data) { int rc = *(int*)data; + (void)type; if (verbose) std::cerr << "SocketConnectCallback(" << fd << ") invoked" << std::endl; sock_cb_count++; return rc; @@ -828,8 +789,46 @@ TEST_P(MockEventThreadTest, PartialQueryCancel) { EXPECT_TRUE(result.done_); EXPECT_EQ(ARES_ECANCELLED, result.status_); } + +// Test case for Issue #798, we're really looking for a crash, the results +// don't matter. Should either be successful or canceled. +TEST_P(MockEventThreadTest, BulkCancel) { + std::vector nothing; + DNSPacket reply; + reply.set_response().set_aa() + .add_question(new DNSQuestion("www.google.com", T_A)) + .add_answer(new DNSARR("www.google.com", 0x0100, {0x01, 0x02, 0x03, 0x04})); + + ON_CALL(server_, OnRequest("www.google.com", T_A)) + .WillByDefault(SetReply(&server_, &reply)); + +#define BULKCANCEL_LOOP 5 +#define BULKCANCEL_CNT 50 + for (size_t l = 0; l { + public: + NoDNS0x20MockTest() + : MockChannelOptsTest(1, GetParam(), false, + FillOptions(&opts_), + ARES_OPT_FLAGS) {} + static struct ares_options* FillOptions(struct ares_options * opts) { + memset(opts, 0, sizeof(struct ares_options)); + opts->flags = ARES_FLAG_EDNS; + return opts; + } + private: + struct ares_options opts_; +}; + + +TEST_P(NoDNS0x20MockTest, Basic) { std::vector reply = { 0x00, 0x00, // qid 0x84, // response + query + AA + not-TC + not-RD @@ -80,6 +98,48 @@ TEST_P(MockChannelTest, Basic) { EXPECT_EQ("{'www.google.com' aliases=[] addrs=[1.2.3.4]}", ss.str()); } +TEST_P(MockUDPChannelTest, DNS0x20BadReply) { + std::vector reply = { + 0x00, 0x00, // qid + 0x84, // response + query + AA + not-TC + not-RD + 0x00, // not-RA + not-Z + not-AD + not-CD + rc=NoError + 0x00, 0x01, // 1 question + 0x00, 0x01, // 1 answer RRs + 0x00, 0x00, // 0 authority RRs + 0x00, 0x00, // 0 additional RRs + // Question + 0x03, 'w', 'w', 'w', + 0x1D, 's', 'o', 'm', 'e', 'l', 'o', 'n', 'g', 'd', 'o', 'm', 'a', 'i', 'n', 'n', 'a', 'm', 'e', 'b', 'e', 'c', 'a', 'u', 's', 'e', 'p', 'r', 'n', 'g', + 0x03, 'c', 'o', 'm', + 0x00, + 0x00, 0x01, // type A + 0x00, 0x01, // class IN + // Answer + 0x03, 'w', 'w', 'w', + 0x1D, 's', 'o', 'm', 'e', 'l', 'o', 'n', 'g', 'd', 'o', 'm', 'a', 'i', 'n', 'n', 'a', 'm', 'e', 'b', 'e', 'c', 'a', 'u', 's', 'e', 'p', 'r', 'n', 'g', + 0x03, 'c', 'o', 'm', + 0x00, + 0x00, 0x01, // type A + 0x00, 0x01, // class IN + 0x00, 0x00, 0x01, 0x00, // TTL + 0x00, 0x04, // rdata length + 0x01, 0x02, 0x03, 0x04 + }; + + ON_CALL(server_, OnRequest("www.somelongdomainnamebecauseprng.com", T_A)) + .WillByDefault(SetReplyData(&server_, reply)); + + /* Reply will be thrown out due to mismatched case for DNS 0x20 in response, + * its technically possible this test case may not fail if somehow the + * PRNG returns all lowercase domain name so we need to make this domain + * fairly long to make sure those odds are very very very low */ + HostResult result; + ares_gethostbyname(channel_, "www.somelongdomainnamebecauseprng.com.", AF_INET, HostCallback, &result); + Process(); + EXPECT_TRUE(result.done_); + EXPECT_EQ(ARES_ETIMEOUT, result.status_); +} + // UDP only so mock server doesn't get confused by concatenated requests TEST_P(MockUDPChannelTest, GetHostByNameParallelLookups) { DNSPacket rsp1; @@ -140,6 +200,7 @@ TEST_P(MockUDPChannelTest, TruncationRetry) { static int sock_cb_count = 0; static int SocketConnectCallback(ares_socket_t fd, int type, void *data) { int rc = *(int*)data; + (void)type; if (verbose) std::cerr << "SocketConnectCallback(" << fd << ") invoked" << std::endl; sock_cb_count++; return rc; @@ -185,6 +246,7 @@ TEST_P(MockChannelTest, SockFailCallback) { static int sock_config_cb_count = 0; static int SocketConfigureCallback(ares_socket_t fd, int type, void *data) { int rc = *(int*)data; + (void)type; if (verbose) std::cerr << "SocketConfigureCallback(" << fd << ") invoked" << std::endl; sock_config_cb_count++; return rc; @@ -1795,6 +1857,8 @@ std::string PrintFamily(const testing::TestParamInfo &info) return name; } +INSTANTIATE_TEST_SUITE_P(AddressFamilies, NoDNS0x20MockTest, ::testing::ValuesIn(ares::test::families), PrintFamily); + INSTANTIATE_TEST_SUITE_P(AddressFamilies, MockChannelTest, ::testing::ValuesIn(ares::test::families_modes), PrintFamilyMode); INSTANTIATE_TEST_SUITE_P(AddressFamilies, MockUDPChannelTest, ::testing::ValuesIn(ares::test::families), PrintFamily); diff --git a/lib/c-ares-1.31.0/test/ares-test-ns.cc b/lib/c-ares-1.32.0/test/ares-test-ns.cc similarity index 99% rename from lib/c-ares-1.31.0/test/ares-test-ns.cc rename to lib/c-ares-1.32.0/test/ares-test-ns.cc index 748c5f40a6f..8837038766b 100644 --- a/lib/c-ares-1.31.0/test/ares-test-ns.cc +++ b/lib/c-ares-1.32.0/test/ares-test-ns.cc @@ -209,7 +209,7 @@ void ContainerFilesystem::EnsureDirExists(const std::string& dir) { return; } size_t idx = dir.rfind('/'); - if (idx != std::string::npos) { + if (idx != SIZE_MAX) { std::string prevdir = dir.substr(0, idx); EnsureDirExists(prevdir); } diff --git a/lib/c-ares-1.31.0/test/ares-test-parse-a.cc b/lib/c-ares-1.32.0/test/ares-test-parse-a.cc similarity index 99% rename from lib/c-ares-1.31.0/test/ares-test-parse-a.cc rename to lib/c-ares-1.32.0/test/ares-test-parse-a.cc index 7e045dcc924..a91ee56a19e 100644 --- a/lib/c-ares-1.31.0/test/ares-test-parse-a.cc +++ b/lib/c-ares-1.32.0/test/ares-test-parse-a.cc @@ -297,7 +297,7 @@ TEST_F(LibraryTest, ParseAReplyErrors) { ASSERT_NE(nullptr, host); std::stringstream ss; ss << HostEnt(host); - EXPECT_EQ("{'Axample.com' aliases=[] addrs=[2.3.4.5]}", ss.str()); + EXPECT_EQ("{'axample.com' aliases=[] addrs=[2.3.4.5]}", ss.str()); ares_free_hostent(host); host = nullptr; diff --git a/lib/c-ares-1.31.0/test/ares-test-parse-aaaa.cc b/lib/c-ares-1.32.0/test/ares-test-parse-aaaa.cc similarity index 99% rename from lib/c-ares-1.31.0/test/ares-test-parse-aaaa.cc rename to lib/c-ares-1.32.0/test/ares-test-parse-aaaa.cc index 17255b0d7d3..8443bea41ba 100644 --- a/lib/c-ares-1.31.0/test/ares-test-parse-aaaa.cc +++ b/lib/c-ares-1.32.0/test/ares-test-parse-aaaa.cc @@ -148,7 +148,7 @@ TEST_F(LibraryTest, ParseAaaaReplyErrors) { ASSERT_NE(nullptr, host); std::stringstream ss; ss << HostEnt(host); - EXPECT_EQ("{'Axample.com' aliases=[] addrs=[0101:0101:0202:0202:0303:0303:0404:0404]}", ss.str()); + EXPECT_EQ("{'axample.com' aliases=[] addrs=[0101:0101:0202:0202:0303:0303:0404:0404]}", ss.str()); ares_free_hostent(host); host = nullptr; diff --git a/lib/c-ares-1.31.0/test/ares-test-parse-caa.cc b/lib/c-ares-1.32.0/test/ares-test-parse-caa.cc similarity index 100% rename from lib/c-ares-1.31.0/test/ares-test-parse-caa.cc rename to lib/c-ares-1.32.0/test/ares-test-parse-caa.cc diff --git a/lib/c-ares-1.31.0/test/ares-test-parse-mx.cc b/lib/c-ares-1.32.0/test/ares-test-parse-mx.cc similarity index 100% rename from lib/c-ares-1.31.0/test/ares-test-parse-mx.cc rename to lib/c-ares-1.32.0/test/ares-test-parse-mx.cc diff --git a/lib/c-ares-1.31.0/test/ares-test-parse-naptr.cc b/lib/c-ares-1.32.0/test/ares-test-parse-naptr.cc similarity index 100% rename from lib/c-ares-1.31.0/test/ares-test-parse-naptr.cc rename to lib/c-ares-1.32.0/test/ares-test-parse-naptr.cc diff --git a/lib/c-ares-1.31.0/test/ares-test-parse-ns.cc b/lib/c-ares-1.32.0/test/ares-test-parse-ns.cc similarity index 100% rename from lib/c-ares-1.31.0/test/ares-test-parse-ns.cc rename to lib/c-ares-1.32.0/test/ares-test-parse-ns.cc diff --git a/lib/c-ares-1.31.0/test/ares-test-parse-ptr.cc b/lib/c-ares-1.32.0/test/ares-test-parse-ptr.cc similarity index 100% rename from lib/c-ares-1.31.0/test/ares-test-parse-ptr.cc rename to lib/c-ares-1.32.0/test/ares-test-parse-ptr.cc diff --git a/lib/c-ares-1.31.0/test/ares-test-parse-soa-any.cc b/lib/c-ares-1.32.0/test/ares-test-parse-soa-any.cc similarity index 100% rename from lib/c-ares-1.31.0/test/ares-test-parse-soa-any.cc rename to lib/c-ares-1.32.0/test/ares-test-parse-soa-any.cc diff --git a/lib/c-ares-1.31.0/test/ares-test-parse-soa.cc b/lib/c-ares-1.32.0/test/ares-test-parse-soa.cc similarity index 100% rename from lib/c-ares-1.31.0/test/ares-test-parse-soa.cc rename to lib/c-ares-1.32.0/test/ares-test-parse-soa.cc diff --git a/lib/c-ares-1.31.0/test/ares-test-parse-srv.cc b/lib/c-ares-1.32.0/test/ares-test-parse-srv.cc similarity index 100% rename from lib/c-ares-1.31.0/test/ares-test-parse-srv.cc rename to lib/c-ares-1.32.0/test/ares-test-parse-srv.cc diff --git a/lib/c-ares-1.31.0/test/ares-test-parse-txt.cc b/lib/c-ares-1.32.0/test/ares-test-parse-txt.cc similarity index 92% rename from lib/c-ares-1.31.0/test/ares-test-parse-txt.cc rename to lib/c-ares-1.32.0/test/ares-test-parse-txt.cc index 181a34e11d6..173d0bded06 100644 --- a/lib/c-ares-1.31.0/test/ares-test-parse-txt.cc +++ b/lib/c-ares-1.32.0/test/ares-test-parse-txt.cc @@ -51,11 +51,14 @@ TEST_F(LibraryTest, ParseTxtReplyOK) { struct ares_txt_reply* txt2 = txt->next; ASSERT_NE(nullptr, txt2); - std::vector rsp = std::vector(expected2a.data(), expected2a.data() + expected2a.size()); - rsp.insert(rsp.end(), expected2b.data(), expected2b.data() + expected2b.size()); - EXPECT_EQ(rsp, + EXPECT_EQ(std::vector(expected2a.data(), expected2a.data() + expected2a.size()), std::vector(txt2->txt, txt2->txt + txt2->length)); + struct ares_txt_reply* txt3 = txt2->next; + ASSERT_NE(nullptr, txt3); + EXPECT_EQ(std::vector(expected2b.data(), expected2b.data() + expected2b.size()), + std::vector(txt3->txt, txt3->txt + txt3->length)); + EXPECT_EQ(nullptr, txt3->next); ares_free_data(txt); } @@ -79,12 +82,16 @@ TEST_F(LibraryTest, ParseTxtExtReplyOK) { struct ares_txt_ext* txt2 = txt->next; ASSERT_NE(nullptr, txt2); - std::vector rsp = std::vector(expected2a.data(), expected2a.data() + expected2a.size()); - rsp.insert(rsp.end(), expected2b.data(), expected2b.data() + expected2b.size()); - EXPECT_EQ(rsp, + EXPECT_EQ(std::vector(expected2a.data(), expected2a.data() + expected2a.size()), std::vector(txt2->txt, txt2->txt + txt2->length)); EXPECT_EQ(1, txt2->record_start); + struct ares_txt_ext* txt3 = txt2->next; + ASSERT_NE(nullptr, txt3); + EXPECT_EQ(std::vector(expected2b.data(), expected2b.data() + expected2b.size()), + std::vector(txt3->txt, txt3->txt + txt3->length)); + EXPECT_EQ(nullptr, txt3->next); + EXPECT_EQ(0, txt3->record_start); ares_free_data(txt); } diff --git a/lib/c-ares-1.31.0/test/ares-test-parse-uri.cc b/lib/c-ares-1.32.0/test/ares-test-parse-uri.cc similarity index 100% rename from lib/c-ares-1.31.0/test/ares-test-parse-uri.cc rename to lib/c-ares-1.32.0/test/ares-test-parse-uri.cc diff --git a/lib/c-ares-1.31.0/test/ares-test-parse.cc b/lib/c-ares-1.32.0/test/ares-test-parse.cc similarity index 100% rename from lib/c-ares-1.31.0/test/ares-test-parse.cc rename to lib/c-ares-1.32.0/test/ares-test-parse.cc diff --git a/lib/c-ares-1.31.0/test/ares-test.cc b/lib/c-ares-1.32.0/test/ares-test.cc similarity index 93% rename from lib/c-ares-1.31.0/test/ares-test.cc rename to lib/c-ares-1.32.0/test/ares-test.cc index c4498f053fb..a0d16e34309 100644 --- a/lib/c-ares-1.31.0/test/ares-test.cc +++ b/lib/c-ares-1.32.0/test/ares-test.cc @@ -58,6 +58,7 @@ extern "C" { #include #include +#include #ifdef WIN32 #define BYTE_CAST (char *) @@ -257,8 +258,11 @@ void ProcessWork(ares_channel_t *channel, fd_set readers, writers; #ifndef CARES_SYMBOL_HIDING - ares_timeval_t tv_begin = ares__tvnow(); - ares_timeval_t tv_cancel = tv_begin; + ares_timeval_t tv_begin; + ares_timeval_t tv_cancel; + + ares__tvnow(&tv_begin); + memcpy(&tv_cancel, &tv_begin, sizeof(tv_cancel)); if (cancel_ms) { if (verbose) std::cerr << "ares_cancel will be called after " << cancel_ms << "ms" << std::endl; @@ -274,8 +278,10 @@ void ProcessWork(ares_channel_t *channel, while (true) { #ifndef CARES_SYMBOL_HIDING - ares_timeval_t tv_now = ares__tvnow(); + ares_timeval_t tv_now; ares_timeval_t atv_remaining; + + ares__tvnow(&tv_now); #endif struct timeval tv; struct timeval *tv_select; @@ -426,6 +432,7 @@ void DefaultChannelModeTest::Process(unsigned int cancel_ms) { MockServer::MockServer(int family, unsigned short port) : udpport_(port), tcpport_(port), qid_(-1) { + reply_ = nullptr; // Create a TCP socket to receive data on. tcp_data_ = NULL; tcp_data_len_ = 0; @@ -521,8 +528,12 @@ static unsigned short getaddrport(struct sockaddr_storage *addr) { if (addr->ss_family == AF_INET) return ntohs(((struct sockaddr_in *)(void *)addr)->sin_port); + if (addr->ss_family == AF_INET6) + return ntohs(((struct sockaddr_in6 *)(void *)addr)->sin6_port); - return ntohs(((struct sockaddr_in6 *)(void *)addr)->sin6_port); + /* TCP should use getpeername() to get the port, getting this from recvfrom + * won't work */ + return 0; } void MockServer::ProcessPacket(ares_socket_t fd, struct sockaddr_storage *addr, ares_socklen_t addrlen, @@ -561,21 +572,22 @@ void MockServer::ProcessPacket(ares_socket_t fd, struct sockaddr_storage *addr, } if (enclen > qlen) { std::cerr << "(error, encoded name len " << enclen << "bigger than remaining data " << qlen << " bytes)" << std::endl; + ares_free_string(name); return; } qlen -= (int)enclen; question += enclen; - std::string namestr(name); - ares_free_string(name); if (qlen < 4) { std::cerr << "Unexpected question size (" << qlen << " bytes after name)" << std::endl; + ares_free_string(name); return; } if (DNS_QUESTION_CLASS(question) != C_IN) { std::cerr << "Unexpected question class (" << DNS_QUESTION_CLASS(question) << ")" << std::endl; + ares_free_string(name); return; } int rrtype = DNS_QUESTION_TYPE(question); @@ -586,11 +598,11 @@ void MockServer::ProcessPacket(ares_socket_t fd, struct sockaddr_storage *addr, std::cerr << "received " << (fd == udpfd_ ? "UDP" : "TCP") << " request " << reqstr << " on port " << (fd == udpfd_ ? udpport_ : tcpport_) << ":" << getaddrport(addr) << std::endl; - std::cerr << "ProcessRequest(" << qid << ", '" << namestr + std::cerr << "ProcessRequest(" << qid << ", '" << name << "', " << RRTypeToString(rrtype) << ")" << std::endl; } - ProcessRequest(fd, addr, addrlen, reqstr, qid, namestr, rrtype); - + ProcessRequest(fd, addr, addrlen, reqstr, qid, name, rrtype); + ares_free_string(name); } void MockServer::ProcessFD(ares_socket_t fd) { @@ -600,7 +612,7 @@ void MockServer::ProcessFD(ares_socket_t fd) { } if (fd == tcpfd_) { ares_socket_t connfd = accept(tcpfd_, NULL, NULL); - if (connfd < 0) { + if (connfd == ARES_SOCKET_BAD) { std::cerr << "Error accepting connection on fd " << fd << std::endl; } else { connfds_.insert(connfd); @@ -611,6 +623,7 @@ void MockServer::ProcessFD(ares_socket_t fd) { // Activity on a data-bearing file descriptor. struct sockaddr_storage addr; socklen_t addrlen = sizeof(addr); + memset(&addr, 0, sizeof(addr)); byte buffer[2048]; ares_ssize_t len = (ares_ssize_t)recvfrom(fd, BYTE_CAST buffer, sizeof(buffer), 0, (struct sockaddr *)&addr, &addrlen); @@ -657,24 +670,32 @@ std::set MockServer::fds() const { return result; } - void MockServer::ProcessRequest(ares_socket_t fd, struct sockaddr_storage* addr, ares_socklen_t addrlen, const std::string &reqstr, - int qid, const std::string& name, int rrtype) { + int qid, const char *name, int rrtype) { + + /* DNS 0x20 will mix case, do case-insensitive matching of name in request */ + char lower_name[256]; + arestest_strtolower(lower_name, name, sizeof(lower_name)); + // Before processing, let gMock know the request is happening. - OnRequest(name, rrtype); + OnRequest(lower_name, rrtype); // If we are expecting a specific request then check it matches here. if (expected_request_.length() > 0) { ASSERT_EQ(expected_request_, reqstr); } - if (reply_.size() == 0) { + if (reply_ != nullptr) { + exact_reply_ = reply_->data(name); + } + + if (exact_reply_.size() == 0) { return; } // Make a local copy of the current pending reply. - std::vector reply = reply_; + std::vector reply = exact_reply_; if (qid_ >= 0) { // Use the explicitly specified query ID. @@ -778,6 +799,12 @@ MockChannelOptsTest::MockChannelOptsTest(int count, optmask |= ARES_OPT_QUERY_CACHE; } + /* Enable DNS0x20 by default. Need to also turn on default flag of EDNS */ + if (!(optmask & ARES_OPT_FLAGS)) { + optmask |= ARES_OPT_FLAGS; + opts.flags = ARES_FLAG_DNS0x20|ARES_FLAG_EDNS; + } + EXPECT_EQ(ARES_SUCCESS, ares_init_options(&channel_, &opts, optmask)); EXPECT_NE(nullptr, channel_); @@ -847,37 +874,37 @@ void MockChannelOptsTest::Process(unsigned int cancel_ms) { cancel_ms); } -void MockEventThreadOptsTest::ProcessThread() { +void MockEventThreadOptsTest::Process(unsigned int cancel_ms) { std::set fds; #ifndef CARES_SYMBOL_HIDING - bool has_cancel_ms = false; + bool has_cancel_ms = (cancel_ms > 0)?true:false; ares_timeval_t tv_begin; ares_timeval_t tv_cancel; #endif - mutex.lock(); - - while (isup) { - int nfds = 0; - fd_set readers; #ifndef CARES_SYMBOL_HIDING - ares_timeval_t tv_now = ares__tvnow(); - ares_timeval_t atv_remaining; - if (cancel_ms_ && !has_cancel_ms) { - tv_begin = ares__tvnow(); - tv_cancel = tv_begin; - if (verbose) std::cerr << "ares_cancel will be called after " << cancel_ms_ << "ms" << std::endl; - tv_cancel.sec += (cancel_ms_ / 1000); - tv_cancel.usec += ((cancel_ms_ % 1000) * 1000); - has_cancel_ms = true; - } + ares_timeval_t tv_now; + ares_timeval_t atv_remaining; + + if (has_cancel_ms) { + ares__tvnow(&tv_begin); + memcpy(&tv_cancel, &tv_begin, sizeof(tv_cancel)); + if (verbose) std::cerr << "ares_cancel will be called after " << cancel_ms << "ms" << std::endl; + tv_cancel.sec += (cancel_ms / 1000); + tv_cancel.usec += ((cancel_ms % 1000) * 1000); + } #else - if (cancel_ms_) { - std::cerr << "library built with symbol hiding, can't test with cancel support" << std::endl; - return; - } + if (cancel_ms) { + std::cerr << "library built with symbol hiding, can't test with cancel support" << std::endl; + return; + } #endif + + while (ares_queue_active_queries(channel_)) { + int nfds = 0; + fd_set readers; + struct timeval tv; /* c-ares is using its own event thread, so we only need to monitor the @@ -891,9 +918,15 @@ void MockEventThreadOptsTest::ProcessThread() { } } + /* We just always wait 20ms then recheck. Not doing any complex signaling. */ + tv.tv_sec = 0; + tv.tv_usec = 20000; + #ifndef CARES_SYMBOL_HIDING + ares__tvnow(&tv_now); + + unsigned int remaining_ms = 0; if (has_cancel_ms) { - unsigned int remaining_ms; ares__timeval_remaining(&atv_remaining, &tv_now, &tv_cancel); @@ -901,17 +934,16 @@ void MockEventThreadOptsTest::ProcessThread() { if (remaining_ms == 0) { if (verbose) std::cerr << "Issuing ares_cancel()" << std::endl; ares_cancel(channel_); - cancel_ms_ = 0; /* Disable issuing cancel again */ + cancel_ms = 0; /* Disable issuing cancel again */ has_cancel_ms = false; } } -#endif - /* We just always wait 20ms then recheck. Not doing any complex signaling. */ - tv.tv_sec = 0; - tv.tv_usec = 20000; + if (has_cancel_ms && remaining_ms < 20) { + tv.tv_usec = (int)remaining_ms * 1000; + } +#endif - mutex.unlock(); if (select(nfds, &readers, nullptr, nullptr, &tv) < 0) { fprintf(stderr, "select() failed, errno %d\n", errno); return; @@ -923,10 +955,7 @@ void MockEventThreadOptsTest::ProcessThread() { ProcessFD(fd); } } - mutex.lock(); } - mutex.unlock(); - } std::ostream& operator<<(std::ostream& os, const HostResult& result) { @@ -949,8 +978,13 @@ HostEnt::HostEnt(const struct hostent *hostent) : addrtype_(-1) { if (!hostent) return; - if (hostent->h_name) - name_ = hostent->h_name; + if (hostent->h_name) { + // DNS 0x20 may mix case, output as all lower for checks as the mixed case + // is really more of an internal thing + char lowername[256]; + arestest_strtolower(lowername, hostent->h_name, sizeof(lowername)); + name_ = lowername; + } if (hostent->h_aliases) { char** palias = hostent->h_aliases; @@ -1034,7 +1068,10 @@ std::ostream& operator<<(std::ostream& os, const AddrInfo& ai) { if(next_cname->name) { os << next_cname->name; } - if((next_cname = next_cname->next)) + + next_cname = next_cname->next; + + if (next_cname != NULL) os << ", "; else os << " "; @@ -1063,7 +1100,8 @@ std::ostream& operator<<(std::ostream& os, const AddrInfo& ai) { os << ":" << port; } os << "]"; - if((next = next->ai_next)) + next = next->ai_next; + if (next != NULL) os << ", "; } os << '}'; diff --git a/lib/c-ares-1.31.0/test/ares-test.h b/lib/c-ares-1.32.0/test/ares-test.h similarity index 96% rename from lib/c-ares-1.31.0/test/ares-test.h rename to lib/c-ares-1.32.0/test/ares-test.h index d935f46d50d..b1d9c8d6f6b 100644 --- a/lib/c-ares-1.31.0/test/ares-test.h +++ b/lib/c-ares-1.32.0/test/ares-test.h @@ -28,10 +28,6 @@ #define ARES_TEST_H #include "ares_setup.h" -#ifdef HAVE_CONFIG_H -# include "ares_config.h" -#endif - #include "dns-proto.h" // Include ares internal file for DNS protocol constants #include "ares_nameser.h" @@ -222,6 +218,7 @@ class DefaultChannelModeTest ares_channel_t *channel_; }; + // Mock DNS server to allow responses to be scripted by tests. class MockServer { public: @@ -236,12 +233,14 @@ class MockServer { // with the value from the request. void SetReplyData(const std::vector &reply) { - reply_ = reply; + exact_reply_ = reply; + reply_ = nullptr; } void SetReply(const DNSPacket *reply) { - SetReplyData(reply->data()); + reply_ = reply; + exact_reply_.clear(); } // Set the reply to be sent next as well as the request (in string form) that @@ -250,7 +249,7 @@ class MockServer { void SetReplyExpRequest(const DNSPacket *reply, const std::string &request) { expected_request_ = request; - SetReply(reply); + reply_ = reply; } void SetReplyQID(int qid) @@ -260,6 +259,8 @@ class MockServer { void Disconnect() { + reply_ = nullptr; + exact_reply_.clear(); for (ares_socket_t fd : connfds_) { sclose(fd); } @@ -289,7 +290,7 @@ class MockServer { private: void ProcessRequest(ares_socket_t fd, struct sockaddr_storage *addr, ares_socklen_t addrlen, const std::string &reqstr, - int qid, const std::string &name, int rrtype); + int qid, const char *name, int rrtype); void ProcessPacket(ares_socket_t fd, struct sockaddr_storage *addr, ares_socklen_t addrlen, byte *data, int len); unsigned short udpport_; @@ -297,7 +298,8 @@ class MockServer { ares_socket_t udpfd_; ares_socket_t tcpfd_; std::set connfds_; - std::vector reply_; + std::vector exact_reply_; + const DNSPacket *reply_; std::string expected_request_; int qid_; unsigned char *tcp_data_; @@ -367,17 +369,10 @@ class MockEventThreadOptsTest : public MockChannelOptsTest { FillOptionsET(&evopts_, givenopts, evsys), optmask | ARES_OPT_EVENT_THREAD) { - cancel_ms_ = 0; - isup = true; - thread = std::thread(&MockEventThreadOptsTest::ProcessThread, this); } ~MockEventThreadOptsTest() { - mutex.lock(); - isup = false; - mutex.unlock(); - thread.join(); } static struct ares_options *FillOptionsET(struct ares_options *opts, @@ -393,21 +388,9 @@ class MockEventThreadOptsTest : public MockChannelOptsTest { return opts; } - void Process(unsigned int cancel_ms = 0) - { - mutex.lock(); - cancel_ms_ = cancel_ms; - mutex.unlock(); - ares_queue_wait_empty(channel_, -1); - } - + void Process(unsigned int cancel_ms = 0); private: - void ProcessThread(); struct ares_options evopts_; - unsigned int cancel_ms_; - bool isup; - std::mutex mutex; - std::thread thread; }; class MockEventThreadTest diff --git a/lib/c-ares-1.31.0/test/ares_queryloop.c b/lib/c-ares-1.32.0/test/ares_queryloop.c similarity index 79% rename from lib/c-ares-1.31.0/test/ares_queryloop.c rename to lib/c-ares-1.32.0/test/ares_queryloop.c index 1ddeb42c037..8422de8d751 100644 --- a/lib/c-ares-1.31.0/test/ares_queryloop.c +++ b/lib/c-ares-1.32.0/test/ares_queryloop.c @@ -37,6 +37,7 @@ # include #else # include +# include # include # include # include @@ -76,6 +77,34 @@ static void ai_callback(void *arg, int status, int timeouts, ares_freeaddrinfo(result); } +static volatile ares_bool_t is_running = ARES_TRUE; + + +#ifdef _WIN32 +static BOOL WINAPI ctrlc_handler(_In_ DWORD dwCtrlType) +{ + switch (dwCtrlType) { + case CTRL_C_EVENT: + is_running = ARES_FALSE; + return TRUE; + default: + break; + } + return FALSE; +} +#else +static void ctrlc_handler(int sig) +{ + switch (sig) { + case SIGINT: + is_running = ARES_FALSE; + break; + default: + break; + } +} +#endif + int main(int argc, char *argv[]) { struct ares_options options; @@ -102,8 +131,10 @@ int main(int argc, char *argv[]) } memset(&options, 0, sizeof(options)); - optmask |= ARES_OPT_EVENT_THREAD; - options.evsys = ARES_EVSYS_DEFAULT; + optmask |= ARES_OPT_EVENT_THREAD; + options.evsys = ARES_EVSYS_DEFAULT; + optmask |= ARES_OPT_QUERY_CACHE; + options.qcache_max_ttl = 0; status = (ares_status_t)ares_init_options(&channel, &options, optmask); if (status != ARES_SUCCESS) { @@ -111,13 +142,23 @@ int main(int argc, char *argv[]) return 1; } +#ifdef _WIN32 + SetConsoleCtrlHandler(ctrlc_handler, TRUE); +#else + signal(SIGINT, ctrlc_handler); +#endif + printf("Querying for %s every 1s, press CTRL-C to quit...\n", argv[1]); - for (count = 1;; count++) { + for (count = 1; is_running == ARES_TRUE; count++) { struct ares_addrinfo_hints hints; + char *servers = ares_get_servers_csv(channel); + memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; - printf("Attempt %zu...\n", count); + printf("Attempt %u using server list: %s ...\n", (unsigned int)count, servers); + ares_free_string(servers); + ares_getaddrinfo(channel, argv[1], NULL, &hints, ai_callback, argv[1]); #ifdef _WIN32 Sleep(1000); @@ -126,6 +167,7 @@ int main(int argc, char *argv[]) #endif } + printf("CTRL-C captured, cleaning up...\n"); ares_destroy(channel); ares_library_cleanup(); diff --git a/lib/c-ares-1.31.0/test/dns-dump.cc b/lib/c-ares-1.32.0/test/dns-dump.cc similarity index 100% rename from lib/c-ares-1.31.0/test/dns-dump.cc rename to lib/c-ares-1.32.0/test/dns-dump.cc diff --git a/lib/c-ares-1.31.0/test/dns-proto-test.cc b/lib/c-ares-1.32.0/test/dns-proto-test.cc similarity index 100% rename from lib/c-ares-1.31.0/test/dns-proto-test.cc rename to lib/c-ares-1.32.0/test/dns-proto-test.cc diff --git a/lib/c-ares-1.31.0/test/dns-proto.cc b/lib/c-ares-1.32.0/test/dns-proto.cc similarity index 90% rename from lib/c-ares-1.31.0/test/dns-proto.cc rename to lib/c-ares-1.32.0/test/dns-proto.cc index f7b360544e1..f9c7d4d56e3 100644 --- a/lib/c-ares-1.31.0/test/dns-proto.cc +++ b/lib/c-ares-1.32.0/test/dns-proto.cc @@ -34,6 +34,33 @@ #include #include +#include + +#if defined(_WIN32) && !defined(strcasecmp) +# define strcasecmp(a,b) stricmp(a,b) +#endif + +void arestest_strtolower(char *dest, const char *src, size_t dest_size) +{ + size_t len; + + if (dest == NULL) + return; + + memset(dest, 0, dest_size); + + if (src == NULL) + return; + + len = strlen(src); + if (len >= dest_size) + return; + + for (size_t i = 0; i& packet, } *len -= (int)enclen; *data += enclen; - ss << "'" << name << "' "; + + // DNS 0x20 may mix case, output as all lower for checks as the mixed case + // is really more of an internal thing + char lowername[256]; + arestest_strtolower(lowername, name, sizeof(lowername)); ares_free_string(name); + + ss << "'" << lowername << "' "; if (*len < NS_QFIXEDSZ) { ss << "(too short, len left " << *len << ")"; return ss.str(); @@ -341,21 +374,21 @@ std::string RRToString(const std::vector& packet, case T_TXT: { const byte* p = *data; while (p < (*data + rdatalen)) { - int len = *p++; - if ((p + len) <= (*data + rdatalen)) { - std::string txt(p, p + len); - ss << " " << len << ":'" << txt << "'"; + int tlen = *p++; + if ((p + tlen) <= (*data + rdatalen)) { + std::string txt(p, p + tlen); + ss << " " << tlen << ":'" << txt << "'"; } else { ss << "(string too long)"; } - p += len; + p += tlen; } break; } case T_CNAME: case T_NS: case T_PTR: { - int rc = ares_expand_name(*data, packet.data(), (int)packet.size(), &name, &enclen); + rc = ares_expand_name(*data, packet.data(), (int)packet.size(), &name, &enclen); if (rc != ARES_SUCCESS) { ss << "(error from ares_expand_name)"; break; @@ -366,7 +399,7 @@ std::string RRToString(const std::vector& packet, } case T_MX: if (rdatalen > 2) { - int rc = ares_expand_name(*data + 2, packet.data(), (int)packet.size(), &name, &enclen); + rc = ares_expand_name(*data + 2, packet.data(), (int)packet.size(), &name, &enclen); if (rc != ARES_SUCCESS) { ss << "(error from ares_expand_name)"; break; @@ -384,7 +417,7 @@ std::string RRToString(const std::vector& packet, unsigned long weight = DNS__16BIT(p + 2); unsigned long port = DNS__16BIT(p + 4); p += 6; - int rc = ares_expand_name(p, packet.data(), (int)packet.size(), &name, &enclen); + rc = ares_expand_name(p, packet.data(), (int)packet.size(), &name, &enclen); if (rc != ARES_SUCCESS) { ss << "(error from ares_expand_name)"; break; @@ -411,7 +444,7 @@ std::string RRToString(const std::vector& packet, } case T_SOA: { const byte* p = *data; - int rc = ares_expand_name(p, packet.data(), (int)packet.size(), &name, &enclen); + rc = ares_expand_name(p, packet.data(), (int)packet.size(), &name, &enclen); if (rc != ARES_SUCCESS) { ss << "(error from ares_expand_name)"; break; @@ -447,22 +480,22 @@ std::string RRToString(const std::vector& packet, p += 4; ss << order << " " << pref; - int len = *p++; - std::string flags(p, p + len); + int nlen = *p++; + std::string flags(p, p + nlen); ss << " " << flags; - p += len; + p += nlen; - len = *p++; - std::string service(p, p + len); + nlen = *p++; + std::string service(p, p + nlen); ss << " '" << service << "'"; - p += len; + p += nlen; - len = *p++; - std::string regexp(p, p + len); + nlen = *p++; + std::string regexp(p, p + nlen); ss << " '" << regexp << "'"; - p += len; + p += nlen; - int rc = ares_expand_name(p, packet.data(), (int)packet.size(), &name, &enclen); + rc = ares_expand_name(p, packet.data(), (int)packet.size(), &name, &enclen); if (rc != ARES_SUCCESS) { ss << "(error from ares_expand_name)"; break; @@ -498,7 +531,7 @@ void PushInt16(std::vector* data, int value) { data->push_back((byte)value & 0x00ff); } -std::vector EncodeString(const std::string& name) { +std::vector EncodeString(const std::string &name) { std::vector data; std::stringstream ss(name); std::string label; @@ -515,9 +548,14 @@ std::vector EncodeString(const std::string& name) { return data; } -std::vector DNSQuestion::data() const { +std::vector DNSQuestion::data(const char *request_name) const { std::vector data; - std::vector encname = EncodeString(name_); + std::vector encname; + if (request_name != nullptr && strcasecmp(request_name, name_.c_str()) == 0) { + encname = EncodeString(request_name); + } else { + encname = EncodeString(name_); + } data.insert(data.end(), encname.begin(), encname.end()); PushInt16(&data, rrtype_); PushInt16(&data, qclass_); @@ -641,7 +679,7 @@ std::vector DNSNaptrRR::data() const { return data; } -std::vector DNSPacket::data() const { +std::vector DNSPacket::data(const char *request_name) const { std::vector data; PushInt16(&data, qid_); byte b = 0x00; @@ -669,7 +707,7 @@ std::vector DNSPacket::data() const { PushInt16(&data, count); for (const std::unique_ptr& question : questions_) { - std::vector qdata = question->data(); + std::vector qdata = question->data(request_name); data.insert(data.end(), qdata.begin(), qdata.end()); } for (const std::unique_ptr& rr : answers_) { diff --git a/lib/c-ares-1.31.0/test/dns-proto.h b/lib/c-ares-1.32.0/test/dns-proto.h similarity index 96% rename from lib/c-ares-1.31.0/test/dns-proto.h rename to lib/c-ares-1.32.0/test/dns-proto.h index 618673ee46c..88e0a23cdc1 100644 --- a/lib/c-ares-1.31.0/test/dns-proto.h +++ b/lib/c-ares-1.32.0/test/dns-proto.h @@ -36,6 +36,8 @@ #include #include +extern "C" void arestest_strtolower(char *dest, const char *src, size_t dest_size); + namespace ares { typedef unsigned char byte; @@ -81,7 +83,13 @@ struct DNSQuestion { { } - virtual std::vector data() const; + virtual std::vector data(const char *request_name) const; + + virtual std::vector data() const + { + return data(nullptr); + } + std::string name_; int rrtype_; int qclass_; @@ -375,7 +383,12 @@ struct DNSPacket { } // Return the encoded packet. - std::vector data() const; + std::vector data(const char *request_name) const; + std::vector data() const + { + return data(nullptr); + } + int qid_; bool response_; diff --git a/lib/c-ares-1.31.0/test/fuzzcheck.sh b/lib/c-ares-1.32.0/test/fuzzcheck.sh similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzcheck.sh rename to lib/c-ares-1.32.0/test/fuzzcheck.sh diff --git a/lib/c-ares-1.31.0/test/fuzzinput/004a216d3cff18b0c5c6b68b807f1529 b/lib/c-ares-1.32.0/test/fuzzinput/004a216d3cff18b0c5c6b68b807f1529 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/004a216d3cff18b0c5c6b68b807f1529 rename to lib/c-ares-1.32.0/test/fuzzinput/004a216d3cff18b0c5c6b68b807f1529 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/00539467ca159b36aea95e61f9729115 b/lib/c-ares-1.32.0/test/fuzzinput/00539467ca159b36aea95e61f9729115 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/00539467ca159b36aea95e61f9729115 rename to lib/c-ares-1.32.0/test/fuzzinput/00539467ca159b36aea95e61f9729115 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/00e846db8f43f2f507cd1666ed5a753e b/lib/c-ares-1.32.0/test/fuzzinput/00e846db8f43f2f507cd1666ed5a753e similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/00e846db8f43f2f507cd1666ed5a753e rename to lib/c-ares-1.32.0/test/fuzzinput/00e846db8f43f2f507cd1666ed5a753e diff --git a/lib/c-ares-1.31.0/test/fuzzinput/0177b7566f08c013699eaea9a77abeb3 b/lib/c-ares-1.32.0/test/fuzzinput/0177b7566f08c013699eaea9a77abeb3 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/0177b7566f08c013699eaea9a77abeb3 rename to lib/c-ares-1.32.0/test/fuzzinput/0177b7566f08c013699eaea9a77abeb3 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/020a4fa317715bfdb236ed13751e6b65 b/lib/c-ares-1.32.0/test/fuzzinput/020a4fa317715bfdb236ed13751e6b65 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/020a4fa317715bfdb236ed13751e6b65 rename to lib/c-ares-1.32.0/test/fuzzinput/020a4fa317715bfdb236ed13751e6b65 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/0310f2e81bea31f4fe3f330872a877dd b/lib/c-ares-1.32.0/test/fuzzinput/0310f2e81bea31f4fe3f330872a877dd similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/0310f2e81bea31f4fe3f330872a877dd rename to lib/c-ares-1.32.0/test/fuzzinput/0310f2e81bea31f4fe3f330872a877dd diff --git a/lib/c-ares-1.31.0/test/fuzzinput/0449be67df1730b2d0887d412a9b7cc4 b/lib/c-ares-1.32.0/test/fuzzinput/0449be67df1730b2d0887d412a9b7cc4 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/0449be67df1730b2d0887d412a9b7cc4 rename to lib/c-ares-1.32.0/test/fuzzinput/0449be67df1730b2d0887d412a9b7cc4 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/0449dd14f7aa94bf0d716bfe09b287a8 b/lib/c-ares-1.32.0/test/fuzzinput/0449dd14f7aa94bf0d716bfe09b287a8 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/0449dd14f7aa94bf0d716bfe09b287a8 rename to lib/c-ares-1.32.0/test/fuzzinput/0449dd14f7aa94bf0d716bfe09b287a8 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/04c93cdf7208979aa4df80a3a0d5a2d8 b/lib/c-ares-1.32.0/test/fuzzinput/04c93cdf7208979aa4df80a3a0d5a2d8 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/04c93cdf7208979aa4df80a3a0d5a2d8 rename to lib/c-ares-1.32.0/test/fuzzinput/04c93cdf7208979aa4df80a3a0d5a2d8 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/0567e7171e08e75f3f91c4ca74c17adc b/lib/c-ares-1.32.0/test/fuzzinput/0567e7171e08e75f3f91c4ca74c17adc similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/0567e7171e08e75f3f91c4ca74c17adc rename to lib/c-ares-1.32.0/test/fuzzinput/0567e7171e08e75f3f91c4ca74c17adc diff --git a/lib/c-ares-1.31.0/test/fuzzinput/05ba948578a397e9cbc6a7b3e78622fa b/lib/c-ares-1.32.0/test/fuzzinput/05ba948578a397e9cbc6a7b3e78622fa similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/05ba948578a397e9cbc6a7b3e78622fa rename to lib/c-ares-1.32.0/test/fuzzinput/05ba948578a397e9cbc6a7b3e78622fa diff --git a/lib/c-ares-1.31.0/test/fuzzinput/060afe5ed25f3e2e86167e545f27edca b/lib/c-ares-1.32.0/test/fuzzinput/060afe5ed25f3e2e86167e545f27edca similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/060afe5ed25f3e2e86167e545f27edca rename to lib/c-ares-1.32.0/test/fuzzinput/060afe5ed25f3e2e86167e545f27edca diff --git a/lib/c-ares-1.31.0/test/fuzzinput/06d47d3681493f1b1d41236f460d896f b/lib/c-ares-1.32.0/test/fuzzinput/06d47d3681493f1b1d41236f460d896f similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/06d47d3681493f1b1d41236f460d896f rename to lib/c-ares-1.32.0/test/fuzzinput/06d47d3681493f1b1d41236f460d896f diff --git a/lib/c-ares-1.31.0/test/fuzzinput/0724a810b0e131c2fddb6de9003b9064 b/lib/c-ares-1.32.0/test/fuzzinput/0724a810b0e131c2fddb6de9003b9064 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/0724a810b0e131c2fddb6de9003b9064 rename to lib/c-ares-1.32.0/test/fuzzinput/0724a810b0e131c2fddb6de9003b9064 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/0b5279148826f5b962bcf1896bdb4ede b/lib/c-ares-1.32.0/test/fuzzinput/0b5279148826f5b962bcf1896bdb4ede similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/0b5279148826f5b962bcf1896bdb4ede rename to lib/c-ares-1.32.0/test/fuzzinput/0b5279148826f5b962bcf1896bdb4ede diff --git a/lib/c-ares-1.31.0/test/fuzzinput/114048c0f6b10bdc67ce9166405d195e b/lib/c-ares-1.32.0/test/fuzzinput/114048c0f6b10bdc67ce9166405d195e similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/114048c0f6b10bdc67ce9166405d195e rename to lib/c-ares-1.32.0/test/fuzzinput/114048c0f6b10bdc67ce9166405d195e diff --git a/lib/c-ares-1.31.0/test/fuzzinput/11b8464a0ef8735d202955c34c36b0c7 b/lib/c-ares-1.32.0/test/fuzzinput/11b8464a0ef8735d202955c34c36b0c7 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/11b8464a0ef8735d202955c34c36b0c7 rename to lib/c-ares-1.32.0/test/fuzzinput/11b8464a0ef8735d202955c34c36b0c7 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/11cb626f1668c7b41954ce7d768fe528 b/lib/c-ares-1.32.0/test/fuzzinput/11cb626f1668c7b41954ce7d768fe528 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/11cb626f1668c7b41954ce7d768fe528 rename to lib/c-ares-1.32.0/test/fuzzinput/11cb626f1668c7b41954ce7d768fe528 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/14b133bf18125b75a1976fa63a1df6b7 b/lib/c-ares-1.32.0/test/fuzzinput/14b133bf18125b75a1976fa63a1df6b7 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/14b133bf18125b75a1976fa63a1df6b7 rename to lib/c-ares-1.32.0/test/fuzzinput/14b133bf18125b75a1976fa63a1df6b7 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/153c6b3afa8faa03c8bc28f936a6d4cf b/lib/c-ares-1.32.0/test/fuzzinput/153c6b3afa8faa03c8bc28f936a6d4cf similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/153c6b3afa8faa03c8bc28f936a6d4cf rename to lib/c-ares-1.32.0/test/fuzzinput/153c6b3afa8faa03c8bc28f936a6d4cf diff --git a/lib/c-ares-1.31.0/test/fuzzinput/182cad2a342ed7317b7c21a5d17020d1 b/lib/c-ares-1.32.0/test/fuzzinput/182cad2a342ed7317b7c21a5d17020d1 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/182cad2a342ed7317b7c21a5d17020d1 rename to lib/c-ares-1.32.0/test/fuzzinput/182cad2a342ed7317b7c21a5d17020d1 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/1c61a61bb7057b52c5b15188345a5238 b/lib/c-ares-1.32.0/test/fuzzinput/1c61a61bb7057b52c5b15188345a5238 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/1c61a61bb7057b52c5b15188345a5238 rename to lib/c-ares-1.32.0/test/fuzzinput/1c61a61bb7057b52c5b15188345a5238 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/1dbe2cf62ed2e4fa1c3cb473f08710b5 b/lib/c-ares-1.32.0/test/fuzzinput/1dbe2cf62ed2e4fa1c3cb473f08710b5 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/1dbe2cf62ed2e4fa1c3cb473f08710b5 rename to lib/c-ares-1.32.0/test/fuzzinput/1dbe2cf62ed2e4fa1c3cb473f08710b5 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/21199be504fcfece5c7096ee0dbba507 b/lib/c-ares-1.32.0/test/fuzzinput/21199be504fcfece5c7096ee0dbba507 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/21199be504fcfece5c7096ee0dbba507 rename to lib/c-ares-1.32.0/test/fuzzinput/21199be504fcfece5c7096ee0dbba507 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/21891480074b5635dbbe7137bdcabccd b/lib/c-ares-1.32.0/test/fuzzinput/21891480074b5635dbbe7137bdcabccd similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/21891480074b5635dbbe7137bdcabccd rename to lib/c-ares-1.32.0/test/fuzzinput/21891480074b5635dbbe7137bdcabccd diff --git a/lib/c-ares-1.31.0/test/fuzzinput/233aea42e15aa73e131eefabf16088c9 b/lib/c-ares-1.32.0/test/fuzzinput/233aea42e15aa73e131eefabf16088c9 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/233aea42e15aa73e131eefabf16088c9 rename to lib/c-ares-1.32.0/test/fuzzinput/233aea42e15aa73e131eefabf16088c9 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/24660d4e7ac7aa21d600ea7a3d198bbb b/lib/c-ares-1.32.0/test/fuzzinput/24660d4e7ac7aa21d600ea7a3d198bbb similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/24660d4e7ac7aa21d600ea7a3d198bbb rename to lib/c-ares-1.32.0/test/fuzzinput/24660d4e7ac7aa21d600ea7a3d198bbb diff --git a/lib/c-ares-1.31.0/test/fuzzinput/25589deb55c08429345f289d1c9b0254 b/lib/c-ares-1.32.0/test/fuzzinput/25589deb55c08429345f289d1c9b0254 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/25589deb55c08429345f289d1c9b0254 rename to lib/c-ares-1.32.0/test/fuzzinput/25589deb55c08429345f289d1c9b0254 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/2573bd823e4da11f727a17f8e1f35c26 b/lib/c-ares-1.32.0/test/fuzzinput/2573bd823e4da11f727a17f8e1f35c26 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/2573bd823e4da11f727a17f8e1f35c26 rename to lib/c-ares-1.32.0/test/fuzzinput/2573bd823e4da11f727a17f8e1f35c26 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/276f12da56866273e76059ad0e7be97e b/lib/c-ares-1.32.0/test/fuzzinput/276f12da56866273e76059ad0e7be97e similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/276f12da56866273e76059ad0e7be97e rename to lib/c-ares-1.32.0/test/fuzzinput/276f12da56866273e76059ad0e7be97e diff --git a/lib/c-ares-1.31.0/test/fuzzinput/29198a2e380cb19babec9e02116d213e b/lib/c-ares-1.32.0/test/fuzzinput/29198a2e380cb19babec9e02116d213e similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/29198a2e380cb19babec9e02116d213e rename to lib/c-ares-1.32.0/test/fuzzinput/29198a2e380cb19babec9e02116d213e diff --git a/lib/c-ares-1.31.0/test/fuzzinput/2c94ba9434b1a1b9396fc5364f101363 b/lib/c-ares-1.32.0/test/fuzzinput/2c94ba9434b1a1b9396fc5364f101363 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/2c94ba9434b1a1b9396fc5364f101363 rename to lib/c-ares-1.32.0/test/fuzzinput/2c94ba9434b1a1b9396fc5364f101363 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/2d578c357dc2f5e02dc55cddb30641d1 b/lib/c-ares-1.32.0/test/fuzzinput/2d578c357dc2f5e02dc55cddb30641d1 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/2d578c357dc2f5e02dc55cddb30641d1 rename to lib/c-ares-1.32.0/test/fuzzinput/2d578c357dc2f5e02dc55cddb30641d1 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/2dff6cc5a223e67fde9e5e79af456992 b/lib/c-ares-1.32.0/test/fuzzinput/2dff6cc5a223e67fde9e5e79af456992 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/2dff6cc5a223e67fde9e5e79af456992 rename to lib/c-ares-1.32.0/test/fuzzinput/2dff6cc5a223e67fde9e5e79af456992 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/2f103b1f9477f2d8934bd84328d51c75 b/lib/c-ares-1.32.0/test/fuzzinput/2f103b1f9477f2d8934bd84328d51c75 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/2f103b1f9477f2d8934bd84328d51c75 rename to lib/c-ares-1.32.0/test/fuzzinput/2f103b1f9477f2d8934bd84328d51c75 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/31cd3a8413de13d9624adbb1613784bf b/lib/c-ares-1.32.0/test/fuzzinput/31cd3a8413de13d9624adbb1613784bf similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/31cd3a8413de13d9624adbb1613784bf rename to lib/c-ares-1.32.0/test/fuzzinput/31cd3a8413de13d9624adbb1613784bf diff --git a/lib/c-ares-1.31.0/test/fuzzinput/36415bdf1d180098fe6234b4186e69f3 b/lib/c-ares-1.32.0/test/fuzzinput/36415bdf1d180098fe6234b4186e69f3 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/36415bdf1d180098fe6234b4186e69f3 rename to lib/c-ares-1.32.0/test/fuzzinput/36415bdf1d180098fe6234b4186e69f3 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/3a04a80f0242e8dff0cd732e7c4767da b/lib/c-ares-1.32.0/test/fuzzinput/3a04a80f0242e8dff0cd732e7c4767da similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/3a04a80f0242e8dff0cd732e7c4767da rename to lib/c-ares-1.32.0/test/fuzzinput/3a04a80f0242e8dff0cd732e7c4767da diff --git a/lib/c-ares-1.31.0/test/fuzzinput/44d0f973b7b0fb3e4a07770c943dcd5a b/lib/c-ares-1.32.0/test/fuzzinput/44d0f973b7b0fb3e4a07770c943dcd5a similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/44d0f973b7b0fb3e4a07770c943dcd5a rename to lib/c-ares-1.32.0/test/fuzzinput/44d0f973b7b0fb3e4a07770c943dcd5a diff --git a/lib/c-ares-1.31.0/test/fuzzinput/50bc00daa0ddcd6cfb2b5d9f62c81f47 b/lib/c-ares-1.32.0/test/fuzzinput/50bc00daa0ddcd6cfb2b5d9f62c81f47 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/50bc00daa0ddcd6cfb2b5d9f62c81f47 rename to lib/c-ares-1.32.0/test/fuzzinput/50bc00daa0ddcd6cfb2b5d9f62c81f47 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/51ed2d1fb77b3078b54e94e85606b7df b/lib/c-ares-1.32.0/test/fuzzinput/51ed2d1fb77b3078b54e94e85606b7df similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/51ed2d1fb77b3078b54e94e85606b7df rename to lib/c-ares-1.32.0/test/fuzzinput/51ed2d1fb77b3078b54e94e85606b7df diff --git a/lib/c-ares-1.31.0/test/fuzzinput/5c5e0e899cf2e7d053a9e45fb76f6e5a b/lib/c-ares-1.32.0/test/fuzzinput/5c5e0e899cf2e7d053a9e45fb76f6e5a similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/5c5e0e899cf2e7d053a9e45fb76f6e5a rename to lib/c-ares-1.32.0/test/fuzzinput/5c5e0e899cf2e7d053a9e45fb76f6e5a diff --git a/lib/c-ares-1.31.0/test/fuzzinput/70152ed033f139443fbfb1b858bb3b1b b/lib/c-ares-1.32.0/test/fuzzinput/70152ed033f139443fbfb1b858bb3b1b similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/70152ed033f139443fbfb1b858bb3b1b rename to lib/c-ares-1.32.0/test/fuzzinput/70152ed033f139443fbfb1b858bb3b1b diff --git a/lib/c-ares-1.31.0/test/fuzzinput/7030ca2b24e5a7f9dd8f62096a48eb33 b/lib/c-ares-1.32.0/test/fuzzinput/7030ca2b24e5a7f9dd8f62096a48eb33 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/7030ca2b24e5a7f9dd8f62096a48eb33 rename to lib/c-ares-1.32.0/test/fuzzinput/7030ca2b24e5a7f9dd8f62096a48eb33 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/71eec1a0ef2d25bb9e2ef17f23be7e9e b/lib/c-ares-1.32.0/test/fuzzinput/71eec1a0ef2d25bb9e2ef17f23be7e9e similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/71eec1a0ef2d25bb9e2ef17f23be7e9e rename to lib/c-ares-1.32.0/test/fuzzinput/71eec1a0ef2d25bb9e2ef17f23be7e9e diff --git a/lib/c-ares-1.31.0/test/fuzzinput/7a6b0177210ea4ef40b254daf99393c5 b/lib/c-ares-1.32.0/test/fuzzinput/7a6b0177210ea4ef40b254daf99393c5 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/7a6b0177210ea4ef40b254daf99393c5 rename to lib/c-ares-1.32.0/test/fuzzinput/7a6b0177210ea4ef40b254daf99393c5 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/7f1567733711ffb61839621af0cbfa33 b/lib/c-ares-1.32.0/test/fuzzinput/7f1567733711ffb61839621af0cbfa33 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/7f1567733711ffb61839621af0cbfa33 rename to lib/c-ares-1.32.0/test/fuzzinput/7f1567733711ffb61839621af0cbfa33 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/850c6d57c5bb7be8205fc2438d14d7e5 b/lib/c-ares-1.32.0/test/fuzzinput/850c6d57c5bb7be8205fc2438d14d7e5 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/850c6d57c5bb7be8205fc2438d14d7e5 rename to lib/c-ares-1.32.0/test/fuzzinput/850c6d57c5bb7be8205fc2438d14d7e5 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/a5c8cd2784a5792b9e91c2d7895b3b34 b/lib/c-ares-1.32.0/test/fuzzinput/a5c8cd2784a5792b9e91c2d7895b3b34 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/a5c8cd2784a5792b9e91c2d7895b3b34 rename to lib/c-ares-1.32.0/test/fuzzinput/a5c8cd2784a5792b9e91c2d7895b3b34 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/a9135cdc7151d023300ff194bad90af9 b/lib/c-ares-1.32.0/test/fuzzinput/a9135cdc7151d023300ff194bad90af9 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/a9135cdc7151d023300ff194bad90af9 rename to lib/c-ares-1.32.0/test/fuzzinput/a9135cdc7151d023300ff194bad90af9 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/af2597e8ac7dec1e8b4a47518312912a b/lib/c-ares-1.32.0/test/fuzzinput/af2597e8ac7dec1e8b4a47518312912a similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/af2597e8ac7dec1e8b4a47518312912a rename to lib/c-ares-1.32.0/test/fuzzinput/af2597e8ac7dec1e8b4a47518312912a diff --git a/lib/c-ares-1.31.0/test/fuzzinput/answer_a b/lib/c-ares-1.32.0/test/fuzzinput/answer_a similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/answer_a rename to lib/c-ares-1.32.0/test/fuzzinput/answer_a diff --git a/lib/c-ares-1.31.0/test/fuzzinput/answer_aaaa b/lib/c-ares-1.32.0/test/fuzzinput/answer_aaaa similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/answer_aaaa rename to lib/c-ares-1.32.0/test/fuzzinput/answer_aaaa diff --git a/lib/c-ares-1.31.0/test/fuzzinput/b3f53ef826b831bb09dd25c7f5960249 b/lib/c-ares-1.32.0/test/fuzzinput/b3f53ef826b831bb09dd25c7f5960249 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/b3f53ef826b831bb09dd25c7f5960249 rename to lib/c-ares-1.32.0/test/fuzzinput/b3f53ef826b831bb09dd25c7f5960249 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/cda0f8751f5c4993974c2b549d29bcc8 b/lib/c-ares-1.32.0/test/fuzzinput/cda0f8751f5c4993974c2b549d29bcc8 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/cda0f8751f5c4993974c2b549d29bcc8 rename to lib/c-ares-1.32.0/test/fuzzinput/cda0f8751f5c4993974c2b549d29bcc8 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/ce6c26c0e469339873d0e7f616ab0945 b/lib/c-ares-1.32.0/test/fuzzinput/ce6c26c0e469339873d0e7f616ab0945 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/ce6c26c0e469339873d0e7f616ab0945 rename to lib/c-ares-1.32.0/test/fuzzinput/ce6c26c0e469339873d0e7f616ab0945 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/clusterfuzz-5637790584012800 b/lib/c-ares-1.32.0/test/fuzzinput/clusterfuzz-5637790584012800 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/clusterfuzz-5637790584012800 rename to lib/c-ares-1.32.0/test/fuzzinput/clusterfuzz-5637790584012800 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/clusterfuzz-5650695891451904 b/lib/c-ares-1.32.0/test/fuzzinput/clusterfuzz-5650695891451904 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/clusterfuzz-5650695891451904 rename to lib/c-ares-1.32.0/test/fuzzinput/clusterfuzz-5650695891451904 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/clusterfuzz-5651369832218624 b/lib/c-ares-1.32.0/test/fuzzinput/clusterfuzz-5651369832218624 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/clusterfuzz-5651369832218624 rename to lib/c-ares-1.32.0/test/fuzzinput/clusterfuzz-5651369832218624 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/clusterfuzz-5674462260756480 b/lib/c-ares-1.32.0/test/fuzzinput/clusterfuzz-5674462260756480 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/clusterfuzz-5674462260756480 rename to lib/c-ares-1.32.0/test/fuzzinput/clusterfuzz-5674462260756480 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/clusterfuzz-5680630672654336 b/lib/c-ares-1.32.0/test/fuzzinput/clusterfuzz-5680630672654336 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/clusterfuzz-5680630672654336 rename to lib/c-ares-1.32.0/test/fuzzinput/clusterfuzz-5680630672654336 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/clusterfuzz-5683497160671232 b/lib/c-ares-1.32.0/test/fuzzinput/clusterfuzz-5683497160671232 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/clusterfuzz-5683497160671232 rename to lib/c-ares-1.32.0/test/fuzzinput/clusterfuzz-5683497160671232 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/clusterfuzz-5687310655422464 b/lib/c-ares-1.32.0/test/fuzzinput/clusterfuzz-5687310655422464 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/clusterfuzz-5687310655422464 rename to lib/c-ares-1.32.0/test/fuzzinput/clusterfuzz-5687310655422464 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/clusterfuzz-5695341573177344 b/lib/c-ares-1.32.0/test/fuzzinput/clusterfuzz-5695341573177344 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/clusterfuzz-5695341573177344 rename to lib/c-ares-1.32.0/test/fuzzinput/clusterfuzz-5695341573177344 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/clusterfuzz-5697835103682560 b/lib/c-ares-1.32.0/test/fuzzinput/clusterfuzz-5697835103682560 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/clusterfuzz-5697835103682560 rename to lib/c-ares-1.32.0/test/fuzzinput/clusterfuzz-5697835103682560 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/clusterfuzz-5728518081609728 b/lib/c-ares-1.32.0/test/fuzzinput/clusterfuzz-5728518081609728 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/clusterfuzz-5728518081609728 rename to lib/c-ares-1.32.0/test/fuzzinput/clusterfuzz-5728518081609728 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/clusterfuzz-5732960017317888 b/lib/c-ares-1.32.0/test/fuzzinput/clusterfuzz-5732960017317888 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/clusterfuzz-5732960017317888 rename to lib/c-ares-1.32.0/test/fuzzinput/clusterfuzz-5732960017317888 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/e4dd7e7c2dd4ed7c2e17a6af5d04f9c9 b/lib/c-ares-1.32.0/test/fuzzinput/e4dd7e7c2dd4ed7c2e17a6af5d04f9c9 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/e4dd7e7c2dd4ed7c2e17a6af5d04f9c9 rename to lib/c-ares-1.32.0/test/fuzzinput/e4dd7e7c2dd4ed7c2e17a6af5d04f9c9 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/ed50ed8ee36230a5a69746ad830437e5 b/lib/c-ares-1.32.0/test/fuzzinput/ed50ed8ee36230a5a69746ad830437e5 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/ed50ed8ee36230a5a69746ad830437e5 rename to lib/c-ares-1.32.0/test/fuzzinput/ed50ed8ee36230a5a69746ad830437e5 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/f1b900d50806021953321c3b604ee497 b/lib/c-ares-1.32.0/test/fuzzinput/f1b900d50806021953321c3b604ee497 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/f1b900d50806021953321c3b604ee497 rename to lib/c-ares-1.32.0/test/fuzzinput/f1b900d50806021953321c3b604ee497 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/f6606f624be8c628328cea01d2cd07a9 b/lib/c-ares-1.32.0/test/fuzzinput/f6606f624be8c628328cea01d2cd07a9 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/f6606f624be8c628328cea01d2cd07a9 rename to lib/c-ares-1.32.0/test/fuzzinput/f6606f624be8c628328cea01d2cd07a9 diff --git a/lib/c-ares-1.31.0/test/fuzzinput/f89f6c8176b564a7dd646f14305573ce b/lib/c-ares-1.32.0/test/fuzzinput/f89f6c8176b564a7dd646f14305573ce similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/f89f6c8176b564a7dd646f14305573ce rename to lib/c-ares-1.32.0/test/fuzzinput/f89f6c8176b564a7dd646f14305573ce diff --git a/lib/c-ares-1.31.0/test/fuzzinput/f9ad508d2dbd08d3aaaabc7d1174677d b/lib/c-ares-1.32.0/test/fuzzinput/f9ad508d2dbd08d3aaaabc7d1174677d similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/f9ad508d2dbd08d3aaaabc7d1174677d rename to lib/c-ares-1.32.0/test/fuzzinput/f9ad508d2dbd08d3aaaabc7d1174677d diff --git a/lib/c-ares-1.31.0/test/fuzzinput/multi-indir b/lib/c-ares-1.32.0/test/fuzzinput/multi-indir similarity index 100% rename from lib/c-ares-1.31.0/test/fuzzinput/multi-indir rename to lib/c-ares-1.32.0/test/fuzzinput/multi-indir diff --git a/lib/c-ares-1.31.0/test/fuzznames/name01 b/lib/c-ares-1.32.0/test/fuzznames/name01 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzznames/name01 rename to lib/c-ares-1.32.0/test/fuzznames/name01 diff --git a/lib/c-ares-1.31.0/test/fuzznames/name02 b/lib/c-ares-1.32.0/test/fuzznames/name02 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzznames/name02 rename to lib/c-ares-1.32.0/test/fuzznames/name02 diff --git a/lib/c-ares-1.31.0/test/fuzznames/name03 b/lib/c-ares-1.32.0/test/fuzznames/name03 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzznames/name03 rename to lib/c-ares-1.32.0/test/fuzznames/name03 diff --git a/lib/c-ares-1.31.0/test/fuzznames/name04 b/lib/c-ares-1.32.0/test/fuzznames/name04 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzznames/name04 rename to lib/c-ares-1.32.0/test/fuzznames/name04 diff --git a/lib/c-ares-1.31.0/test/fuzznames/name05 b/lib/c-ares-1.32.0/test/fuzznames/name05 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzznames/name05 rename to lib/c-ares-1.32.0/test/fuzznames/name05 diff --git a/lib/c-ares-1.31.0/test/fuzznames/name06 b/lib/c-ares-1.32.0/test/fuzznames/name06 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzznames/name06 rename to lib/c-ares-1.32.0/test/fuzznames/name06 diff --git a/lib/c-ares-1.31.0/test/fuzznames/name07 b/lib/c-ares-1.32.0/test/fuzznames/name07 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzznames/name07 rename to lib/c-ares-1.32.0/test/fuzznames/name07 diff --git a/lib/c-ares-1.31.0/test/fuzznames/name08 b/lib/c-ares-1.32.0/test/fuzznames/name08 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzznames/name08 rename to lib/c-ares-1.32.0/test/fuzznames/name08 diff --git a/lib/c-ares-1.31.0/test/fuzznames/name09 b/lib/c-ares-1.32.0/test/fuzznames/name09 similarity index 100% rename from lib/c-ares-1.31.0/test/fuzznames/name09 rename to lib/c-ares-1.32.0/test/fuzznames/name09