diff --git a/.github/workflows/alpine-latest.yml b/.github/workflows/alpine-latest.yml index fdcf84a14c..80d3620d18 100644 --- a/.github/workflows/alpine-latest.yml +++ b/.github/workflows/alpine-latest.yml @@ -38,7 +38,7 @@ jobs: TEST_DEBUGGER: gdb run: | ./ci/build.sh - ./ci/test.sh + sudo ./ci/test.sh - name: "Autotools: build and test c-ares" env: BUILD_TYPE: autotools @@ -58,7 +58,7 @@ jobs: TEST_DEBUGGER: "none" run: | ./ci/build.sh - ./ci/test.sh + sudo ./ci/test.sh - name: "CMake: ASAN: build and test c-ares" env: BUILD_TYPE: "asan" @@ -71,7 +71,7 @@ jobs: TEST_DEBUGGER: "none" run: | ./ci/build.sh - ./ci/test.sh + sudo ./ci/test.sh - name: "CMake: Static Analyzer: build c-ares" env: BUILD_TYPE: "analyze" diff --git a/.github/workflows/coveralls.yml b/.github/workflows/coveralls.yml index d5e6639721..b4165716bb 100644 --- a/.github/workflows/coveralls.yml +++ b/.github/workflows/coveralls.yml @@ -8,7 +8,9 @@ on: jobs: build: name: Coveralls - runs-on: ubuntu-latest + # Note gcov on ubuntu-latest (24.04) has some bugs: + # https://www.reddit.com/r/cpp_questions/comments/1ewnv8d/lcov_geninfo_error/ + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - uses: awalsh128/cache-apt-pkgs-action@latest @@ -25,7 +27,7 @@ jobs: shell: bash run: | cd build - ./bin/arestest -v --gtest_filter='-*LiveSearchTXT*:*LiveSearchANY*:*LiveSearchNS*' + sudo ./bin/arestest -v --gtest_filter='-*LiveSearchTXT*:*LiveSearchANY*:*LiveSearchNS*' - name: Generate Coverage shell: bash run: | diff --git a/.github/workflows/ubuntu-latest.yml b/.github/workflows/ubuntu-latest.yml index 2aada5f6d1..d149d670fc 100644 --- a/.github/workflows/ubuntu-latest.yml +++ b/.github/workflows/ubuntu-latest.yml @@ -36,7 +36,7 @@ jobs: TEST_DEBUGGER: gdb run: | ./ci/build.sh - ./ci/test.sh + sudo ./ci/test.sh - name: "Autotools: build and test c-ares" env: BUILD_TYPE: autotools @@ -53,7 +53,7 @@ jobs: TEST_DEBUGGER: gdb run: | ./ci/build.sh - ./ci/test.sh + sudo ./ci/test.sh - name: "CMake: (hide symbols) build and test c-ares" env: BUILD_TYPE: CMAKE @@ -62,7 +62,7 @@ jobs: TEST_DEBUGGER: gdb run: | ./ci/build.sh - ./ci/test.sh + sudo ./ci/test.sh - name: "CMake: UBSAN: build and test c-ares" env: BUILD_TYPE: "ubsan" @@ -75,7 +75,7 @@ jobs: TEST_DEBUGGER: "none" run: | ./ci/build.sh - ./ci/test.sh + sudo ./ci/test.sh - name: "CMake: ASAN: build and test c-ares" env: BUILD_TYPE: "asan" @@ -88,7 +88,7 @@ jobs: TEST_DEBUGGER: "none" run: | ./ci/build.sh - ./ci/test.sh + sudo ./ci/test.sh - name: "CMake: Static Analyzer: build c-ares" env: BUILD_TYPE: "analyze" @@ -119,4 +119,4 @@ jobs: run: | sudo sysctl -w net.ipv4.tcp_fastopen=0 ./ci/build.sh - ./ci/test.sh + sudo ./ci/test.sh diff --git a/.reuse/dep5 b/.reuse/dep5 index aa893f0c21..a5f16f1855 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -5,17 +5,17 @@ Source: https://c-ares.org/ # Fuzzer data Files: test/fuzzinput/* test/fuzznames/* -Copyright: The c-ares project and its contributors. +Copyright: The c-ares project and its contributors License: MIT # Docs Files: AUTHORS CONTRIBUTING.md GIT-INFO README.md README.msvc RELEASE-PROCEDURE.md RELEASE-NOTES.md FEATURES.md SECURITY.md DEVELOPER-NOTES.md INSTALL.md FUZZING.md test/README.md src/lib/include/README.md src/lib/thirdparty/apple/README.md -Copyright: The c-ares project and its contributors. +Copyright: The c-ares project and its contributors License: MIT # dotfiles Files: .gitignore .gitattributes m4/.gitignore test/.gitignore -Copyright: The c-ares project and its contributors. +Copyright: The c-ares project and its contributors License: MIT # Imported m4 files diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c1c6ac33e..3117ea77c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -275,12 +275,14 @@ ELSEIF (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") ELSEIF (CMAKE_SYSTEM_NAME STREQUAL "QNX") LIST (APPEND SYSFLAGS -D_QNX_SOURCE) ELSEIF (WIN32) - LIST (APPEND SYSFLAGS -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_WIN32_WINNT=0x0602) + LIST (APPEND SYSFLAGS -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) + IF (NOT CMAKE_C_FLAGS MATCHES ".*-D_WIN32_WINNT=.*") + LIST (APPEND SYSFLAGS -D_WIN32_WINNT=0x0602) + ENDIF () ENDIF () ADD_DEFINITIONS(${SYSFLAGS}) - # Tell C-Ares about libraries to depend on IF (HAVE_LIBRESOLV) LIST (APPEND CARES_DEPENDENT_LIBS resolv) @@ -388,7 +390,7 @@ CARES_TYPE_EXISTS ("struct in6_addr" HAVE_STRUCT_IN6_ADDR) CARES_TYPE_EXISTS ("struct sockaddr_in6" HAVE_STRUCT_SOCKADDR_IN6) CARES_TYPE_EXISTS ("struct sockaddr_storage" HAVE_STRUCT_SOCKADDR_STORAGE) CARES_TYPE_EXISTS ("struct timeval" HAVE_STRUCT_TIMEVAL) - +CARES_TYPE_EXISTS ("OVERLAPPED_ENTRY" HAVE_OVERLAPPED_ENTRY) # Check for preprocessor defines CHECK_SYMBOL_EXISTS (AF_INET6 "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_AF_INET6) @@ -427,10 +429,14 @@ CHECK_SYMBOL_EXISTS (getservbyname_r "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_GETSERV CHECK_SYMBOL_EXISTS (gettimeofday "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_GETTIMEOFDAY) CHECK_SYMBOL_EXISTS (if_indextoname "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_IF_INDEXTONAME) CHECK_SYMBOL_EXISTS (if_nametoindex "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_IF_NAMETOINDEX) +CHECK_SYMBOL_EXISTS (GetBestRoute2 "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_GETBESTROUTE2) +CHECK_SYMBOL_EXISTS (WSAIoctl "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_WSAIOCTL) +CHECK_SYMBOL_EXISTS (GetQueuedCompletionStatusEx "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_GETQUEUEDCOMPLETIONSTATUSEX) CHECK_SYMBOL_EXISTS (ConvertInterfaceIndexToLuid "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_CONVERTINTERFACEINDEXTOLUID) CHECK_SYMBOL_EXISTS (ConvertInterfaceLuidToNameA "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_CONVERTINTERFACELUIDTONAMEA) CHECK_SYMBOL_EXISTS (NotifyIpInterfaceChange "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_NOTIFYIPINTERFACECHANGE) CHECK_SYMBOL_EXISTS (RegisterWaitForSingleObject "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_REGISTERWAITFORSINGLEOBJECT) +CHECK_SYMBOL_EXISTS (SetFileCompletionNotificationModes "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_SETFILECOMPLETIONNOTIFICATIONMODES) CHECK_SYMBOL_EXISTS (inet_net_pton "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_INET_NET_PTON) @@ -504,11 +510,7 @@ IF (CARES_THREADS) CARES_EXTRAINCLUDE_IFSET (HAVE_PTHREAD_H pthread.h) CARES_EXTRAINCLUDE_IFSET (HAVE_PTHREAD_NP_H pthread_np.h) CHECK_SYMBOL_EXISTS (pthread_init "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_PTHREAD_INIT) - # Make sure libcares.pc.cmake knows about thread libraries on static builds - # The variable set by FIND_PACKAGE(Threads) has a -l prefix on it, we need - # to strip that first since CARES_DEPENDENT_LIBS doesn't expect that. - STRING (REPLACE "-l" "" CARES_THREAD_LIBRARY "${CMAKE_THREAD_LIBS_INIT}") - LIST (APPEND CARES_DEPENDENT_LIBS ${CARES_THREAD_LIBRARY}) + LIST (APPEND CARES_DEPENDENT_LIBS ${CMAKE_THREAD_LIBS_INIT}) ELSE () MESSAGE (WARNING "Threading support not found, disabling...") SET (CARES_THREADS OFF) @@ -788,7 +790,10 @@ IF (CARES_INSTALL) # pkgconfig support for static builds FOREACH (LIB ${CARES_DEPENDENT_LIBS}) - SET (CARES_PRIVATE_LIBS "${CARES_PRIVATE_LIBS} -l${LIB}") + IF (NOT LIB MATCHES "^-") + SET (LIB "-l${LIB}") + ENDIF () + SET (CARES_PRIVATE_LIBS "${CARES_PRIVATE_LIBS} ${LIB}") ENDFOREACH () CONFIGURE_FILE("libcares.pc.cmake" "libcares.pc" @ONLY) diff --git a/Makefile.m32 b/Makefile.m32 index 7bd8516597..427b08771e 100644 --- a/Makefile.m32 +++ b/Makefile.m32 @@ -19,7 +19,9 @@ RANLIB = $(CROSSPREFIX)ranlib #RM = rm -f CP = cp -afv -CFLAGS = $(CARES_CFLAG_EXTRAS) -O2 -Wall -I./include -I./src/lib -I./src/lib/include -D_WIN32_WINNT=0x0602 +WIN32_WINNT ?= 0x0602 + +CFLAGS = $(CARES_CFLAG_EXTRAS) -O2 -Wall -I./include -I./src/lib -I./src/lib/include -D_WIN32_WINNT=$(WIN32_WINNT) CFLAGS += -DCARES_STATICLIB LDFLAGS = $(CARES_LDFLAG_EXTRAS) -s LIBS = -lws2_32 -liphlpapi diff --git a/SECURITY.md b/SECURITY.md index 0b66cc1146..9964f51900 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1,11 +1,15 @@ -c-ares security -=============== +# c-ares Security Reporting Policy + +- [Publishing](#publishing) +- [Reporting Vulnerabilities](#reporting-vulnerabilities) + - [Reporting Requirements](#reporting-requirements) +- [Vulnerability Handling](#vulnerability-handling) +- [Joining the Security Team](#joining-the-security-team) This document is intended to provide guidance on how security vulnerabilities should be handled in the c-ares project. -Publishing Information ----------------------- +## Publishing All known and public c-ares vulnerabilities will be listed on [the c-ares web site](https://c-ares.org/vulns.html). @@ -14,8 +18,58 @@ Security vulnerabilities should not be entered in the project's public bug tracker unless the necessary configuration is in place to limit access to the issue to only the reporter and the project's security team. -Vulnerability Handling ----------------------- +## Reporting Vulnerabilities + +- The person discovering the issue, the reporter, reports the vulnerability + privately to [c-ares-security@haxx.se](mailto:c-ares-security@haxx.se). That's + an email alias that reaches a handful of selected and trusted people. + +- Messages that do not relate to the reporting or managing of an undisclosed + security vulnerability in c-ares are ignored and no further action is + required. + +### Reporting Requirements + +1. The reporter should take great care in ensuring the security vulnerability + report is valid and accurate. The reporter must understand reviewing + security vulnerability reports is a time consuming process and the c-ares + security team are volunteers. A vast majority of vulnerability reports + we receive are invalid. Please don't waste their time. +2. The report must have a detailed description of the issue or issues. +3. The report must contain the c-ares version that was tested. If from an + unreleased version (e.g. from git main), please provide the branch name and + git hash tested. +4. The report should have a valid minimal test case to reproduce the issue. + 1. Any code in a test case that isn't relevant to reproducing the issue + ***must*** be removed. + 2. The test case ***must*** compile cleanly with warnings enabled, for + clang/gcc at a minimum, `-Wall -W`, or `/W3` for MSVC. + 3. The reporter ***must*** validate the API being called is being used in an + appropriate manner, in accordance with common C best practices and + requirements. e.g.: + 1. If an API takes a C string, that means the input must be a valid C + string (e.g. NULL terminated). + 2. Must not cast incompatible data types to silence compiler warnings + as this will cause undefined behavior. Use the right data types. (e.g. + `struct ares_txt_reply *` can't be cast to `ares_dns_record_t *`, they + are different types). + 3. Make sure to free/destroy any c-ares generated objects using the + correct function as documented in the man page of the function that + generated the object (e.g. use `ares_free_hostent()` to free + a `struct hostent *` created by `ares_parse_ptr_reply()`, not + `ares_free_data()`). +5. The report should include a stacktrace/backtrace of the issue if possible. +6. Include the below acknowledgement statement in the email containing the + vulnerability report. Evaluation of the vulnerabilities will not occur + without this statement. The team will simply respond redirecting you to this + document on reporting requirements if the statement is not included. + Acknowledgement statement: + ``` + I acknowledge I have read and complied with the security reporting + requirements as described in https://c-ares.org/security.html + ``` + +## Vulnerability Handling The typical process for handling a new security vulnerability is as follows. @@ -27,13 +81,7 @@ mailing list. Also messages associated with any commits should not make any reference to the security nature of the commit if done prior to the public announcement. -- The person discovering the issue, the reporter, reports the vulnerability - privately to `c-ares-security@haxx.se`. That's an email alias that reaches a - handful of selected and trusted people. - -- Messages that do not relate to the reporting or managing of an undisclosed - security vulnerability in c-ares are ignored and no further action is - required. +- A vulnerability report is sent as per [Reporting Vulnerabilities](#reporting-vulnerabilities). - A person in the security team sends an e-mail to the original reporter to acknowledge the report. @@ -46,10 +94,6 @@ announcement. - If the report is accepted, the team writes to the reporter to let them know it is accepted and that they are working on a fix. -- The security team discusses the problem, works out a fix, considers the - impact of the problem and suggests a release schedule. This discussion - should involve the reporter as much as possible. - - The release of the information should be "as soon as possible" and is most often synced with an upcoming release that contains the fix. If the reporter, or anyone else, thinks the next planned release is too far away @@ -60,22 +104,30 @@ announcement. workarounds, when the release is out and make sure to credit all contributors properly. -- Request a CVE number from - [distros@openwall](http://oss-security.openwall.org/wiki/mailing-lists/distros) - when also informing and preparing them for the upcoming public security - vulnerability announcement - attach the advisory draft for information. Note - that 'distros' won't accept an embargo longer than 19 days. +- Request a CVE number from GitHub by drafting a security advisory via + [GitHub Security](https://github.com/c-ares/c-ares/security), then requesting + a CVE be assigned. -- Update the "security advisory" with the CVE number. +- The security team discusses the problem, works out a fix, considers the + impact of the problem and suggests a release schedule. This discussion + should involve the reporter as much as possible. -- The security team commits the fix in a private branch. The commit message +- The security team commits the fix in a private branch automatically generated + by the GitHub security advisory creation process. The commit message should ideally contain the CVE number. This fix is usually also distributed to the 'distros' mailing list to allow them to use the fix prior to the public announcement. +- Send the advisory draft to [distros@openwall](http://oss-security.openwall.org/wiki/mailing-lists/distros) + to prepare them for the upcoming public security vulnerability announcement. + For high-severity fixes, a patch should also be attached so it can be + integrated prior to the official release. Note that 'distros' won't accept an + embargo longer than 19 days. + - At the day of the next release, the private branch is merged into the master - branch and pushed. Once pushed, the information is accessible to the public - and the actual release should follow suit immediately afterwards. + branch and pushed, the GitHub advisory is made public. Once pushed, the + information is accessible to the public and the actual release should follow + suit immediately afterwards. - The project team creates a release that includes the fix. @@ -86,15 +138,17 @@ announcement. - The security web page on the web site should get the new vulnerability mentioned. -C-ARES-SECURITY (at haxx dot se) --------------------------------- -Who is on this list? There are a couple of criteria you must meet, and then we -might ask you to join the list or you can ask to join it. It really isn't very -formal. We basically only require that you have a long-term presence in the -c-ares project and you have shown an understanding for the project and its way -of working. You must've been around for a good while and you should have no -plans in vanishing in the near future. +## Joining the Security Team + +Who is on the security team receiving notices via [c-ares-security@haxx.se](mailto:c-ares-security@haxx.se)? + +There are a couple of criteria you must meet, and then we might ask you to join +the list or you can ask to join it. It really isn't very formal. We basically +only require that you have a long-term presence in the c-ares project and you +have shown an understanding for the project and its way of working. You must've +been around for a good while and you should have no plans in vanishing in the +near future. We do not make the list of partipants public mostly because it tends to vary somewhat over time and a list somewhere will only risk getting outdated. diff --git a/appveyor.yml b/appveyor.yml index 63e396671a..481178afb8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -23,14 +23,14 @@ configuration: # CMAKE_EXTRA_OPTIONS: -DOPENSSL_ROOT_DIR=C:/OpenSSL-Win32 environment: matrix: - # MSVC 2022, 32-bit x86 (cmake) + # MSVC 2022, 32-bit x86 (cmake, WindowsXP) - COMPILER: MSVC CONFTOOL: CMAKE SYSTEM: CONSOLE SKIP_TESTS: no MSVC_SETUP_ARG: x86 MSVC_SETUP_PATH: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars32.bat - CMAKE_EXTRA_OPTIONS: -GNinja -DCARES_BUILD_TESTS=ON -DGTEST_ROOT=C:\projects\googletest -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebugDLL + CMAKE_EXTRA_OPTIONS: -GNinja -DCARES_BUILD_TESTS=ON -DGTEST_ROOT=C:\projects\googletest -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebugDLL -DCMAKE_C_FLAGS="-D_WIN32_WINNT=0x0501" -DCMAKE_CXX_FLAGS="-D_WIN32_WINNT=0x0501" TOOLSDIR: ./build/bin TESTDIR: ./build/bin BUILD_GOOGLETEST: yes @@ -65,15 +65,16 @@ environment: MSVC_SETUP_PATH: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars32.bat BUILD_GOOGLETEST: yes - # MinGW, 32-bit x86 (makefiles) + # MinGW, 32-bit x86 (makefiles, Windows XP) - COMPILER: MINGW CONFTOOL: MAKE SYSTEM: CONSOLE SKIP_TESTS: no PATH: C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin;%PATH% BUILD_GOOGLETEST: yes + MAKE_FLAGS: WIN32_WINNT=0x0501 - # MinGW, 32-bit x86 (cmake static only) + # MinGW, 32-bit x86 (cmake static only, Windows XP) - COMPILER: MINGW CONFTOOL: CMAKE SYSTEM: CONSOLE @@ -81,7 +82,7 @@ environment: TOOLSDIR: ./build/bin TESTDIR: ./build/bin PATH: C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin;%PATH% - CMAKE_EXTRA_OPTIONS: -DCARES_SHARED=OFF -GNinja -DCARES_BUILD_TESTS=ON -DGTEST_ROOT=C:\projects\googletest + CMAKE_EXTRA_OPTIONS: -DCARES_SHARED=OFF -GNinja -DCARES_BUILD_TESTS=ON -DGTEST_ROOT=C:\projects\googletest -DCMAKE_C_FLAGS="-D_WIN32_WINNT=0x0501" -DCMAKE_CXX_FLAGS="-D_WIN32_WINNT=0x0501" BUILD_GOOGLETEST: yes # Disabled until AppVeyor updates their Visual Studio with this patch: @@ -117,7 +118,7 @@ build_script: - if "%SYSTEM%" == "CONSOLE" if "%CONFTOOL%" == "CMAKE" cmake --build build --config Debug - if "%SYSTEM%" == "CONSOLE" if "%CONFTOOL%" == "CMAKE" cmake --install build --config Debug - if "%SYSTEM%" == "CONSOLE" if "%CONFTOOL%" == "MAKE" copy .\include\ares_build.h.dist .\include\ares_build.h - - if "%SYSTEM%" == "CONSOLE" if "%CONFTOOL%" == "MAKE" mingw32-make.exe -f Makefile.m32 demos + - if "%SYSTEM%" == "CONSOLE" if "%CONFTOOL%" == "MAKE" mingw32-make.exe -f Makefile.m32 demos %MAKE_FLAGS% test_script: # We can't use powershell for tests due to treating stderr as an error @@ -126,8 +127,8 @@ test_script: - if "%SYSTEM%" == "CONSOLE" if "%CONFTOOL%" == "NMAKE" if not "%SKIP_TESTS%" == "yes" nmake GTEST_ROOT=C:\projects\googletest /NOLOGO /f .\Makefile.msvc aresfuzz aresfuzzname dnsdump - if "%SYSTEM%" == "CONSOLE" if "%CONFTOOL%" == "NMAKE" if not "%SKIP_TESTS%" == "yes" .\msvc\arestest\lib-debug\dnsdump.exe fuzzinput\answer_a fuzzinput\answer_aaaa - if "%SYSTEM%" == "CONSOLE" if "%CONFTOOL%" == "MAKE" if not "%SKIP_TESTS%" == "yes" cd test - - if "%SYSTEM%" == "CONSOLE" if "%CONFTOOL%" == "MAKE" if not "%SKIP_TESTS%" == "yes" mingw32-make.exe GTEST_ROOT=C:\projects\googletest -f Makefile.m32 vtest - - if "%SYSTEM%" == "CONSOLE" if "%CONFTOOL%" == "MAKE" if not "%SKIP_TESTS%" == "yes" mingw32-make.exe GTEST_ROOT=C:\projects\googletest -f Makefile.m32 aresfuzz.exe aresfuzzname.exe dnsdump.exe + - if "%SYSTEM%" == "CONSOLE" if "%CONFTOOL%" == "MAKE" if not "%SKIP_TESTS%" == "yes" mingw32-make.exe GTEST_ROOT=C:\projects\googletest -f Makefile.m32 vtest %MAKE_FLAGS% + - if "%SYSTEM%" == "CONSOLE" if "%CONFTOOL%" == "MAKE" if not "%SKIP_TESTS%" == "yes" mingw32-make.exe GTEST_ROOT=C:\projects\googletest -f Makefile.m32 aresfuzz.exe aresfuzzname.exe dnsdump.exe %MAKE_FLAGS% - if "%SYSTEM%" == "CONSOLE" if "%CONFTOOL%" == "MAKE" if not "%SKIP_TESTS%" == "yes" .\dnsdump.exe fuzzinput\answer_a fuzzinput\answer_aaaa - if "%SYSTEM%" == "CONSOLE" if "%CONFTOOL%" == "CMAKE" if not "%SKIP_TESTS%" == "yes" cd %TESTDIR% - if "%SYSTEM%" == "CONSOLE" if "%CONFTOOL%" == "CMAKE" if not "%SKIP_TESTS%" == "yes" .\adig.exe www.google.com diff --git a/configure.ac b/configure.ac index 0a46edf731..e3e005c958 100644 --- a/configure.ac +++ b/configure.ac @@ -541,6 +541,8 @@ AC_CHECK_TYPE(socklen_t, AC_CHECK_TYPE(SOCKET, [], [], $cares_all_includes) +AC_CHECK_TYPE(OVERLAPPED_ENTRY, [AC_DEFINE([HAVE_OVERLAPPED_ENTRY], 1, [Define to 1 if you have `OVERLAPPED_ENTRY`] )], [], $cares_all_includes) + dnl ############################################################################### dnl clock_gettime might require an external library @@ -600,11 +602,15 @@ AC_CHECK_DECL(pipe, [AC_DEFINE([HAVE_PIPE], 1, [Define t AC_CHECK_DECL(pipe2, [AC_DEFINE([HAVE_PIPE2], 1, [Define to 1 if you have `pipe2`] )], [], $cares_all_includes) AC_CHECK_DECL(kqueue, [AC_DEFINE([HAVE_KQUEUE], 1, [Define to 1 if you have `kqueue`] )], [], $cares_all_includes) AC_CHECK_DECL(epoll_create1, [AC_DEFINE([HAVE_EPOLL], 1, [Define to 1 if you have `epoll_{create1,ctl,wait}`])], [], $cares_all_includes) +AC_CHECK_DECL(GetBestRoute2, [AC_DEFINE([HAVE_GETBESTROUTE2], 1, [Define to 1 if you have `GetBestRoute2`] )], [], $cares_all_includes) +AC_CHECK_DECL(GetQueuedCompletionStatusEx, [AC_DEFINE([HAVE_GETQUEUEDCOMPLETIONSTATUSEX], 1, [Define to 1 if you have `GetQueuedCompletionStatusEx`])], [], $cares_all_includes) AC_CHECK_DECL(ConvertInterfaceIndexToLuid, [AC_DEFINE([HAVE_CONVERTINTERFACEINDEXTOLUID], 1, [Define to 1 if you have `ConvertInterfaceIndexToLuid`])], [], $cares_all_includes) AC_CHECK_DECL(ConvertInterfaceLuidToNameA, [AC_DEFINE([HAVE_CONVERTINTERFACELUIDTONAMEA], 1, [Define to 1 if you have `ConvertInterfaceLuidToNameA`])], [], $cares_all_includes) AC_CHECK_DECL(NotifyIpInterfaceChange, [AC_DEFINE([HAVE_NOTIFYIPINTERFACECHANGE], 1, [Define to 1 if you have `NotifyIpInterfaceChange`] )], [], $cares_all_includes) AC_CHECK_DECL(RegisterWaitForSingleObject, [AC_DEFINE([HAVE_REGISTERWAITFORSINGLEOBJECT], 1, [Define to 1 if you have `RegisterWaitForSingleObject`])], [], $cares_all_includes) AC_CHECK_DECL(__system_property_get, [AC_DEFINE([HAVE___SYSTEM_PROPERTY_GET], 1, [Define to 1 if you have `__system_property_get`] )], [], $cares_all_includes) +AC_CHECK_DECL(SetFileCompletionNotificationModes, [AC_DEFINE([HAVE_SETFILECOMPLETIONNOTIFICATIONMODES], 1, [Define to 1 if you have `SetFileCompletionNotificationModes`])], [], $cares_all_includes) +AC_CHECK_DECL(WSAIoctl, [AC_DEFINE([HAVE_WSAIoctl], 1, [Define to 1 if you have `WSAIoctl`])], [], $cares_all_includes) dnl ############################################################################### diff --git a/docs/ares_dns_class_t.3 b/docs/ares_dns_class_t.3 index 4acc581d29..363b1fc637 100644 --- a/docs/ares_dns_class_t.3 +++ b/docs/ares_dns_class_t.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_record.3 diff --git a/docs/ares_dns_flags_t.3 b/docs/ares_dns_flags_t.3 index 4acc581d29..363b1fc637 100644 --- a/docs/ares_dns_flags_t.3 +++ b/docs/ares_dns_flags_t.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_record.3 diff --git a/docs/ares_dns_mapping.3 b/docs/ares_dns_mapping.3 index 451839153c..e5d5d5721c 100644 --- a/docs/ares_dns_mapping.3 +++ b/docs/ares_dns_mapping.3 @@ -1,4 +1,4 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .\" .TH ARES_DNS_MAPPINGS 3 "12 November 2023" diff --git a/docs/ares_dns_opcode_t.3 b/docs/ares_dns_opcode_t.3 index 4acc581d29..363b1fc637 100644 --- a/docs/ares_dns_opcode_t.3 +++ b/docs/ares_dns_opcode_t.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_record.3 diff --git a/docs/ares_dns_parse.3 b/docs/ares_dns_parse.3 index 4acc581d29..363b1fc637 100644 --- a/docs/ares_dns_parse.3 +++ b/docs/ares_dns_parse.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_record.3 diff --git a/docs/ares_dns_rcode_t.3 b/docs/ares_dns_rcode_t.3 index 4acc581d29..363b1fc637 100644 --- a/docs/ares_dns_rcode_t.3 +++ b/docs/ares_dns_rcode_t.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_record.3 diff --git a/docs/ares_dns_rec_type_t.3 b/docs/ares_dns_rec_type_t.3 index 4acc581d29..363b1fc637 100644 --- a/docs/ares_dns_rec_type_t.3 +++ b/docs/ares_dns_rec_type_t.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_record.3 diff --git a/docs/ares_dns_record.3 b/docs/ares_dns_record.3 index 47ca95b057..a8d05eeab6 100644 --- a/docs/ares_dns_record.3 +++ b/docs/ares_dns_record.3 @@ -1,4 +1,4 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .\" .TH ARES_DNS_RECORD 3 "12 November 2023" @@ -339,7 +339,7 @@ from \fIares_send_dnsrec(3)\fP or \fIares_search_dnsrec(3)\fP. The structure to be duplicated is passed in the .IR dnsrec parameter, and the duplicated copy is returned, or NULL on error such as -out of memory. +out of memory, or if argument is NULL. The \fIares_dns_record_get_id(3)\fP function is used to retrieve the DNS message id from the DNS record provided in the diff --git a/docs/ares_dns_record_create.3 b/docs/ares_dns_record_create.3 index 4acc581d29..363b1fc637 100644 --- a/docs/ares_dns_record_create.3 +++ b/docs/ares_dns_record_create.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_record.3 diff --git a/docs/ares_dns_record_destroy.3 b/docs/ares_dns_record_destroy.3 index 4acc581d29..363b1fc637 100644 --- a/docs/ares_dns_record_destroy.3 +++ b/docs/ares_dns_record_destroy.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_record.3 diff --git a/docs/ares_dns_record_duplicate.3 b/docs/ares_dns_record_duplicate.3 index 4acc581d29..363b1fc637 100644 --- a/docs/ares_dns_record_duplicate.3 +++ b/docs/ares_dns_record_duplicate.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_record.3 diff --git a/docs/ares_dns_record_get_flags.3 b/docs/ares_dns_record_get_flags.3 index 4acc581d29..363b1fc637 100644 --- a/docs/ares_dns_record_get_flags.3 +++ b/docs/ares_dns_record_get_flags.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_record.3 diff --git a/docs/ares_dns_record_get_id.3 b/docs/ares_dns_record_get_id.3 index 4acc581d29..363b1fc637 100644 --- a/docs/ares_dns_record_get_id.3 +++ b/docs/ares_dns_record_get_id.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_record.3 diff --git a/docs/ares_dns_record_get_opcode.3 b/docs/ares_dns_record_get_opcode.3 index 4acc581d29..363b1fc637 100644 --- a/docs/ares_dns_record_get_opcode.3 +++ b/docs/ares_dns_record_get_opcode.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_record.3 diff --git a/docs/ares_dns_record_get_rcode.3 b/docs/ares_dns_record_get_rcode.3 index 4acc581d29..363b1fc637 100644 --- a/docs/ares_dns_record_get_rcode.3 +++ b/docs/ares_dns_record_get_rcode.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_record.3 diff --git a/docs/ares_dns_record_query_add.3 b/docs/ares_dns_record_query_add.3 index 4acc581d29..363b1fc637 100644 --- a/docs/ares_dns_record_query_add.3 +++ b/docs/ares_dns_record_query_add.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_record.3 diff --git a/docs/ares_dns_record_query_cnt.3 b/docs/ares_dns_record_query_cnt.3 index 4acc581d29..363b1fc637 100644 --- a/docs/ares_dns_record_query_cnt.3 +++ b/docs/ares_dns_record_query_cnt.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_record.3 diff --git a/docs/ares_dns_record_query_get.3 b/docs/ares_dns_record_query_get.3 index 4acc581d29..363b1fc637 100644 --- a/docs/ares_dns_record_query_get.3 +++ b/docs/ares_dns_record_query_get.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_record.3 diff --git a/docs/ares_dns_record_query_set_name.3 b/docs/ares_dns_record_query_set_name.3 index 4acc581d29..363b1fc637 100644 --- a/docs/ares_dns_record_query_set_name.3 +++ b/docs/ares_dns_record_query_set_name.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_record.3 diff --git a/docs/ares_dns_record_query_set_type.3 b/docs/ares_dns_record_query_set_type.3 index 4acc581d29..363b1fc637 100644 --- a/docs/ares_dns_record_query_set_type.3 +++ b/docs/ares_dns_record_query_set_type.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_record.3 diff --git a/docs/ares_dns_record_rr_add.3 b/docs/ares_dns_record_rr_add.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_record_rr_add.3 +++ b/docs/ares_dns_record_rr_add.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_record_rr_cnt.3 b/docs/ares_dns_record_rr_cnt.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_record_rr_cnt.3 +++ b/docs/ares_dns_record_rr_cnt.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_record_rr_del.3 b/docs/ares_dns_record_rr_del.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_record_rr_del.3 +++ b/docs/ares_dns_record_rr_del.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_record_rr_get.3 b/docs/ares_dns_record_rr_get.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_record_rr_get.3 +++ b/docs/ares_dns_record_rr_get.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_record_rr_get_const.3 b/docs/ares_dns_record_rr_get_const.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_record_rr_get_const.3 +++ b/docs/ares_dns_record_rr_get_const.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_record_set_id.3 b/docs/ares_dns_record_set_id.3 index 4acc581d29..363b1fc637 100644 --- a/docs/ares_dns_record_set_id.3 +++ b/docs/ares_dns_record_set_id.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_record.3 diff --git a/docs/ares_dns_rr.3 b/docs/ares_dns_rr.3 index 4da768650b..fc30152d62 100644 --- a/docs/ares_dns_rr.3 +++ b/docs/ares_dns_rr.3 @@ -1,4 +1,4 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .\" .TH ARES_DNS_RR 3 "12 November 2023" diff --git a/docs/ares_dns_rr_add_abin.3 b/docs/ares_dns_rr_add_abin.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_add_abin.3 +++ b/docs/ares_dns_rr_add_abin.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_rr_del_abin.3 b/docs/ares_dns_rr_del_abin.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_del_abin.3 +++ b/docs/ares_dns_rr_del_abin.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_rr_del_opt_byid.3 b/docs/ares_dns_rr_del_opt_byid.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_del_opt_byid.3 +++ b/docs/ares_dns_rr_del_opt_byid.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_rr_get_abin.3 b/docs/ares_dns_rr_get_abin.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_get_abin.3 +++ b/docs/ares_dns_rr_get_abin.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_rr_get_abin_cnt.3 b/docs/ares_dns_rr_get_abin_cnt.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_get_abin_cnt.3 +++ b/docs/ares_dns_rr_get_abin_cnt.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_rr_get_addr.3 b/docs/ares_dns_rr_get_addr.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_get_addr.3 +++ b/docs/ares_dns_rr_get_addr.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_rr_get_addr6.3 b/docs/ares_dns_rr_get_addr6.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_get_addr6.3 +++ b/docs/ares_dns_rr_get_addr6.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_rr_get_bin.3 b/docs/ares_dns_rr_get_bin.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_get_bin.3 +++ b/docs/ares_dns_rr_get_bin.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_rr_get_class.3 b/docs/ares_dns_rr_get_class.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_get_class.3 +++ b/docs/ares_dns_rr_get_class.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_rr_get_keys.3 b/docs/ares_dns_rr_get_keys.3 index a7758577c5..2c2a954969 100644 --- a/docs/ares_dns_rr_get_keys.3 +++ b/docs/ares_dns_rr_get_keys.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_mapping.3 diff --git a/docs/ares_dns_rr_get_name.3 b/docs/ares_dns_rr_get_name.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_get_name.3 +++ b/docs/ares_dns_rr_get_name.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_rr_get_opt.3 b/docs/ares_dns_rr_get_opt.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_get_opt.3 +++ b/docs/ares_dns_rr_get_opt.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_rr_get_opt_byid.3 b/docs/ares_dns_rr_get_opt_byid.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_get_opt_byid.3 +++ b/docs/ares_dns_rr_get_opt_byid.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_rr_get_opt_cnt.3 b/docs/ares_dns_rr_get_opt_cnt.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_get_opt_cnt.3 +++ b/docs/ares_dns_rr_get_opt_cnt.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_rr_get_str.3 b/docs/ares_dns_rr_get_str.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_get_str.3 +++ b/docs/ares_dns_rr_get_str.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_rr_get_ttl.3 b/docs/ares_dns_rr_get_ttl.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_get_ttl.3 +++ b/docs/ares_dns_rr_get_ttl.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_rr_get_type.3 b/docs/ares_dns_rr_get_type.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_get_type.3 +++ b/docs/ares_dns_rr_get_type.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_rr_get_u16.3 b/docs/ares_dns_rr_get_u16.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_get_u16.3 +++ b/docs/ares_dns_rr_get_u16.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_rr_get_u32.3 b/docs/ares_dns_rr_get_u32.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_get_u32.3 +++ b/docs/ares_dns_rr_get_u32.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_rr_get_u8.3 b/docs/ares_dns_rr_get_u8.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_get_u8.3 +++ b/docs/ares_dns_rr_get_u8.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_rr_key_t.3 b/docs/ares_dns_rr_key_t.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_key_t.3 +++ b/docs/ares_dns_rr_key_t.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_rr_set_addr.3 b/docs/ares_dns_rr_set_addr.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_set_addr.3 +++ b/docs/ares_dns_rr_set_addr.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_rr_set_addr6.3 b/docs/ares_dns_rr_set_addr6.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_set_addr6.3 +++ b/docs/ares_dns_rr_set_addr6.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_rr_set_bin.3 b/docs/ares_dns_rr_set_bin.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_set_bin.3 +++ b/docs/ares_dns_rr_set_bin.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_rr_set_opt.3 b/docs/ares_dns_rr_set_opt.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_set_opt.3 +++ b/docs/ares_dns_rr_set_opt.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_rr_set_str.3 b/docs/ares_dns_rr_set_str.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_set_str.3 +++ b/docs/ares_dns_rr_set_str.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_rr_set_u16.3 b/docs/ares_dns_rr_set_u16.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_set_u16.3 +++ b/docs/ares_dns_rr_set_u16.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_rr_set_u32.3 b/docs/ares_dns_rr_set_u32.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_set_u32.3 +++ b/docs/ares_dns_rr_set_u32.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_rr_set_u8.3 b/docs/ares_dns_rr_set_u8.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_rr_set_u8.3 +++ b/docs/ares_dns_rr_set_u8.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_section_t.3 b/docs/ares_dns_section_t.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_dns_section_t.3 +++ b/docs/ares_dns_section_t.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_dns_write.3 b/docs/ares_dns_write.3 index 4acc581d29..363b1fc637 100644 --- a/docs/ares_dns_write.3 +++ b/docs/ares_dns_write.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_record.3 diff --git a/docs/ares_init.3 b/docs/ares_init.3 index 6f81734ce3..979a4cc6ea 100644 --- a/docs/ares_init.3 +++ b/docs/ares_init.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_init_options.3 diff --git a/docs/ares_process_fd.3 b/docs/ares_process_fd.3 index 94e50f41a9..32eef39356 100644 --- a/docs/ares_process_fd.3 +++ b/docs/ares_process_fd.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_process.3 diff --git a/docs/ares_process_fds.3 b/docs/ares_process_fds.3 index 94e50f41a9..32eef39356 100644 --- a/docs/ares_process_fds.3 +++ b/docs/ares_process_fds.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_process.3 diff --git a/docs/ares_process_pending_write.3 b/docs/ares_process_pending_write.3 index 9084334195..0eb271b90c 100644 --- a/docs/ares_process_pending_write.3 +++ b/docs/ares_process_pending_write.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_set_pending_write_cb.3 diff --git a/docs/ares_query_dnsrec.3 b/docs/ares_query_dnsrec.3 index b178e98764..3335517718 100644 --- a/docs/ares_query_dnsrec.3 +++ b/docs/ares_query_dnsrec.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_query.3 diff --git a/docs/ares_queue.3 b/docs/ares_queue.3 index 276d31f608..b462bc34f5 100644 --- a/docs/ares_queue.3 +++ b/docs/ares_queue.3 @@ -1,5 +1,5 @@ .\" -.\" Copyright 2024 by the c-ares project and its contributors +.\" Copyright 2024 by The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .\" .TH ARES_QUEUE 3 "16 February 2024" diff --git a/docs/ares_queue_active_queries.3 b/docs/ares_queue_active_queries.3 index c16c69ddcb..940944d80e 100644 --- a/docs/ares_queue_active_queries.3 +++ b/docs/ares_queue_active_queries.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2024 The c-ares project and its contributors. +.\" Copyright (C) 2024 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_queue.3 diff --git a/docs/ares_queue_wait_empty.3 b/docs/ares_queue_wait_empty.3 index c16c69ddcb..940944d80e 100644 --- a/docs/ares_queue_wait_empty.3 +++ b/docs/ares_queue_wait_empty.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2024 The c-ares project and its contributors. +.\" Copyright (C) 2024 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_queue.3 diff --git a/docs/ares_reinit.3 b/docs/ares_reinit.3 index 242483690e..123c69c47c 100644 --- a/docs/ares_reinit.3 +++ b/docs/ares_reinit.3 @@ -1,5 +1,5 @@ .\" -.\" Copyright 2023 by the c-ares project and its contributors +.\" Copyright 2023 by The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .\" .TH ARES_REINIT 3 "12 November 2023" diff --git a/docs/ares_search_dnsrec.3 b/docs/ares_search_dnsrec.3 index 86c2317c07..abd5acdc77 100644 --- a/docs/ares_search_dnsrec.3 +++ b/docs/ares_search_dnsrec.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_search.3 diff --git a/docs/ares_send.3 b/docs/ares_send.3 index df3e3bbe41..f6ea9140e2 100644 --- a/docs/ares_send.3 +++ b/docs/ares_send.3 @@ -113,9 +113,6 @@ is being destroyed; the query will not be completed. .B ARES_ENOSERVER The query will not be completed because no DNS servers were configured on the channel. -.TP 19 -.B ARES_EBADQUERY -Misformatted DNS query. .PP The callback argument diff --git a/docs/ares_send_dnsrec.3 b/docs/ares_send_dnsrec.3 index f5596f5cf0..2674ae303e 100644 --- a/docs/ares_send_dnsrec.3 +++ b/docs/ares_send_dnsrec.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_send.3 diff --git a/docs/ares_set_pending_write_cb.3 b/docs/ares_set_pending_write_cb.3 index 7af06e47de..94e5171066 100644 --- a/docs/ares_set_pending_write_cb.3 +++ b/docs/ares_set_pending_write_cb.3 @@ -1,5 +1,5 @@ .\" -.\" Copyright 2024 by the c-ares project and its contributors +.\" Copyright 2024 by The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .\" .TH ARES_SET_NOTIFY_PENDING_WRITE_CALLBACK 3 "13 Aug 2024" diff --git a/docs/ares_set_server_state_callback.3 b/docs/ares_set_server_state_callback.3 index 04fbde4c7a..d66a7a9f67 100644 --- a/docs/ares_set_server_state_callback.3 +++ b/docs/ares_set_server_state_callback.3 @@ -1,5 +1,5 @@ .\" -.\" Copyright 2024 by the c-ares project and its contributors +.\" Copyright 2024 by The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .\" .TH ARES_SET_SERVER_STATE_CALLBACK 3 "26 Apr 2024" diff --git a/docs/ares_set_socket_functions_ex.3 b/docs/ares_set_socket_functions_ex.3 index a0f02456c3..f387c3f3ee 100644 --- a/docs/ares_set_socket_functions_ex.3 +++ b/docs/ares_set_socket_functions_ex.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2024 The c-ares project and its contributors. +.\" Copyright (C) 2024 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_set_socket_functions.3 diff --git a/docs/ares_threadsafety.3 b/docs/ares_threadsafety.3 index d9c38d801e..27606330e2 100644 --- a/docs/ares_threadsafety.3 +++ b/docs/ares_threadsafety.3 @@ -1,5 +1,5 @@ .\" -.\" Copyright 2023 by the c-ares project and its contributors +.\" Copyright 2023 by The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .\" .TH ARES_THREADSAFETY 3 "26 November 2023" diff --git a/docs/ares_tlsa_match_t.3 b/docs/ares_tlsa_match_t.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_tlsa_match_t.3 +++ b/docs/ares_tlsa_match_t.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_tlsa_selector_t.3 b/docs/ares_tlsa_selector_t.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_tlsa_selector_t.3 +++ b/docs/ares_tlsa_selector_t.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/docs/ares_tlsa_usage_t.3 b/docs/ares_tlsa_usage_t.3 index b93e4cd4e3..b1f4f54647 100644 --- a/docs/ares_tlsa_usage_t.3 +++ b/docs/ares_tlsa_usage_t.3 @@ -1,3 +1,3 @@ -.\" Copyright (C) 2023 The c-ares project and its contributors. +.\" Copyright (C) 2023 The c-ares project and its contributors .\" SPDX-License-Identifier: MIT .so man3/ares_dns_rr.3 diff --git a/include/ares_dns_record.h b/include/ares_dns_record.h index 2896eab24b..17469d62bd 100644 --- a/include/ares_dns_record.h +++ b/include/ares_dns_record.h @@ -1103,8 +1103,10 @@ CARES_EXTERN ares_status_t ares_dns_write(const ares_dns_record_t *dnsrec, /*! Duplicate a complete DNS message. This does not copy internal members * (such as the ttl decrement capability). * + * Returns NULL if \p dnsrec is NULL. + * * \param[in] dnsrec Pointer to initialized and filled DNS record object. - * \return duplicted DNS record object, or NULL on out of memory. + * \return duplicated DNS record object, or NULL on out of memory. */ CARES_EXTERN ares_dns_record_t * ares_dns_record_duplicate(const ares_dns_record_t *dnsrec); diff --git a/src/lib/ares_config.h.cmake b/src/lib/ares_config.h.cmake index def1e2b8ca..1cc7e93baf 100644 --- a/src/lib/ares_config.h.cmake +++ b/src/lib/ares_config.h.cmake @@ -145,6 +145,18 @@ /* Define to 1 if you have the `if_nametoindex' function. */ #cmakedefine HAVE_IF_NAMETOINDEX 1 +/* Define to 1 if you have the `GetBestRoute2' function. */ +#cmakedefine HAVE_GETBESTROUTE2 1 + +/* Define to 1 if you have the `WSAIoctl' function. */ +#cmakedefine HAVE_WSAIOCTL 1 + +/* Define to 1 if you have the `OVERLAPPED_ENTRY' data type. */ +#cmakedefine HAVE_OVERLAPPED_ENTRY 1 + +/* Define to 1 if you have the `GetQueuedCompletionStatusEx' function. */ +#cmakedefine HAVE_GETQUEUEDCOMPLETIONSTATUSEX 1 + /* Define to 1 if you have the `ConvertInterfaceIndexToLuid' function. */ #cmakedefine HAVE_CONVERTINTERFACEINDEXTOLUID 1 @@ -157,6 +169,9 @@ /* Define to 1 if you have the `RegisterWaitForSingleObject' function. */ #cmakedefine HAVE_REGISTERWAITFORSINGLEOBJECT 1 +/* Define to 1 if you have the `SetFileCompletionNotificationModes' function. */ +#cmakedefine HAVE_SETFILECOMPLETIONNOTIFICATIONMODES 1 + /* Define to 1 if you have a IPv6 capable working inet_net_pton function. */ #cmakedefine HAVE_INET_NET_PTON 1 diff --git a/src/lib/ares_cookie.c b/src/lib/ares_cookie.c index f31c74e748..ed50aacfa8 100644 --- a/src/lib/ares_cookie.c +++ b/src/lib/ares_cookie.c @@ -115,7 +115,7 @@ * - If `cookie.unsupported_ts` evaluates less than * `COOKIE_UNSUPPORTED_TIMEOUT` * - Ensure there is no EDNS cookie opt (10) set (shouldn't be unless - * requestor had put this themselves), then **skip any remaining + * requester had put this themselves), then **skip any remaining * processing** as we don't want to try to send cookies. * - Otherwise: * - clear all cookie settings, set `cookie.state = INITIAL`. diff --git a/src/lib/ares_ipv6.h b/src/lib/ares_ipv6.h index 5da341b010..d2007cc29e 100644 --- a/src/lib/ares_ipv6.h +++ b/src/lib/ares_ipv6.h @@ -90,6 +90,16 @@ struct addrinfo { # define NS_INT16SZ 2 #endif +/* Windows XP Compatibility with later MSVC/Mingw versions */ +#if defined(_WIN32) +# if !defined(IF_MAX_STRING_SIZE) +# define IF_MAX_STRING_SIZE 256 /* =256 in */ +# endif +# if !defined(NDIS_IF_MAX_STRING_SIZE) +# define NDIS_IF_MAX_STRING_SIZE IF_MAX_STRING_SIZE /* =256 in */ +# endif +#endif + #ifndef IF_NAMESIZE # ifdef IFNAMSIZ # define IF_NAMESIZE IFNAMSIZ diff --git a/src/lib/ares_sysconfig_win.c b/src/lib/ares_sysconfig_win.c index f6e07f92e4..01109a89ba 100644 --- a/src/lib/ares_sysconfig_win.c +++ b/src/lib/ares_sysconfig_win.c @@ -176,6 +176,7 @@ static int compareAddresses(const void *arg1, const void *arg2) return 0; } +#if defined(HAVE_GETBESTROUTE2) && !defined(__WATCOMC__) /* There can be multiple routes to "the Internet". And there can be different * DNS servers associated with each of the interfaces that offer those routes. * We have to assume that any DNS server can serve any request. But, some DNS @@ -213,18 +214,6 @@ static ULONG getBestRouteMetric(IF_LUID * const luid, /* Can't be const :( */ const SOCKADDR_INET * const dest, const ULONG interfaceMetric) { - /* On this interface, get the best route to that destination. */ -# if defined(__WATCOMC__) - /* OpenWatcom's builtin Windows SDK does not have a definition for - * MIB_IPFORWARD_ROW2, and also does not allow the usage of SOCKADDR_INET - * as a variable. Let's work around this by returning the worst possible - * metric, but only when using the OpenWatcom compiler. - * It may be worth investigating using a different version of the Windows - * SDK with OpenWatcom in the future, though this may be fixed in OpenWatcom - * 2.0. - */ - return (ULONG)-1; -# else MIB_IPFORWARD_ROW2 row; SOCKADDR_INET ignored; if (GetBestRoute2(/* The interface to use. The index is ignored since we are @@ -257,8 +246,8 @@ static ULONG getBestRouteMetric(IF_LUID * const luid, /* Can't be const :( */ * which describes the combination as a "sum". */ return row.Metric + interfaceMetric; -# endif /* __WATCOMC__ */ } +#endif /* * get_DNS_Windows() @@ -379,9 +368,21 @@ static ares_bool_t get_DNS_Windows(char **outptr) addressesSize = newSize; } +# if defined(HAVE_GETBESTROUTE2) && !defined(__WATCOMC__) + /* OpenWatcom's builtin Windows SDK does not have a definition for + * MIB_IPFORWARD_ROW2, and also does not allow the usage of SOCKADDR_INET + * as a variable. Let's work around this by returning the worst possible + * metric, but only when using the OpenWatcom compiler. + * It may be worth investigating using a different version of the Windows + * SDK with OpenWatcom in the future, though this may be fixed in OpenWatcom + * 2.0. + */ addresses[addressesIndex].metric = getBestRouteMetric( &ipaaEntry->Luid, (SOCKADDR_INET *)((void *)(namesrvr.sa)), ipaaEntry->Ipv4Metric); +# else + addresses[addressesIndex].metric = (ULONG)-1; +# endif /* Record insertion index to make qsort stable */ addresses[addressesIndex].orig_idx = addressesIndex; @@ -423,9 +424,13 @@ static ares_bool_t get_DNS_Windows(char **outptr) ll_scope = ipaaEntry->Ipv6IfIndex; } +# if defined(HAVE_GETBESTROUTE2) && !defined(__WATCOMC__) addresses[addressesIndex].metric = getBestRouteMetric( &ipaaEntry->Luid, (SOCKADDR_INET *)((void *)(namesrvr.sa)), ipaaEntry->Ipv6Metric); +# else + addresses[addressesIndex].metric = (ULONG)-1; +# endif /* Record insertion index to make qsort stable */ addresses[addressesIndex].orig_idx = addressesIndex; diff --git a/src/lib/config-win32.h b/src/lib/config-win32.h index be233a2f8b..5fe7815a0d 100644 --- a/src/lib/config-win32.h +++ b/src/lib/config-win32.h @@ -237,7 +237,7 @@ # undef HAVE_NETIOAPI_H #endif -/* Threading support enabled */ +/* Threading support enabled on Windows always (really XP+ only). */ #define CARES_THREADS 1 /* ---------------------------------------------------------------- */ @@ -358,6 +358,29 @@ /* Define to 1 if you have the `RegisterWaitForSingleObject' function. */ #define HAVE_REGISTERWAITFORSINGLEOBJECT 1 +#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0600) +/* Define to 1 if you have the `SetFileCompletionNotificationModes' function. */ +# define HAVE_SETFILECOMPLETIONNOTIFICATIONMODES 1 +/* Define to 1 if you have the `WSAIoctl' function. */ +# define HAVE_WSAIOCTL 1 +/* Define to 1 if you have the `GetQueuedCompletionStatusEx' function. */ +# define HAVE_GETQUEUEDCOMPLETIONSTATUSEX 1 +#endif + +/* OVERLAPPED_ENTRY was introduced with Windows Vista for use by + * GetQueuedCompletionStatusEx(). We define it if it doesn't exist as we + * re-implement GetQueuedCompletionStatusEx() for compatibility with XP. + * However, OVERLAPPED_ENTRY is *always* defined when using a Vista or Later + * SDK even when _WIN32_WINNT is set to < 0x0600. So we're assuming anyone + * trying to support older windows versions is still probably compiling with a + * newer SDK. + * We have no way to detect the existence at compile time since we're not using + * autotools or cmake, so assume it is defined. If someone is using something + * ancient like VC6 with the Windows Platform SDK for XP, then they'll need to + * modify this define. + */ +#define HAVE_OVERLAPPED_ENTRY 1 + #if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0600) && \ !defined(__WATCOMC__) && !defined(WATT32) /* Define if you have if_nametoindex() */ @@ -370,6 +393,8 @@ # define HAVE_CONVERTINTERFACELUIDTONAMEA 1 /* Define to 1 if you have the `NotifyIpInterfaceChange' function. */ # define HAVE_NOTIFYIPINTERFACECHANGE 1 +/* Define to 1 if you have the `GetBestRoute2` function */ +# define HAVE_GETBESTROUTE2 1 #endif /* ---------------------------------------------------------------- */ diff --git a/src/lib/event/ares_event.h b/src/lib/event/ares_event.h index 36cd10dcf8..bf298dfb61 100644 --- a/src/lib/event/ares_event.h +++ b/src/lib/event/ares_event.h @@ -159,30 +159,33 @@ ares_status_t ares_event_update(ares_event_t **event, ares_event_thread_t *e, ares_event_signal_cb_t signal_cb); -#ifdef HAVE_PIPE +#ifdef CARES_THREADS +# ifdef HAVE_PIPE ares_event_t *ares_pipeevent_create(ares_event_thread_t *e); -#endif +# endif -#ifdef HAVE_POLL +# ifdef HAVE_POLL extern const ares_event_sys_t ares_evsys_poll; -#endif +# endif -#ifdef HAVE_KQUEUE +# ifdef HAVE_KQUEUE extern const ares_event_sys_t ares_evsys_kqueue; -#endif +# endif -#ifdef HAVE_EPOLL +# ifdef HAVE_EPOLL extern const ares_event_sys_t ares_evsys_epoll; -#endif +# endif -#ifdef _WIN32 +# ifdef _WIN32 extern const ares_event_sys_t ares_evsys_win32; -#endif +# endif /* All systems have select(), but not all have a way to wake, so we require * pipe() to wake the select() */ -#ifdef HAVE_PIPE +# ifdef HAVE_PIPE extern const ares_event_sys_t ares_evsys_select; +# endif + #endif #endif diff --git a/src/lib/event/ares_event_configchg.c b/src/lib/event/ares_event_configchg.c index 5ecc6888ab..4dd6df8d1d 100644 --- a/src/lib/event/ares_event_configchg.c +++ b/src/lib/event/ares_event_configchg.c @@ -26,7 +26,7 @@ #include "ares_private.h" #include "ares_event.h" -#ifdef __ANDROID__ +#if defined(__ANDROID__) && defined(CARES_THREADS) ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, ares_event_thread_t *e) @@ -43,7 +43,7 @@ void ares_event_configchg_destroy(ares_event_configchg_t *configchg) (void)configchg; } -#elif defined(__linux__) +#elif defined(__linux__) && defined(CARES_THREADS) # include @@ -174,7 +174,7 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, return status; } -#elif defined(USE_WINSOCK) +#elif defined(USE_WINSOCK) && defined(CARES_THREADS) # include # include @@ -379,7 +379,7 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, return status; } -#elif defined(__APPLE__) +#elif defined(__APPLE__) && defined(CARES_THREADS) # include # include @@ -531,7 +531,7 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, return status; } -#elif defined(HAVE_STAT) && !defined(_WIN32) +#elif defined(HAVE_STAT) && !defined(_WIN32) && defined(CARES_THREADS) # ifdef HAVE_SYS_TYPES_H # include # endif @@ -722,6 +722,8 @@ void ares_event_configchg_destroy(ares_event_configchg_t *configchg) 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; } @@ -729,6 +731,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; } #endif diff --git a/src/lib/event/ares_event_epoll.c b/src/lib/event/ares_event_epoll.c index 538c38b4f9..d451c86a3d 100644 --- a/src/lib/event/ares_event_epoll.c +++ b/src/lib/event/ares_event_epoll.c @@ -26,6 +26,8 @@ #include "ares_private.h" #include "ares_event.h" +#if defined(HAVE_EPOLL) && defined(CARES_THREADS) + #ifdef HAVE_SYS_EPOLL_H # include #endif @@ -33,8 +35,6 @@ # include #endif -#ifdef HAVE_EPOLL - typedef struct { int epoll_fd; } ares_evsys_epoll_t; diff --git a/src/lib/event/ares_event_kqueue.c b/src/lib/event/ares_event_kqueue.c index dbbd0dbd9f..00cdcbe9c2 100644 --- a/src/lib/event/ares_event_kqueue.c +++ b/src/lib/event/ares_event_kqueue.c @@ -26,6 +26,8 @@ #include "ares_private.h" #include "ares_event.h" +#if defined(HAVE_KQUEUE) && defined(CARES_THREADS) + #ifdef HAVE_SYS_TYPES_H # include #endif @@ -39,8 +41,6 @@ # include #endif -#ifdef HAVE_KQUEUE - typedef struct { int kqueue_fd; struct kevent *changelist; diff --git a/src/lib/event/ares_event_poll.c b/src/lib/event/ares_event_poll.c index c6ab4b6207..28e3c09657 100644 --- a/src/lib/event/ares_event_poll.c +++ b/src/lib/event/ares_event_poll.c @@ -25,12 +25,13 @@ */ #include "ares_private.h" #include "ares_event.h" + +#if defined(HAVE_POLL) && defined(CARES_THREADS) + #ifdef HAVE_POLL_H # include #endif -#if defined(HAVE_POLL) - static ares_bool_t ares_evsys_poll_init(ares_event_thread_t *e) { e->ev_signal = ares_pipeevent_create(e); diff --git a/src/lib/event/ares_event_select.c b/src/lib/event/ares_event_select.c index 4d7c085d87..df758b5a1e 100644 --- a/src/lib/event/ares_event_select.c +++ b/src/lib/event/ares_event_select.c @@ -31,13 +31,14 @@ #include "ares_private.h" #include "ares_event.h" -#ifdef HAVE_SYS_SELECT_H -# include -#endif /* All systems have select(), but not all have a way to wake, so we require * pipe() to wake the select() */ -#if defined(HAVE_PIPE) +#if defined(HAVE_PIPE) && defined(CARES_THREADS) + +#ifdef HAVE_SYS_SELECT_H +# include +#endif static ares_bool_t ares_evsys_select_init(ares_event_thread_t *e) { diff --git a/src/lib/event/ares_event_thread.c b/src/lib/event/ares_event_thread.c index d59b7880a4..c77514e02c 100644 --- a/src/lib/event/ares_event_thread.c +++ b/src/lib/event/ares_event_thread.c @@ -26,6 +26,7 @@ #include "ares_private.h" #include "ares_event.h" +#ifdef CARES_THREADS static void ares_event_destroy_cb(void *arg) { ares_event_t *event = arg; @@ -549,3 +550,18 @@ ares_status_t ares_event_thread_init(ares_channel_t *channel) return ARES_SUCCESS; } + +#else + +ares_status_t ares_event_thread_init(ares_channel_t *channel) +{ + (void)channel; + return ARES_ENOTIMP; +} + +void ares_event_thread_destroy(ares_channel_t *channel) +{ + (void)channel; +} + +#endif diff --git a/src/lib/event/ares_event_wake_pipe.c b/src/lib/event/ares_event_wake_pipe.c index d3b166a3d6..cd1534bbbd 100644 --- a/src/lib/event/ares_event_wake_pipe.c +++ b/src/lib/event/ares_event_wake_pipe.c @@ -25,14 +25,16 @@ */ #include "ares_private.h" #include "ares_event.h" -#ifdef HAVE_UNISTD_H -# include -#endif -#ifdef HAVE_FCNTL_H -# include -#endif -#ifdef HAVE_PIPE +#if defined(HAVE_PIPE) && defined(CARES_THREADS) + +# ifdef HAVE_UNISTD_H +# include +# endif +# ifdef HAVE_FCNTL_H +# include +# endif + typedef struct { int filedes[2]; } ares_pipeevent_t; diff --git a/src/lib/event/ares_event_win32.c b/src/lib/event/ares_event_win32.c index 1531b6d81d..4111f17dee 100644 --- a/src/lib/event/ares_event_win32.c +++ b/src/lib/event/ares_event_win32.c @@ -37,12 +37,14 @@ #include "ares_private.h" #include "ares_event.h" #include "ares_event_win32.h" + + +#if defined(USE_WINSOCK) && defined(CARES_THREADS) + #ifdef HAVE_LIMITS_H # include #endif -#if defined(USE_WINSOCK) - /* IMPLEMENTATION NOTES * ==================== * @@ -402,10 +404,12 @@ static ares_slist_node_t *ares_afd_handle_create(ares_evsys_win32_t *ew) goto fail; } +#ifdef HAVE_SETFILECOMPLETIONNOTIFICATIONMODES if (!SetFileCompletionNotificationModes(afd->afd_handle, FILE_SKIP_SET_EVENT_ON_HANDLE)) { goto fail; } +#endif node = ares_slist_insert(ew->afd_handles, afd); if (node == NULL) { @@ -519,6 +523,11 @@ static ares_bool_t ares_evsys_win32_init(ares_event_thread_t *e) static ares_socket_t ares_evsys_win32_basesocket(ares_socket_t socket) { +#ifndef HAVE_WSAIOCTL + /* Assume we don't have an LSP and return the provided socket as the base + * socket. WSAIoctl() isn't supported on Windows XP or below */ + return socket; +#else while (1) { DWORD bytes; /* Not used */ ares_socket_t base_socket = ARES_SOCKET_BAD; @@ -556,6 +565,7 @@ static ares_socket_t ares_evsys_win32_basesocket(ares_socket_t socket) } return socket; +#endif } static ares_bool_t ares_evsys_win32_afd_enqueue(ares_event_t *event, @@ -667,7 +677,7 @@ static ares_bool_t ares_evsys_win32_afd_cancel(ares_evsys_win32_eventdata_t *ed) /* NtCancelIoFileEx() may return STATUS_NOT_FOUND if the operation completed * just before calling NtCancelIoFileEx(), but we have not yet received the - * notifiction (but it should be queued for the next IOCP event). */ + * notification (but it should be queued for the next IOCP event). */ if (status == STATUS_SUCCESS || status == STATUS_NOT_FOUND) { return ARES_TRUE; } @@ -904,6 +914,46 @@ static ares_bool_t ares_evsys_win32_process_socket_event( return ARES_TRUE; } +static BOOL ares_GetQueuedCompletionStatusEx( + HANDLE CompletionPort, + LPOVERLAPPED_ENTRY lpCompletionPortEntries, + ULONG ulCount, + PULONG ulNumEntriesRemoved, + DWORD dwMilliseconds, + BOOL fAlertable) +{ +#ifdef HAVE_GETQUEUEDCOMPLETIONSTATUSEX + return GetQueuedCompletionStatusEx(CompletionPort, lpCompletionPortEntries, + ulCount, ulNumEntriesRemoved, dwMilliseconds, fAlertable); +#else + ULONG i; + + (void)fAlertable; + + memset(lpCompletionPortEntries, 0, + ulCount * sizeof(*lpCompletionPortEntries)); + (*ulNumEntriesRemoved) = 0; + + for (i=0; i 0) { + return TRUE; + } + + return FALSE; +#endif +} + static size_t ares_evsys_win32_wait(ares_event_thread_t *e, unsigned long timeout_ms) { @@ -921,8 +971,9 @@ static size_t ares_evsys_win32_wait(ares_event_thread_t *e, * on subsequent attempts, ensure the timeout is 0 */ do { nentries = maxentries; - status = GetQueuedCompletionStatusEx(ew->iocp_handle, entries, nentries, - &nentries, tout, FALSE); + status = ares_GetQueuedCompletionStatusEx(ew->iocp_handle, entries, + nentries, &nentries, tout, + FALSE); /* Next loop around, we want to return instantly if there are no events to * be processed */ diff --git a/src/lib/event/ares_event_win32.h b/src/lib/event/ares_event_win32.h index 5d0274cd85..f6a242cd1d 100644 --- a/src/lib/event/ares_event_win32.h +++ b/src/lib/event/ares_event_win32.h @@ -156,6 +156,16 @@ typedef NTSTATUS(NTAPI *NtCreateFile_t)( # define HANDLE_FLAG_INHERIT 0x00000001 # endif + +# ifndef HAVE_OVERLAPPED_ENTRY +typedef struct _OVERLAPPED_ENTRY { + ULONG_PTR lpCompletionKey; + LPOVERLAPPED lpOverlapped; + ULONG_PTR Internal; + DWORD dwNumberOfBytesTransferred; +} OVERLAPPED_ENTRY, *LPOVERLAPPED_ENTRY; +# endif + #endif /* _WIN32 */ #endif /* __ARES_EVENT_WIN32_H */ diff --git a/src/lib/inet_net_pton.c b/src/lib/inet_net_pton.c index e1f76ef834..9c1b2bc775 100644 --- a/src/lib/inet_net_pton.c +++ b/src/lib/inet_net_pton.c @@ -82,6 +82,7 @@ static int ares_inet_net_pton_ipv4(const char *src, unsigned char *dst, int bits; const unsigned char *odst = dst; + memset(dst, 0, size); ch = *src++; if (ch == '0' && (src[0] == 'x' || src[0] == 'X') && ares_isascii(src[1]) && ares_isxdigit(src[1])) { diff --git a/src/lib/util/ares_iface_ips.c b/src/lib/util/ares_iface_ips.c index 46cb291e30..c5f507f87e 100644 --- a/src/lib/util/ares_iface_ips.c +++ b/src/lib/util/ares_iface_ips.c @@ -431,8 +431,14 @@ static ares_status_t ares_iface_ips_enumerate(ares_iface_ips_t *ips, } status = ares_iface_ips_add(ips, addrflag, ifname, &addr, +#if _WIN32_WINNT >= 0x0600 ipaddr->OnLinkPrefixLength /* netmask */, - address->Ipv6IfIndex /* ll_scope */); +#else + ipaddr->Address.lpSockaddr->sa_family + == AF_INET?32:128, +#endif + address->Ipv6IfIndex /* ll_scope */ + ); if (status != ARES_SUCCESS) { goto done; diff --git a/src/lib/util/ares_threads.c b/src/lib/util/ares_threads.c index ab0b51afb7..830c854bcc 100644 --- a/src/lib/util/ares_threads.c +++ b/src/lib/util/ares_threads.c @@ -24,6 +24,9 @@ * SPDX-License-Identifier: MIT */ #include "ares_private.h" +#ifdef HAVE_STDINT_H +# include +#endif #ifdef CARES_THREADS # ifdef _WIN32 @@ -68,6 +71,8 @@ void ares_thread_mutex_unlock(ares_thread_mutex_t *mut) LeaveCriticalSection(&mut->mutex); } +# if _WIN32_WINNT >= 0x0600 /* Vista */ + struct ares_thread_cond { CONDITION_VARIABLE cond; }; @@ -119,19 +124,227 @@ ares_status_t ares_thread_cond_wait(ares_thread_cond_t *cond, ares_status_t ares_thread_cond_timedwait(ares_thread_cond_t *cond, ares_thread_mutex_t *mut, - unsigned long timeout_ms) + size_t timeout_ms) { + DWORD tout; + if (cond == NULL || mut == NULL) { return ARES_EFORMERR; } - if (!SleepConditionVariableCS(&cond->cond, &mut->mutex, timeout_ms)) { + if (timeout_ms == SIZE_MAX) { + tout = INFINITE; + } else { + tout = (DWORD)timeout_ms; + } + + if (!SleepConditionVariableCS(&cond->cond, &mut->mutex, tout)) { return ARES_ETIMEOUT; } return ARES_SUCCESS; } +# else + +typedef enum { + ARES_W32_COND_SIGNAL = 0, + ARES_W32_COND_BROADCAST, + ARES_W32_COND_EVMAX, + ARES_W32_COND_NONE = ARES_W32_COND_EVMAX +} ares_w32_cond_event_t; + +struct ares_thread_cond { + HANDLE events[2]; + HANDLE gate; + CRITICAL_SECTION mutex; + size_t waiters; + ares_w32_cond_event_t event; +}; + +ares_thread_cond_t *ares_thread_cond_create(void) +{ + ares_thread_cond_t *cond; + + cond = ares_malloc_zero(sizeof(*cond)); + if (cond == NULL) { + return NULL; + } + + cond->events[ARES_W32_COND_SIGNAL] = CreateEvent(NULL, FALSE, FALSE, NULL); + if (cond->events[ARES_W32_COND_SIGNAL] == NULL) { + goto fail; + } + + cond->events[ARES_W32_COND_BROADCAST] = CreateEvent(NULL, TRUE, FALSE, NULL); + if (cond->events[ARES_W32_COND_BROADCAST] == NULL) { + goto fail; + } + + /* Use a semaphore as a gate so we don't lose signals */ + cond->gate = CreateSemaphore(NULL, 1, 1, NULL); + if (cond->gate == NULL) { + goto fail; + } + + InitializeCriticalSection(&cond->mutex); + cond->waiters = 0; + cond->event = ARES_W32_COND_NONE; + + return cond; + +fail: + ares_thread_cond_destroy(cond); + return NULL; +} + +void ares_thread_cond_destroy(ares_thread_cond_t *cond) +{ + if (cond == NULL) + return; + + if (cond->events[ARES_W32_COND_SIGNAL]) { + CloseHandle(cond->events[ARES_W32_COND_SIGNAL]); + } + if (cond->events[ARES_W32_COND_BROADCAST]) { + CloseHandle(cond->events[ARES_W32_COND_BROADCAST]); + } + if (cond->gate) { + CloseHandle(cond->gate); + } + DeleteCriticalSection(&cond->mutex); + + ares_free(cond); +} + +ares_status_t ares_thread_cond_timedwait(ares_thread_cond_t *cond, + ares_thread_mutex_t *mut, + size_t timeout_ms) +{ + DWORD rv; + DWORD dwMilliseconds; + + if (cond == NULL || mut == NULL) { + return ARES_EFORMERR; + } + + /* We may only enter when no wakeups active this will prevent the lost + * wakeup */ + WaitForSingleObject(cond->gate, INFINITE); + + EnterCriticalSection(&cond->mutex); + /* count waiters passing through */ + cond->waiters++; + LeaveCriticalSection(&cond->mutex); + + /* Open Gate */ + ReleaseSemaphore(cond->gate, 1, NULL); + + /* Release passed in mutex */ + ares_thread_mutex_unlock(mut); + + if (timeout_ms == SIZE_MAX) { + dwMilliseconds = INFINITE; + } else { + dwMilliseconds = (DWORD)timeout_ms; + } + rv = WaitForMultipleObjects(ARES_W32_COND_EVMAX, cond->events, FALSE, + dwMilliseconds); + + /* We go into a critical section to make sure cond->waiters isn't checked + * while we decrement. This is especially important for a timeout since the + * gate may not be closed. We need to check to see if a broadcast/signal was + * pending as this thread could have been preempted prior to + * EnterCriticalSection but after WaitForMultipleObjects() so we may be + * responsible for resetting the event and closing the gate */ + EnterCriticalSection(&cond->mutex); + cond->waiters--; + + if (cond->event != ARES_W32_COND_NONE && cond->waiters == 0) { + /* Last waiter needs to reset the event on(as a broadcast event is not + * automatic) and also re-open the gate */ + if (cond->event == ARES_W32_COND_BROADCAST) { + ResetEvent(cond->events[ARES_W32_COND_BROADCAST]); + } + + /* Open Gate (closed by ares_thread_cond_broadcast()) since there are no + * more waiters for the event */ + ReleaseSemaphore(cond->gate, 1, NULL); + cond->event = ARES_W32_COND_NONE; + } else if (rv == WAIT_OBJECT_0 + ARES_W32_COND_SIGNAL) { + /* If specifically, this thread was signalled and there are more waiting, + * re-open the gate and reset the event */ + ReleaseSemaphore(cond->gate, 1, NULL); + cond->event = ARES_W32_COND_NONE; + } else { + /* This could be a standard timeout with more waiters, don't do anything */ + } + LeaveCriticalSection(&cond->mutex); + + /* re-lock the passed in mutex */ + ares_thread_mutex_lock(mut); + + if (rv == WAIT_TIMEOUT) { + return ARES_ETIMEOUT; + } + + return ARES_SUCCESS; +} + +ares_status_t ares_thread_cond_wait(ares_thread_cond_t *cond, + ares_thread_mutex_t *mut) +{ + return ares_thread_cond_timedwait(cond, mut, SIZE_MAX); +} + +void ares_thread_cond_broadcast(ares_thread_cond_t *cond) +{ + if (cond == NULL) { + return; + } + + /* close gate to prevent more waiters while broadcasting */ + WaitForSingleObject(cond->gate, INFINITE); + + /* If there are waiters, send a broadcast event, + * otherwise, just reopen the gate */ + EnterCriticalSection(&cond->mutex); + + cond->event = ARES_W32_COND_BROADCAST; + if (cond->waiters) { + /* wake all waiters */ + SetEvent(cond->events[ARES_W32_COND_BROADCAST]); + } else { + /* if no waiters just reopen gate */ + ReleaseSemaphore(cond->gate, 1, NULL); + } + + LeaveCriticalSection(&cond->mutex); +} + +void ares_thread_cond_signal(ares_thread_cond_t *cond) +{ + if (cond == NULL) { + return; + } + + /* close gate to prevent more waiters while signalling */ + WaitForSingleObject(cond->gate, INFINITE); + + EnterCriticalSection(&cond->mutex); + cond->event = ARES_W32_COND_SIGNAL; + if (cond->waiters) { + /* wake one waiter */ + SetEvent(cond->events[ARES_W32_COND_SIGNAL]); + } else { + /* no waiters, just reopen the gate */ + ReleaseSemaphore(cond->gate, 1, NULL); + } + LeaveCriticalSection(&cond->mutex); +} + +# endif + struct ares_thread { HANDLE thread; DWORD id; @@ -322,7 +535,7 @@ ares_status_t ares_thread_cond_wait(ares_thread_cond_t *cond, return ARES_SUCCESS; } -static void ares_timespec_timeout(struct timespec *ts, unsigned long add_ms) +static void ares_timespec_timeout(struct timespec *ts, size_t add_ms) { # if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_REALTIME) clock_gettime(CLOCK_REALTIME, ts); @@ -347,7 +560,7 @@ static void ares_timespec_timeout(struct timespec *ts, unsigned long add_ms) ares_status_t ares_thread_cond_timedwait(ares_thread_cond_t *cond, ares_thread_mutex_t *mut, - unsigned long timeout_ms) + size_t timeout_ms) { struct timespec ts; @@ -355,6 +568,10 @@ ares_status_t ares_thread_cond_timedwait(ares_thread_cond_t *cond, return ARES_EFORMERR; } + if (timeout_ms == SIZE_MAX) { + return ares_thread_cond_wait(cond, mut); + } + ares_timespec_timeout(&ts, timeout_ms); if (pthread_cond_timedwait(&cond->cond, &mut->mutex, &ts) != 0) { @@ -470,7 +687,7 @@ ares_status_t ares_thread_cond_wait(ares_thread_cond_t *cond, ares_status_t ares_thread_cond_timedwait(ares_thread_cond_t *cond, ares_thread_mutex_t *mut, - unsigned long timeout_ms) + size_t timeout_ms) { (void)cond; (void)mut; diff --git a/src/lib/util/ares_threads.h b/src/lib/util/ares_threads.h index 95c543e6e9..d7bf551739 100644 --- a/src/lib/util/ares_threads.h +++ b/src/lib/util/ares_threads.h @@ -44,9 +44,11 @@ void ares_thread_cond_signal(ares_thread_cond_t *cond); void ares_thread_cond_broadcast(ares_thread_cond_t *cond); ares_status_t ares_thread_cond_wait(ares_thread_cond_t *cond, ares_thread_mutex_t *mut); + +/* NOTE: value of SIZE_MAX for timeout_ms means infinite */ ares_status_t ares_thread_cond_timedwait(ares_thread_cond_t *cond, ares_thread_mutex_t *mut, - unsigned long timeout_ms); + size_t timeout_ms); struct ares_thread; diff --git a/src/lib/util/ares_uri.h b/src/lib/util/ares_uri.h index 6a703cba5b..2d8138fdc3 100644 --- a/src/lib/util/ares_uri.h +++ b/src/lib/util/ares_uri.h @@ -175,7 +175,7 @@ ares_status_t ares_uri_set_query_key(ares_uri_t *uri, const char *key, */ ares_status_t ares_uri_del_query_key(ares_uri_t *uri, const char *key); -/*! Retrieve the value associted with a query key. Keys are case-insensitive. +/*! Retrieve the value associated with a query key. Keys are case-insensitive. * * \param[in] uri Initialized URI object * \param[in] key Key to retrieve. diff --git a/test/Makefile.m32 b/test/Makefile.m32 index 5227f98fbb..26ab0421a2 100644 --- a/test/Makefile.m32 +++ b/test/Makefile.m32 @@ -10,6 +10,8 @@ CXX = g++ CC = gcc LD = g++ +WIN32_WINNT ?= 0x0602 + ifeq "$(GTEST_ROOT)" "" $(error missing GTEST_ROOT) endif @@ -19,7 +21,7 @@ ARES_SRC_DIR = .. # Where to find the built c-ares static library ARES_BLD_DIR = .. ARESLIB = $(ARES_BLD_DIR)/src/lib/libcares.a -CPPFLAGS = -I$(ARES_SRC_DIR)/include -I$(ARES_SRC_DIR)/src/lib -I$(ARES_SRC_DIR)/src/lib/include -I$(GTEST_ROOT)/include -DCARES_STATICLIB -DCARES_NO_DEPRECATED +CPPFLAGS = -I$(ARES_SRC_DIR)/include -I$(ARES_SRC_DIR)/src/lib -I$(ARES_SRC_DIR)/src/lib/include -I$(GTEST_ROOT)/include -DCARES_STATICLIB -DCARES_NO_DEPRECATED -D_WIN32_WINNT=$(WIN32_WINNT) CXXFLAGS = -Wall $(PTHREAD_CFLAGS) -std=gnu++14 LDFLAGS = LDLIBS = -lws2_32 -liphlpapi diff --git a/test/ares-fuzz.c b/test/ares-fuzz.c index 8203d48da8..239f127dbf 100644 --- a/test/ares-fuzz.c +++ b/test/ares-fuzz.c @@ -33,7 +33,7 @@ #include #include #include -#ifdef WIN32 +#ifdef _WIN32 # include #else # include diff --git a/test/ares-test-internal.cc b/test/ares-test-internal.cc index 3e3760bf13..40bf29f489 100644 --- a/test/ares-test-internal.cc +++ b/test/ares-test-internal.cc @@ -154,6 +154,12 @@ TEST_F(LibraryTest, InetNetPtoN) { CheckPtoN4(2 * 8, 0x01020000, "0x0102/16"); CheckPtoN4(4 * 8, 0x02030405, "02.3.4.5"); + // Partially specified + // (ensures 4 octets are properly zeroed) + a4.s_addr = 0xFFFFFFFF; + ares_inet_net_pton(AF_INET, "10/8", &a4, sizeof(a4)); + EXPECT_EQ(htonl(0x0A000000), a4.s_addr); + EXPECT_EQ(16 * 8, ares_inet_net_pton(AF_INET6, "::", &a6, sizeof(a6))); EXPECT_EQ(16 * 8, ares_inet_net_pton(AF_INET6, "::1", &a6, sizeof(a6))); EXPECT_EQ(16 * 8, ares_inet_net_pton(AF_INET6, "1234:5678::", &a6, sizeof(a6))); @@ -299,6 +305,7 @@ TEST_F(LibraryTest, SlistMisuse) { EXPECT_EQ(NULL, ares_slist_node_claim(NULL)); } +#if !defined(_WIN32) || _WIN32_WINNT >= 0x0600 TEST_F(LibraryTest, IfaceIPs) { ares_status_t status; ares_iface_ips_t *ips = NULL; @@ -354,6 +361,7 @@ TEST_F(LibraryTest, IfaceIPs) { ares_iface_ips_destroy(ips); } +#endif TEST_F(LibraryTest, HtableMisuse) { EXPECT_EQ(NULL, ares_htable_create(NULL, NULL, NULL, NULL)); diff --git a/test/ares-test-live.cc b/test/ares-test-live.cc index e23dadfe23..557c485e36 100644 --- a/test/ares-test-live.cc +++ b/test/ares-test-live.cc @@ -669,115 +669,7 @@ VIRT_NONVIRT_TEST_F(DefaultChannelTest, LiveGetNameInfoAllocFail) { EXPECT_EQ(ARES_ENOMEM, result.status_); } -VIRT_NONVIRT_TEST_F(DefaultChannelTest, GetSock) { - ares_socket_t socks[3] = {ARES_SOCKET_BAD, ARES_SOCKET_BAD, ARES_SOCKET_BAD}; - int bitmask = ares_getsock(channel_, socks, 3); - EXPECT_EQ(0, bitmask); - bitmask = ares_getsock(channel_, nullptr, 0); - EXPECT_EQ(0, bitmask); - - // Ask again with a pending query. - HostResult result; - ares_gethostbyname(channel_, "www.google.com.", AF_INET, HostCallback, &result); - bitmask = ares_getsock(channel_, socks, 3); - EXPECT_NE(0, bitmask); - - size_t sock_cnt = 0; - for (size_t i=0; i<3; i++) { - if (ARES_GETSOCK_READABLE(bitmask, i) || ARES_GETSOCK_WRITABLE(bitmask, i)) { - EXPECT_NE(ARES_SOCKET_BAD, socks[i]); - if (socks[i] != ARES_SOCKET_BAD) - sock_cnt++; - } - } - EXPECT_NE((size_t)0, sock_cnt); - - bitmask = ares_getsock(channel_, nullptr, 0); - EXPECT_EQ(0, bitmask); - - Process(); -} - -TEST_F(LibraryTest, GetTCPSock) { - ares_channel_t *channel; - struct ares_options opts; - memset(&opts, 0, sizeof(opts)); - opts.tcp_port = 53; - opts.flags = ARES_FLAG_USEVC; - int optmask = ARES_OPT_TCP_PORT | ARES_OPT_FLAGS; - EXPECT_EQ(ARES_SUCCESS, ares_init_options(&channel, &opts, optmask)); - EXPECT_NE(nullptr, channel); - - ares_socket_t socks[3] = {ARES_SOCKET_BAD, ARES_SOCKET_BAD, ARES_SOCKET_BAD}; - int bitmask = ares_getsock(channel, socks, 3); - EXPECT_EQ(0, bitmask); - bitmask = ares_getsock(channel, nullptr, 0); - EXPECT_EQ(0, bitmask); - - // Ask again with a pending query. - HostResult result; - ares_gethostbyname(channel, "www.google.com.", AF_INET, HostCallback, &result); - bitmask = ares_getsock(channel, socks, 3); - EXPECT_NE(0, bitmask); - - size_t sock_cnt = 0; - for (size_t i=0; i<3; i++) { - if (ARES_GETSOCK_READABLE(bitmask, i) || ARES_GETSOCK_WRITABLE(bitmask, i)) { - EXPECT_NE(ARES_SOCKET_BAD, socks[i]); - if (socks[i] != ARES_SOCKET_BAD) - sock_cnt++; - } - } - EXPECT_NE((size_t)0, sock_cnt); - - bitmask = ares_getsock(channel, nullptr, 0); - EXPECT_EQ(0, bitmask); - - ProcessWork(channel, NoExtraFDs, nullptr); - ares_destroy(channel); -} - -TEST_F(DefaultChannelTest, VerifySocketFunctionCallback) { - VirtualizeIO vio(channel_); - - auto my_functions = VirtualizeIO::default_functions; - size_t count = 0; - - my_functions.asocket = [](int af, int type, int protocol, void * p) -> ares_socket_t { - EXPECT_NE(nullptr, p); - (*reinterpret_cast(p))++; - return ::socket(af, type, protocol); - }; - - ares_set_socket_functions(channel_, &my_functions, &count); - - { - count = 0; - HostResult result; - ares_gethostbyname(channel_, "www.google.com.", AF_INET, HostCallback, &result); - Process(); - - EXPECT_TRUE(result.done_); - EXPECT_NE((size_t)0, count); - } - - { - count = 0; - ares_channel_t *copy; - EXPECT_EQ(ARES_SUCCESS, ares_dup(©, channel_)); - - HostResult result; - ares_gethostbyname(copy, "www.google.com.", AF_INET, HostCallback, &result); - - ProcessWork(copy, NoExtraFDs, nullptr); - - EXPECT_TRUE(result.done_); - ares_destroy(copy); - EXPECT_NE((size_t)0, count); - } - -} TEST_F(DefaultChannelTest, LiveSetServers) { struct ares_addr_node server1; diff --git a/test/ares-test-misc.cc b/test/ares-test-misc.cc index 783f2c3e38..ab1fbd37ca 100644 --- a/test/ares-test-misc.cc +++ b/test/ares-test-misc.cc @@ -207,6 +207,10 @@ TEST_F(DefaultChannelTest, TimeoutValue) { Process(); } +TEST_F(LibraryTest, RecordDuplicateNull) { + EXPECT_EQ(ares_dns_record_duplicate(NULL), nullptr); +} + TEST_F(LibraryTest, InetNtoP) { struct in_addr addr; addr.s_addr = htonl(0x01020304); diff --git a/test/ares-test-mock.cc b/test/ares-test-mock.cc index 8c74c05f33..ebae7140aa 100644 --- a/test/ares-test-mock.cc +++ b/test/ares-test-mock.cc @@ -1662,6 +1662,135 @@ TEST_P(MockChannelTest, GetHostByAddrDestroy) { EXPECT_EQ(0, result.timeouts_); } +TEST_P(MockUDPChannelTest, GetSock) { + 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)); + + ares_socket_t socks[3] = {ARES_SOCKET_BAD, ARES_SOCKET_BAD, ARES_SOCKET_BAD}; + int bitmask; + + bitmask = ares_getsock(channel_, socks, 3); + EXPECT_EQ(0, bitmask); + bitmask = ares_getsock(channel_, nullptr, 0); + EXPECT_EQ(0, bitmask); + + // Ask again with a pending query. + HostResult result; + ares_gethostbyname(channel_, "www.google.com.", AF_INET, HostCallback, &result); + bitmask = ares_getsock(channel_, socks, 3); + EXPECT_NE(0, bitmask); + + size_t sock_cnt = 0; + for (size_t i=0; i<3; i++) { + if (ARES_GETSOCK_READABLE(bitmask, i) || ARES_GETSOCK_WRITABLE(bitmask, i)) { + EXPECT_NE(ARES_SOCKET_BAD, socks[i]); + if (socks[i] != ARES_SOCKET_BAD) + sock_cnt++; + } + } + EXPECT_NE((size_t)0, sock_cnt); + + Process(); + + bitmask = ares_getsock(channel_, nullptr, 0); + EXPECT_EQ(0, bitmask); +} + +TEST_P(MockTCPChannelTest, GetSock) { + 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)); + + ares_socket_t socks[3] = {ARES_SOCKET_BAD, ARES_SOCKET_BAD, ARES_SOCKET_BAD}; + int bitmask; + + bitmask = ares_getsock(channel_, socks, 3); + EXPECT_EQ(0, bitmask); + bitmask = ares_getsock(channel_, nullptr, 0); + EXPECT_EQ(0, bitmask); + + // Ask again with a pending query. + HostResult result; + ares_gethostbyname(channel_, "www.google.com.", AF_INET, HostCallback, &result); + bitmask = ares_getsock(channel_, socks, 3); + EXPECT_NE(0, bitmask); + + size_t sock_cnt = 0; + for (size_t i=0; i<3; i++) { + if (ARES_GETSOCK_READABLE(bitmask, i) || ARES_GETSOCK_WRITABLE(bitmask, i)) { + EXPECT_NE(ARES_SOCKET_BAD, socks[i]); + if (socks[i] != ARES_SOCKET_BAD) + sock_cnt++; + } + } + EXPECT_NE((size_t)0, sock_cnt); + + Process(); + + bitmask = ares_getsock(channel_, nullptr, 0); + EXPECT_EQ(0, bitmask); +} + + +TEST_P(MockChannelTest, VerifySocketFunctionCallback) { + ares_socket_functions sock_funcs; + memset(&sock_funcs, 0, sizeof(sock_funcs)); + + 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)); + + size_t count = 0; + + sock_funcs.asocket = [](int af, int type, int protocol, void * p) -> ares_socket_t { + EXPECT_NE(nullptr, p); + (*reinterpret_cast(p))++; + return ::socket(af, type, protocol); + }; + + ares_set_socket_functions(channel_, &sock_funcs, &count); + + { + count = 0; + HostResult result; + ares_gethostbyname(channel_, "www.google.com.", AF_INET, HostCallback, &result); + Process(); + + EXPECT_TRUE(result.done_); + EXPECT_EQ(ARES_SUCCESS, result.status_); + EXPECT_EQ(0, result.timeouts_); + EXPECT_NE((size_t)0, count); + } + + { + count = 0; + ares_channel_t *copy; + EXPECT_EQ(ARES_SUCCESS, ares_dup(©, channel_)); + + HostResult result; + ares_gethostbyname(copy, "www.google.com.", AF_INET, HostCallback, &result); + + ProcessAltChannel(copy); + + EXPECT_TRUE(result.done_); + ares_destroy(copy); + EXPECT_NE((size_t)0, count); + EXPECT_EQ(ARES_SUCCESS, result.status_); + EXPECT_EQ(0, result.timeouts_); + } + +} + static const unsigned char * fetch_server_cookie(const ares_dns_record_t *dnsrec, size_t *len) { diff --git a/test/ares-test.cc b/test/ares-test.cc index 99ab0a0085..f383ecbe13 100644 --- a/test/ares-test.cc +++ b/test/ares-test.cc @@ -888,14 +888,18 @@ void MockChannelOptsTest::ProcessFD(ares_socket_t fd) { } } -void MockChannelOptsTest::Process(unsigned int cancel_ms) { +void MockChannelOptsTest::ProcessAltChannel(ares_channel_t *chan, unsigned int cancel_ms) { using namespace std::placeholders; - ProcessWork(channel_, + ProcessWork(chan, std::bind(&MockChannelOptsTest::fds, this), std::bind(&MockChannelOptsTest::ProcessFD, this, _1), cancel_ms); } +void MockChannelOptsTest::Process(unsigned int cancel_ms) { + ProcessAltChannel(channel_, cancel_ms); +} + void MockEventThreadOptsTest::Process(unsigned int cancel_ms) { std::set fds; diff --git a/test/ares-test.h b/test/ares-test.h index 612759212a..77baa902ad 100644 --- a/test/ares-test.h +++ b/test/ares-test.h @@ -328,6 +328,7 @@ class MockChannelOptsTest : public LibraryTest { // Process all pending work on ares-owned and mock-server-owned file // descriptors. + void ProcessAltChannel(ares_channel_t *chan, unsigned int cancel_ms = 0); void Process(unsigned int cancel_ms = 0); protected: