From b39fad6052b17b5c211c675111da0a6846134c3a Mon Sep 17 00:00:00 2001 From: "Node.js GitHub Bot" Date: Mon, 26 Aug 2024 20:54:35 -0400 Subject: [PATCH] deps: update c-ares to v1.33.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/54549 Reviewed-By: Luigi Pinca Reviewed-By: Michaƫl Zasso Reviewed-By: Mohammed Keyvanzadeh Reviewed-By: James M Snell Reviewed-By: Marco Ippolito Reviewed-By: Rafael Gonzaga --- deps/cares/CMakeLists.txt | 15 +- deps/cares/Makefile.in | 2 + deps/cares/RELEASE-NOTES.md | 32 + deps/cares/aminclude_static.am | 2 +- deps/cares/configure | 562 ++++++++++-------- deps/cares/configure.ac | 12 +- deps/cares/docs/Makefile.in | 2 + deps/cares/include/Makefile.in | 2 + deps/cares/include/ares_version.h | 4 +- deps/cares/libcares.pc.cmake | 7 +- deps/cares/src/Makefile.in | 2 + deps/cares/src/lib/Makefile.in | 4 +- deps/cares/src/lib/ares__close_sockets.c | 2 +- deps/cares/src/lib/ares__socket.c | 2 +- deps/cares/src/lib/ares_android.c | 3 +- deps/cares/src/lib/ares_cookie.c | 3 +- deps/cares/src/lib/ares_getaddrinfo.c | 7 + deps/cares/src/lib/ares_metrics.c | 2 +- deps/cares/src/lib/ares_private.h | 12 +- deps/cares/src/lib/ares_process.c | 21 +- deps/cares/src/lib/ares_qcache.c | 12 +- deps/cares/src/lib/ares_search.c | 72 ++- deps/cares/src/lib/ares_send.c | 6 +- deps/cares/src/lib/ares_sysconfig.c | 3 +- deps/cares/src/lib/dsa/ares__htable.c | 2 +- .../src/lib/event/ares_event_configchg.c | 5 +- deps/cares/src/lib/str/ares__buf.c | 6 +- deps/cares/src/tools/Makefile.in | 2 + 28 files changed, 495 insertions(+), 311 deletions(-) diff --git a/deps/cares/CMakeLists.txt b/deps/cares/CMakeLists.txt index d3f6907564868e..9862406495f4fa 100644 --- a/deps/cares/CMakeLists.txt +++ b/deps/cares/CMakeLists.txt @@ -12,7 +12,7 @@ INCLUDE (CheckCSourceCompiles) INCLUDE (CheckStructHasMember) INCLUDE (CheckLibraryExists) -PROJECT (c-ares LANGUAGES C VERSION "1.33.0" ) +PROJECT (c-ares LANGUAGES C VERSION "1.33.1" ) # 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 "20:0:18") +SET (CARES_LIB_VERSIONINFO "20:1:18") OPTION (CARES_STATIC "Build as a static library" OFF) @@ -772,12 +772,11 @@ IF (CARES_INSTALL) INSTALL (EXPORT ${PROJECT_NAME}-targets COMPONENT Devel DESTINATION ${CMAKECONFIG_INSTALL_DIR} NAMESPACE ${PROJECT_NAME}::) INSTALL (FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake" COMPONENT Devel DESTINATION ${CMAKECONFIG_INSTALL_DIR}) - # pkgconfig support - IF (NOT CARES_SHARED) - FOREACH (LIB ${CARES_DEPENDENT_LIBS}) - SET (CARES_PRIVATE_LIBS "${CARES_PRIVATE_LIBS} -l${LIB}") - ENDFOREACH () - ENDIF () + # pkgconfig support for static builds + FOREACH (LIB ${CARES_DEPENDENT_LIBS}) + SET (CARES_PRIVATE_LIBS "${CARES_PRIVATE_LIBS} -l${LIB}") + ENDFOREACH () + CONFIGURE_FILE("libcares.pc.cmake" "libcares.pc" @ONLY) INSTALL (FILES "${CMAKE_CURRENT_BINARY_DIR}/libcares.pc" COMPONENT Devel DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") ENDIF () diff --git a/deps/cares/Makefile.in b/deps/cares/Makefile.in index 4feaae7267c0fc..706dafdbdfc5fa 100644 --- a/deps/cares/Makefile.in +++ b/deps/cares/Makefile.in @@ -328,6 +328,8 @@ FGREP = @FGREP@ FILECMD = @FILECMD@ GCOV = @GCOV@ GENHTML = @GENHTML@ +GMOCK112_CFLAGS = @GMOCK112_CFLAGS@ +GMOCK112_LIBS = @GMOCK112_LIBS@ GMOCK_CFLAGS = @GMOCK_CFLAGS@ GMOCK_LIBS = @GMOCK_LIBS@ GREP = @GREP@ diff --git a/deps/cares/RELEASE-NOTES.md b/deps/cares/RELEASE-NOTES.md index b072feb29fdebe..e9c04953dc6022 100644 --- a/deps/cares/RELEASE-NOTES.md +++ b/deps/cares/RELEASE-NOTES.md @@ -1,3 +1,35 @@ +## c-ares version 1.33.1 - August 23 2024 + +This is a bugfix release. + +Bugfixes: +* Work around systemd-resolved quirk that returns unexpected codes for single + label names. Also adds test cases to validate the work around works and + will continue to work in future releases. + [PR #863](https://github.com/c-ares/c-ares/pull/863), + See Also https://github.com/systemd/systemd/issues/34101 +* Fix sysconfig ndots default value, also adds containerized test case to + prevent future regressions. + [PR #862](https://github.com/c-ares/c-ares/pull/862) +* Fix blank DNS name returning error code rather than valid record for + commands like: `adig -t SOA .`. Also adds test case to prevent future + regressions. + [9e574af](https://github.com/c-ares/c-ares/commit/9e574af) +* Fix calculation of query times > 1s. + [2b2eae7](https://github.com/c-ares/c-ares/commit/2b2eae7) +* Fix building on old Linux releases that don't have `TCP_FASTOPEN_CONNECT`. + [b7a89b9](https://github.com/c-ares/c-ares/commit/b7a89b9) +* Fix minor Android build warnings. + [PR #848](https://github.com/c-ares/c-ares/pull/848) + +Thanks go to these friendly people for their efforts and contributions for this +release: +* Brad House (@bradh352) +* Erik Lax (@eriklax) +* Hans-Christian Egtvedt (@egtvedt) +* Mikael Lindemann (@mikaellindemann) +* Nodar Chkuaselidze (@nodech) + ## c-ares version 1.33.0 - August 2 2024 This is a feature and bugfix release. diff --git a/deps/cares/aminclude_static.am b/deps/cares/aminclude_static.am index 436bfe5a5be5d1..538a810c9eb0ee 100644 --- a/deps/cares/aminclude_static.am +++ b/deps/cares/aminclude_static.am @@ -1,6 +1,6 @@ # aminclude_static.am generated automatically by Autoconf -# from AX_AM_MACROS_STATIC on Fri Aug 2 08:48:39 EDT 2024 +# from AX_AM_MACROS_STATIC on Fri Aug 23 09:37:25 EDT 2024 # Code coverage diff --git a/deps/cares/configure b/deps/cares/configure index d9dad13dd30287..74e9741fe6ee7a 100755 --- a/deps/cares/configure +++ b/deps/cares/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.33.0. +# Generated by GNU Autoconf 2.72 for c-ares 1.33.1. # # Report bugs to . # @@ -614,8 +614,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='c-ares' PACKAGE_TARNAME='c-ares' -PACKAGE_VERSION='1.33.0' -PACKAGE_STRING='c-ares 1.33.0' +PACKAGE_VERSION='1.33.1' +PACKAGE_STRING='c-ares 1.33.1' PACKAGE_BUGREPORT='c-ares mailing list: http://lists.haxx.se/listinfo/c-ares' PACKAGE_URL='' @@ -663,6 +663,8 @@ AM_CPPFLAGS AM_CFLAGS BUILD_TESTS_FALSE BUILD_TESTS_TRUE +GMOCK112_LIBS +GMOCK112_CFLAGS GMOCK_LIBS GMOCK_CFLAGS PKG_CONFIG_LIBDIR @@ -868,7 +870,9 @@ PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR GMOCK_CFLAGS -GMOCK_LIBS' +GMOCK_LIBS +GMOCK112_CFLAGS +GMOCK112_LIBS' # Initialize some variables set by options. @@ -1417,7 +1421,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.33.0 to adapt to many kinds of systems. +'configure' configures c-ares 1.33.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1488,7 +1492,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of c-ares 1.33.0:";; + short | recursive ) echo "Configuration of c-ares 1.33.1:";; esac cat <<\_ACEOF @@ -1557,6 +1561,10 @@ Some influential environment variables: GMOCK_CFLAGS C compiler flags for GMOCK, overriding pkg-config GMOCK_LIBS linker flags for GMOCK, overriding pkg-config + GMOCK112_CFLAGS + C compiler flags for GMOCK112, overriding pkg-config + GMOCK112_LIBS + linker flags for GMOCK112, overriding pkg-config Use these variables to override the choices made by 'configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -1625,7 +1633,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -c-ares configure 1.33.0 +c-ares configure 1.33.1 generated by GNU Autoconf 2.72 Copyright (C) 2023 Free Software Foundation, Inc. @@ -1953,50 +1961,6 @@ fi } # ac_fn_cxx_try_link -# ac_fn_c_try_run LINENO -# ---------------------- -# Try to run conftest.$ac_ext, and return whether this succeeded. Assumes that -# executables *can* be run. -ac_fn_c_try_run () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; } -then : - ac_retval=0 -else case e in #( - e) printf "%s\n" "$as_me: program exited with status $ac_status" >&5 - printf "%s\n" "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=$ac_status ;; -esac -fi - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_run - # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. @@ -2245,6 +2209,50 @@ printf "%s\n" "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_member + +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to run conftest.$ac_ext, and return whether this succeeded. Assumes that +# executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } +then : + ac_retval=0 +else case e in #( + e) printf "%s\n" "$as_me: program exited with status $ac_status" >&5 + printf "%s\n" "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status ;; +esac +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run ac_configure_args_raw= for ac_arg do @@ -2269,7 +2277,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.33.0, which was +It was created by c-ares $as_me 1.33.1, which was generated by GNU Autoconf 2.72. Invocation command line was $ $0$ac_configure_args_raw @@ -3261,7 +3269,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu -CARES_VERSION_INFO="20:0:18" +CARES_VERSION_INFO="20:1:18" @@ -6182,7 +6190,7 @@ fi # Define the identity of the package. PACKAGE='c-ares' - VERSION='1.33.0' + VERSION='1.33.1' printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h @@ -20044,190 +20052,6 @@ fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether user namespaces are supported" >&5 -printf %s "checking whether user namespaces are supported... " >&6; } -if test ${ax_cv_user_namespace+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - if test "$cross_compiling" = yes -then : - ax_cv_user_namespace=no -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include - -int userfn(void *d) { - usleep(100000); /* synchronize by sleep */ - return (getuid() != 0); -} -char userst[1024*1024]; -int main() { - char buffer[1024]; - int rc, status, fd; - pid_t child = clone(userfn, userst + 1024*1024, CLONE_NEWUSER|SIGCHLD, 0); - if (child < 0) return 1; - - snprintf(buffer, sizeof(buffer), "/proc/%d/uid_map", child); - fd = open(buffer, O_CREAT|O_WRONLY|O_TRUNC, 0755); - snprintf(buffer, sizeof(buffer), "0 %d 1\n", getuid()); - write(fd, buffer, strlen(buffer)); - close(fd); - - rc = waitpid(child, &status, 0); - if (rc <= 0) return 1; - if (!WIFEXITED(status)) return 1; - return WEXITSTATUS(status); -} - -_ACEOF -if ac_fn_c_try_run "$LINENO" -then : - ax_cv_user_namespace=yes -else case e in #( - e) ax_cv_user_namespace=no ;; -esac -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext ;; -esac -fi - - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_user_namespace" >&5 -printf "%s\n" "$ax_cv_user_namespace" >&6; } - if test "$ax_cv_user_namespace" = yes; then - -printf "%s\n" "#define HAVE_USER_NAMESPACE 1" >>confdefs.h - - fi - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether UTS namespaces are supported" >&5 -printf %s "checking whether UTS namespaces are supported... " >&6; } -if test ${ax_cv_uts_namespace+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - if test "$cross_compiling" = yes -then : - ax_cv_uts_namespace=no -else case e in #( - e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include -#include - -int utsfn(void *d) { - char buffer[1024]; - const char *name = "autoconftest"; - int rc = sethostname(name, strlen(name)); - if (rc != 0) return 1; - gethostname(buffer, 1024); - return (strcmp(buffer, name) != 0); -} - -char st2[1024*1024]; -int fn(void *d) { - pid_t child; - int rc, status; - usleep(100000); /* synchronize by sleep */ - if (getuid() != 0) return 1; - child = clone(utsfn, st2 + 1024*1024, CLONE_NEWUTS|SIGCHLD, 0); - if (child < 0) return 1; - rc = waitpid(child, &status, 0); - if (rc <= 0) return 1; - if (!WIFEXITED(status)) return 1; - return WEXITSTATUS(status); -} -char st[1024*1024]; -int main() { - char buffer[1024]; - int rc, status, fd; - pid_t child = clone(fn, st + 1024*1024, CLONE_NEWUSER|SIGCHLD, 0); - if (child < 0) return 1; - - snprintf(buffer, sizeof(buffer), "/proc/%d/uid_map", child); - fd = open(buffer, O_CREAT|O_WRONLY|O_TRUNC, 0755); - snprintf(buffer, sizeof(buffer), "0 %d 1\n", getuid()); - write(fd, buffer, strlen(buffer)); - close(fd); - - rc = waitpid(child, &status, 0); - if (rc <= 0) return 1; - if (!WIFEXITED(status)) return 1; - return WEXITSTATUS(status); -} - - -_ACEOF -if ac_fn_c_try_run "$LINENO" -then : - ax_cv_uts_namespace=yes -else case e in #( - e) ax_cv_uts_namespace=no ;; -esac -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext ;; -esac -fi - - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_uts_namespace" >&5 -printf "%s\n" "$ax_cv_uts_namespace" >&6; } - if test "$ax_cv_uts_namespace" = yes; then - -printf "%s\n" "#define HAVE_UTS_NAMESPACE 1" >>confdefs.h - - fi - # Check whether --enable-largefile was given. if test ${enable_largefile+y} then : @@ -24753,6 +24577,264 @@ printf "%s\n" "$as_me: WARNING: gmock could not be found, not building tests" >& else as_fn_error $? "tests require gmock" "$LINENO" 5 fi + else + +pkg_failed=no +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gmock >= 1.12.0" >&5 +printf %s "checking for gmock >= 1.12.0... " >&6; } + +if test -n "$GMOCK112_CFLAGS"; then + pkg_cv_GMOCK112_CFLAGS="$GMOCK112_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gmock >= 1.12.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gmock >= 1.12.0") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_GMOCK112_CFLAGS=`$PKG_CONFIG --cflags "gmock >= 1.12.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$GMOCK112_LIBS"; then + pkg_cv_GMOCK112_LIBS="$GMOCK112_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gmock >= 1.12.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gmock >= 1.12.0") 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_GMOCK112_LIBS=`$PKG_CONFIG --libs "gmock >= 1.12.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + GMOCK112_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "gmock >= 1.12.0" 2>&1` + else + GMOCK112_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "gmock >= 1.12.0" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$GMOCK112_PKG_ERRORS" >&5 + + have_gmock_v112=no +elif test $pkg_failed = untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + have_gmock_v112=no +else + GMOCK112_CFLAGS=$pkg_cv_GMOCK112_CFLAGS + GMOCK112_LIBS=$pkg_cv_GMOCK112_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + have_gmock_v112=yes +fi + if test "x$have_gmock_v112" = "xyes" ; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether user namespaces are supported" >&5 +printf %s "checking whether user namespaces are supported... " >&6; } +if test ${ax_cv_user_namespace+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + if test "$cross_compiling" = yes +then : + ax_cv_user_namespace=no +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include + +int userfn(void *d) { + usleep(100000); /* synchronize by sleep */ + return (getuid() != 0); +} +char userst[1024*1024]; +int main() { + char buffer[1024]; + int rc, status, fd; + pid_t child = clone(userfn, userst + 1024*1024, CLONE_NEWUSER|SIGCHLD, 0); + if (child < 0) return 1; + + snprintf(buffer, sizeof(buffer), "/proc/%d/uid_map", child); + fd = open(buffer, O_CREAT|O_WRONLY|O_TRUNC, 0755); + snprintf(buffer, sizeof(buffer), "0 %d 1\n", getuid()); + write(fd, buffer, strlen(buffer)); + close(fd); + + rc = waitpid(child, &status, 0); + if (rc <= 0) return 1; + if (!WIFEXITED(status)) return 1; + return WEXITSTATUS(status); +} + +_ACEOF +if ac_fn_c_try_run "$LINENO" +then : + ax_cv_user_namespace=yes +else case e in #( + e) ax_cv_user_namespace=no ;; +esac +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac +fi + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_user_namespace" >&5 +printf "%s\n" "$ax_cv_user_namespace" >&6; } + if test "$ax_cv_user_namespace" = yes; then + +printf "%s\n" "#define HAVE_USER_NAMESPACE 1" >>confdefs.h + + fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether UTS namespaces are supported" >&5 +printf %s "checking whether UTS namespaces are supported... " >&6; } +if test ${ax_cv_uts_namespace+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + if test "$cross_compiling" = yes +then : + ax_cv_uts_namespace=no +else case e in #( + e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include + +int utsfn(void *d) { + char buffer[1024]; + const char *name = "autoconftest"; + int rc = sethostname(name, strlen(name)); + if (rc != 0) return 1; + gethostname(buffer, 1024); + return (strcmp(buffer, name) != 0); +} + +char st2[1024*1024]; +int fn(void *d) { + pid_t child; + int rc, status; + usleep(100000); /* synchronize by sleep */ + if (getuid() != 0) return 1; + child = clone(utsfn, st2 + 1024*1024, CLONE_NEWUTS|SIGCHLD, 0); + if (child < 0) return 1; + rc = waitpid(child, &status, 0); + if (rc <= 0) return 1; + if (!WIFEXITED(status)) return 1; + return WEXITSTATUS(status); +} +char st[1024*1024]; +int main() { + char buffer[1024]; + int rc, status, fd; + pid_t child = clone(fn, st + 1024*1024, CLONE_NEWUSER|SIGCHLD, 0); + if (child < 0) return 1; + + snprintf(buffer, sizeof(buffer), "/proc/%d/uid_map", child); + fd = open(buffer, O_CREAT|O_WRONLY|O_TRUNC, 0755); + snprintf(buffer, sizeof(buffer), "0 %d 1\n", getuid()); + write(fd, buffer, strlen(buffer)); + close(fd); + + rc = waitpid(child, &status, 0); + if (rc <= 0) return 1; + if (!WIFEXITED(status)) return 1; + return WEXITSTATUS(status); +} + + +_ACEOF +if ac_fn_c_try_run "$LINENO" +then : + ax_cv_uts_namespace=yes +else case e in #( + e) ax_cv_uts_namespace=no ;; +esac +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext ;; +esac +fi + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_uts_namespace" >&5 +printf "%s\n" "$ax_cv_uts_namespace" >&6; } + if test "$ax_cv_uts_namespace" = yes; then + +printf "%s\n" "#define HAVE_UTS_NAMESPACE 1" >>confdefs.h + + fi + + fi fi fi if test "x$build_tests" != "xno" ; then @@ -26629,7 +26711,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.33.0, which was +This file was extended by c-ares $as_me 1.33.1, which was generated by GNU Autoconf 2.72. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -26697,7 +26779,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.33.0 +c-ares config.status 1.33.1 configured by $0, generated by GNU Autoconf 2.72, with options \\"\$ac_cs_config\\" diff --git a/deps/cares/configure.ac b/deps/cares/configure.ac index be891e40621ffd..59fd975b64f873 100644 --- a/deps/cares/configure.ac +++ b/deps/cares/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.33.0], +AC_INIT([c-ares], [1.33.1], [c-ares mailing list: http://lists.haxx.se/listinfo/c-ares]) -CARES_VERSION_INFO="20:0:18" +CARES_VERSION_INFO="20:1:18" 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. @@ -153,8 +153,6 @@ _EOF ]) AX_CODE_COVERAGE -AX_CHECK_USER_NAMESPACE -AX_CHECK_UTS_NAMESPACE AC_SYS_LARGEFILE case $host_os in @@ -819,6 +817,12 @@ if test "x$build_tests" != "xno" ; then else AC_MSG_ERROR([tests require gmock]) fi + else + PKG_CHECK_MODULES([GMOCK112], [gmock >= 1.12.0], [ have_gmock_v112=yes ], [ have_gmock_v112=no ]) + if test "x$have_gmock_v112" = "xyes" ; then + AX_CHECK_USER_NAMESPACE + AX_CHECK_UTS_NAMESPACE + fi fi fi if test "x$build_tests" != "xno" ; then diff --git a/deps/cares/docs/Makefile.in b/deps/cares/docs/Makefile.in index 155ab9d3017e5b..a57cd0abc18846 100644 --- a/deps/cares/docs/Makefile.in +++ b/deps/cares/docs/Makefile.in @@ -227,6 +227,8 @@ FGREP = @FGREP@ FILECMD = @FILECMD@ GCOV = @GCOV@ GENHTML = @GENHTML@ +GMOCK112_CFLAGS = @GMOCK112_CFLAGS@ +GMOCK112_LIBS = @GMOCK112_LIBS@ GMOCK_CFLAGS = @GMOCK_CFLAGS@ GMOCK_LIBS = @GMOCK_LIBS@ GREP = @GREP@ diff --git a/deps/cares/include/Makefile.in b/deps/cares/include/Makefile.in index 2960e5a55237c4..99936f8649748f 100644 --- a/deps/cares/include/Makefile.in +++ b/deps/cares/include/Makefile.in @@ -238,6 +238,8 @@ FGREP = @FGREP@ FILECMD = @FILECMD@ GCOV = @GCOV@ GENHTML = @GENHTML@ +GMOCK112_CFLAGS = @GMOCK112_CFLAGS@ +GMOCK112_LIBS = @GMOCK112_LIBS@ GMOCK_CFLAGS = @GMOCK_CFLAGS@ GMOCK_LIBS = @GMOCK_LIBS@ GREP = @GREP@ diff --git a/deps/cares/include/ares_version.h b/deps/cares/include/ares_version.h index fef66b739791be..c910d79209a3fb 100644 --- a/deps/cares/include/ares_version.h +++ b/deps/cares/include/ares_version.h @@ -32,11 +32,11 @@ #define ARES_VERSION_MAJOR 1 #define ARES_VERSION_MINOR 33 -#define ARES_VERSION_PATCH 0 +#define ARES_VERSION_PATCH 1 #define ARES_VERSION \ ((ARES_VERSION_MAJOR << 16) | (ARES_VERSION_MINOR << 8) | \ (ARES_VERSION_PATCH)) -#define ARES_VERSION_STR "1.33.0" +#define ARES_VERSION_STR "1.33.1" #define CARES_HAVE_ARES_LIBRARY_INIT 1 #define CARES_HAVE_ARES_LIBRARY_CLEANUP 1 diff --git a/deps/cares/libcares.pc.cmake b/deps/cares/libcares.pc.cmake index 74e4d0cf445978..257255d84d5ce9 100644 --- a/deps/cares/libcares.pc.cmake +++ b/deps/cares/libcares.pc.cmake @@ -7,9 +7,9 @@ # Copyright (C) The c-ares project and its contributors # SPDX-License-Identifier: MIT prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=@CMAKE_INSTALL_FULL_BINDIR@ -libdir=@CMAKE_INSTALL_FULL_LIBDIR@ -includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ +exec_prefix=${prefix}/@CMAKE_INSTALL_BINDIR@ +libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ Name: c-ares URL: https://c-ares.org/ @@ -18,5 +18,6 @@ Version: @CARES_VERSION@ Requires: Requires.private: Cflags: -I${includedir} +Cflags.private: -DCARES_STATICLIB Libs: -L${libdir} -lcares Libs.private: @CARES_PRIVATE_LIBS@ diff --git a/deps/cares/src/Makefile.in b/deps/cares/src/Makefile.in index 45558374c870ad..3ad8a92a6a4f15 100644 --- a/deps/cares/src/Makefile.in +++ b/deps/cares/src/Makefile.in @@ -250,6 +250,8 @@ FGREP = @FGREP@ FILECMD = @FILECMD@ GCOV = @GCOV@ GENHTML = @GENHTML@ +GMOCK112_CFLAGS = @GMOCK112_CFLAGS@ +GMOCK112_LIBS = @GMOCK112_LIBS@ GMOCK_CFLAGS = @GMOCK_CFLAGS@ GMOCK_LIBS = @GMOCK_LIBS@ GREP = @GREP@ diff --git a/deps/cares/src/lib/Makefile.in b/deps/cares/src/lib/Makefile.in index c0d96ed81bb29b..30d33843d5d2d8 100644 --- a/deps/cares/src/lib/Makefile.in +++ b/deps/cares/src/lib/Makefile.in @@ -15,7 +15,7 @@ @SET_MAKE@ # aminclude_static.am generated automatically by Autoconf -# from AX_AM_MACROS_STATIC on Fri Aug 2 08:48:39 EDT 2024 +# from AX_AM_MACROS_STATIC on Fri Aug 23 09:37:25 EDT 2024 # Copyright (C) The c-ares project and its contributors # SPDX-License-Identifier: MIT @@ -490,6 +490,8 @@ FGREP = @FGREP@ FILECMD = @FILECMD@ GCOV = @GCOV@ GENHTML = @GENHTML@ +GMOCK112_CFLAGS = @GMOCK112_CFLAGS@ +GMOCK112_LIBS = @GMOCK112_LIBS@ GMOCK_CFLAGS = @GMOCK_CFLAGS@ GMOCK_LIBS = @GMOCK_LIBS@ GREP = @GREP@ diff --git a/deps/cares/src/lib/ares__close_sockets.c b/deps/cares/src/lib/ares__close_sockets.c index 27bbaacf0e8931..71c7e64f08ad38 100644 --- a/deps/cares/src/lib/ares__close_sockets.c +++ b/deps/cares/src/lib/ares__close_sockets.c @@ -37,7 +37,7 @@ static void ares__requeue_queries(ares_conn_t *conn, ares__tvnow(&now); while ((query = ares__llist_first_val(conn->queries_to_conn)) != NULL) { - ares__requeue_query(query, &now, requeue_status, ARES_TRUE); + ares__requeue_query(query, &now, requeue_status, ARES_TRUE, NULL); } } diff --git a/deps/cares/src/lib/ares__socket.c b/deps/cares/src/lib/ares__socket.c index 2e360efb4148d9..86e281fcddadd4 100644 --- a/deps/cares/src/lib/ares__socket.c +++ b/deps/cares/src/lib/ares__socket.c @@ -56,7 +56,7 @@ #include #include -#if defined(__linux__) && defined(MSG_FASTOPEN) +#if defined(__linux__) && defined(TCP_FASTOPEN_CONNECT) # define TFO_SUPPORTED 1 # define TFO_SKIP_CONNECT 0 # define TFO_USE_SENDTO 0 diff --git a/deps/cares/src/lib/ares_android.c b/deps/cares/src/lib/ares_android.c index 4c0ffa04f7c36e..06ab8940ad736d 100644 --- a/deps/cares/src/lib/ares_android.c +++ b/deps/cares/src/lib/ares_android.c @@ -27,6 +27,7 @@ # include "ares_private.h" # include # include +# include "ares_android.h" static JavaVM *android_jvm = NULL; static jobject android_connectivity_manager = NULL; @@ -227,7 +228,7 @@ int ares_library_init_android(jobject connectivity_manager) (*android_jvm)->DetachCurrentThread(android_jvm); } - return ret; + return (int)ret; } int ares_library_android_initialized(void) diff --git a/deps/cares/src/lib/ares_cookie.c b/deps/cares/src/lib/ares_cookie.c index 0680fe9ec7b6a3..bf9d1ba25da41d 100644 --- a/deps/cares/src/lib/ares_cookie.c +++ b/deps/cares/src/lib/ares_cookie.c @@ -427,7 +427,8 @@ ares_status_t ares_cookie_validate(ares_query_t *query, /* Resend the request, hopefully it will work the next time as we should * have recorded a server cookie */ ares__requeue_query(query, now, ARES_SUCCESS, - ARES_FALSE /* Don't increment try count */); + ARES_FALSE /* Don't increment try count */, + NULL); /* Parent needs to drop this response */ return ARES_EBADRESP; diff --git a/deps/cares/src/lib/ares_getaddrinfo.c b/deps/cares/src/lib/ares_getaddrinfo.c index f67acdec2fac81..713acf744a0dca 100644 --- a/deps/cares/src/lib/ares_getaddrinfo.c +++ b/deps/cares/src/lib/ares_getaddrinfo.c @@ -528,6 +528,13 @@ static void host_callback(void *arg, ares_status_t status, size_t timeouts, hquery->nodata_cnt++; } next_lookup(hquery, hquery->nodata_cnt ? ARES_ENODATA : status); + } else if ( + (status == ARES_ESERVFAIL || status == ARES_EREFUSED) && + ares__name_label_cnt(hquery->names[hquery->next_name_idx-1]) == 1 + ) { + /* Issue #852, systemd-resolved may return SERVFAIL or REFUSED on a + * single label domain name. */ + next_lookup(hquery, hquery->nodata_cnt ? ARES_ENODATA : status); } else { end_hquery(hquery, status); } diff --git a/deps/cares/src/lib/ares_metrics.c b/deps/cares/src/lib/ares_metrics.c index aa0ea8c01707a4..0e22fc37e7cb46 100644 --- a/deps/cares/src/lib/ares_metrics.c +++ b/deps/cares/src/lib/ares_metrics.c @@ -170,7 +170,7 @@ void ares_metrics_record(const ares_query_t *query, ares_server_t *server, } ares__timeval_diff(&tvdiff, &query->ts, &now); - query_ms = (unsigned int)(tvdiff.sec + (tvdiff.usec / 1000)); + query_ms = (unsigned int)((tvdiff.sec * 1000) + (tvdiff.usec / 1000)); if (query_ms == 0) { query_ms = 1; } diff --git a/deps/cares/src/lib/ares_private.h b/deps/cares/src/lib/ares_private.h index b85ecb5e14d73d..263c2a606d3708 100644 --- a/deps/cares/src/lib/ares_private.h +++ b/deps/cares/src/lib/ares_private.h @@ -462,10 +462,14 @@ ares_bool_t ares__timedout(const ares_timeval_t *now, /* Returns one of the normal ares status codes like ARES_SUCCESS */ ares_status_t ares__send_query(ares_query_t *query, const ares_timeval_t *now); -ares_status_t ares__requeue_query(ares_query_t *query, - const ares_timeval_t *now, - ares_status_t status, - ares_bool_t inc_try_count); +ares_status_t ares__requeue_query(ares_query_t *query, + const ares_timeval_t *now, + ares_status_t status, + ares_bool_t inc_try_count, + const ares_dns_record_t *dnsrec); + +/*! Count the number of labels (dots+1) in a domain */ +size_t ares__name_label_cnt(const char *name); /*! Retrieve a list of names to use for searching. The first successful * query in the list wins. This function also uses the HOSTSALIASES file diff --git a/deps/cares/src/lib/ares_process.c b/deps/cares/src/lib/ares_process.c index 65ee673f6edcd5..f05f67d8f2b176 100644 --- a/deps/cares/src/lib/ares_process.c +++ b/deps/cares/src/lib/ares_process.c @@ -571,7 +571,7 @@ static void process_timeouts(ares_channel_t *channel, const ares_timeval_t *now) conn = query->conn; server_increment_failures(conn->server, query->using_tcp); - ares__requeue_query(query, now, ARES_ETIMEOUT, ARES_TRUE); + ares__requeue_query(query, now, ARES_ETIMEOUT, ARES_TRUE, NULL); } } @@ -711,7 +711,7 @@ static ares_status_t process_answer(ares_channel_t *channel, } server_increment_failures(server, query->using_tcp); - ares__requeue_query(query, now, status, ARES_TRUE); + ares__requeue_query(query, now, status, ARES_TRUE, rdnsrec); /* Should any of these cause a connection termination? * Maybe SERVER_FAILURE? */ @@ -756,10 +756,11 @@ static void handle_conn_error(ares_conn_t *conn, ares_bool_t critical_failure, ares__close_connection(conn, failure_status); } -ares_status_t ares__requeue_query(ares_query_t *query, - const ares_timeval_t *now, - ares_status_t status, - ares_bool_t inc_try_count) +ares_status_t ares__requeue_query(ares_query_t *query, + const ares_timeval_t *now, + ares_status_t status, + ares_bool_t inc_try_count, + const ares_dns_record_t *dnsrec) { ares_channel_t *channel = query->channel; size_t max_tries = ares__slist_len(channel->servers) * channel->tries; @@ -783,7 +784,7 @@ ares_status_t ares__requeue_query(ares_query_t *query, query->error_status = ARES_ETIMEOUT; } - end_query(channel, NULL, query, query->error_status, NULL); + end_query(channel, NULL, query, query->error_status, dnsrec); return ARES_ETIMEOUT; } @@ -1078,7 +1079,7 @@ ares_status_t ares__send_query(ares_query_t *query, const ares_timeval_t *now) case ARES_ECONNREFUSED: case ARES_EBADFAMILY: server_increment_failures(server, query->using_tcp); - return ares__requeue_query(query, now, status, ARES_TRUE); + return ares__requeue_query(query, now, status, ARES_TRUE, NULL); /* Anything else is not retryable, likely ENOMEM */ default: @@ -1104,7 +1105,7 @@ ares_status_t ares__send_query(ares_query_t *query, const ares_timeval_t *now) case ARES_ECONNREFUSED: case ARES_EBADFAMILY: handle_conn_error(conn, ARES_TRUE, status); - status = ares__requeue_query(query, now, status, ARES_TRUE); + status = ares__requeue_query(query, now, status, ARES_TRUE, NULL); if (status == ARES_ETIMEOUT) { status = ARES_ECONNREFUSED; } @@ -1114,7 +1115,7 @@ ares_status_t ares__send_query(ares_query_t *query, const ares_timeval_t *now) * just requeue to a different server/connection. */ default: server_increment_failures(server, query->using_tcp); - status = ares__requeue_query(query, now, status, ARES_TRUE); + status = ares__requeue_query(query, now, status, ARES_TRUE, NULL); return status; } diff --git a/deps/cares/src/lib/ares_qcache.c b/deps/cares/src/lib/ares_qcache.c index aee1328b51c7bc..9725212fded7d1 100644 --- a/deps/cares/src/lib/ares_qcache.c +++ b/deps/cares/src/lib/ares_qcache.c @@ -121,9 +121,11 @@ static char *ares__qcache_calc_key(const ares_dns_record_t *dnsrec) name_len--; } - status = ares__buf_append(buf, (const unsigned char *)name, name_len); - if (status != ARES_SUCCESS) { - goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + if (name_len > 0) { + status = ares__buf_append(buf, (const unsigned char *)name, name_len); + if (status != ARES_SUCCESS) { + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ + } } } @@ -346,8 +348,8 @@ static ares_status_t ares__qcache_insert(ares__qcache_t *qcache, } entry->dnsrec = qresp; - entry->expire_ts = now->sec + (time_t)ttl; - entry->insert_ts = now->sec; + entry->expire_ts = (time_t)now->sec + (time_t)ttl; + entry->insert_ts = (time_t)now->sec; /* We can't guarantee the server responded with the same flags as the * request had, so we have to re-parse the request in order to generate the diff --git a/deps/cares/src/lib/ares_search.c b/deps/cares/src/lib/ares_search.c index ae98df39a80a8f..2d3c0fc5145684 100644 --- a/deps/cares/src/lib/ares_search.c +++ b/deps/cares/src/lib/ares_search.c @@ -107,26 +107,37 @@ static void search_callback(void *arg, ares_status_t status, size_t timeouts, { struct search_query *squery = (struct search_query *)arg; ares_channel_t *channel = squery->channel; - ares_dns_rcode_t rcode; - size_t ancount; + ares_status_t mystatus; ares_bool_t skip_cleanup = ARES_FALSE; squery->timeouts += timeouts; - if (status != ARES_SUCCESS) { - end_squery(squery, status, dnsrec); - return; - } - - rcode = ares_dns_record_get_rcode(dnsrec); - ancount = ares_dns_record_rr_cnt(dnsrec, ARES_SECTION_ANSWER); - mystatus = ares_dns_query_reply_tostatus(rcode, ancount); - - if (mystatus != ARES_ENODATA && mystatus != ARES_ESERVFAIL && - mystatus != ARES_ENOTFOUND) { - end_squery(squery, mystatus, dnsrec); - return; + if (dnsrec) { + ares_dns_rcode_t rcode = ares_dns_record_get_rcode(dnsrec); + size_t ancount = ares_dns_record_rr_cnt(dnsrec, + ARES_SECTION_ANSWER); + mystatus = ares_dns_query_reply_tostatus(rcode, ancount); + } else { + mystatus = status; + } + + switch (mystatus) { + case ARES_ENODATA: + case ARES_ENOTFOUND: + break; + case ARES_ESERVFAIL: + case ARES_EREFUSED: + /* Issue #852, systemd-resolved may return SERVFAIL or REFUSED on a + * single label domain name. */ + if (ares__name_label_cnt(squery->names[squery->next_name_idx-1]) != 1) { + end_squery(squery, mystatus, dnsrec); + return; + } + break; + default: + end_squery(squery, mystatus, dnsrec); + return; } /* If we ever get ARES_ENODATA along the way, record that; if the search @@ -147,7 +158,6 @@ static void search_callback(void *arg, ares_status_t status, size_t timeouts, return; } - /* We have no more domains to search, return an appropriate response. */ if (mystatus == ARES_ENOTFOUND && squery->ever_got_nodata) { end_squery(squery, ARES_ENODATA, NULL); @@ -176,6 +186,25 @@ static ares_bool_t ares__search_eligible(const ares_channel_t *channel, return ARES_TRUE; } +size_t ares__name_label_cnt(const char *name) +{ + const char *p; + size_t ndots = 0; + + if (name == NULL) { + return 0; + } + + for (p = name; p != NULL && *p != 0; p++) { + if (*p == '.') { + ndots++; + } + } + + /* Label count is 1 greater than ndots */ + return ndots+1; +} + ares_status_t ares__search_name_list(const ares_channel_t *channel, const char *name, char ***names, size_t *names_len) @@ -186,7 +215,6 @@ ares_status_t ares__search_name_list(const ares_channel_t *channel, char *alias = NULL; size_t ndots = 0; size_t idx = 0; - const char *p; size_t i; /* Perform HOSTALIASES resolution */ @@ -223,12 +251,10 @@ ares_status_t ares__search_name_list(const ares_channel_t *channel, goto done; } - /* Count the number of dots in name */ - ndots = 0; - for (p = name; *p != 0; p++) { - if (*p == '.') { - ndots++; - } + /* Count the number of dots in name, 1 less than label count */ + ndots = ares__name_label_cnt(name); + if (ndots > 0) { + ndots--; } /* Allocate an entry for each search domain, plus one for as-is */ diff --git a/deps/cares/src/lib/ares_send.c b/deps/cares/src/lib/ares_send.c index 9441534404962f..64ff7edd3ac602 100644 --- a/deps/cares/src/lib/ares_send.c +++ b/deps/cares/src/lib/ares_send.c @@ -62,7 +62,11 @@ static ares_status_t ares_apply_dns0x20(ares_channel_t *channel, } len = ares_strlen(name); - if (len == 0 || len >= sizeof(dns0x20name)) { + if (len == 0) { + return ARES_SUCCESS; + } + + if (len >= sizeof(dns0x20name)) { status = ARES_EBADNAME; goto done; } diff --git a/deps/cares/src/lib/ares_sysconfig.c b/deps/cares/src/lib/ares_sysconfig.c index 2cd3df28235ec3..61e6a423a7578a 100644 --- a/deps/cares/src/lib/ares_sysconfig.c +++ b/deps/cares/src/lib/ares_sysconfig.c @@ -239,7 +239,7 @@ static ares_status_t ares__init_sysconfig_android(ares_sysconfig_t *sysconfig) 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); + snprintf(propname, sizeof(propname), "%s%zu", DNS_PROP_NAME_PREFIX, i); if (__system_property_get(propname, propvalue) < 1) { break; } @@ -494,6 +494,7 @@ ares_status_t ares__init_by_sysconfig(ares_channel_t *channel) ares_sysconfig_t sysconfig; memset(&sysconfig, 0, sizeof(sysconfig)); + sysconfig.ndots = 1; /* Default value if not otherwise set */ #if defined(USE_WINSOCK) status = ares__init_sysconfig_windows(&sysconfig); diff --git a/deps/cares/src/lib/dsa/ares__htable.c b/deps/cares/src/lib/dsa/ares__htable.c index d608d60ce3a51a..9049b3246b36f1 100644 --- a/deps/cares/src/lib/dsa/ares__htable.c +++ b/deps/cares/src/lib/dsa/ares__htable.c @@ -59,7 +59,7 @@ static unsigned int ares__htable_generate_seed(ares__htable_t *htable) * collision attack is very low with a small amount of effort */ seed |= (unsigned int)((size_t)htable & 0xFFFFFFFF); seed |= (unsigned int)((size_t)&seed & 0xFFFFFFFF); - seed |= (unsigned int)(t & 0xFFFFFFFF); + seed |= (unsigned int)(((ares_uint64_t)t) & 0xFFFFFFFF); return seed; } diff --git a/deps/cares/src/lib/event/ares_event_configchg.c b/deps/cares/src/lib/event/ares_event_configchg.c index 030c76c69c9148..10f0e21dde77fa 100644 --- a/deps/cares/src/lib/event/ares_event_configchg.c +++ b/deps/cares/src/lib/event/ares_event_configchg.c @@ -31,6 +31,8 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, ares_event_thread_t *e) { + (void)configchg; + (void)e; /* No ability */ return ARES_ENOTIMP; } @@ -38,6 +40,7 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, void ares_event_configchg_destroy(ares_event_configchg_t *configchg) { /* No-op */ + (void)configchg; } #elif defined(__linux__) @@ -107,7 +110,7 @@ static void ares_event_configchg_cb(ares_event_thread_t *e, ares_socket_t fd, * size provided, so I assume it won't ever return partial events. */ for (ptr = buf; ptr < buf + len; ptr += sizeof(struct inotify_event) + event->len) { - event = (const struct inotify_event *)ptr; + event = (const struct inotify_event *)((const void *)ptr); if (event->len == 0 || ares_strlen(event->name) == 0) { continue; diff --git a/deps/cares/src/lib/str/ares__buf.c b/deps/cares/src/lib/str/ares__buf.c index b855260ab37322..bf6d4a0e1d3712 100644 --- a/deps/cares/src/lib/str/ares__buf.c +++ b/deps/cares/src/lib/str/ares__buf.c @@ -213,10 +213,14 @@ ares_status_t ares__buf_append(ares__buf_t *buf, const unsigned char *data, { ares_status_t status; - if (data == NULL || data_len == 0) { + if (data == NULL && data_len != 0) { return ARES_EFORMERR; } + if (data_len == 0) { + return ARES_SUCCESS; + } + status = ares__buf_ensure_space(buf, data_len); if (status != ARES_SUCCESS) { return status; diff --git a/deps/cares/src/tools/Makefile.in b/deps/cares/src/tools/Makefile.in index 9c896092b1ec19..e1b661ec1d7cbf 100644 --- a/deps/cares/src/tools/Makefile.in +++ b/deps/cares/src/tools/Makefile.in @@ -275,6 +275,8 @@ FGREP = @FGREP@ FILECMD = @FILECMD@ GCOV = @GCOV@ GENHTML = @GENHTML@ +GMOCK112_CFLAGS = @GMOCK112_CFLAGS@ +GMOCK112_LIBS = @GMOCK112_LIBS@ GMOCK_CFLAGS = @GMOCK_CFLAGS@ GMOCK_LIBS = @GMOCK_LIBS@ GREP = @GREP@