diff --git a/deps/cares/CHANGES b/deps/cares/CHANGES deleted file mode 100644 index f1426fda7977f7..00000000000000 --- a/deps/cares/CHANGES +++ /dev/null @@ -1,7 +0,0 @@ -This file no longer holds the changelog. Now you can generate it yourself -like this: - - $ git log --pretty=fuller --no-color --date=short --decorate=full -1000 | - ./git2changes.pl - -The older, manually edited, changelog is found in git named CHANGES.0 diff --git a/deps/cares/CMakeLists.txt b/deps/cares/CMakeLists.txt index 467c55ce66c0ee..0f3c77ba0aeb8e 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.30.0" ) +PROJECT (c-ares LANGUAGES C VERSION "1.31.0" ) # Set this version before release SET (CARES_VERSION "${PROJECT_VERSION}") @@ -30,7 +30,7 @@ INCLUDE (GNUInstallDirs) # include this *AFTER* PROJECT(), otherwise paths are w # For example, a version of 4:0:2 would generate output such as: # libname.so -> libname.so.2 # libname.so.2 -> libname.so.2.2.0 -SET (CARES_LIB_VERSIONINFO "17:0:15") +SET (CARES_LIB_VERSIONINFO "18:0:16") OPTION (CARES_STATIC "Build as a static library" OFF) diff --git a/deps/cares/INSTALL.md b/deps/cares/INSTALL.md index de766aad283d1b..268157b737971c 100644 --- a/deps/cares/INSTALL.md +++ b/deps/cares/INSTALL.md @@ -1,5 +1,3 @@ -** This file is adapted from libcurl and not yet fully rewritten for c-ares! ** - ``` ___ __ _ _ __ ___ ___ / __| ___ / _` | '__/ _ \/ __| diff --git a/deps/cares/Makefile.Watcom b/deps/cares/Makefile.Watcom index 0cbae5c53c3255..f6eb7c070b2c01 100644 --- a/deps/cares/Makefile.Watcom +++ b/deps/cares/Makefile.Watcom @@ -42,7 +42,7 @@ RD = rmdir /q /s 2>NUL CP = copy CFLAGS = -3r -mf -hc -zff -zgf -zq -zm -zc -s -fr=con -w2 -fpi -oilrtfm -aa & - -wcd=201 -bt=nt -d+ -dWIN32 -dCARES_BUILDING_LIBRARY & + -wcd=201 -bt=nt -d+ -dCARES_BUILDING_LIBRARY & -dNTDDI_VERSION=0x06020000 -I. -I.\include -I.\src\lib $(SYS_INCL) LFLAGS = option quiet, map, caseexact, eliminate diff --git a/deps/cares/Makefile.am b/deps/cares/Makefile.am index 22b02cd89ce7c0..6c71f4d77d88b1 100644 --- a/deps/cares/Makefile.am +++ b/deps/cares/Makefile.am @@ -26,11 +26,11 @@ MSVCFILES = msvc_ver.inc buildconf.bat # adig and ahost are just sample programs and thus not mentioned with the # regular sources and headers -EXTRA_DIST = AUTHORS CHANGES README.cares $(man_MANS) RELEASE-NOTES.md \ - c-ares-config.cmake.in libcares.pc.cmake libcares.pc.in buildconf get_ver.awk \ - maketgz TODO README.msvc $(MSVCFILES) INSTALL.md README.md LICENSE.md \ +EXTRA_DIST = AUTHORS $(man_MANS) RELEASE-NOTES.md \ + c-ares-config.cmake.in libcares.pc.cmake libcares.pc.in buildconf \ + README.msvc $(MSVCFILES) INSTALL.md README.md LICENSE.md \ CMakeLists.txt Makefile.dj Makefile.m32 Makefile.netware Makefile.msvc \ - Makefile.Watcom AUTHORS CONTRIBUTING.md SECURITY.md DEVELOPER-NOTES.md TODO \ + Makefile.Watcom CONTRIBUTING.md SECURITY.md DEVELOPER-NOTES.md \ cmake/EnableWarnings.cmake CLEANFILES = $(PDFPAGES) $(HTMLPAGES) diff --git a/deps/cares/Makefile.in b/deps/cares/Makefile.in index 25d77367202ebc..7b5a962b8ccdf3 100644 --- a/deps/cares/Makefile.in +++ b/deps/cares/Makefile.in @@ -230,8 +230,8 @@ am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/libcares.pc.in \ $(top_srcdir)/config/compile $(top_srcdir)/config/config.guess \ $(top_srcdir)/config/config.sub \ $(top_srcdir)/config/install-sh $(top_srcdir)/config/ltmain.sh \ - $(top_srcdir)/config/missing AUTHORS INSTALL.md NEWS README.md \ - TODO config/compile config/config.guess config/config.sub \ + $(top_srcdir)/config/missing AUTHORS INSTALL.md README.md \ + config/compile config/config.guess config/config.sub \ config/install-sh config/ltmain.sh config/missing DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) @@ -439,11 +439,11 @@ MSVCFILES = msvc_ver.inc buildconf.bat # adig and ahost are just sample programs and thus not mentioned with the # regular sources and headers -EXTRA_DIST = AUTHORS CHANGES README.cares $(man_MANS) RELEASE-NOTES.md \ - c-ares-config.cmake.in libcares.pc.cmake libcares.pc.in buildconf get_ver.awk \ - maketgz TODO README.msvc $(MSVCFILES) INSTALL.md README.md LICENSE.md \ +EXTRA_DIST = AUTHORS $(man_MANS) RELEASE-NOTES.md \ + c-ares-config.cmake.in libcares.pc.cmake libcares.pc.in buildconf \ + README.msvc $(MSVCFILES) INSTALL.md README.md LICENSE.md \ CMakeLists.txt Makefile.dj Makefile.m32 Makefile.netware Makefile.msvc \ - Makefile.Watcom AUTHORS CONTRIBUTING.md SECURITY.md DEVELOPER-NOTES.md TODO \ + Makefile.Watcom CONTRIBUTING.md SECURITY.md DEVELOPER-NOTES.md \ cmake/EnableWarnings.cmake CLEANFILES = $(PDFPAGES) $(HTMLPAGES) diff --git a/deps/cares/Makefile.msvc b/deps/cares/Makefile.msvc index f6e8f4e71f2e6f..5969ec705aacd2 100644 --- a/deps/cares/Makefile.msvc +++ b/deps/cares/Makefile.msvc @@ -71,7 +71,9 @@ RTLIBD = /MTd # otherwise Winsock tcp/ip stack will be used as default. # -------------------------------------------------------- +!IFNDEF USE_WATT32 USE_WATT32 = 0 +!ENDIF # -------------------------------------------------------- # Detect compiler version. @@ -176,11 +178,14 @@ PROG3_OBJDIR = $(PROG3_OUTDIR)\obj # ------------------------------------- !IF "$(USE_WATT32)" == "1" -CFLAGS = /UWIN32 /DWATT32 /I$(WATT_ROOT)\inc -EX_LIBS_REL = $(WATT_ROOT)\lib\wattcpvc_imp.lib -EX_LIBS_DBG = $(WATT_ROOT)\lib\wattcpvc_imp_d.lib +CFLAGS = /D_WIN32_WINNT=0x0602 /DWATT32 /I$(WATT_ROOT)\inc +! IFNDEF PLATFORM +PLATFORM = x86 +! ENDIF +EX_LIBS_REL = $(WATT_ROOT)\lib\$(PLATFORM)\wattcpvc_imp.lib advapi32.lib +EX_LIBS_DBG = $(WATT_ROOT)\lib\$(PLATFORM)\wattcpvc_imp_d.lib advapi32.lib !ELSE -CFLAGS = /DWIN32 /D_WIN32_WINNT=0x0602 +CFLAGS = /D_WIN32_WINNT=0x0602 EX_LIBS_REL = ws2_32.lib advapi32.lib kernel32.lib iphlpapi.lib EX_LIBS_DBG = ws2_32.lib advapi32.lib kernel32.lib iphlpapi.lib !ENDIF diff --git a/deps/cares/NEWS b/deps/cares/NEWS deleted file mode 100644 index 95a2eeea2742b0..00000000000000 --- a/deps/cares/NEWS +++ /dev/null @@ -1,21 +0,0 @@ -Major changes since: -* see the CHANGES file - -Major changes in release 1.1.1: -* ares should now compile as C++ code (no longer uses reserved word - "class"). -* Added SRV support to adig test program. -* Fixed a few error handling bugs in query processing. - -Major changes in release 1.1.0: -* Added ares_free_string() function so that memory can be freed in the - same layer as it is allocated, a desirable feature in some - environments. -* A few of the ares_dns.h macros are fixed to use the proper bitwise - operator. -* Fixed a couple of fenceposts fixed in ares_expand_name()'s - bounds-checking. -* In process_timeouts(), extract query->next before calling - next_server() and possibly freeing the query structure. -* Casted arguments to ctype macros casted to unsigned char, since not - all char values are valid inputs to those macros according to ANSI. diff --git a/deps/cares/README.cares b/deps/cares/README.cares deleted file mode 100644 index ec809ab948367c..00000000000000 --- a/deps/cares/README.cares +++ /dev/null @@ -1,15 +0,0 @@ -c-ares -====== - -This package is based on ares 1.1.1 (written by Greg Hudson). Daniel Stenberg -decided to fork and release a separate project since the original ares author -didn't want the improvements that were vital for our use of it. - -This package is dubbed 'c-ares' since Daniel wanted this for use within the -curl project (hence the letter C) and it makes a nice pun. c-ares is not API -compatible with ares: a new name makes that more obvious to the public. - -The original libares was distributed at -ftp://athena-dist.mit.edu:pub/ATHENA/ares (which seems to not be alive -anymore). A local copy of the original ares package is kept here: -https://c-ares.org/download/ares-1.1.1.tar.gz diff --git a/deps/cares/README.md b/deps/cares/README.md index 5e022a85c15410..86b25bc31597d2 100644 --- a/deps/cares/README.md +++ b/deps/cares/README.md @@ -2,7 +2,7 @@ [![Build Status](https://api.cirrus-ci.com/github/c-ares/c-ares.svg?branch=main)](https://cirrus-ci.com/github/c-ares/c-ares) [![Windows Build Status](https://ci.appveyor.com/api/projects/status/aevgc5914tm72pvs/branch/main?svg=true)](https://ci.appveyor.com/project/c-ares/c-ares/branch/main) -[![Coverage Status](https://coveralls.io/repos/github/c-ares/c-ares/badge.svg)](https://coveralls.io/github/c-ares/c-ares) +[![Coverage Status](https://coveralls.io/repos/github/c-ares/c-ares/badge.svg?branch=main)](https://coveralls.io/github/c-ares/c-ares?branch=main) [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/291/badge)](https://bestpractices.coreinfrastructure.org/projects/291) [![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/c-ares.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:c-ares) [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=c-ares_c-ares&metric=bugs)](https://sonarcloud.io/summary/new_code?id=c-ares_c-ares) @@ -39,7 +39,7 @@ best practices in regards to C coding standards. The full source code and revision history is available in our [GitHub repository](https://github.com/c-ares/c-ares). Our signed releases -are available in the ['c-ares' release archives](https://c-ares.org/download/). +are available in the [release archives](https://c-ares.org/download/). See the [INSTALL.md](INSTALL.md) file for build information. diff --git a/deps/cares/RELEASE-NOTES.md b/deps/cares/RELEASE-NOTES.md index 7d30a3d4e755d4..eea305a5b6c2a0 100644 --- a/deps/cares/RELEASE-NOTES.md +++ b/deps/cares/RELEASE-NOTES.md @@ -1,33 +1,24 @@ -## c-ares version 1.30.0 - June 7 2024 +## c-ares version 1.31.0 - June 18 2024 This is a maintenance and bugfix release. -Features: - -* Basic support for SIG RR record (RFC 2931 / RFC 2535) [PR #773](https://github.com/c-ares/c-ares/pull/773) - Changes: -* Validation that DNS strings can only consist of printable ascii characters - otherwise will trigger a parse failure. - [75de16c](https://github.com/c-ares/c-ares/commit/75de16c) and - [40fb125](https://github.com/c-ares/c-ares/commit/40fb125) -* Windows: use `GetTickCount64()` for a monotonic timer that does not wrap. [1dff8f6](https://github.com/c-ares/c-ares/commit/1dff8f6) +* Enable Query Cache by default. [PR #786](https://github.com/c-ares/c-ares/pull/786) Bugfixes: -* QueryCache: Fix issue where purging on server changes wasn't working. [a6c8fe6](https://github.com/c-ares/c-ares/commit/a6c8fe6) -* Windows: Fix Y2K38 issue by creating our own `ares_timeval_t` datatype. [PR #772](https://github.com/c-ares/c-ares/pull/772) -* Fix packaging issue affecting MacOS due to a missing header. [55afad6](https://github.com/c-ares/c-ares/commit/55afad6) -* MacOS: Fix UBSAN warnings that are likely meaningless due to alignment issues - in new MacOS config reader. -* Android: arm 32bit build failure due to missing symbol. [d1722e6](https://github.com/c-ares/c-ares/commit/d1722e6) +* Enhance Windows DNS configuration change detection to also detect manual DNS + configuration changes. [PR #785](https://github.com/c-ares/c-ares/issues/785) +* Various legacy MacOS Build fixes. [Issue #782](https://github.com/c-ares/c-ares/issues/782) +* Ndots value of zero in resolv.conf was not being honored. [852a60a](https://github.com/c-ares/c-ares/commit/852a60a) +* Watt-32 build support had been broken for some time. [PR #781](https://github.com/c-ares/c-ares/pull/781) +* Distribute `ares_dns_rec_type_tostr` manpage. [PR #778](https://github.com/c-ares/c-ares/pull/778) Thanks go to these friendly people for their efforts and contributions for this release: * Brad House (@bradh352) -* Daniel Stenberg (@bagder) - +* Gregor Jasny (@gjasny) diff --git a/deps/cares/TODO b/deps/cares/TODO deleted file mode 100644 index 3b200926e352de..00000000000000 --- a/deps/cares/TODO +++ /dev/null @@ -1,4 +0,0 @@ -TODO -==== - -Please see https://github.com/c-ares/c-ares/issues diff --git a/deps/cares/aminclude_static.am b/deps/cares/aminclude_static.am index ffebf497eaa1e6..7cafa3443cd56d 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 Jun 7 06:50:45 EDT 2024 +# from AX_AM_MACROS_STATIC on Tue Jun 18 05:51:32 EDT 2024 # Code coverage diff --git a/deps/cares/configure b/deps/cares/configure index e97df51338799e..a19193e42062e1 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.30.0. +# Generated by GNU Autoconf 2.72 for c-ares 1.31.0. # # Report bugs to . # @@ -614,8 +614,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='c-ares' PACKAGE_TARNAME='c-ares' -PACKAGE_VERSION='1.30.0' -PACKAGE_STRING='c-ares 1.30.0' +PACKAGE_VERSION='1.31.0' +PACKAGE_STRING='c-ares 1.31.0' PACKAGE_BUGREPORT='c-ares mailing list: http://lists.haxx.se/listinfo/c-ares' PACKAGE_URL='' @@ -1415,7 +1415,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -'configure' configures c-ares 1.30.0 to adapt to many kinds of systems. +'configure' configures c-ares 1.31.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1486,7 +1486,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of c-ares 1.30.0:";; + short | recursive ) echo "Configuration of c-ares 1.31.0:";; esac cat <<\_ACEOF @@ -1623,7 +1623,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -c-ares configure 1.30.0 +c-ares configure 1.31.0 generated by GNU Autoconf 2.72 Copyright (C) 2023 Free Software Foundation, Inc. @@ -2267,7 +2267,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by c-ares $as_me 1.30.0, which was +It was created by c-ares $as_me 1.31.0, which was generated by GNU Autoconf 2.72. Invocation command line was $ $0$ac_configure_args_raw @@ -3259,7 +3259,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu -CARES_VERSION_INFO="17:0:15" +CARES_VERSION_INFO="18:0:16" @@ -5999,7 +5999,7 @@ fi # Define the identity of the package. PACKAGE='c-ares' - VERSION='1.30.0' + VERSION='1.31.0' printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h @@ -26370,7 +26370,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.30.0, which was +This file was extended by c-ares $as_me 1.31.0, which was generated by GNU Autoconf 2.72. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -26438,7 +26438,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.30.0 +c-ares config.status 1.31.0 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 0e8dd4746d2c1b..9e21619ae73dc1 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.30.0], +AC_INIT([c-ares], [1.31.0], [c-ares mailing list: http://lists.haxx.se/listinfo/c-ares]) -CARES_VERSION_INFO="17:0:15" +CARES_VERSION_INFO="18:0:16" 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. diff --git a/deps/cares/docs/Makefile.in b/deps/cares/docs/Makefile.in index 08886323ef50c7..d4bb7795a58786 100644 --- a/deps/cares/docs/Makefile.in +++ b/deps/cares/docs/Makefile.in @@ -375,6 +375,7 @@ MANPAGES = ares_cancel.3 \ ares_dns_record_rr_get.3 \ ares_dns_record_rr_get_const.3 \ ares_dns_rec_type_fromstr.3 \ + ares_dns_rec_type_tostr.3 \ ares_dns_rec_type_t.3 \ ares_dns_rr.3 \ ares_dns_rr_get_addr.3 \ diff --git a/deps/cares/docs/Makefile.inc b/deps/cares/docs/Makefile.inc index 685978674e358b..097bf26589be67 100644 --- a/deps/cares/docs/Makefile.inc +++ b/deps/cares/docs/Makefile.inc @@ -37,6 +37,7 @@ MANPAGES = ares_cancel.3 \ ares_dns_record_rr_get.3 \ ares_dns_record_rr_get_const.3 \ ares_dns_rec_type_fromstr.3 \ + ares_dns_rec_type_tostr.3 \ ares_dns_rec_type_t.3 \ ares_dns_rr.3 \ ares_dns_rr_get_addr.3 \ diff --git a/deps/cares/docs/ares_dns_rec_type_tostr.3 b/deps/cares/docs/ares_dns_rec_type_tostr.3 new file mode 100644 index 00000000000000..4587b9a586ef8e --- /dev/null +++ b/deps/cares/docs/ares_dns_rec_type_tostr.3 @@ -0,0 +1,4 @@ +.\" +.\" Copyright (C) Daniel Stenberg +.\" SPDX-License-Identifier: MIT +.so man3/ares_dns_mapping.3 diff --git a/deps/cares/docs/ares_init_options.3 b/deps/cares/docs/ares_init_options.3 index 81e53cd0f2835a..3d983ebe6ddda4 100644 --- a/deps/cares/docs/ares_init_options.3 +++ b/deps/cares/docs/ares_init_options.3 @@ -291,13 +291,15 @@ or less will be considered unlimited, and is the default. .B ARES_OPT_QUERY_CACHE .B unsigned int \fIqcache_max_ttl\fP; .br -Enable the built-in query cache. Will cache queries based on the returned TTL -in the DNS message. Only fully successful and NXDOMAIN query results will be -cached. Fill in the \fIqcache_max_ttl\fP with the maximum number of seconds -a query result may be cached which will override a larger TTL in the response -message. This must be a non-zero value otherwise the cache will be disabled. -Choose a reasonable value for your application such as 300 (5 minutes) or -3600 (1 hour). +As of c-ares 1.31.0, the query cache is enabled by default with a TTL of 1hr. +To disable the query cache, specify this option with a TTL of 0. The query +cache is based on the returned TTL in the DNS message. Only fully successful +and NXDOMAIN query results will be cached. Fill in the \fIqcache_max_ttl\fP +with the maximum number of seconds a query result may be cached which will +override a larger TTL in the response message. This must be a non-zero value +otherwise the cache will be disabled. Choose a reasonable value for your +application such as 300 (5 minutes) or 3600 (1 hour). The query cache is +automatically flushed if a server configuration change is made. .br .TP 18 .B ARES_OPT_EVENT_THREAD diff --git a/deps/cares/get_ver.awk b/deps/cares/get_ver.awk deleted file mode 100644 index 263ca02ded084e..00000000000000 --- a/deps/cares/get_ver.awk +++ /dev/null @@ -1,29 +0,0 @@ -# *************************************************************************** -# * Project: c-ares -# * -# * Copyright (C) The c-ares project and its contributors -# * SPDX-License-Identifier: MIT -# *************************************************************************** -# awk script which fetches c-ares version number and string from input -# file and writes them to STDOUT. Here you can get an awk version for Win32: -# http://www.gknw.net/development/prgtools/awk-20100523.zip -# -BEGIN { - while ((getline < ARGV[1]) > 0) { - sub("\r", "") # make MSYS gawk work with CRLF header input. - if (match ($0, /^#define ARES_COPYRIGHT "[^"]+"$/)) - copyright_string = substr($0, 25, length($0)-25) - else if (match ($0, /^#define ARES_VERSION_STR "[^"]+"$/)) - version_string = substr($3, 2, length($3)-2) - else if (match ($0, /^#define ARES_VERSION_MAJOR [0-9]+$/)) - version_major = $3 - else if (match ($0, /^#define ARES_VERSION_MINOR [0-9]+$/)) - version_minor = $3 - else if (match ($0, /^#define ARES_VERSION_PATCH [0-9]+$/)) - version_patch = $3 - } - print "LIBCARES_VERSION = " version_major "," version_minor "," version_patch - print "LIBCARES_VERSION_STR = " version_string - print "LIBCARES_COPYRIGHT_STR = " copyright_string -} - diff --git a/deps/cares/include/ares.h b/deps/cares/include/ares.h index 0785ae48083dbb..58cac6cd71fcef 100644 --- a/deps/cares/include/ares.h +++ b/deps/cares/include/ares.h @@ -32,15 +32,6 @@ #include "ares_build.h" /* c-ares build definitions */ #include "ares_rules.h" /* c-ares rules enforcement */ -/* - * Define WIN32 when build target is Win32 API - */ - -#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) && \ - !defined(__SYMBIAN32__) -# define WIN32 -#endif - #include /* HP-UX systems version 9, 10 and 11 lack sys/select.h and so does oldish @@ -56,20 +47,20 @@ # include #endif +#if defined(_WIN32) +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif +#endif + #if defined(WATT32) # include # include # include #elif defined(_WIN32_WCE) -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -# endif # include # include -#elif defined(WIN32) -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -# endif +#elif defined(_WIN32) # include # include # include @@ -315,7 +306,7 @@ typedef enum { */ #ifndef ares_socket_typedef -# ifdef WIN32 +# if defined(_WIN32) && !defined(WATT32) typedef SOCKET ares_socket_t; # define ARES_SOCKET_BAD INVALID_SOCKET # else diff --git a/deps/cares/include/ares_version.h b/deps/cares/include/ares_version.h index e791568e6bd80b..cd5a2551534589 100644 --- a/deps/cares/include/ares_version.h +++ b/deps/cares/include/ares_version.h @@ -31,12 +31,12 @@ #define ARES_COPYRIGHT "2004 - 2024 Daniel Stenberg, ." #define ARES_VERSION_MAJOR 1 -#define ARES_VERSION_MINOR 30 +#define ARES_VERSION_MINOR 31 #define ARES_VERSION_PATCH 0 #define ARES_VERSION \ ((ARES_VERSION_MAJOR << 16) | (ARES_VERSION_MINOR << 8) | \ (ARES_VERSION_PATCH)) -#define ARES_VERSION_STR "1.30.0" +#define ARES_VERSION_STR "1.31.0" #if (ARES_VERSION >= 0x010700) # define CARES_HAVE_ARES_LIBRARY_INIT 1 diff --git a/deps/cares/maketgz b/deps/cares/maketgz deleted file mode 100755 index e97230b2da1624..00000000000000 --- a/deps/cares/maketgz +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env perl -# Copyright (C) Daniel Stenberg -# SPDX-License-Identifier: MIT - -$version = $ARGV[0]; - -if($version eq "") { - print "Enter version number!\n"; - exit; -} - -if(!-f "include/ares.h") { - print "run this script in the ares source root dir\n"; - exit; -} - -my ($major, $minor, $patch)=split(/\./, $version); - -$major += 0; -$minor += 0; -$patch += 0; - -open(VER, "include/ares_version.h.dist"); -while() { - $_ =~ s/^\#define ARES_VERSION_MAJOR .*/\#define ARES_VERSION_MAJOR $major/; - $_ =~ s/^\#define ARES_VERSION_MINOR .*/\#define ARES_VERSION_MINOR $minor/; - $_ =~ s/^\#define ARES_VERSION_PATCH .*/\#define ARES_VERSION_PATCH $patch/; - $_ =~ s/^\#define ARES_VERSION_STR .*/\#define ARES_VERSION_STR \"$version\"/; - - print NEWV $_; -} -close(VER); -close(NEWV); -print "include/ares_version.h.dist created\n"; - -if(!-f "configure") { - print "running buildconf\n"; - `./buildconf`; -} -print "adding $version in the configure.ac file\n"; -`sed -e 's/AC_INIT.*/AC_INIT([c-ares], [$version],/' < configure.ac > configure.ac.dist`; - -print "adding $version in the CMakeLists.txt file\n"; -`sed -e 's/SET.*CARES_VERSION.*/SET (CARES_VERSION "$version")/' < CMakeLists.txt > CMakeLists.txt.dist && rm -f CMakeLists.txt && mv CMakeLists.txt.dist CMakeLists.txt`; - -# now make a new configure script with this -print "makes a new configure script\n"; -`autoconf configure.ac.dist >configure`; - -# now run this new configure to get a fine makefile -print "running configure\n"; -`./configure`; - -print "produce CHANGES\n"; -`git log --pretty=fuller --no-color --date=short --decorate=full -1000 | ./git2changes.pl > CHANGES.dist`; - -# now make the actual tarball -print "running make dist\n"; -`make dist VERSION=$version`; - -# remove temporary sourced man pages -`make -s clean-sourced-manpages`; - -print "removing temporary configure.ac file\n"; -`rm configure.ac.dist`; -print "removing temporary ares_version.h file\n"; -`rm include/ares_version.h.dist`; - -print "NOTE: now tag this release!\n"; diff --git a/deps/cares/src/lib/Makefile.in b/deps/cares/src/lib/Makefile.in index 98fc92b68faf34..f9e7b7ea1ce29f 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 Jun 7 06:50:45 EDT 2024 +# from AX_AM_MACROS_STATIC on Tue Jun 18 05:51:32 EDT 2024 # Copyright (C) The c-ares project and its contributors # SPDX-License-Identifier: MIT diff --git a/deps/cares/src/lib/ares__addrinfo2hostent.c b/deps/cares/src/lib/ares__addrinfo2hostent.c index 95717890c2ff7c..3e22bc270f6ef7 100644 --- a/deps/cares/src/lib/ares__addrinfo2hostent.c +++ b/deps/cares/src/lib/ares__addrinfo2hostent.c @@ -39,8 +39,6 @@ # include #endif -#include "ares_nameser.h" - #ifdef HAVE_STRINGS_H # include #endif @@ -50,8 +48,6 @@ #endif #include "ares.h" -#include "ares_dns.h" -#include "ares_inet_net_pton.h" #include "ares_private.h" ares_status_t ares__addrinfo2hostent(const struct ares_addrinfo *ai, int family, @@ -67,7 +63,7 @@ ares_status_t ares__addrinfo2hostent(const struct ares_addrinfo *ai, int family, size_t i; if (ai == NULL || host == NULL) { - return ARES_EBADQUERY; + return ARES_EBADQUERY; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* Use the first node of the response as the family, since hostent can only @@ -78,12 +74,12 @@ ares_status_t ares__addrinfo2hostent(const struct ares_addrinfo *ai, int family, } if (family != AF_INET && family != AF_INET6) { - return ARES_EBADQUERY; + return ARES_EBADQUERY; /* LCOV_EXCL_LINE: DefensiveCoding */ } *host = ares_malloc(sizeof(**host)); if (!(*host)) { - goto enomem; + goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */ } memset(*host, 0, sizeof(**host)); @@ -105,7 +101,7 @@ ares_status_t ares__addrinfo2hostent(const struct ares_addrinfo *ai, int family, aliases = ares_malloc((naliases + 1) * sizeof(char *)); if (!aliases) { - goto enomem; + goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */ } (*host)->h_aliases = aliases; memset(aliases, 0, (naliases + 1) * sizeof(char *)); @@ -118,7 +114,7 @@ ares_status_t ares__addrinfo2hostent(const struct ares_addrinfo *ai, int family, } aliases[alias] = ares_strdup(next_cname->alias); if (!aliases[alias]) { - goto enomem; + goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */ } alias++; } @@ -127,7 +123,7 @@ ares_status_t ares__addrinfo2hostent(const struct ares_addrinfo *ai, int family, (*host)->h_addr_list = ares_malloc((naddrs + 1) * sizeof(char *)); if (!(*host)->h_addr_list) { - goto enomem; + goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */ } memset((*host)->h_addr_list, 0, (naddrs + 1) * sizeof(char *)); @@ -135,12 +131,12 @@ ares_status_t ares__addrinfo2hostent(const struct ares_addrinfo *ai, int family, if (ai->cnames) { (*host)->h_name = ares_strdup(ai->cnames->name); if ((*host)->h_name == NULL && ai->cnames->name) { - goto enomem; + goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */ } } else { (*host)->h_name = ares_strdup(ai->name); if ((*host)->h_name == NULL && ai->name) { - goto enomem; + goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -157,7 +153,7 @@ ares_status_t ares__addrinfo2hostent(const struct ares_addrinfo *ai, int family, if (naddrs) { addrs = ares_malloc(naddrs * (size_t)(*host)->h_length); if (!addrs) { - goto enomem; + goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */ } i = 0; @@ -194,10 +190,12 @@ ares_status_t ares__addrinfo2hostent(const struct ares_addrinfo *ai, int family, return ARES_SUCCESS; +/* LCOV_EXCL_START: OutOfMemory */ enomem: ares_free_hostent(*host); *host = NULL; return ARES_ENOMEM; +/* LCOV_EXCL_STOP */ } ares_status_t ares__addrinfo2addrttl(const struct ares_addrinfo *ai, int family, @@ -211,23 +209,23 @@ ares_status_t ares__addrinfo2addrttl(const struct ares_addrinfo *ai, int family, int cname_ttl = INT_MAX; if (family != AF_INET && family != AF_INET6) { - return ARES_EBADQUERY; + return ARES_EBADQUERY; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (ai == NULL || naddrttls == NULL) { - return ARES_EBADQUERY; + return ARES_EBADQUERY; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (family == AF_INET && addrttls == NULL) { - return ARES_EBADQUERY; + return ARES_EBADQUERY; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (family == AF_INET6 && addr6ttls == NULL) { - return ARES_EBADQUERY; + return ARES_EBADQUERY; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (req_naddrttls == 0) { - return ARES_EBADQUERY; + return ARES_EBADQUERY; /* LCOV_EXCL_LINE: DefensiveCoding */ } *naddrttls = 0; diff --git a/deps/cares/src/lib/ares__addrinfo_localhost.c b/deps/cares/src/lib/ares__addrinfo_localhost.c index baa9b37212bb94..89ad35d6ec3bc0 100644 --- a/deps/cares/src/lib/ares__addrinfo_localhost.c +++ b/deps/cares/src/lib/ares__addrinfo_localhost.c @@ -37,11 +37,10 @@ # include #endif -#if defined(_WIN32) && defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0600 -# include -#endif - #if defined(USE_WINSOCK) +# if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0600 +# include +# endif # if defined(HAVE_IPHLPAPI_H) # include # endif @@ -62,7 +61,7 @@ ares_status_t ares_append_ai_node(int aftype, unsigned short port, node = ares__append_addrinfo_node(nodes); if (!node) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } memset(node, 0, sizeof(*node)); @@ -70,7 +69,7 @@ ares_status_t ares_append_ai_node(int aftype, unsigned short port, if (aftype == AF_INET) { struct sockaddr_in *sin = ares_malloc(sizeof(*sin)); if (!sin) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } memset(sin, 0, sizeof(*sin)); @@ -88,7 +87,7 @@ ares_status_t ares_append_ai_node(int aftype, unsigned short port, if (aftype == AF_INET6) { struct sockaddr_in6 *sin6 = ares_malloc(sizeof(*sin6)); if (!sin6) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } memset(sin6, 0, sizeof(*sin6)); @@ -117,7 +116,7 @@ static ares_status_t ares_inet_pton(AF_INET6, "::1", &addr6); status = ares_append_ai_node(AF_INET6, port, 0, &addr6, nodes); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -126,7 +125,7 @@ static ares_status_t ares_inet_pton(AF_INET, "127.0.0.1", &addr4); status = ares_append_ai_node(AF_INET, port, 0, &addr4, nodes); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -137,7 +136,7 @@ static ares_status_t ares__system_loopback_addrs(int aftype, unsigned short port, struct ares_addrinfo_node **nodes) { -#if defined(_WIN32) && defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0600 && \ +#if defined(USE_WINSOCK) && defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0600 && \ !defined(__WATCOMC__) PMIB_UNICASTIPADDRESS_TABLE table; unsigned int i; @@ -209,13 +208,13 @@ ares_status_t ares__addrinfo_localhost(const char *name, unsigned short port, case AF_INET6: case AF_UNSPEC: break; - default: - return ARES_EBADFAMILY; + default: /* LCOV_EXCL_LINE: DefensiveCoding */ + return ARES_EBADFAMILY; /* LCOV_EXCL_LINE: DefensiveCoding */ } ai->name = ares_strdup(name); if (!ai->name) { - goto enomem; + goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ares__system_loopback_addrs(hints->ai_family, port, &nodes); @@ -228,9 +227,11 @@ ares_status_t ares__addrinfo_localhost(const char *name, unsigned short port, return status; +/* LCOV_EXCL_START: OutOfMemory */ enomem: ares__freeaddrinfo_nodes(nodes); ares_free(ai->name); ai->name = NULL; return ARES_ENOMEM; +/* LCOV_EXCL_STOP */ } diff --git a/deps/cares/src/lib/ares__buf.c b/deps/cares/src/lib/ares__buf.c index 2203662fab532a..4388a7d8918fad 100644 --- a/deps/cares/src/lib/ares__buf.c +++ b/deps/cares/src/lib/ares__buf.c @@ -87,7 +87,7 @@ void ares__buf_destroy(ares__buf_t *buf) static ares_bool_t ares__buf_is_const(const ares__buf_t *buf) { if (buf == NULL) { - return ARES_FALSE; + return ARES_FALSE; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (buf->data != NULL && buf->alloc_buf == NULL) { @@ -107,7 +107,7 @@ void ares__buf_reclaim(ares__buf_t *buf) } if (ares__buf_is_const(buf)) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* Silence coverity. All lengths are zero so would bail out later but @@ -135,8 +135,6 @@ void ares__buf_reclaim(ares__buf_t *buf) if (buf->tag_offset != SIZE_MAX) { buf->tag_offset -= prefix_size; } - - return; } static ares_status_t ares__buf_ensure_space(ares__buf_t *buf, @@ -151,7 +149,7 @@ static ares_status_t ares__buf_ensure_space(ares__buf_t *buf, } if (ares__buf_is_const(buf)) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* When calling ares__buf_finish_str() we end up adding a null terminator, @@ -201,11 +199,11 @@ static ares_status_t ares__buf_ensure_space(ares__buf_t *buf, ares_status_t ares__buf_set_length(ares__buf_t *buf, size_t len) { if (buf == NULL || ares__buf_is_const(buf)) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (len >= buf->alloc_buf_len - buf->offset) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } buf->data_len = len; @@ -231,9 +229,9 @@ ares_status_t ares__buf_append(ares__buf_t *buf, const unsigned char *data, return ARES_SUCCESS; } -ares_status_t ares__buf_append_byte(ares__buf_t *buf, unsigned char byte) +ares_status_t ares__buf_append_byte(ares__buf_t *buf, unsigned char b) { - return ares__buf_append(buf, &byte, 1); + return ares__buf_append(buf, &b, 1); } ares_status_t ares__buf_append_be16(ares__buf_t *buf, unsigned short u16) @@ -242,12 +240,12 @@ ares_status_t ares__buf_append_be16(ares__buf_t *buf, unsigned short u16) status = ares__buf_append_byte(buf, (unsigned char)((u16 >> 8) & 0xff)); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ares__buf_append_byte(buf, (unsigned char)(u16 & 0xff)); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } return ARES_SUCCESS; @@ -259,22 +257,22 @@ ares_status_t ares__buf_append_be32(ares__buf_t *buf, unsigned int u32) status = ares__buf_append_byte(buf, ((unsigned char)(u32 >> 24) & 0xff)); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ares__buf_append_byte(buf, ((unsigned char)(u32 >> 16) & 0xff)); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ares__buf_append_byte(buf, ((unsigned char)(u32 >> 8) & 0xff)); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ares__buf_append_byte(buf, ((unsigned char)u32 & 0xff)); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } return ARES_SUCCESS; @@ -319,7 +317,7 @@ unsigned char *ares__buf_finish_bin(ares__buf_t *buf, size_t *len) /* We don't want to return NULL except on failure, may be zero-length */ if (buf->alloc_buf == NULL && ares__buf_ensure_space(buf, 1) != ARES_SUCCESS) { - return NULL; + return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ } ptr = buf->alloc_buf; *len = buf->data_len; @@ -540,7 +538,7 @@ ares_status_t ares__buf_fetch_bytes_dup(ares__buf_t *buf, size_t len, *bytes = ares_malloc(null_term ? len + 1 : len); if (*bytes == NULL) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } memcpy(*bytes, ptr, len); @@ -561,7 +559,7 @@ ares_status_t ares__buf_fetch_str_dup(ares__buf_t *buf, size_t len, char **str) *str = ares_malloc(len + 1); if (*str == NULL) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } memcpy(*str, ptr, len); @@ -787,7 +785,7 @@ ares_status_t ares__buf_split(ares__buf_t *buf, const unsigned char *delims, ares_bool_t first = ARES_TRUE; if (buf == NULL || delims == NULL || delims_len == 0 || list == NULL) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } *list = ares__llist_create(ares__buf_destroy_cb); @@ -825,7 +823,7 @@ ares_status_t ares__buf_split(ares__buf_t *buf, const unsigned char *delims, /* Shouldn't be possible */ if (ptr == NULL) { - status = ARES_EFORMERR; + status = ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ goto done; } @@ -934,7 +932,7 @@ ares_status_t ares__buf_set_position(ares__buf_t *buf, size_t idx) } if (idx > buf->data_len) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } buf->offset = idx; @@ -966,7 +964,7 @@ static ares_status_t ares__buf_parse_dns_binstr_int( while (orig_len - ares__buf_len(buf) < remaining_len) { status = ares__buf_fetch_bytes(buf, &len, 1); if (status != ARES_SUCCESS) { - break; + break; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (len) { @@ -1049,13 +1047,13 @@ ares_status_t ares__buf_append_num_dec(ares__buf_t *buf, size_t num, size_t len) /* Silence coverity. Shouldn't be possible since we calculate it above */ if (mod == 0) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } digit /= mod; status = ares__buf_append_byte(buf, '0' + (unsigned char)(digit & 0xFF)); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } } return ARES_SUCCESS; @@ -1074,7 +1072,7 @@ ares_status_t ares__buf_append_num_hex(ares__buf_t *buf, size_t num, size_t len) ares_status_t status; status = ares__buf_append_byte(buf, hexbytes[(num >> ((i - 1) * 4)) & 0xF]); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } } return ARES_SUCCESS; @@ -1095,13 +1093,13 @@ static ares_status_t ares__buf_hexdump_line(ares__buf_t *buf, size_t idx, /* Address */ status = ares__buf_append_num_hex(buf, idx, 6); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* | */ status = ares__buf_append_str(buf, " | "); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } for (i = 0; i < 16; i++) { @@ -1111,19 +1109,19 @@ static ares_status_t ares__buf_hexdump_line(ares__buf_t *buf, size_t idx, status = ares__buf_append_num_hex(buf, data[i], 2); } if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ares__buf_append_byte(buf, ' '); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } } /* | */ status = ares__buf_append_str(buf, " | "); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } for (i = 0; i < 16; i++) { @@ -1132,7 +1130,7 @@ static ares_status_t ares__buf_hexdump_line(ares__buf_t *buf, size_t idx, } status = ares__buf_append_byte(buf, ares__isprint(data[i]) ? data[i] : '.'); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -1149,7 +1147,7 @@ ares_status_t ares__buf_hexdump(ares__buf_t *buf, const unsigned char *data, ares_status_t status; status = ares__buf_hexdump_line(buf, i, data + i, len - i); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -1166,7 +1164,7 @@ ares_status_t ares__buf_load_file(const char *filename, ares__buf_t *buf) ares_status_t status; if (filename == NULL || buf == NULL) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } fp = fopen(filename, "rb"); @@ -1188,39 +1186,39 @@ ares_status_t ares__buf_load_file(const char *filename, ares__buf_t *buf) /* Get length portably, fstat() is POSIX, not C */ if (fseek(fp, 0, SEEK_END) != 0) { - status = ARES_EFILE; - goto done; + status = ARES_EFILE; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } ftell_len = ftell(fp); if (ftell_len < 0) { - status = ARES_EFILE; - goto done; + status = ARES_EFILE; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } len = (size_t)ftell_len; if (fseek(fp, 0, SEEK_SET) != 0) { - status = ARES_EFILE; - goto done; + status = ARES_EFILE; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (len == 0) { - status = ARES_SUCCESS; - goto done; + status = ARES_SUCCESS; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* Read entire data into buffer */ ptr_len = len; ptr = ares__buf_append_start(buf, &ptr_len); if (ptr == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } ptr_len = fread(ptr, 1, len, fp); if (ptr_len != len) { - status = ARES_EFILE; - goto done; + status = ARES_EFILE; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } ares__buf_append_finish(buf, len); diff --git a/deps/cares/src/lib/ares__buf.h b/deps/cares/src/lib/ares__buf.h index 4298814f7b4396..a9af6431e0f323 100644 --- a/deps/cares/src/lib/ares__buf.h +++ b/deps/cares/src/lib/ares__buf.h @@ -85,10 +85,10 @@ ares_status_t ares__buf_append(ares__buf_t *buf, const unsigned char *data, /*! Append a single byte to the dynamic buffer object * * \param[in] buf Initialized buffer object - * \param[in] byte Single byte to append to buffer object. + * \param[in] b Single byte to append to buffer object. * \return ARES_SUCCESS or one of the c-ares error codes */ -ares_status_t ares__buf_append_byte(ares__buf_t *buf, unsigned char byte); +ares_status_t ares__buf_append_byte(ares__buf_t *buf, unsigned char b); /*! Append a null-terminated string to the dynamic buffer object * diff --git a/deps/cares/src/lib/ares__close_sockets.c b/deps/cares/src/lib/ares__close_sockets.c index 03ba4abf89fbd1..06537a5de75f0b 100644 --- a/deps/cares/src/lib/ares__close_sockets.c +++ b/deps/cares/src/lib/ares__close_sockets.c @@ -85,7 +85,7 @@ void ares__check_cleanup_conn(const ares_channel_t *channel, ares_bool_t do_cleanup = ARES_FALSE; if (channel == NULL || conn == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (ares__llist_len(conn->queries_to_conn)) { diff --git a/deps/cares/src/lib/ares__hosts_file.c b/deps/cares/src/lib/ares__hosts_file.c index e279623de37e64..0f2875766586c7 100644 --- a/deps/cares/src/lib/ares__hosts_file.c +++ b/deps/cares/src/lib/ares__hosts_file.c @@ -105,7 +105,7 @@ const void *ares_dns_pton(const char *ipaddr, struct ares_addr *addr, size_t ptr_len = 0; if (ipaddr == NULL || addr == NULL || out_len == NULL) { - return NULL; + return NULL; /* LCOV_EXCL_LINE: DefensiveCoding */ } *out_len = 0; @@ -150,7 +150,7 @@ static ares_bool_t ares__normalize_ipaddr(const char *ipaddr, char *out, } if (!ares_inet_ntop(data.family, addr, out, (ares_socklen_t)out_len)) { - return ARES_FALSE; + return ARES_FALSE; /* LCOV_EXCL_LINE: DefensiveCoding */ } return ARES_TRUE; @@ -315,8 +315,8 @@ static ares_status_t ares__hosts_file_add(ares_hosts_file_t *hosts, if (matchtype != ARES_MATCH_NONE) { status = ares__hosts_file_merge_entry(hosts, match, entry, matchtype); if (status != ARES_SUCCESS) { - ares__hosts_entry_destroy(entry); - return status; + ares__hosts_entry_destroy(entry); /* LCOV_EXCL_LINE: DefensiveCoding */ + return status; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* entry was invalidated above by merging */ entry = match; @@ -617,7 +617,7 @@ static ares_bool_t ares__hosts_expired(const char *filename, /* Expire every 60s if we can't get a time */ if (mod_ts == 0) { - mod_ts = time(NULL) - 60; + mod_ts = time(NULL) - 60; /* LCOV_EXCL_LINE: only on systems without stat() */ } /* If filenames are different, its expired */ @@ -642,7 +642,7 @@ static ares_status_t ares__hosts_path(const ares_channel_t *channel, if (channel->hosts_path) { path_hosts = ares_strdup(channel->hosts_path); if (!path_hosts) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -653,12 +653,12 @@ static ares_status_t ares__hosts_path(const ares_channel_t *channel, path_hosts = ares_strdup(getenv("CARES_HOSTS")); if (!path_hosts) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } } if (!path_hosts) { -#ifdef WIN32 +#if defined(USE_WINSOCK) char PATH_HOSTS[MAX_PATH] = ""; char tmp[MAX_PATH]; HKEY hkeyHosts; @@ -728,7 +728,7 @@ ares_status_t ares__hosts_search_ipaddr(ares_channel_t *channel, } if (channel->hf == NULL) { - return ARES_ENOTFOUND; + return ARES_ENOTFOUND; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (!ares__normalize_ipaddr(ipaddr, addr, sizeof(addr))) { @@ -757,7 +757,7 @@ ares_status_t ares__hosts_search_host(ares_channel_t *channel, } if (channel->hf == NULL) { - return ARES_ENOTFOUND; + return ARES_ENOTFOUND; /* LCOV_EXCL_LINE: DefensiveCoding */ } *entry = ares__htable_strvp_get_direct(channel->hf->hosthash, host); @@ -778,8 +778,8 @@ ares_status_t ares__hosts_entry_to_hostent(const ares_hosts_entry_t *entry, *hostent = ares_malloc_zero(sizeof(**hostent)); if (*hostent == NULL) { - status = ARES_ENOMEM; - goto fail; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } (*hostent)->h_addrtype = (HOSTENT_ADDRTYPE_TYPE)family; @@ -813,16 +813,16 @@ ares_status_t ares__hosts_entry_to_hostent(const ares_hosts_entry_t *entry, (idx + 1) * sizeof(*(*hostent)->h_addr_list), (idx + 2) * sizeof(*(*hostent)->h_addr_list)); if (temp == NULL) { - status = ARES_ENOMEM; - goto fail; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } (*hostent)->h_addr_list = temp; (*hostent)->h_addr_list[idx] = ares_malloc(ptr_len); if ((*hostent)->h_addr_list[idx] == NULL) { - status = ARES_ENOMEM; - goto fail; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } memcpy((*hostent)->h_addr_list[idx], ptr, ptr_len); @@ -839,8 +839,8 @@ ares_status_t ares__hosts_entry_to_hostent(const ares_hosts_entry_t *entry, /* Copy main hostname */ (*hostent)->h_name = ares_strdup(ares__llist_first_val(entry->hosts)); if ((*hostent)->h_name == NULL) { - status = ARES_ENOMEM; - goto fail; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Copy aliases */ @@ -849,14 +849,14 @@ ares_status_t ares__hosts_entry_to_hostent(const ares_hosts_entry_t *entry, /* Cap at 100, some people use https://github.com/StevenBlack/hosts and we * don't need 200k+ aliases */ if (naliases > 100) { - naliases = 100; + naliases = 100; /* LCOV_EXCL_LINE: DefensiveCoding */ } (*hostent)->h_aliases = ares_malloc_zero((naliases + 1) * sizeof(*(*hostent)->h_aliases)); if ((*hostent)->h_aliases == NULL) { - status = ARES_ENOMEM; - goto fail; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Copy all entries to the alias except the first */ @@ -866,8 +866,8 @@ ares_status_t ares__hosts_entry_to_hostent(const ares_hosts_entry_t *entry, while (node != NULL) { (*hostent)->h_aliases[idx] = ares_strdup(ares__llist_node_val(node)); if ((*hostent)->h_aliases[idx] == NULL) { - status = ARES_ENOMEM; - goto fail; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } idx++; @@ -880,10 +880,12 @@ ares_status_t ares__hosts_entry_to_hostent(const ares_hosts_entry_t *entry, return ARES_SUCCESS; +/* LCOV_EXCL_START: defensive coding */ fail: ares_free_hostent(*hostent); *hostent = NULL; return status; +/* LCOV_EXCL_STOP */ } static ares_status_t @@ -909,25 +911,25 @@ static ares_status_t * https://github.com/StevenBlack/hosts and we don't need 200k+ aliases */ cnt++; if (cnt > 100) { - break; + break; /* LCOV_EXCL_LINE: DefensiveCoding */ } cname = ares__append_addrinfo_cname(&cnames); if (cname == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } cname->alias = ares_strdup(host); if (cname->alias == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } cname->name = ares_strdup(primaryhost); if (cname->name == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } node = ares__llist_node_next(node); @@ -937,22 +939,22 @@ static ares_status_t if (cnames == NULL) { cname = ares__append_addrinfo_cname(&cnames); if (cname == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } cname->name = ares_strdup(primaryhost); if (cname->name == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } status = ARES_SUCCESS; done: if (status != ARES_SUCCESS) { - ares__freeaddrinfo_cnames(cnames); - return status; + ares__freeaddrinfo_cnames(cnames); /* LCOV_EXCL_LINE: DefensiveCoding */ + return status; /* LCOV_EXCL_LINE: DefensiveCoding */ } *cnames_out = cnames; @@ -975,14 +977,14 @@ ares_status_t ares__hosts_entry_to_addrinfo(const ares_hosts_entry_t *entry, case AF_INET6: case AF_UNSPEC: break; - default: - return ARES_EBADFAMILY; + default: /* LCOV_EXCL_LINE: DefensiveCoding */ + return ARES_EBADFAMILY; /* LCOV_EXCL_LINE: DefensiveCoding */ } ai->name = ares_strdup(name); if (ai->name == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } for (node = ares__llist_node_first(entry->ips); node != NULL; @@ -1002,14 +1004,14 @@ ares_status_t ares__hosts_entry_to_addrinfo(const ares_hosts_entry_t *entry, status = ares_append_ai_node(addr.family, port, 0, ptr, &ainodes); if (status != ARES_SUCCESS) { - goto done; + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } } if (want_cnames) { status = ares__hosts_ai_append_cnames(entry, &cnames); if (status != ARES_SUCCESS) { - goto done; + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } } @@ -1017,11 +1019,13 @@ ares_status_t ares__hosts_entry_to_addrinfo(const ares_hosts_entry_t *entry, done: if (status != ARES_SUCCESS) { + /* LCOV_EXCL_START: defensive coding */ ares__freeaddrinfo_cnames(cnames); ares__freeaddrinfo_nodes(ainodes); ares_free(ai->name); ai->name = NULL; return status; + /* LCOV_EXCL_STOP */ } ares__addrinfo_cat_cnames(&ai->cnames, cnames); ares__addrinfo_cat_nodes(&ai->nodes, ainodes); diff --git a/deps/cares/src/lib/ares__htable_asvp.c b/deps/cares/src/lib/ares__htable_asvp.c index 3c1d2a336fad35..42951712934a86 100644 --- a/deps/cares/src/lib/ares__htable_asvp.c +++ b/deps/cares/src/lib/ares__htable_asvp.c @@ -121,7 +121,7 @@ ares_socket_t *ares__htable_asvp_keys(const ares__htable_asvp_t *htable, size_t i; if (htable == NULL || num == NULL) { - return NULL; + return NULL; /* LCOV_EXCL_LINE: DefensiveCoding */ } *num = 0; @@ -133,8 +133,8 @@ ares_socket_t *ares__htable_asvp_keys(const ares__htable_asvp_t *htable, out = ares_malloc_zero(sizeof(*out) * cnt); if (out == NULL) { - ares_free(buckets); - return NULL; + ares_free(buckets); /* LCOV_EXCL_LINE: OutOfMemory */ + return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ } for (i = 0; i < cnt; i++) { @@ -157,7 +157,7 @@ ares_bool_t ares__htable_asvp_insert(ares__htable_asvp_t *htable, bucket = ares_malloc(sizeof(*bucket)); if (bucket == NULL) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } bucket->parent = htable; @@ -165,14 +165,14 @@ ares_bool_t ares__htable_asvp_insert(ares__htable_asvp_t *htable, bucket->val = val; if (!ares__htable_insert(htable->hash, bucket)) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } return ARES_TRUE; fail: if (bucket) { - ares_free(bucket); + ares_free(bucket); /* LCOV_EXCL_LINE: OutOfMemory */ } return ARES_FALSE; } diff --git a/deps/cares/src/lib/ares__htable_strvp.h b/deps/cares/src/lib/ares__htable_strvp.h index 25dd2b90777d8d..878c71869a92dc 100644 --- a/deps/cares/src/lib/ares__htable_strvp.h +++ b/deps/cares/src/lib/ares__htable_strvp.h @@ -115,4 +115,4 @@ size_t ares__htable_strvp_num_keys(const ares__htable_strvp_t *htable); /*! @} */ -#endif /* __ARES__HTABLE_STVP_H */ +#endif /* __ARES__HTABLE_STRVP_H */ diff --git a/deps/cares/src/lib/ares__htable_szvp.c b/deps/cares/src/lib/ares__htable_szvp.c index 2ff64784bcd6dd..33d8ed3a8dfb9f 100644 --- a/deps/cares/src/lib/ares__htable_szvp.c +++ b/deps/cares/src/lib/ares__htable_szvp.c @@ -123,7 +123,7 @@ ares_bool_t ares__htable_szvp_insert(ares__htable_szvp_t *htable, size_t key, bucket = ares_malloc(sizeof(*bucket)); if (bucket == NULL) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } bucket->parent = htable; @@ -131,14 +131,14 @@ ares_bool_t ares__htable_szvp_insert(ares__htable_szvp_t *htable, size_t key, bucket->val = val; if (!ares__htable_insert(htable->hash, bucket)) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } return ARES_TRUE; fail: if (bucket) { - ares_free(bucket); + ares_free(bucket); /* LCOV_EXCL_LINE: OutOfMemory */ } return ARES_FALSE; } diff --git a/deps/cares/src/lib/ares__htable_vpvp.c b/deps/cares/src/lib/ares__htable_vpvp.c index 3558fa5a9b77b7..e0c009a6401a1c 100644 --- a/deps/cares/src/lib/ares__htable_vpvp.c +++ b/deps/cares/src/lib/ares__htable_vpvp.c @@ -44,7 +44,7 @@ typedef struct { void ares__htable_vpvp_destroy(ares__htable_vpvp_t *htable) { if (htable == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } ares__htable_destroy(htable->hash); @@ -93,13 +93,13 @@ ares__htable_vpvp_t * { ares__htable_vpvp_t *htable = ares_malloc(sizeof(*htable)); if (htable == NULL) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } htable->hash = ares__htable_create(hash_func, bucket_key, bucket_free, key_eq); if (htable->hash == NULL) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } htable->free_key = key_free; @@ -107,12 +107,14 @@ ares__htable_vpvp_t * return htable; +/* LCOV_EXCL_START: OutOfMemory */ fail: if (htable) { ares__htable_destroy(htable->hash); ares_free(htable); } return NULL; +/* LCOV_EXCL_STOP */ } ares_bool_t ares__htable_vpvp_insert(ares__htable_vpvp_t *htable, void *key, diff --git a/deps/cares/src/lib/ares__iface_ips.c b/deps/cares/src/lib/ares__iface_ips.c index b252a7ab492191..bc120c7039310a 100644 --- a/deps/cares/src/lib/ares__iface_ips.c +++ b/deps/cares/src/lib/ares__iface_ips.c @@ -81,15 +81,15 @@ static ares__iface_ips_t *ares__iface_ips_alloc(ares__iface_ip_flags_t flags) { ares__iface_ips_t *ips = ares_malloc_zero(sizeof(*ips)); if (ips == NULL) { - return NULL; + return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Prealloc 4 entries */ ips->alloc_size = 4; ips->ips = ares_malloc_zero(ips->alloc_size * sizeof(*ips->ips)); if (ips->ips == NULL) { - ares_free(ips); - return NULL; + ares_free(ips); /* LCOV_EXCL_LINE: OutOfMemory */ + return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ } ips->enum_flags = flags; return ips; @@ -98,7 +98,7 @@ static ares__iface_ips_t *ares__iface_ips_alloc(ares__iface_ip_flags_t flags) static void ares__iface_ip_destroy(ares__iface_ip_t *ip) { if (ip == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } ares_free(ip->name); memset(ip, 0, sizeof(*ip)); @@ -130,14 +130,16 @@ ares_status_t ares__iface_ips(ares__iface_ips_t **ips, *ips = ares__iface_ips_alloc(flags); if (*ips == NULL) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ares__iface_ips_enumerate(*ips, name); if (status != ARES_SUCCESS) { + /* LCOV_EXCL_START: UntestablePath */ ares__iface_ips_destroy(*ips); *ips = NULL; return status; + /* LCOV_EXCL_STOP */ } return ARES_SUCCESS; @@ -151,7 +153,7 @@ static ares_status_t size_t idx; if (ips == NULL || name == NULL || addr == NULL) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* Don't want loopback */ @@ -204,7 +206,7 @@ static ares_status_t temp = ares_realloc_zero(ips->ips, ips->alloc_size * sizeof(*ips->ips), alloc_size * sizeof(*ips->ips)); if (temp == NULL) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } ips->ips = temp; ips->alloc_size = alloc_size; @@ -215,11 +217,13 @@ static ares_status_t ips->ips[idx].flags = flags; ips->ips[idx].netmask = netmask; - ips->ips[idx].ll_scope = ll_scope; + if (flags & ARES_IFACE_IP_LINKLOCAL) { + ips->ips[idx].ll_scope = ll_scope; + } memcpy(&ips->ips[idx].addr, addr, sizeof(*addr)); ips->ips[idx].name = ares_strdup(name); if (ips->ips[idx].name == NULL) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } return ARES_SUCCESS; @@ -490,7 +494,7 @@ static ares_status_t ares__iface_ips_enumerate(ares__iface_ips_t *ips, } /* Name mismatch */ - if (strcasecmp(ifa->ifa_name, name) != 0) { + if (name != NULL && strcasecmp(ifa->ifa_name, name) != 0) { continue; } @@ -522,6 +526,8 @@ static ares_status_t ares__iface_ips_enumerate(ares__iface_ips_t *ips, unsigned int ares__if_nametoindex(const char *name) { #ifdef HAVE_IF_NAMETOINDEX + if (name == NULL) + return 0; return if_nametoindex(name); #else ares_status_t status; @@ -529,6 +535,9 @@ unsigned int ares__if_nametoindex(const char *name) size_t i; unsigned int index = 0; + if (name == NULL) + return 0; + status = ares__iface_ips(&ips, ARES_IFACE_IP_V6 | ARES_IFACE_IP_LINKLOCAL, name); if (status != ARES_SUCCESS) { @@ -562,7 +571,7 @@ const char *ares__if_indextoname(unsigned int index, char *name, size_t i; const char *ptr = NULL; - if (name_len < IF_NAMESIZE) { + if (name == NULL || name_len < IF_NAMESIZE) { goto done; } diff --git a/deps/cares/src/lib/ares__llist.c b/deps/cares/src/lib/ares__llist.c index d175da2bd3baf6..a094889d687acf 100644 --- a/deps/cares/src/lib/ares__llist.c +++ b/deps/cares/src/lib/ares__llist.c @@ -77,7 +77,7 @@ static void ares__llist_attach_at(ares__llist_t *list, ares__llist_node_t *node) { if (list == NULL || node == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } node->parent = list; @@ -127,7 +127,7 @@ static ares__llist_node_t *ares__llist_insert_at(ares__llist_t *list, ares__llist_node_t *node = NULL; if (list == NULL || val == NULL) { - return NULL; + return NULL; /* LCOV_EXCL_LINE: DefensiveCoding */ } node = ares_malloc_zero(sizeof(*node)); @@ -250,7 +250,7 @@ static void ares__llist_node_detach(ares__llist_node_t *node) ares__llist_t *list; if (node == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } list = node->parent; @@ -341,7 +341,7 @@ void ares__llist_node_move_parent_last(ares__llist_node_t *node, ares__llist_t *new_parent) { if (node == NULL || new_parent == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } ares__llist_node_detach(node); @@ -352,7 +352,7 @@ void ares__llist_node_move_parent_first(ares__llist_node_t *node, ares__llist_t *new_parent) { if (node == NULL || new_parent == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } ares__llist_node_detach(node); diff --git a/deps/cares/src/lib/ares__parse_into_addrinfo.c b/deps/cares/src/lib/ares__parse_into_addrinfo.c index 90e951c02f3f6d..e886585d06a386 100644 --- a/deps/cares/src/lib/ares__parse_into_addrinfo.c +++ b/deps/cares/src/lib/ares__parse_into_addrinfo.c @@ -65,7 +65,7 @@ ares_status_t ares__parse_into_addrinfo(const ares_dns_record_t *dnsrec, /* Save question hostname */ status = ares_dns_record_query_get(dnsrec, 0, &hostname, NULL, NULL); if (status != ARES_SUCCESS) { - goto done; + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } ancount = ares_dns_record_rr_cnt(dnsrec, ARES_SECTION_ANSWER); @@ -107,19 +107,19 @@ ares_status_t ares__parse_into_addrinfo(const ares_dns_record_t *dnsrec, cname = ares__append_addrinfo_cname(&cnames); if (cname == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } cname->ttl = (int)ares_dns_rr_get_ttl(rr); cname->alias = ares_strdup(ares_dns_rr_get_name(rr)); if (cname->alias == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } cname->name = ares_strdup(hostname); if (cname->name == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } else if (rtype == ARES_REC_TYPE_A) { got_a = ARES_TRUE; @@ -127,7 +127,7 @@ ares_status_t ares__parse_into_addrinfo(const ares_dns_record_t *dnsrec, ares_append_ai_node(AF_INET, port, ares_dns_rr_get_ttl(rr), ares_dns_rr_get_addr(rr, ARES_RR_A_ADDR), &nodes); if (status != ARES_SUCCESS) { - goto done; + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } else if (rtype == ARES_REC_TYPE_AAAA) { got_aaaa = ARES_TRUE; @@ -135,7 +135,7 @@ ares_status_t ares__parse_into_addrinfo(const ares_dns_record_t *dnsrec, ares_dns_rr_get_addr6(rr, ARES_RR_AAAA_ADDR), &nodes); if (status != ARES_SUCCESS) { - goto done; + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } else { continue; @@ -153,8 +153,8 @@ ares_status_t ares__parse_into_addrinfo(const ares_dns_record_t *dnsrec, ares_free(ai->name); ai->name = ares_strdup(hostname); if (ai->name == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } diff --git a/deps/cares/src/lib/ares__slist.c b/deps/cares/src/lib/ares__slist.c index 5b8098435513ae..0c92b552ecb0d1 100644 --- a/deps/cares/src/lib/ares__slist.c +++ b/deps/cares/src/lib/ares__slist.c @@ -206,7 +206,7 @@ ares__slist_node_t *ares__slist_insert(ares__slist_t *list, void *val) node = ares_malloc_zero(sizeof(*node)); if (node == NULL) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } node->data = val; @@ -218,12 +218,12 @@ ares__slist_node_t *ares__slist_insert(ares__slist_t *list, void *val) /* Allocate array of next and prev nodes for linking each level */ node->next = ares_malloc_zero(sizeof(*node->next) * node->levels); if (node->next == NULL) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } node->prev = ares_malloc_zero(sizeof(*node->prev) * node->levels); if (node->prev == NULL) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } /* If the number of levels is greater than we currently support in the slist, @@ -233,7 +233,7 @@ ares__slist_node_t *ares__slist_insert(ares__slist_t *list, void *val) ares_realloc_zero(list->head, sizeof(*list->head) * list->levels, sizeof(*list->head) * node->levels); if (ptr == NULL) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } list->head = ptr; @@ -246,6 +246,7 @@ ares__slist_node_t *ares__slist_insert(ares__slist_t *list, void *val) return node; +/* LCOV_EXCL_START: OutOfMemory */ fail: if (node) { ares_free(node->prev); @@ -253,6 +254,7 @@ ares__slist_node_t *ares__slist_insert(ares__slist_t *list, void *val) ares_free(node); } return NULL; +/* LCOV_EXCL_STOP */ } static void ares__slist_node_pop(ares__slist_node_t *node) diff --git a/deps/cares/src/lib/ares__socket.c b/deps/cares/src/lib/ares__socket.c index d3990e7660e694..7c19574e9f763d 100644 --- a/deps/cares/src/lib/ares__socket.c +++ b/deps/cares/src/lib/ares__socket.c @@ -145,7 +145,7 @@ static int setsocknonblock(ares_socket_t sockfd, /* operate on this */ #endif } -#if defined(IPV6_V6ONLY) && defined(WIN32) +#if defined(IPV6_V6ONLY) && defined(USE_WINSOCK) /* It makes support for IPv4-mapped IPv6 addresses. * Linux kernel, NetBSD, FreeBSD and Darwin: default is off; * Windows Vista and later: default is on; @@ -191,14 +191,14 @@ static int configure_socket(ares_socket_t s, struct server_state *server) setsockopt(s, SOL_SOCKET, SO_SNDBUF, (void *)&channel->socket_send_buffer_size, sizeof(channel->socket_send_buffer_size)) == -1) { - return -1; + return -1; /* LCOV_EXCL_LINE: UntestablePath */ } if ((channel->socket_receive_buffer_size > 0) && setsockopt(s, SOL_SOCKET, SO_RCVBUF, (void *)&channel->socket_receive_buffer_size, sizeof(channel->socket_receive_buffer_size)) == -1) { - return -1; + return -1; /* LCOV_EXCL_LINE: UntestablePath */ } #ifdef SO_BINDTODEVICE @@ -304,8 +304,8 @@ ares_status_t ares__open_connection(ares_channel_t *channel, if ((!channel->sock_funcs || !channel->sock_funcs->asocket) && setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (void *)&opt, sizeof(opt)) == -1) { - ares__close_socket(channel, s); - return ARES_ECONNREFUSED; + ares__close_socket(channel, s); /* LCOV_EXCL_LINE: UntestablePath */ + return ARES_ECONNREFUSED; /* LCOV_EXCL_LINE: UntestablePath */ } } #endif @@ -338,8 +338,8 @@ ares_status_t ares__open_connection(ares_channel_t *channel, conn = ares_malloc(sizeof(*conn)); if (conn == NULL) { - ares__close_socket(channel, s); - return ARES_ENOMEM; + ares__close_socket(channel, s); /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } memset(conn, 0, sizeof(*conn)); conn->fd = s; @@ -347,9 +347,11 @@ ares_status_t ares__open_connection(ares_channel_t *channel, conn->queries_to_conn = ares__llist_create(NULL); conn->is_tcp = is_tcp; if (conn->queries_to_conn == NULL) { + /* LCOV_EXCL_START: OutOfMemory */ ares__close_socket(channel, s); ares_free(conn); return ARES_ENOMEM; + /* LCOV_EXCL_STOP */ } /* TCP connections are thrown to the end as we don't spawn multiple TCP @@ -361,20 +363,24 @@ ares_status_t ares__open_connection(ares_channel_t *channel, node = ares__llist_insert_first(server->connections, conn); } if (node == NULL) { + /* LCOV_EXCL_START: OutOfMemory */ ares__close_socket(channel, s); ares__llist_destroy(conn->queries_to_conn); ares_free(conn); return ARES_ENOMEM; + /* LCOV_EXCL_STOP */ } /* Register globally to quickly map event on file descriptor to connection * node object */ if (!ares__htable_asvp_insert(channel->connnode_by_socket, s, node)) { + /* LCOV_EXCL_START: OutOfMemory */ ares__close_socket(channel, s); ares__llist_destroy(conn->queries_to_conn); ares__llist_node_claim(node); ares_free(conn); return ARES_ENOMEM; + /* LCOV_EXCL_STOP */ } SOCK_STATE_CALLBACK(channel, s, 1, 0); diff --git a/deps/cares/src/lib/ares__threads.c b/deps/cares/src/lib/ares__threads.c index 53c81d41b287e7..efa0e09ef27b8e 100644 --- a/deps/cares/src/lib/ares__threads.c +++ b/deps/cares/src/lib/ares__threads.c @@ -226,25 +226,27 @@ ares__thread_mutex_t *ares__thread_mutex_create(void) } if (pthread_mutexattr_init(&attr) != 0) { - ares_free(mut); - return NULL; + ares_free(mut); /* LCOV_EXCL_LINE: UntestablePath */ + return NULL; /* LCOV_EXCL_LINE: UntestablePath */ } if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) != 0) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: UntestablePath */ } if (pthread_mutex_init(&mut->mutex, &attr) != 0) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: UntestablePath */ } pthread_mutexattr_destroy(&attr); return mut; +/* LCOV_EXCL_START: UntestablePath */ fail: pthread_mutexattr_destroy(&attr); ares_free(mut); return NULL; +/* LCOV_EXCL_STOP */ } void ares__thread_mutex_destroy(ares__thread_mutex_t *mut) @@ -379,11 +381,11 @@ ares_status_t ares__thread_create(ares__thread_t **thread, thr = ares_malloc_zero(sizeof(*thr)); if (thr == NULL) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } if (pthread_create(&thr->thread, NULL, func, arg) != 0) { - ares_free(thr); - return ARES_ESERVFAIL; + ares_free(thr); /* LCOV_EXCL_LINE: UntestablePath */ + return ARES_ESERVFAIL; /* LCOV_EXCL_LINE: UntestablePath */ } *thread = thr; diff --git a/deps/cares/src/lib/ares__timeval.c b/deps/cares/src/lib/ares__timeval.c index fae5ad7e871a20..a41c70631bba30 100644 --- a/deps/cares/src/lib/ares__timeval.c +++ b/deps/cares/src/lib/ares__timeval.c @@ -28,7 +28,7 @@ #include "ares.h" #include "ares_private.h" -#if defined(WIN32) && !defined(MSDOS) +#if defined(_WIN32) && !defined(MSDOS) ares_timeval_t ares__tvnow(void) { @@ -57,10 +57,12 @@ ares_timeval_t ares__tvnow(void) now.sec = (ares_int64_t)tsnow.tv_sec; now.usec = (unsigned int)(tsnow.tv_nsec / 1000); } else { + /* LCOV_EXCL_START: FallbackCode */ struct timeval tv; (void)gettimeofday(&tv, NULL); now.sec = (ares_int64_t)tv.tv_sec; now.usec = (unsigned int)tv.tv_usec; + /* LCOV_EXCL_STOP */ } return now; } diff --git a/deps/cares/src/lib/ares_cancel.c b/deps/cares/src/lib/ares_cancel.c index 5a9fb722cb7778..8686c366594ccb 100644 --- a/deps/cares/src/lib/ares_cancel.c +++ b/deps/cares/src/lib/ares_cancel.c @@ -57,8 +57,8 @@ void ares_cancel(ares_channel_t *channel) /* Out of memory, this function doesn't return a result code though so we * can't report to caller */ if (channel->all_queries == NULL) { - channel->all_queries = list_copy; - goto done; + channel->all_queries = list_copy; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } node = ares__llist_node_first(list_copy); diff --git a/deps/cares/src/lib/ares_config.h.cmake b/deps/cares/src/lib/ares_config.h.cmake index 10a1b7a971604b..ffe4adf25ae138 100644 --- a/deps/cares/src/lib/ares_config.h.cmake +++ b/deps/cares/src/lib/ares_config.h.cmake @@ -41,356 +41,356 @@ #define GETSERVBYNAME_R_ARGS @GETSERVBYNAME_R_ARGS@ /* Define to 1 if you have AF_INET6. */ -#cmakedefine HAVE_AF_INET6 +#cmakedefine HAVE_AF_INET6 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_ARPA_INET_H +#cmakedefine HAVE_ARPA_INET_H 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_ARPA_NAMESER_COMPAT_H +#cmakedefine HAVE_ARPA_NAMESER_COMPAT_H 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_ARPA_NAMESER_H +#cmakedefine HAVE_ARPA_NAMESER_H 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_ASSERT_H +#cmakedefine HAVE_ASSERT_H 1 /* Define to 1 if you have the clock_gettime function and monotonic timer. */ -#cmakedefine HAVE_CLOCK_GETTIME_MONOTONIC +#cmakedefine HAVE_CLOCK_GETTIME_MONOTONIC 1 /* Define to 1 if you have the closesocket function. */ -#cmakedefine HAVE_CLOSESOCKET +#cmakedefine HAVE_CLOSESOCKET 1 /* Define to 1 if you have the CloseSocket camel case function. */ -#cmakedefine HAVE_CLOSESOCKET_CAMEL +#cmakedefine HAVE_CLOSESOCKET_CAMEL 1 /* Define to 1 if you have the connect function. */ -#cmakedefine HAVE_CONNECT +#cmakedefine HAVE_CONNECT 1 /* define if the compiler supports basic C++11 syntax */ -#cmakedefine HAVE_CXX11 +#cmakedefine HAVE_CXX11 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_DLFCN_H +#cmakedefine HAVE_DLFCN_H 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_ERRNO_H +#cmakedefine HAVE_ERRNO_H 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_POLL_H +#cmakedefine HAVE_POLL_H 1 /* Define to 1 if you have the poll function. */ -#cmakedefine HAVE_POLL +#cmakedefine HAVE_POLL 1 /* Define to 1 if you have the pipe function. */ -#cmakedefine HAVE_PIPE +#cmakedefine HAVE_PIPE 1 /* Define to 1 if you have the pipe2 function. */ -#cmakedefine HAVE_PIPE2 +#cmakedefine HAVE_PIPE2 1 /* Define to 1 if you have the kqueue function. */ -#cmakedefine HAVE_KQUEUE +#cmakedefine HAVE_KQUEUE 1 /* Define to 1 if you have the epoll{_create,ctl,wait} functions. */ -#cmakedefine HAVE_EPOLL +#cmakedefine HAVE_EPOLL 1 /* Define to 1 if you have the fcntl function. */ -#cmakedefine HAVE_FCNTL +#cmakedefine HAVE_FCNTL 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_FCNTL_H +#cmakedefine HAVE_FCNTL_H 1 /* Define to 1 if you have a working fcntl O_NONBLOCK function. */ -#cmakedefine HAVE_FCNTL_O_NONBLOCK +#cmakedefine HAVE_FCNTL_O_NONBLOCK 1 /* Define to 1 if you have the freeaddrinfo function. */ -#cmakedefine HAVE_FREEADDRINFO +#cmakedefine HAVE_FREEADDRINFO 1 /* Define to 1 if you have a working getaddrinfo function. */ -#cmakedefine HAVE_GETADDRINFO +#cmakedefine HAVE_GETADDRINFO 1 /* Define to 1 if the getaddrinfo function is threadsafe. */ -#cmakedefine HAVE_GETADDRINFO_THREADSAFE +#cmakedefine HAVE_GETADDRINFO_THREADSAFE 1 /* Define to 1 if you have the getenv function. */ -#cmakedefine HAVE_GETENV +#cmakedefine HAVE_GETENV 1 /* Define to 1 if you have the gethostname function. */ -#cmakedefine HAVE_GETHOSTNAME +#cmakedefine HAVE_GETHOSTNAME 1 /* Define to 1 if you have the getnameinfo function. */ -#cmakedefine HAVE_GETNAMEINFO +#cmakedefine HAVE_GETNAMEINFO 1 /* Define to 1 if you have the getrandom function. */ -#cmakedefine HAVE_GETRANDOM +#cmakedefine HAVE_GETRANDOM 1 /* Define to 1 if you have the getservbyport_r function. */ -#cmakedefine HAVE_GETSERVBYPORT_R +#cmakedefine HAVE_GETSERVBYPORT_R 1 /* Define to 1 if you have the getservbyname_r function. */ -#cmakedefine HAVE_GETSERVBYNAME_R +#cmakedefine HAVE_GETSERVBYNAME_R 1 /* Define to 1 if you have the `gettimeofday' function. */ -#cmakedefine HAVE_GETTIMEOFDAY +#cmakedefine HAVE_GETTIMEOFDAY 1 /* Define to 1 if you have the `if_indextoname' function. */ -#cmakedefine HAVE_IF_INDEXTONAME +#cmakedefine HAVE_IF_INDEXTONAME 1 /* Define to 1 if you have the `if_nametoindex' function. */ -#cmakedefine HAVE_IF_NAMETOINDEX +#cmakedefine HAVE_IF_NAMETOINDEX 1 /* Define to 1 if you have the `ConvertInterfaceIndexToLuid' function. */ -#cmakedefine HAVE_CONVERTINTERFACEINDEXTOLUID +#cmakedefine HAVE_CONVERTINTERFACEINDEXTOLUID 1 /* Define to 1 if you have the `ConvertInterfaceLuidToNameA' function. */ -#cmakedefine HAVE_CONVERTINTERFACELUIDTONAMEA +#cmakedefine HAVE_CONVERTINTERFACELUIDTONAMEA 1 /* Define to 1 if you have a IPv6 capable working inet_net_pton function. */ -#cmakedefine HAVE_INET_NET_PTON +#cmakedefine HAVE_INET_NET_PTON 1 /* Define to 1 if you have a IPv6 capable working inet_ntop function. */ -#cmakedefine HAVE_INET_NTOP +#cmakedefine HAVE_INET_NTOP 1 /* Define to 1 if you have a IPv6 capable working inet_pton function. */ -#cmakedefine HAVE_INET_PTON +#cmakedefine HAVE_INET_PTON 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_INTTYPES_H +#cmakedefine HAVE_INTTYPES_H 1 /* Define to 1 if you have the ioctl function. */ -#cmakedefine HAVE_IOCTL +#cmakedefine HAVE_IOCTL 1 /* Define to 1 if you have the ioctlsocket function. */ -#cmakedefine HAVE_IOCTLSOCKET +#cmakedefine HAVE_IOCTLSOCKET 1 /* Define to 1 if you have the IoctlSocket camel case function. */ -#cmakedefine HAVE_IOCTLSOCKET_CAMEL +#cmakedefine HAVE_IOCTLSOCKET_CAMEL 1 /* Define to 1 if you have a working IoctlSocket camel case FIONBIO function. */ -#cmakedefine HAVE_IOCTLSOCKET_CAMEL_FIONBIO +#cmakedefine HAVE_IOCTLSOCKET_CAMEL_FIONBIO 1 /* Define to 1 if you have a working ioctlsocket FIONBIO function. */ -#cmakedefine HAVE_IOCTLSOCKET_FIONBIO +#cmakedefine HAVE_IOCTLSOCKET_FIONBIO 1 /* Define to 1 if you have a working ioctl FIONBIO function. */ -#cmakedefine HAVE_IOCTL_FIONBIO +#cmakedefine HAVE_IOCTL_FIONBIO 1 /* Define to 1 if you have a working ioctl SIOCGIFADDR function. */ -#cmakedefine HAVE_IOCTL_SIOCGIFADDR +#cmakedefine HAVE_IOCTL_SIOCGIFADDR 1 /* Define to 1 if you have the `resolve' library (-lresolve). */ -#cmakedefine HAVE_LIBRESOLV +#cmakedefine HAVE_LIBRESOLV 1 /* Define to 1 if you have iphlpapi.h */ -#cmakedefine HAVE_IPHLPAPI_H +#cmakedefine HAVE_IPHLPAPI_H 1 /* Define to 1 if you have netioapi.h */ -#cmakedefine HAVE_NETIOAPI_H +#cmakedefine HAVE_NETIOAPI_H 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_LIMITS_H +#cmakedefine HAVE_LIMITS_H 1 /* Define to 1 if the compiler supports the 'long long' data type. */ -#cmakedefine HAVE_LONGLONG +#cmakedefine HAVE_LONGLONG 1 /* Define to 1 if you have the malloc.h header file. */ -#cmakedefine HAVE_MALLOC_H +#cmakedefine HAVE_MALLOC_H 1 /* Define to 1 if you have the memory.h header file. */ -#cmakedefine HAVE_MEMORY_H +#cmakedefine HAVE_MEMORY_H 1 /* Define to 1 if you have the AvailabilityMacros.h header file. */ -#cmakedefine HAVE_AVAILABILITYMACROS_H +#cmakedefine HAVE_AVAILABILITYMACROS_H 1 /* Define to 1 if you have the MSG_NOSIGNAL flag. */ -#cmakedefine HAVE_MSG_NOSIGNAL +#cmakedefine HAVE_MSG_NOSIGNAL 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_NETDB_H +#cmakedefine HAVE_NETDB_H 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_NETINET_IN_H +#cmakedefine HAVE_NETINET_IN_H 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_NETINET6_IN6_H +#cmakedefine HAVE_NETINET6_IN6_H 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_NETINET_TCP_H +#cmakedefine HAVE_NETINET_TCP_H 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_NET_IF_H +#cmakedefine HAVE_NET_IF_H 1 /* Define to 1 if you have PF_INET6. */ -#cmakedefine HAVE_PF_INET6 +#cmakedefine HAVE_PF_INET6 1 /* Define to 1 if you have the recv function. */ -#cmakedefine HAVE_RECV +#cmakedefine HAVE_RECV 1 /* Define to 1 if you have the recvfrom function. */ -#cmakedefine HAVE_RECVFROM +#cmakedefine HAVE_RECVFROM 1 /* Define to 1 if you have the send function. */ -#cmakedefine HAVE_SEND +#cmakedefine HAVE_SEND 1 /* Define to 1 if you have the setsockopt function. */ -#cmakedefine HAVE_SETSOCKOPT +#cmakedefine HAVE_SETSOCKOPT 1 /* Define to 1 if you have a working setsockopt SO_NONBLOCK function. */ -#cmakedefine HAVE_SETSOCKOPT_SO_NONBLOCK +#cmakedefine HAVE_SETSOCKOPT_SO_NONBLOCK 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SIGNAL_H +#cmakedefine HAVE_SIGNAL_H 1 /* Define to 1 if your struct sockaddr_in6 has sin6_scope_id. */ -#cmakedefine HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID +#cmakedefine HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID 1 /* Define to 1 if you have the socket function. */ -#cmakedefine HAVE_SOCKET +#cmakedefine HAVE_SOCKET 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SOCKET_H +#cmakedefine HAVE_SOCKET_H 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STDBOOL_H +#cmakedefine HAVE_STDBOOL_H 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STDINT_H +#cmakedefine HAVE_STDINT_H 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STDLIB_H +#cmakedefine HAVE_STDLIB_H 1 /* Define to 1 if you have the strcasecmp function. */ -#cmakedefine HAVE_STRCASECMP +#cmakedefine HAVE_STRCASECMP 1 /* Define to 1 if you have the strcmpi function. */ -#cmakedefine HAVE_STRCMPI +#cmakedefine HAVE_STRCMPI 1 /* Define to 1 if you have the strdup function. */ -#cmakedefine HAVE_STRDUP +#cmakedefine HAVE_STRDUP 1 /* Define to 1 if you have the stricmp function. */ -#cmakedefine HAVE_STRICMP +#cmakedefine HAVE_STRICMP 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STRINGS_H +#cmakedefine HAVE_STRINGS_H 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STRING_H +#cmakedefine HAVE_STRING_H 1 /* Define to 1 if you have the strncasecmp function. */ -#cmakedefine HAVE_STRNCASECMP +#cmakedefine HAVE_STRNCASECMP 1 /* Define to 1 if you have the strncmpi function. */ -#cmakedefine HAVE_STRNCMPI +#cmakedefine HAVE_STRNCMPI 1 /* Define to 1 if you have the strnicmp function. */ -#cmakedefine HAVE_STRNICMP +#cmakedefine HAVE_STRNICMP 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STROPTS_H +#cmakedefine HAVE_STROPTS_H 1 /* Define to 1 if you have struct addrinfo. */ -#cmakedefine HAVE_STRUCT_ADDRINFO +#cmakedefine HAVE_STRUCT_ADDRINFO 1 /* Define to 1 if you have struct in6_addr. */ -#cmakedefine HAVE_STRUCT_IN6_ADDR +#cmakedefine HAVE_STRUCT_IN6_ADDR 1 /* Define to 1 if you have struct sockaddr_in6. */ -#cmakedefine HAVE_STRUCT_SOCKADDR_IN6 +#cmakedefine HAVE_STRUCT_SOCKADDR_IN6 1 /* if struct sockaddr_storage is defined */ -#cmakedefine HAVE_STRUCT_SOCKADDR_STORAGE +#cmakedefine HAVE_STRUCT_SOCKADDR_STORAGE 1 /* Define to 1 if you have the timeval struct. */ -#cmakedefine HAVE_STRUCT_TIMEVAL +#cmakedefine HAVE_STRUCT_TIMEVAL 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_IOCTL_H +#cmakedefine HAVE_SYS_IOCTL_H 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_PARAM_H +#cmakedefine HAVE_SYS_PARAM_H 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_RANDOM_H +#cmakedefine HAVE_SYS_RANDOM_H 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_EVENT_H +#cmakedefine HAVE_SYS_EVENT_H 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_EPOLL_H +#cmakedefine HAVE_SYS_EPOLL_H 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_SELECT_H +#cmakedefine HAVE_SYS_SELECT_H 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_SOCKET_H +#cmakedefine HAVE_SYS_SOCKET_H 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_STAT_H +#cmakedefine HAVE_SYS_STAT_H 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_TIME_H +#cmakedefine HAVE_SYS_TIME_H 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_TYPES_H +#cmakedefine HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_UIO_H +#cmakedefine HAVE_SYS_UIO_H 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_TIME_H +#cmakedefine HAVE_TIME_H 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_IFADDRS_H +#cmakedefine HAVE_IFADDRS_H 1 /* Define to 1 if you have the header file. */ -#cmakedefine HAVE_UNISTD_H +#cmakedefine HAVE_UNISTD_H 1 /* Define to 1 if you have the windows.h header file. */ -#cmakedefine HAVE_WINDOWS_H +#cmakedefine HAVE_WINDOWS_H 1 /* Define to 1 if you have the winsock2.h header file. */ -#cmakedefine HAVE_WINSOCK2_H +#cmakedefine HAVE_WINSOCK2_H 1 /* Define to 1 if you have the winsock.h header file. */ -#cmakedefine HAVE_WINSOCK_H +#cmakedefine HAVE_WINSOCK_H 1 /* Define to 1 if you have the mswsock.h header file. */ -#cmakedefine HAVE_MSWSOCK_H +#cmakedefine HAVE_MSWSOCK_H 1 /* Define to 1 if you have the winternl.h header file. */ -#cmakedefine HAVE_WINTERNL_H +#cmakedefine HAVE_WINTERNL_H 1 /* Define to 1 if you have the ntstatus.h header file. */ -#cmakedefine HAVE_NTSTATUS_H +#cmakedefine HAVE_NTSTATUS_H 1 /* Define to 1 if you have the ntdef.h header file. */ -#cmakedefine HAVE_NTDEF_H +#cmakedefine HAVE_NTDEF_H 1 /* Define to 1 if you have the writev function. */ -#cmakedefine HAVE_WRITEV +#cmakedefine HAVE_WRITEV 1 /* Define to 1 if you have the ws2tcpip.h header file. */ -#cmakedefine HAVE_WS2TCPIP_H +#cmakedefine HAVE_WS2TCPIP_H 1 /* Define to 1 if you have the __system_property_get function */ -#cmakedefine HAVE___SYSTEM_PROPERTY_GET +#cmakedefine HAVE___SYSTEM_PROPERTY_GET 1 /* Define to 1 if you need the malloc.h header file even with stdlib.h */ -#cmakedefine NEED_MALLOC_H +#cmakedefine NEED_MALLOC_H 1 /* Define to 1 if you need the memory.h header file even with stdlib.h */ -#cmakedefine NEED_MEMORY_H +#cmakedefine NEED_MEMORY_H 1 /* Define if have arc4random_buf() */ -#cmakedefine HAVE_ARC4RANDOM_BUF +#cmakedefine HAVE_ARC4RANDOM_BUF 1 /* Define if have getifaddrs() */ -#cmakedefine HAVE_GETIFADDRS +#cmakedefine HAVE_GETIFADDRS 1 /* Define if have stat() */ -#cmakedefine HAVE_STAT +#cmakedefine HAVE_STAT 1 /* a suitable file/device to read random data from */ #cmakedefine CARES_RANDOM_FILE "@CARES_RANDOM_FILE@" @@ -468,14 +468,14 @@ #undef WIN32_LEAN_AND_MEAN /* Define to 1 if you have the pthread.h header file. */ -#cmakedefine HAVE_PTHREAD_H +#cmakedefine HAVE_PTHREAD_H 1 /* Define to 1 if you have the pthread_np.h header file. */ -#cmakedefine HAVE_PTHREAD_NP_H +#cmakedefine HAVE_PTHREAD_NP_H 1 /* Define to 1 if threads are enabled */ -#cmakedefine CARES_THREADS +#cmakedefine CARES_THREADS 1 /* Define to 1 if pthread_init() exists */ -#cmakedefine HAVE_PTHREAD_INIT +#cmakedefine HAVE_PTHREAD_INIT 1 diff --git a/deps/cares/src/lib/ares_destroy.c b/deps/cares/src/lib/ares_destroy.c index 672f8b06184255..a19e6d0d97c482 100644 --- a/deps/cares/src/lib/ares_destroy.c +++ b/deps/cares/src/lib/ares_destroy.c @@ -129,7 +129,7 @@ void ares_destroy(ares_channel_t *channel) void ares__destroy_server(struct server_state *server) { if (server == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } ares__close_sockets(server); diff --git a/deps/cares/src/lib/ares_dns_name.c b/deps/cares/src/lib/ares_dns_name.c index 85e26cd25b57fe..754f9fadd2b5c8 100644 --- a/deps/cares/src/lib/ares_dns_name.c +++ b/deps/cares/src/lib/ares_dns_name.c @@ -37,7 +37,7 @@ static void ares__nameoffset_free(void *arg) { ares_nameoffset_t *off = arg; if (off == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } ares_free(off->name); ares_free(off); @@ -51,20 +51,20 @@ static ares_status_t ares__nameoffset_create(ares__llist_t **list, if (list == NULL || name == NULL || ares_strlen(name) == 0 || ares_strlen(name) > 255) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (*list == NULL) { *list = ares__llist_create(ares__nameoffset_free); } if (*list == NULL) { - status = ARES_ENOMEM; - goto fail; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } off = ares_malloc_zero(sizeof(*off)); if (off == NULL) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } off->name = ares_strdup(name); @@ -72,15 +72,17 @@ static ares_status_t ares__nameoffset_create(ares__llist_t **list, off->idx = idx; if (ares__llist_insert_last(*list, off) == NULL) { - status = ARES_ENOMEM; - goto fail; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } return ARES_SUCCESS; +/* LCOV_EXCL_START: OutOfMemory */ fail: ares__nameoffset_free(off); return status; +/* LCOV_EXCL_STOP */ } static const ares_nameoffset_t *ares__nameoffset_find(ares__llist_t *list, @@ -138,7 +140,7 @@ static void ares_dns_labels_free(ares_dns_labels_t *labels) size_t i; if (labels == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } for (i = 0; i < labels->num; i++) { @@ -155,20 +157,20 @@ static ares__buf_t *ares_dns_labels_add(ares_dns_labels_t *labels) void *temp; if (labels == NULL) { - return NULL; + return NULL; /* LCOV_EXCL_LINE: DefensiveCoding */ } temp = ares_realloc_zero(labels->label, sizeof(*labels->label) * labels->num, sizeof(*labels->label) * (labels->num + 1)); if (temp == NULL) { - return NULL; + return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ } labels->label = temp; labels->label[labels->num] = ares__buf_create(); if (labels->label[labels->num] == NULL) { - return NULL; + return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ } labels->num++; @@ -179,7 +181,7 @@ static const ares__buf_t * ares_dns_labels_get_last(const ares_dns_labels_t *labels) { if (labels == NULL || labels->num == 0) { - return NULL; + return NULL; /* LCOV_EXCL_LINE: DefensiveCoding */ } return labels->label[labels->num - 1]; @@ -188,7 +190,7 @@ static const ares__buf_t * static void ares_dns_name_labels_del_last(ares_dns_labels_t *labels) { if (labels == NULL || labels->num == 0) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } ares__buf_destroy(labels->label[labels->num - 1]); @@ -260,29 +262,29 @@ static ares_status_t ares_split_dns_name(ares_dns_labels_t *labels, unsigned char c; if (name == NULL || labels == NULL) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* Put name into a buffer for parsing */ namebuf = ares__buf_create(); if (namebuf == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } if (*name != '\0') { status = ares__buf_append(namebuf, (const unsigned char *)name, ares_strlen(name)); if (status != ARES_SUCCESS) { - goto done; + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } /* Start with 1 label */ label = ares_dns_labels_add(labels); if (label == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } while (ares__buf_fetch_bytes(namebuf, &c, 1) == ARES_SUCCESS) { @@ -290,8 +292,8 @@ static ares_status_t ares_split_dns_name(ares_dns_labels_t *labels, if (c == '.') { label = ares_dns_labels_add(labels); if (label == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } continue; } @@ -313,7 +315,7 @@ static ares_status_t ares_split_dns_name(ares_dns_labels_t *labels, status = ares__buf_append_byte(label, c); if (status != ARES_SUCCESS) { - goto done; + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -369,7 +371,7 @@ ares_status_t ares__dns_name_write(ares__buf_t *buf, ares__llist_t **list, ares_status_t status; if (buf == NULL || name == NULL) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } memset(&labels, 0, sizeof(labels)); @@ -404,12 +406,12 @@ ares_status_t ares__dns_name_write(ares__buf_t *buf, ares__llist_t **list, status = ares__buf_append_byte(buf, (unsigned char)(len & 0xFF)); if (status != ARES_SUCCESS) { - goto done; + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ares__buf_append(buf, ptr, len); if (status != ARES_SUCCESS) { - goto done; + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -417,7 +419,7 @@ ares_status_t ares__dns_name_write(ares__buf_t *buf, ares__llist_t **list, if (off == NULL) { status = ares__buf_append_byte(buf, 0); if (status != ARES_SUCCESS) { - goto done; + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } } @@ -428,7 +430,7 @@ ares_status_t ares__dns_name_write(ares__buf_t *buf, ares__llist_t **list, (unsigned short)0xC000 | (unsigned short)(off->idx & 0x3FFF); status = ares__buf_append_be16(buf, u16); if (status != ARES_SUCCESS) { - goto done; + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -438,7 +440,7 @@ ares_status_t ares__dns_name_write(ares__buf_t *buf, ares__llist_t **list, name_len > 0) { status = ares__nameoffset_create(list, name /* not truncated copy! */, pos); if (status != ARES_SUCCESS) { - goto done; + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -509,7 +511,7 @@ static ares_status_t ares__fetch_dnsname_into_buf(ares__buf_t *buf, status = ares__buf_append(dest, escape, sizeof(escape)); if (status != ARES_SUCCESS) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } continue; @@ -519,13 +521,13 @@ static ares_status_t ares__fetch_dnsname_into_buf(ares__buf_t *buf, if (is_reservedch(c)) { status = ares__buf_append_byte(dest, '\\'); if (status != ARES_SUCCESS) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } } status = ares__buf_append_byte(dest, c); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -641,7 +643,7 @@ ares_status_t ares__dns_name_parse(ares__buf_t *buf, char **name, if (ares__buf_len(namebuf) != 0 && name != NULL) { status = ares__buf_append_byte(namebuf, '.'); if (status != ARES_SUCCESS) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -660,8 +662,8 @@ ares_status_t ares__dns_name_parse(ares__buf_t *buf, char **name, if (name != NULL) { *name = ares__buf_finish_str(namebuf, NULL); if (*name == NULL) { - status = ARES_ENOMEM; - goto fail; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } } diff --git a/deps/cares/src/lib/ares_dns_parse.c b/deps/cares/src/lib/ares_dns_parse.c index 8b771ee1faf3cc..765f70ce636885 100644 --- a/deps/cares/src/lib/ares_dns_parse.c +++ b/deps/cares/src/lib/ares_dns_parse.c @@ -925,7 +925,7 @@ static ares_status_t ares_dns_parse_header(ares__buf_t *buf, unsigned int flags, status = ares_dns_record_rr_prealloc(*dnsrec, ARES_SECTION_ANSWER, *ancount); if (status != ARES_SUCCESS) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -933,7 +933,7 @@ static ares_status_t ares_dns_parse_header(ares__buf_t *buf, unsigned int flags, status = ares_dns_record_rr_prealloc(*dnsrec, ARES_SECTION_AUTHORITY, *nscount); if (status != ARES_SUCCESS) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -941,7 +941,7 @@ static ares_status_t ares_dns_parse_header(ares__buf_t *buf, unsigned int flags, status = ares_dns_record_rr_prealloc(*dnsrec, ARES_SECTION_ADDITIONAL, *arcount); if (status != ARES_SUCCESS) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -1216,7 +1216,7 @@ static ares_status_t ares_dns_parse_buf(ares__buf_t *buf, unsigned int flags, unsigned short i; if (buf == NULL || dnsrec == NULL) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* Maximum DNS packet size is 64k, even over TCP */ diff --git a/deps/cares/src/lib/ares_dns_record.c b/deps/cares/src/lib/ares_dns_record.c index e6b7bf7fe1d9c7..5d109999946eef 100644 --- a/deps/cares/src/lib/ares_dns_record.c +++ b/deps/cares/src/lib/ares_dns_record.c @@ -292,8 +292,8 @@ ares_status_t ares_dns_record_query_set_name(ares_dns_record_t *dnsrec, orig_name = dnsrec->qd[idx].name; dnsrec->qd[idx].name = ares_strdup(name); if (dnsrec->qd[idx].name == NULL) { - dnsrec->qd[idx].name = orig_name; - return ARES_ENOMEM; + dnsrec->qd[idx].name = orig_name; /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } ares_free(orig_name); @@ -354,7 +354,7 @@ size_t ares_dns_record_rr_cnt(const ares_dns_record_t *dnsrec, return dnsrec->arcount; } - return 0; + return 0; /* LCOV_EXCL_LINE: DefensiveCoding */ } ares_status_t ares_dns_record_rr_prealloc(ares_dns_record_t *dnsrec, @@ -365,7 +365,7 @@ ares_status_t ares_dns_record_rr_prealloc(ares_dns_record_t *dnsrec, ares_dns_rr_t *temp = NULL; if (dnsrec == NULL || cnt == 0 || !ares_dns_section_isvalid(sect)) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } switch (sect) { @@ -440,7 +440,7 @@ ares_status_t ares_dns_record_rr_add(ares_dns_rr_t **rr_out, status = ares_dns_record_rr_prealloc(dnsrec, sect, *rr_len + 1); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } idx = *rr_len; @@ -580,7 +580,7 @@ static void *ares_dns_rr_data_ptr(ares_dns_rr_t *dns_rr, ares_dns_rr_key_t key, size_t **lenptr) { if (dns_rr == NULL || dns_rr->type != ares_dns_rr_key_to_rec_type(key)) { - return NULL; + return NULL; /* LCOV_EXCL_LINE: DefensiveCoding */ } switch (key) { diff --git a/deps/cares/src/lib/ares_dns_write.c b/deps/cares/src/lib/ares_dns_write.c index 1643f0810322c1..6cf15bf4e614bc 100644 --- a/deps/cares/src/lib/ares_dns_write.c +++ b/deps/cares/src/lib/ares_dns_write.c @@ -44,7 +44,7 @@ static ares_status_t ares_dns_write_header(const ares_dns_record_t *dnsrec, /* ID */ status = ares__buf_append_be16(buf, dnsrec->id); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Flags */ @@ -103,31 +103,31 @@ static ares_status_t ares_dns_write_header(const ares_dns_record_t *dnsrec, status = ares__buf_append_be16(buf, u16); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* QDCOUNT */ status = ares__buf_append_be16(buf, (unsigned short)dnsrec->qdcount); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* ANCOUNT */ status = ares__buf_append_be16(buf, (unsigned short)dnsrec->ancount); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* NSCOUNT */ status = ares__buf_append_be16(buf, (unsigned short)dnsrec->nscount); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* ARCOUNT */ status = ares__buf_append_be16(buf, (unsigned short)dnsrec->arcount); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } return ARES_SUCCESS; @@ -159,13 +159,13 @@ static ares_status_t ares_dns_write_questions(const ares_dns_record_t *dnsrec, /* Type */ status = ares__buf_append_be16(buf, (unsigned short)qtype); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Class */ status = ares__buf_append_be16(buf, (unsigned short)qclass); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -182,7 +182,7 @@ static ares_status_t ares_dns_write_rr_name(ares__buf_t *buf, name = ares_dns_rr_get_str(rr, key); if (name == NULL) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } return ares__dns_name_write(buf, namelist, validate_hostname, name); @@ -198,7 +198,7 @@ static ares_status_t ares_dns_write_rr_str(ares__buf_t *buf, str = ares_dns_rr_get_str(rr, key); if (str == NULL) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } len = ares_strlen(str); @@ -209,7 +209,7 @@ static ares_status_t ares_dns_write_rr_str(ares__buf_t *buf, /* Write 1 byte length */ status = ares__buf_append_byte(buf, (unsigned char)(len & 0xFF)); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } if (len == 0) { @@ -232,7 +232,7 @@ static ares_status_t ares_dns_write_rr_binstrs(ares__buf_t *buf, bin = ares_dns_rr_get_bin(rr, key, &bin_len); if (bin == NULL) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* split into possible multiple 255-byte or less length strings */ ptr = bin; @@ -246,14 +246,14 @@ static ares_status_t ares_dns_write_rr_binstrs(ares__buf_t *buf, /* Length */ status = ares__buf_append_byte(buf, (unsigned char)(len & 0xFF)); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* String */ if (len) { status = ares__buf_append(buf, ptr, len); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -269,7 +269,7 @@ static ares_status_t ares_dns_write_rr_be32(ares__buf_t *buf, ares_dns_rr_key_t key) { if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_U32) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } return ares__buf_append_be32(buf, ares_dns_rr_get_u32(rr, key)); } @@ -279,7 +279,7 @@ static ares_status_t ares_dns_write_rr_be16(ares__buf_t *buf, ares_dns_rr_key_t key) { if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_U16) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } return ares__buf_append_be16(buf, ares_dns_rr_get_u16(rr, key)); } @@ -289,7 +289,7 @@ static ares_status_t ares_dns_write_rr_u8(ares__buf_t *buf, ares_dns_rr_key_t key) { if (ares_dns_rr_key_datatype(key) != ARES_DATATYPE_U8) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } return ares__buf_append_byte(buf, ares_dns_rr_get_u8(rr, key)); } @@ -303,7 +303,7 @@ static ares_status_t ares_dns_write_rr_a(ares__buf_t *buf, addr = ares_dns_rr_get_addr(rr, ARES_RR_A_ADDR); if (addr == NULL) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } return ares__buf_append(buf, (const unsigned char *)addr, sizeof(*addr)); @@ -348,25 +348,25 @@ static ares_status_t ares_dns_write_rr_soa(ares__buf_t *buf, /* SERIAL */ status = ares_dns_write_rr_be32(buf, rr, ARES_RR_SOA_SERIAL); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* REFRESH */ status = ares_dns_write_rr_be32(buf, rr, ARES_RR_SOA_REFRESH); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* RETRY */ status = ares_dns_write_rr_be32(buf, rr, ARES_RR_SOA_RETRY); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* EXPIRE */ status = ares_dns_write_rr_be32(buf, rr, ARES_RR_SOA_EXPIRE); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* MINIMUM */ @@ -408,7 +408,7 @@ static ares_status_t ares_dns_write_rr_mx(ares__buf_t *buf, /* PREFERENCE */ status = ares_dns_write_rr_be16(buf, rr, ARES_RR_MX_PREFERENCE); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* EXCHANGE */ @@ -437,43 +437,43 @@ static ares_status_t ares_dns_write_rr_sig(ares__buf_t *buf, /* TYPE COVERED */ status = ares_dns_write_rr_be16(buf, rr, ARES_RR_SIG_TYPE_COVERED); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* ALGORITHM */ status = ares_dns_write_rr_u8(buf, rr, ARES_RR_SIG_ALGORITHM); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* LABELS */ status = ares_dns_write_rr_u8(buf, rr, ARES_RR_SIG_LABELS); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* ORIGINAL TTL */ status = ares_dns_write_rr_be32(buf, rr, ARES_RR_SIG_ORIGINAL_TTL); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* EXPIRATION */ status = ares_dns_write_rr_be32(buf, rr, ARES_RR_SIG_EXPIRATION); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* INCEPTION */ status = ares_dns_write_rr_be32(buf, rr, ARES_RR_SIG_INCEPTION); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* KEY TAG */ status = ares_dns_write_rr_be16(buf, rr, ARES_RR_SIG_KEY_TAG); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* SIGNERS NAME */ @@ -501,7 +501,7 @@ static ares_status_t ares_dns_write_rr_aaaa(ares__buf_t *buf, addr = ares_dns_rr_get_addr6(rr, ARES_RR_AAAA_ADDR); if (addr == NULL) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } return ares__buf_append(buf, (const unsigned char *)addr, sizeof(*addr)); @@ -516,19 +516,19 @@ static ares_status_t ares_dns_write_rr_srv(ares__buf_t *buf, /* PRIORITY */ status = ares_dns_write_rr_be16(buf, rr, ARES_RR_SRV_PRIORITY); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* WEIGHT */ status = ares_dns_write_rr_be16(buf, rr, ARES_RR_SRV_WEIGHT); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* PORT */ status = ares_dns_write_rr_be16(buf, rr, ARES_RR_SRV_PORT); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* TARGET */ @@ -545,31 +545,31 @@ static ares_status_t ares_dns_write_rr_naptr(ares__buf_t *buf, /* ORDER */ status = ares_dns_write_rr_be16(buf, rr, ARES_RR_NAPTR_ORDER); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* PREFERENCE */ status = ares_dns_write_rr_be16(buf, rr, ARES_RR_NAPTR_PREFERENCE); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* FLAGS */ status = ares_dns_write_rr_str(buf, rr, ARES_RR_NAPTR_FLAGS); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* SERVICES */ status = ares_dns_write_rr_str(buf, rr, ARES_RR_NAPTR_SERVICES); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* REGEXP */ status = ares_dns_write_rr_str(buf, rr, ARES_RR_NAPTR_REGEXP); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* REPLACEMENT */ @@ -601,7 +601,7 @@ static ares_status_t ares_dns_write_rr_opt(ares__buf_t *buf, /* Class -> UDP Size */ status = ares_dns_write_rr_be16(buf, rr, ARES_RR_OPT_UDP_SIZE); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* TTL -> rcode (u8) << 24 | version (u8) << 16 | flags (u16) */ @@ -611,7 +611,7 @@ static ares_status_t ares_dns_write_rr_opt(ares__buf_t *buf, status = ares__buf_append_be32(buf, ttl); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Now go back to real end */ @@ -631,20 +631,20 @@ static ares_status_t ares_dns_write_rr_opt(ares__buf_t *buf, /* BE16 option */ status = ares__buf_append_be16(buf, opt); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* BE16 length */ status = ares__buf_append_be16(buf, (unsigned short)(val_len & 0xFFFF)); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Value */ if (val && val_len) { status = ares__buf_append(buf, val, val_len); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } } } @@ -665,19 +665,19 @@ static ares_status_t ares_dns_write_rr_tlsa(ares__buf_t *buf, /* CERT_USAGE */ status = ares_dns_write_rr_u8(buf, rr, ARES_RR_TLSA_CERT_USAGE); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* SELECTOR */ status = ares_dns_write_rr_u8(buf, rr, ARES_RR_TLSA_SELECTOR); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* MATCH */ status = ares_dns_write_rr_u8(buf, rr, ARES_RR_TLSA_MATCH); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* DATA -- binary, rest of buffer, required to be non-zero length */ @@ -699,7 +699,7 @@ static ares_status_t ares_dns_write_rr_svcb(ares__buf_t *buf, /* PRIORITY */ status = ares_dns_write_rr_be16(buf, rr, ARES_RR_SVCB_PRIORITY); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* TARGET */ @@ -720,20 +720,20 @@ static ares_status_t ares_dns_write_rr_svcb(ares__buf_t *buf, /* BE16 option */ status = ares__buf_append_be16(buf, opt); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* BE16 length */ status = ares__buf_append_be16(buf, (unsigned short)(val_len & 0xFFFF)); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Value */ if (val && val_len) { status = ares__buf_append(buf, val, val_len); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } } } @@ -750,7 +750,7 @@ static ares_status_t ares_dns_write_rr_https(ares__buf_t *buf, /* PRIORITY */ status = ares_dns_write_rr_be16(buf, rr, ARES_RR_HTTPS_PRIORITY); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* TARGET */ @@ -771,20 +771,20 @@ static ares_status_t ares_dns_write_rr_https(ares__buf_t *buf, /* BE16 option */ status = ares__buf_append_be16(buf, opt); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* BE16 length */ status = ares__buf_append_be16(buf, (unsigned short)(val_len & 0xFFFF)); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Value */ if (val && val_len) { status = ares__buf_append(buf, val, val_len); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } } } @@ -803,13 +803,13 @@ static ares_status_t ares_dns_write_rr_uri(ares__buf_t *buf, /* PRIORITY */ status = ares_dns_write_rr_be16(buf, rr, ARES_RR_URI_PRIORITY); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* WEIGHT */ status = ares_dns_write_rr_be16(buf, rr, ARES_RR_URI_WEIGHT); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* TARGET -- not in DNS string format, rest of buffer, required to be @@ -836,13 +836,13 @@ static ares_status_t ares_dns_write_rr_caa(ares__buf_t *buf, /* CRITICAL */ status = ares_dns_write_rr_u8(buf, rr, ARES_RR_CAA_CRITICAL); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Tag */ status = ares_dns_write_rr_str(buf, rr, ARES_RR_CAA_TAG); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Value - binary! (remaining buffer */ @@ -877,7 +877,7 @@ static ares_status_t ares_dns_write_rr_raw_rr(ares__buf_t *buf, status = ares_dns_write_rr_be16(buf, rr, ARES_RR_RAW_RR_TYPE); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Now go back to real end */ @@ -919,7 +919,7 @@ static ares_status_t ares_dns_write_rr(const ares_dns_record_t *dnsrec, rr = ares_dns_record_rr_get_const(dnsrec, section, i); if (rr == NULL) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } type = ares_dns_rr_get_type(rr); @@ -938,14 +938,14 @@ static ares_status_t ares_dns_write_rr(const ares_dns_record_t *dnsrec, /* Type */ status = ares__buf_append_be16(buf, (unsigned short)type); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Class */ status = ares__buf_append_be16(buf, (unsigned short)ares_dns_rr_get_class(rr)); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* TTL */ @@ -957,14 +957,14 @@ static ares_status_t ares_dns_write_rr(const ares_dns_record_t *dnsrec, } status = ares__buf_append_be32(buf, ttl); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Length */ pos_len = ares__buf_len(buf); /* Save to write real length later */ status = ares__buf_append_be16(buf, 0); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Data */ @@ -1047,7 +1047,7 @@ static ares_status_t ares_dns_write_rr(const ares_dns_record_t *dnsrec, status = ares__buf_append_be16(buf, (unsigned short)(rdlength & 0xFFFF)); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ares__buf_set_length(buf, end_length); @@ -1075,7 +1075,7 @@ ares_status_t ares_dns_write(const ares_dns_record_t *dnsrec, b = ares__buf_create(); if (b == NULL) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ares_dns_write_header(dnsrec, b); diff --git a/deps/cares/src/lib/ares_event_configchg.c b/deps/cares/src/lib/ares_event_configchg.c index c7bc9ffd58b4e4..b7c5ad8c75b621 100644 --- a/deps/cares/src/lib/ares_event_configchg.c +++ b/deps/cares/src/lib/ares_event_configchg.c @@ -54,7 +54,7 @@ struct ares_event_configchg { void ares_event_configchg_destroy(ares_event_configchg_t *configchg) { if (configchg == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* Tell event system to stop monitoring for changes. This will cause the @@ -67,7 +67,7 @@ static void ares_event_configchg_free(void *data) { ares_event_configchg_t *configchg = data; if (configchg == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (configchg->inotify_fd >= 0) { @@ -142,22 +142,22 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, c = ares_malloc_zero(sizeof(*c)); if (c == NULL) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } c->e = e; c->inotify_fd = inotify_init1(IN_NONBLOCK | IN_CLOEXEC); if (c->inotify_fd == -1) { - status = ARES_ESERVFAIL; - goto done; + status = ARES_ESERVFAIL; /* LCOV_EXCL_LINE: UntestablePath */ + goto done; /* LCOV_EXCL_LINE: UntestablePath */ } /* We need to monitor /etc/resolv.conf, /etc/nsswitch.conf */ if (inotify_add_watch(c->inotify_fd, "/etc", IN_CREATE | IN_MODIFY | IN_MOVED_TO | IN_ONLYDIR) == -1) { - status = ARES_ESERVFAIL; - goto done; + status = ARES_ESERVFAIL; /* LCOV_EXCL_LINE: UntestablePath */ + goto done; /* LCOV_EXCL_LINE: UntestablePath */ } status = @@ -173,7 +173,7 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, return status; } -#elif defined(_WIN32) +#elif defined(USE_WINSOCK) # include # include @@ -182,31 +182,66 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, struct ares_event_configchg { HANDLE ifchg_hnd; + HKEY regip4; + HANDLE regip4_event; + HANDLE regip4_wait; + HKEY regip6; + HANDLE regip6_event; + HANDLE regip6_wait; ares_event_thread_t *e; }; void ares_event_configchg_destroy(ares_event_configchg_t *configchg) { -# ifdef __WATCOMC__ - /* Not supported */ -# else if (configchg == NULL) { return; } +# ifndef __WATCOMC__ if (configchg->ifchg_hnd != NULL) { CancelMibChangeNotify2(configchg->ifchg_hnd); configchg->ifchg_hnd = NULL; } +# endif + + if (configchg->regip4_wait != NULL) { + UnregisterWait(configchg->regip4_wait); + configchg->regip4_wait = NULL; + } + + if (configchg->regip6_wait != NULL) { + UnregisterWait(configchg->regip6_wait); + configchg->regip6_wait = NULL; + } + + if (configchg->regip4 != NULL) { + RegCloseKey(configchg->regip4); + configchg->regip4 = NULL; + } + + if (configchg->regip6 != NULL) { + RegCloseKey(configchg->regip6); + configchg->regip6 = NULL; + } + + if (configchg->regip4_event != NULL) { + CloseHandle(configchg->regip4_event); + configchg->regip4_event = NULL; + } + + if (configchg->regip6_event != NULL) { + CloseHandle(configchg->regip6_event); + configchg->regip6_event = NULL; + } ares_free(configchg); -# endif } + # ifndef __WATCOMC__ -static void ares_event_configchg_cb(PVOID CallerContext, - PMIB_IPINTERFACE_ROW Row, - MIB_NOTIFICATION_TYPE NotificationType) +static void ares_event_configchg_ip_cb(PVOID CallerContext, + PMIB_IPINTERFACE_ROW Row, + MIB_NOTIFICATION_TYPE NotificationType) { ares_event_configchg_t *configchg = CallerContext; (void)Row; @@ -215,43 +250,125 @@ static void ares_event_configchg_cb(PVOID CallerContext, } # endif +static ares_bool_t ares_event_configchg_regnotify(ares_event_configchg_t *configchg) +{ +# if defined(__WATCOMC__) && !defined(REG_NOTIFY_THREAD_AGNOSTIC) +# define REG_NOTIFY_THREAD_AGNOSTIC 0x10000000L +# endif + DWORD flags = + REG_NOTIFY_CHANGE_NAME|REG_NOTIFY_CHANGE_LAST_SET|REG_NOTIFY_THREAD_AGNOSTIC; + + if (RegNotifyChangeKeyValue(configchg->regip4, TRUE, + flags, + configchg->regip4_event, + TRUE) != ERROR_SUCCESS) { + return ARES_FALSE; + } + + if (RegNotifyChangeKeyValue(configchg->regip6, TRUE, + flags, + configchg->regip6_event, + TRUE) != ERROR_SUCCESS) { + return ARES_FALSE; + } + + return ARES_TRUE; +} + +static VOID CALLBACK ares_event_configchg_reg_cb(PVOID lpParameter, + BOOLEAN TimerOrWaitFired) +{ + ares_event_configchg_t *configchg = lpParameter; + (void)TimerOrWaitFired; + + ares_reinit(configchg->e->channel); + + /* Re-arm, as its single-shot. However, we don't know which one needs to + * be re-armed, so we just do both */ + ares_event_configchg_regnotify(configchg); +} ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, ares_event_thread_t *e) { -# ifdef __WATCOMC__ - return ARES_ENOTIMP; -# else - ares_status_t status = ARES_SUCCESS; + ares_status_t status = ARES_SUCCESS; + ares_event_configchg_t *c = NULL; - *configchg = ares_malloc_zero(sizeof(**configchg)); - if (*configchg == NULL) { + c = ares_malloc_zero(sizeof(**configchg)); + if (c == NULL) { return ARES_ENOMEM; } - (*configchg)->e = e; + c->e = e; +#ifndef __WATCOMC__ /* NOTE: If a user goes into the control panel and changes the network * adapter DNS addresses manually, this will NOT trigger a notification. * We've also tried listening on NotifyUnicastIpAddressChange(), but * that didn't get triggered either. */ - if (NotifyIpInterfaceChange( - AF_UNSPEC, (PIPINTERFACE_CHANGE_CALLBACK)ares_event_configchg_cb, - *configchg, FALSE, &(*configchg)->ifchg_hnd) != NO_ERROR) { + AF_UNSPEC, (PIPINTERFACE_CHANGE_CALLBACK)ares_event_configchg_ip_cb, + *configchg, FALSE, &c->ifchg_hnd) != NO_ERROR) { + status = ARES_ESERVFAIL; + goto done; + } +#endif + + /* Monitor HKLM\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\Interfaces + * and HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces + * for changes via RegNotifyChangeKeyValue() */ + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, + "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces", + 0, KEY_NOTIFY, &c->regip4) != ERROR_SUCCESS) { + status = ARES_ESERVFAIL; + goto done; + } + + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, + "SYSTEM\\CurrentControlSet\\Services\\Tcpip6\\Parameters\\Interfaces", + 0, KEY_NOTIFY, &c->regip6) != ERROR_SUCCESS) { + status = ARES_ESERVFAIL; + goto done; + } + + c->regip4_event = CreateEvent(NULL, TRUE, FALSE, NULL); + if (c->regip4_event == NULL) { + status = ARES_ESERVFAIL; + goto done; + } + + c->regip6_event = CreateEvent(NULL, TRUE, FALSE, NULL); + if (c->regip6_event == NULL) { + status = ARES_ESERVFAIL; + goto done; + } + + if (!RegisterWaitForSingleObject(&c->regip4_wait, c->regip4_event, + ares_event_configchg_reg_cb, c, INFINITE, WT_EXECUTEDEFAULT)) { + status = ARES_ESERVFAIL; + goto done; + } + + if (!RegisterWaitForSingleObject(&c->regip6_wait, c->regip6_event, + ares_event_configchg_reg_cb, c, INFINITE, WT_EXECUTEDEFAULT)) { + status = ARES_ESERVFAIL; + goto done; + } + + if (!ares_event_configchg_regnotify(c)) { status = ARES_ESERVFAIL; goto done; } done: if (status != ARES_SUCCESS) { - ares_event_configchg_destroy(*configchg); - *configchg = NULL; + ares_event_configchg_destroy(c); + } else { + *configchg = c; } return status; -# endif } #elif defined(__APPLE__) @@ -260,6 +377,7 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, # include # include # include +# include struct ares_event_configchg { int fd; @@ -328,11 +446,17 @@ static void ares_event_configchg_cb(ares_event_thread_t *e, ares_socket_t fd, ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, ares_event_thread_t *e) { - ares_status_t status = ARES_SUCCESS; - void *handle = NULL; - const char *(*pdns_configuration_notify_key)(void) = NULL; - const char *notify_key = NULL; - int flags; + ares_status_t status = ARES_SUCCESS; + void *handle = NULL; + const char *(*pdns_configuration_notify_key)(void) = NULL; + const char *notify_key = NULL; + int flags; + size_t i; + const char *searchlibs[] = { + "/usr/lib/libSystem.dylib", + "/System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration", + NULL + }; *configchg = ares_malloc_zero(sizeof(**configchg)); if (*configchg == NULL) { @@ -340,13 +464,22 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, } /* Load symbol as it isn't normally public */ - handle = dlopen("/usr/lib/libSystem.dylib", RTLD_LAZY | RTLD_NOLOAD); - if (handle == NULL) { - status = ARES_ESERVFAIL; - goto done; - } + for (i=0; searchlibs[i] != NULL; i++) { + handle = dlopen(searchlibs[i], RTLD_LAZY); + if (handle == NULL) { + /* Fail, loop! */ + continue; + } - pdns_configuration_notify_key = dlsym(handle, "dns_configuration_notify_key"); + pdns_configuration_notify_key = dlsym(handle, "dns_configuration_notify_key"); + if (pdns_configuration_notify_key != NULL) { + break; + } + + /* Fail, loop! */ + dlclose(handle); + handle = NULL; + } if (pdns_configuration_notify_key == NULL) { status = ARES_ESERVFAIL; @@ -388,7 +521,7 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg, return status; } -#elif defined(HAVE_STAT) +#elif defined(HAVE_STAT) && !defined(_WIN32) # ifdef HAVE_SYS_TYPES_H # include # endif diff --git a/deps/cares/src/lib/ares_event_epoll.c b/deps/cares/src/lib/ares_event_epoll.c index 78cbbc368c8ef0..9ebd87c05c25ce 100644 --- a/deps/cares/src/lib/ares_event_epoll.c +++ b/deps/cares/src/lib/ares_event_epoll.c @@ -46,12 +46,12 @@ static void ares_evsys_epoll_destroy(ares_event_thread_t *e) ares_evsys_epoll_t *ep = NULL; if (e == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } ep = e->ev_sys_data; if (ep == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (ep->epoll_fd != -1) { @@ -68,15 +68,15 @@ static ares_bool_t ares_evsys_epoll_init(ares_event_thread_t *e) ep = ares_malloc_zero(sizeof(*ep)); if (ep == NULL) { - return ARES_FALSE; + return ARES_FALSE; /* LCOV_EXCL_LINE: OutOfMemory */ } e->ev_sys_data = ep; ep->epoll_fd = epoll_create1(0); if (ep->epoll_fd == -1) { - ares_evsys_epoll_destroy(e); - return ARES_FALSE; + ares_evsys_epoll_destroy(e); /* LCOV_EXCL_LINE: UntestablePath */ + return ARES_FALSE; /* LCOV_EXCL_LINE: UntestablePath */ } # ifdef FD_CLOEXEC @@ -85,8 +85,8 @@ static ares_bool_t ares_evsys_epoll_init(ares_event_thread_t *e) e->ev_signal = ares_pipeevent_create(e); if (e->ev_signal == NULL) { - ares_evsys_epoll_destroy(e); - return ARES_FALSE; + ares_evsys_epoll_destroy(e); /* LCOV_EXCL_LINE: UntestablePath */ + return ARES_FALSE; /* LCOV_EXCL_LINE: UntestablePath */ } return ARES_TRUE; @@ -108,7 +108,7 @@ static ares_bool_t ares_evsys_epoll_event_add(ares_event_t *event) epev.events |= EPOLLOUT; } if (epoll_ctl(ep->epoll_fd, EPOLL_CTL_ADD, event->fd, &epev) != 0) { - return ARES_FALSE; + return ARES_FALSE; /* LCOV_EXCL_LINE: UntestablePath */ } return ARES_TRUE; } @@ -158,7 +158,7 @@ static size_t ares_evsys_epoll_wait(ares_event_thread_t *e, rv = epoll_wait(ep->epoll_fd, events, (int)nevents, (timeout_ms == 0) ? -1 : (int)timeout_ms); if (rv < 0) { - return 0; + return 0; /* LCOV_EXCL_LINE: UntestablePath */ } nevents = (size_t)rv; @@ -170,7 +170,7 @@ static size_t ares_evsys_epoll_wait(ares_event_thread_t *e, ev = ares__htable_asvp_get_direct(e->ev_sock_handles, (ares_socket_t)events[i].data.fd); if (ev == NULL || ev->cb == NULL) { - continue; + continue; /* LCOV_EXCL_LINE: DefensiveCoding */ } cnt++; diff --git a/deps/cares/src/lib/ares_event_poll.c b/deps/cares/src/lib/ares_event_poll.c index a06c6e3fc410a4..bcaac7919945f1 100644 --- a/deps/cares/src/lib/ares_event_poll.c +++ b/deps/cares/src/lib/ares_event_poll.c @@ -37,7 +37,7 @@ static ares_bool_t ares_evsys_poll_init(ares_event_thread_t *e) { e->ev_signal = ares_pipeevent_create(e); if (e->ev_signal == NULL) { - return ARES_FALSE; + return ARES_FALSE; /* LCOV_EXCL_LINE: UntestablePath */ } return ARES_TRUE; } @@ -78,7 +78,7 @@ static size_t ares_evsys_poll_wait(ares_event_thread_t *e, if (fdlist != NULL && num_fds) { pollfd = ares_malloc_zero(sizeof(*pollfd) * num_fds); if (pollfd == NULL) { - goto done; + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } for (i = 0; i < num_fds; i++) { const ares_event_t *ev = @@ -111,7 +111,7 @@ static size_t ares_evsys_poll_wait(ares_event_thread_t *e, ev = ares__htable_asvp_get_direct(e->ev_sock_handles, pollfd[i].fd); if (ev == NULL || ev->cb == NULL) { - continue; + continue; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (pollfd[i].revents & (POLLERR | POLLHUP | POLLIN)) { diff --git a/deps/cares/src/lib/ares_event_select.c b/deps/cares/src/lib/ares_event_select.c index 57a4271ea7da25..89b399b92acad5 100644 --- a/deps/cares/src/lib/ares_event_select.c +++ b/deps/cares/src/lib/ares_event_select.c @@ -45,7 +45,7 @@ static ares_bool_t ares_evsys_select_init(ares_event_thread_t *e) { e->ev_signal = ares_pipeevent_create(e); if (e->ev_signal == NULL) { - return ARES_FALSE; + return ARES_FALSE; /* LCOV_EXCL_LINE: UntestablePath */ } return ARES_TRUE; } @@ -118,7 +118,7 @@ static size_t ares_evsys_select_wait(ares_event_thread_t *e, ev = ares__htable_asvp_get_direct(e->ev_sock_handles, fdlist[i]); if (ev == NULL || ev->cb == NULL) { - continue; + continue; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (FD_ISSET(fdlist[i], &read_fds)) { diff --git a/deps/cares/src/lib/ares_event_thread.c b/deps/cares/src/lib/ares_event_thread.c index d9d904f29ba943..e87313f6296b79 100644 --- a/deps/cares/src/lib/ares_event_thread.c +++ b/deps/cares/src/lib/ares_event_thread.c @@ -32,7 +32,7 @@ static void ares_event_destroy_cb(void *arg) { ares_event_t *event = arg; if (event == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* Unregister from the event thread if it was registered with one */ @@ -90,7 +90,7 @@ ares_status_t ares_event_update(ares_event_t **event, ares_event_thread_t *e, ares_event_t *ev = NULL; if (e == NULL) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* Callback must be specified if not a removal event. */ @@ -124,12 +124,12 @@ ares_status_t ares_event_update(ares_event_t **event, ares_event_thread_t *e, /* Allocate a new one */ ev = ares_malloc_zero(sizeof(*ev)); if (ev == NULL) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } if (ares__llist_insert_last(e->ev_updates, ev) == NULL) { - ares_free(ev); - return ARES_ENOMEM; + ares_free(ev); /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -158,7 +158,7 @@ ares_status_t ares_event_update(ares_event_t **event, ares_event_thread_t *e, static void ares_event_signal(const ares_event_t *event) { if (event == NULL || event->signal_cb == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } event->signal_cb(event); } @@ -166,7 +166,7 @@ static void ares_event_signal(const ares_event_t *event) static void ares_event_thread_wake(const ares_event_thread_t *e) { if (e == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } ares_event_signal(e->ev_signal); @@ -345,7 +345,7 @@ void ares_event_thread_destroy(ares_channel_t *channel) ares_event_thread_t *e = channel->sock_state_cb_data; if (e == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } ares_event_thread_destroy_int(e); @@ -355,7 +355,7 @@ static const ares_event_sys_t *ares_event_fetch_sys(ares_evsys_t evsys) { switch (evsys) { case ARES_EVSYS_WIN32: -#if defined(_WIN32) +#if defined(USE_WINSOCK) return &ares_evsys_win32; #else return NULL; @@ -391,7 +391,7 @@ static const ares_event_sys_t *ares_event_fetch_sys(ares_evsys_t evsys) /* case ARES_EVSYS_DEFAULT: */ default: -#if defined(_WIN32) +#if defined(USE_WINSOCK) return &ares_evsys_win32; #elif defined(HAVE_KQUEUE) return &ares_evsys_kqueue; @@ -415,49 +415,51 @@ ares_status_t ares_event_thread_init(ares_channel_t *channel) e = ares_malloc_zero(sizeof(*e)); if (e == NULL) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } e->mutex = ares__thread_mutex_create(); if (e->mutex == NULL) { - ares_event_thread_destroy_int(e); - return ARES_ENOMEM; + ares_event_thread_destroy_int(e); /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } e->ev_updates = ares__llist_create(NULL); if (e->ev_updates == NULL) { - ares_event_thread_destroy_int(e); - return ARES_ENOMEM; + ares_event_thread_destroy_int(e); /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } e->ev_sock_handles = ares__htable_asvp_create(ares_event_destroy_cb); if (e->ev_sock_handles == NULL) { - ares_event_thread_destroy_int(e); - return ARES_ENOMEM; + ares_event_thread_destroy_int(e); /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } e->ev_cust_handles = ares__htable_vpvp_create(NULL, ares_event_destroy_cb); if (e->ev_cust_handles == NULL) { - ares_event_thread_destroy_int(e); - return ARES_ENOMEM; + ares_event_thread_destroy_int(e); /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } e->channel = channel; e->isup = ARES_TRUE; e->ev_sys = ares_event_fetch_sys(channel->evsys); if (e->ev_sys == NULL) { - ares_event_thread_destroy_int(e); - return ARES_ENOTIMP; + ares_event_thread_destroy_int(e); /* LCOV_EXCL_LINE: UntestablePath */ + return ARES_ENOTIMP; /* LCOV_EXCL_LINE: UntestablePath */ } channel->sock_state_cb = ares_event_thread_sockstate_cb; channel->sock_state_cb_data = e; if (!e->ev_sys->init(e)) { + /* LCOV_EXCL_START: UntestablePath */ ares_event_thread_destroy_int(e); channel->sock_state_cb = NULL; channel->sock_state_cb_data = NULL; return ARES_ESERVFAIL; + /* LCOV_EXCL_STOP */ } /* Before starting the thread, process any possible events the initialization @@ -469,10 +471,12 @@ ares_status_t ares_event_thread_init(ares_channel_t *channel) /* Start thread */ if (ares__thread_create(&e->thread, ares_event_thread, e) != ARES_SUCCESS) { + /* LCOV_EXCL_START: UntestablePath */ ares_event_thread_destroy_int(e); channel->sock_state_cb = NULL; channel->sock_state_cb_data = NULL; return ARES_ESERVFAIL; + /* LCOV_EXCL_STOP */ } return ARES_SUCCESS; diff --git a/deps/cares/src/lib/ares_event_wake_pipe.c b/deps/cares/src/lib/ares_event_wake_pipe.c index a2cd6f609a4c30..c0aa70b5dea45f 100644 --- a/deps/cares/src/lib/ares_event_wake_pipe.c +++ b/deps/cares/src/lib/ares_event_wake_pipe.c @@ -60,7 +60,7 @@ static ares_pipeevent_t *ares_pipeevent_init(void) { ares_pipeevent_t *p = ares_malloc_zero(sizeof(*p)); if (p == NULL) { - return NULL; + return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ } p->filedes[0] = -1; @@ -68,8 +68,8 @@ static ares_pipeevent_t *ares_pipeevent_init(void) # ifdef HAVE_PIPE2 if (pipe2(p->filedes, O_NONBLOCK | O_CLOEXEC) != 0) { - ares_pipeevent_destroy(p); - return NULL; + ares_pipeevent_destroy(p); /* LCOV_EXCL_LINE: UntestablePath */ + return NULL; /* LCOV_EXCL_LINE: UntestablePath */ } # else if (pipe(p->filedes) != 0) { @@ -113,7 +113,7 @@ static void ares_pipeevent_signal(const ares_event_t *e) const ares_pipeevent_t *p; if (e == NULL || e->data == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } p = e->data; @@ -131,7 +131,7 @@ static void ares_pipeevent_cb(ares_event_thread_t *e, ares_socket_t fd, (void)flags; if (data == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } p = data; @@ -156,8 +156,8 @@ ares_event_t *ares_pipeevent_create(ares_event_thread_t *e) p->filedes[0], p, ares_pipeevent_destroy_cb, ares_pipeevent_signal); if (status != ARES_SUCCESS) { - ares_pipeevent_destroy(p); - return NULL; + ares_pipeevent_destroy(p); /* LCOV_EXCL_LINE: DefensiveCoding */ + return NULL; /* LCOV_EXCL_LINE: DefensiveCoding */ } return event; diff --git a/deps/cares/src/lib/ares_event_win32.c b/deps/cares/src/lib/ares_event_win32.c index 718e865085116c..fa84864b4bedce 100644 --- a/deps/cares/src/lib/ares_event_win32.c +++ b/deps/cares/src/lib/ares_event_win32.c @@ -33,7 +33,7 @@ # include #endif -#ifdef _WIN32 +#if defined(USE_WINSOCK) /* IMPLEMENTATION NOTES * ==================== diff --git a/deps/cares/src/lib/ares_expand_name.c b/deps/cares/src/lib/ares_expand_name.c index 280490b86a3310..8f6728dedd315b 100644 --- a/deps/cares/src/lib/ares_expand_name.c +++ b/deps/cares/src/lib/ares_expand_name.c @@ -91,8 +91,8 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf, size_t enclen_temp = 0; ares_status_t status; - if (alen < 0) { - return ARES_EBADRESP; + if (encoded == NULL || abuf == NULL || alen <= 0 || enclen == NULL) { + return ARES_EBADNAME; } status = ares__expand_name_validated(encoded, abuf, (size_t)alen, s, @@ -100,19 +100,3 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf, *enclen = (long)enclen_temp; return (int)status; } - -/* Like ares_expand_name_validated but returns EBADRESP in case of invalid - * input. */ -ares_status_t ares__expand_name_for_response(const unsigned char *encoded, - const unsigned char *abuf, - size_t alen, char **s, - size_t *enclen, - ares_bool_t is_hostname) -{ - ares_status_t status = - ares__expand_name_validated(encoded, abuf, alen, s, enclen, is_hostname); - if (status == ARES_EBADNAME) { - status = ARES_EBADRESP; - } - return status; -} diff --git a/deps/cares/src/lib/ares_expand_string.c b/deps/cares/src/lib/ares_expand_string.c index be7034e2719df1..502125a8af5f67 100644 --- a/deps/cares/src/lib/ares_expand_string.c +++ b/deps/cares/src/lib/ares_expand_string.c @@ -100,7 +100,7 @@ int ares_expand_string(const unsigned char *encoded, const unsigned char *abuf, ares_status_t status; size_t temp_enclen = 0; - if (alen < 0) { + if (encoded == NULL || abuf == NULL || alen <= 0 || enclen == NULL) { return ARES_EBADRESP; } diff --git a/deps/cares/src/lib/ares_getaddrinfo.c b/deps/cares/src/lib/ares_getaddrinfo.c index cfc889c70a84e2..51463402e2fc87 100644 --- a/deps/cares/src/lib/ares_getaddrinfo.c +++ b/deps/cares/src/lib/ares_getaddrinfo.c @@ -60,10 +60,7 @@ #include "ares_private.h" #include "ares_dns.h" -#ifdef WATT32 -# undef WIN32 -#endif -#ifdef WIN32 +#ifdef _WIN32 # include "ares_platform.h" #endif @@ -112,7 +109,7 @@ struct ares_addrinfo_cname * struct ares_addrinfo_cname *last = *head; if (tail == NULL) { - return NULL; + return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ } if (!last) { @@ -152,7 +149,7 @@ struct ares_addrinfo_node * struct ares_addrinfo_node *last = *head; if (tail == NULL) { - return NULL; + return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ } if (!last) { @@ -277,8 +274,8 @@ static ares_bool_t fake_addrinfo(const char *name, unsigned short port, if (result) { status = ares_append_ai_node(AF_INET, port, 0, &addr4, &ai->nodes); if (status != ARES_SUCCESS) { - callback(arg, (int)status, 0, NULL); - return ARES_TRUE; + callback(arg, (int)status, 0, NULL); /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_TRUE; /* LCOV_EXCL_LINE: OutOfMemory */ } } } @@ -291,8 +288,8 @@ static ares_bool_t fake_addrinfo(const char *name, unsigned short port, if (result) { status = ares_append_ai_node(AF_INET6, port, 0, &addr6, &ai->nodes); if (status != ARES_SUCCESS) { - callback(arg, (int)status, 0, NULL); - return ARES_TRUE; + callback(arg, (int)status, 0, NULL); /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_TRUE; /* LCOV_EXCL_LINE: OutOfMemory */ } } } @@ -304,9 +301,11 @@ static ares_bool_t fake_addrinfo(const char *name, unsigned short port, if (hints->ai_flags & ARES_AI_CANONNAME) { cname = ares__append_addrinfo_cname(&ai->cnames); if (!cname) { + /* LCOV_EXCL_START: OutOfMemory */ ares_freeaddrinfo(ai); callback(arg, ARES_ENOMEM, 0, NULL); return ARES_TRUE; + /* LCOV_EXCL_STOP */ } /* Duplicate the name, to avoid a constness violation. */ @@ -371,7 +370,7 @@ ares_bool_t ares__is_localhost(const char *name) size_t len; if (name == NULL) { - return ARES_FALSE; + return ARES_FALSE; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (strcmp(name, "localhost") == 0) { @@ -415,7 +414,7 @@ static ares_status_t file_lookup(struct host_query *hquery) hquery->ai); if (status != ARES_SUCCESS) { - goto done; + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } @@ -497,7 +496,7 @@ static void host_callback(void *arg, ares_status_t status, size_t timeouts, if (status == ARES_SUCCESS) { if (dnsrec == NULL) { - addinfostatus = ARES_EBADRESP; + addinfostatus = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ } else { addinfostatus = ares__parse_into_addrinfo(dnsrec, ARES_TRUE, hquery->port, hquery->ai); diff --git a/deps/cares/src/lib/ares_gethostbyaddr.c b/deps/cares/src/lib/ares_gethostbyaddr.c index 453673260dcee5..9676e17edfb12b 100644 --- a/deps/cares/src/lib/ares_gethostbyaddr.c +++ b/deps/cares/src/lib/ares_gethostbyaddr.c @@ -44,10 +44,6 @@ #include "ares_platform.h" #include "ares_private.h" -#ifdef WATT32 -# undef WIN32 -#endif - struct addr_query { /* Arguments passed to ares_gethostbyaddr() */ ares_channel_t *channel; @@ -92,9 +88,11 @@ static void ares_gethostbyaddr_int(ares_channel_t *channel, const void *addr, } aquery->lookups = ares_strdup(channel->lookups); if (aquery->lookups == NULL) { + /* LCOV_EXCL_START: OutOfMemory */ ares_free(aquery); callback(arg, ARES_ENOMEM, 0, NULL); return; + /* LCOV_EXCL_STOP */ } aquery->channel = channel; if (family == AF_INET) { @@ -134,8 +132,8 @@ static void next_lookup(struct addr_query *aquery) case 'b': name = ares_dns_addr_to_ptr(&aquery->addr); if (name == NULL) { - end_aquery(aquery, ARES_ENOMEM, NULL); - return; + end_aquery(aquery, ARES_ENOMEM, NULL); /* LCOV_EXCL_LINE: OutOfMemory */ + return; /* LCOV_EXCL_LINE: OutOfMemory */ } aquery->remaining_lookups = p + 1; ares_query_dnsrec(aquery->channel, name, ARES_CLASS_IN, @@ -227,7 +225,7 @@ static ares_status_t file_lookup(ares_channel_t *channel, status = ares__hosts_entry_to_hostent(entry, addr->family, host); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } return ARES_SUCCESS; diff --git a/deps/cares/src/lib/ares_gethostbyname.c b/deps/cares/src/lib/ares_gethostbyname.c index 299c35b4169c3d..2a8ec555d4edbf 100644 --- a/deps/cares/src/lib/ares_gethostbyname.c +++ b/deps/cares/src/lib/ares_gethostbyname.c @@ -248,18 +248,18 @@ static ares_status_t ares__hostent_localhost(const char *name, int family, ai = ares_malloc_zero(sizeof(*ai)); if (ai == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ares__addrinfo_localhost(name, 0, &hints, ai); if (status != ARES_SUCCESS) { - goto done; + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ares__addrinfo2hostent(ai, family, host_out); if (status != ARES_SUCCESS) { - goto done; + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } done: @@ -298,7 +298,7 @@ static ares_status_t ares_gethostbyname_file_int(ares_channel_t *channel, status = ares__hosts_entry_to_hostent(entry, family, host); if (status != ARES_SUCCESS) { - goto done; + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } done: diff --git a/deps/cares/src/lib/ares_getnameinfo.c b/deps/cares/src/lib/ares_getnameinfo.c index d4cf58ea516535..57c6ddaf999046 100644 --- a/deps/cares/src/lib/ares_getnameinfo.c +++ b/deps/cares/src/lib/ares_getnameinfo.c @@ -82,7 +82,7 @@ static char *lookup_service(unsigned short port, unsigned int flags, char *buf, size_t buflen); #ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID static void append_scopeid(const struct sockaddr_in6 *addr6, - unsigned int scopeid, char *buf, size_t buflen); + unsigned int flags, char *buf, size_t buflen); #endif static char *ares_striendstr(const char *s1, const char *s2); diff --git a/deps/cares/src/lib/ares_init.c b/deps/cares/src/lib/ares_init.c index c8b4c3456411e5..be3cfacf58109f 100644 --- a/deps/cares/src/lib/ares_init.c +++ b/deps/cares/src/lib/ares_init.c @@ -67,11 +67,6 @@ #include "ares_private.h" #include "ares_event.h" -#ifdef WATT32 -# undef WIN32 /* Redefined in MingW/MSVC headers */ -#endif - - int ares_init(ares_channel_t **channelptr) { return ares_init_options(channelptr, NULL, 0); @@ -122,7 +117,7 @@ static int server_sort_cb(const void *data1, const void *data2) static void server_destroy_cb(void *data) { if (data == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } ares__destroy_server(data); } @@ -167,7 +162,7 @@ static ares_status_t init_by_defaults(ares_channel_t *channel) rc = ares__sconfig_append(&sconfig, &addr, 0, 0, NULL); if (rc != ARES_SUCCESS) { - goto error; + goto error; /* LCOV_EXCL_LINE: OutOfMemory */ } rc = ares__servers_update(channel, sconfig, ARES_FALSE); @@ -201,8 +196,8 @@ static ares_status_t init_by_defaults(ares_channel_t *channel) hostname = ares_malloc(len); if (!hostname) { - rc = ARES_ENOMEM; - goto error; + rc = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto error; /* LCOV_EXCL_LINE: OutOfMemory */ } do { @@ -214,8 +209,8 @@ static ares_status_t init_by_defaults(ares_channel_t *channel) lenv *= 2; p = ares_realloc(hostname, len); if (!p) { - rc = ARES_ENOMEM; - goto error; + rc = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto error; /* LCOV_EXCL_LINE: OutOfMemory */ } hostname = p; continue; @@ -233,13 +228,13 @@ static ares_status_t init_by_defaults(ares_channel_t *channel) /* a dot was found */ channel->domains = ares_malloc(sizeof(char *)); if (!channel->domains) { - rc = ARES_ENOMEM; - goto error; + rc = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto error; /* LCOV_EXCL_LINE: OutOfMemory */ } channel->domains[0] = ares_strdup(dot + 1); if (!channel->domains[0]) { - rc = ARES_ENOMEM; - goto error; + rc = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto error; /* LCOV_EXCL_LINE: OutOfMemory */ } channel->ndomains = 1; } @@ -253,7 +248,7 @@ static ares_status_t init_by_defaults(ares_channel_t *channel) if (!channel->lookups) { channel->lookups = ares_strdup("fb"); if (!channel->lookups) { - rc = ARES_ENOMEM; + rc = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -351,12 +346,13 @@ int ares_init_options(ares_channel_t **channelptr, goto done; } - if (channel->qcache_max_ttl > 0) { - status = ares__qcache_create(channel->rand_state, channel->qcache_max_ttl, - &channel->qcache); - if (status != ARES_SUCCESS) { - goto done; - } + /* Go ahead and let it initialize the query cache even if the ttl is 0 and + * completely unused. This reduces the number of different code paths that + * might be followed even if there is a minor performance hit. */ + status = ares__qcache_create(channel->rand_state, channel->qcache_max_ttl, + &channel->qcache); + if (status != ARES_SUCCESS) { + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } if (status == ARES_SUCCESS) { @@ -384,7 +380,7 @@ int ares_init_options(ares_channel_t **channelptr, status = ares_event_thread_init(channel); if (status != ARES_SUCCESS) { - goto done; + goto done; /* LCOV_EXCL_LINE: UntestablePath */ } /* Initialize monitor for configuration changes. In some rare cases, @@ -392,7 +388,7 @@ int ares_init_options(ares_channel_t **channelptr, e = channel->sock_state_cb_data; status = ares_event_configchg_init(&e->configchg, e); if (status != ARES_SUCCESS && status != ARES_ENOTIMP) { - goto done; + goto done; /* LCOV_EXCL_LINE: UntestablePath */ } status = ARES_SUCCESS; } @@ -464,9 +460,11 @@ ares_status_t ares_reinit(ares_channel_t *channel) status = ares__thread_create(&channel->reinit_thread, ares_reinit_thread, channel); if (status != ARES_SUCCESS) { + /* LCOV_EXCL_START: UntestablePath */ ares__channel_lock(channel); channel->reinit_pending = ARES_FALSE; ares__channel_unlock(channel); + /* LCOV_EXCL_STOP */ } } else { /* Threading support not available, call directly */ @@ -539,18 +537,22 @@ int ares_dup(ares_channel_t **dest, const ares_channel_t *src) if (optmask & ARES_OPT_SERVERS) { char *csv = ares_get_servers_csv(src); if (csv == NULL) { + /* LCOV_EXCL_START: OutOfMemory */ ares_destroy(*dest); *dest = NULL; rc = ARES_ENOMEM; goto done; + /* LCOV_EXCL_STOP */ } rc = (ares_status_t)ares_set_servers_ports_csv(*dest, csv); ares_free_string(csv); if (rc != ARES_SUCCESS) { + /* LCOV_EXCL_START: OutOfMemory */ ares_destroy(*dest); *dest = NULL; goto done; + /* LCOV_EXCL_STOP */ } } diff --git a/deps/cares/src/lib/ares_library_init.c b/deps/cares/src/lib/ares_library_init.c index 2767f1f93c77e4..1d98acc403e3ea 100644 --- a/deps/cares/src/lib/ares_library_init.c +++ b/deps/cares/src/lib/ares_library_init.c @@ -55,7 +55,7 @@ static void *default_malloc(size_t size) return malloc(size); } -#if defined(WIN32) +#if defined(_WIN32) /* We need indirections to handle Windows DLL rules. */ static void *default_realloc(void *p, size_t size) { diff --git a/deps/cares/src/lib/ares_options.c b/deps/cares/src/lib/ares_options.c index 6f50f2e4981354..959c4f7a8c9c5a 100644 --- a/deps/cares/src/lib/ares_options.c +++ b/deps/cares/src/lib/ares_options.c @@ -249,7 +249,7 @@ static ares_status_t ares__init_options_servers(ares_channel_t *channel, status = ares_in_addr_to_server_config_llist(servers, nservers, &slist); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ares__servers_update(channel, slist, ARES_TRUE); @@ -266,12 +266,12 @@ ares_status_t ares__init_by_options(ares_channel_t *channel, size_t i; if (channel == NULL) { - return ARES_ENODATA; + return ARES_ENODATA; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (options == NULL) { if (optmask != 0) { - return ARES_ENODATA; + return ARES_ENODATA; /* LCOV_EXCL_LINE: DefensiveCoding */ } return ARES_SUCCESS; } @@ -389,13 +389,13 @@ ares_status_t ares__init_by_options(ares_channel_t *channel, channel->domains = ares_malloc_zero((size_t)options->ndomains * sizeof(char *)); if (!channel->domains) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } channel->ndomains = (size_t)options->ndomains; for (i = 0; i < (size_t)options->ndomains; i++) { channel->domains[i] = ares_strdup(options->domains[i]); if (!channel->domains[i]) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } } } @@ -407,7 +407,7 @@ ares_status_t ares__init_by_options(ares_channel_t *channel, } else { channel->lookups = ares_strdup(options->lookups); if (!channel->lookups) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } } } @@ -418,7 +418,7 @@ ares_status_t ares__init_by_options(ares_channel_t *channel, channel->sortlist = ares_malloc((size_t)options->nsort * sizeof(struct apattern)); if (!channel->sortlist) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } for (i = 0; i < (size_t)options->nsort; i++) { channel->sortlist[i] = options->sortlist[i]; @@ -432,7 +432,7 @@ ares_status_t ares__init_by_options(ares_channel_t *channel, } else { channel->resolvconf_path = ares_strdup(options->resolvconf_path); if (channel->resolvconf_path == NULL) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } } } @@ -444,7 +444,7 @@ ares_status_t ares__init_by_options(ares_channel_t *channel, } else { channel->hosts_path = ares_strdup(options->hosts_path); if (channel->hosts_path == NULL) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } } } @@ -457,13 +457,15 @@ ares_status_t ares__init_by_options(ares_channel_t *channel, } } + /* As of c-ares 1.31.0, the Query Cache is on by default. The only way to + * disable it is to set options->qcache_max_ttl = 0 while specifying the + * ARES_OPT_QUERY_CACHE which will actually disable it completely. */ if (optmask & ARES_OPT_QUERY_CACHE) { /* qcache_max_ttl is unsigned unlike the others */ - if (options->qcache_max_ttl == 0) { - optmask &= ~(ARES_OPT_QUERY_CACHE); - } else { - channel->qcache_max_ttl = options->qcache_max_ttl; - } + channel->qcache_max_ttl = options->qcache_max_ttl; + } else { + optmask |= ARES_OPT_QUERY_CACHE; + channel->qcache_max_ttl = 3600; } /* Initialize the ipv4 servers if provided */ @@ -475,7 +477,7 @@ ares_status_t ares__init_by_options(ares_channel_t *channel, status = ares__init_options_servers(channel, options->servers, (size_t)options->nservers); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } } } diff --git a/deps/cares/src/lib/ares_parse_a_reply.c b/deps/cares/src/lib/ares_parse_a_reply.c index da841f0da9af36..2b7b0e6be2801d 100644 --- a/deps/cares/src/lib/ares_parse_a_reply.c +++ b/deps/cares/src/lib/ares_parse_a_reply.c @@ -85,7 +85,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen, if (host != NULL) { status = ares__addrinfo2hostent(&ai, AF_INET, host); if (status != ARES_SUCCESS && status != ARES_ENODATA) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: DefensiveCoding */ } } diff --git a/deps/cares/src/lib/ares_parse_aaaa_reply.c b/deps/cares/src/lib/ares_parse_aaaa_reply.c index b3eba166be6ad6..6e2a466482a69d 100644 --- a/deps/cares/src/lib/ares_parse_aaaa_reply.c +++ b/deps/cares/src/lib/ares_parse_aaaa_reply.c @@ -87,7 +87,7 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen, if (host != NULL) { status = ares__addrinfo2hostent(&ai, AF_INET6, host); if (status != ARES_SUCCESS && status != ARES_ENODATA) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: DefensiveCoding */ } } diff --git a/deps/cares/src/lib/ares_parse_caa_reply.c b/deps/cares/src/lib/ares_parse_caa_reply.c index 6c30305ee18935..42f2525697d6c1 100644 --- a/deps/cares/src/lib/ares_parse_caa_reply.c +++ b/deps/cares/src/lib/ares_parse_caa_reply.c @@ -66,8 +66,8 @@ int ares_parse_caa_reply(const unsigned char *abuf, int alen_int, if (rr == NULL) { /* Shouldn't be possible */ - status = ARES_EBADRESP; - goto done; + status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* XXX: Why do we allow Chaos class? */ @@ -84,8 +84,8 @@ int ares_parse_caa_reply(const unsigned char *abuf, int alen_int, /* Allocate storage for this CAA answer appending it to the list */ caa_curr = ares_malloc_data(ARES_DATATYPE_CAA_REPLY); if (caa_curr == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Link in the record */ @@ -100,8 +100,8 @@ int ares_parse_caa_reply(const unsigned char *abuf, int alen_int, caa_curr->property = (unsigned char *)ares_strdup(ares_dns_rr_get_str(rr, ARES_RR_CAA_TAG)); if (caa_curr->property == NULL) { - status = ARES_ENOMEM; - break; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + break; /* LCOV_EXCL_LINE: OutOfMemory */ } /* RFC6844 says this can only be ascii, so not sure why we're recording a * length */ @@ -109,15 +109,15 @@ int ares_parse_caa_reply(const unsigned char *abuf, int alen_int, ptr = ares_dns_rr_get_bin(rr, ARES_RR_CAA_VALUE, &ptr_len); if (ptr == NULL) { - status = ARES_EBADRESP; - goto done; + status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* Wants NULL termination for some reason */ caa_curr->value = ares_malloc(ptr_len + 1); if (caa_curr->value == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } memcpy(caa_curr->value, ptr, ptr_len); caa_curr->value[ptr_len] = 0; diff --git a/deps/cares/src/lib/ares_parse_mx_reply.c b/deps/cares/src/lib/ares_parse_mx_reply.c index db7155d2e8fe4b..f9e5f025a8f7fe 100644 --- a/deps/cares/src/lib/ares_parse_mx_reply.c +++ b/deps/cares/src/lib/ares_parse_mx_reply.c @@ -64,8 +64,8 @@ int ares_parse_mx_reply(const unsigned char *abuf, int alen_int, if (rr == NULL) { /* Shouldn't be possible */ - status = ARES_EBADRESP; - goto done; + status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (ares_dns_rr_get_class(rr) != ARES_CLASS_IN || @@ -76,8 +76,8 @@ int ares_parse_mx_reply(const unsigned char *abuf, int alen_int, /* Allocate storage for this MX answer appending it to the list */ mx_curr = ares_malloc_data(ARES_DATATYPE_MX_REPLY); if (mx_curr == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Link in the record */ @@ -92,8 +92,8 @@ int ares_parse_mx_reply(const unsigned char *abuf, int alen_int, mx_curr->host = ares_strdup(ares_dns_rr_get_str(rr, ARES_RR_MX_EXCHANGE)); if (mx_curr->host == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } diff --git a/deps/cares/src/lib/ares_parse_naptr_reply.c b/deps/cares/src/lib/ares_parse_naptr_reply.c index 1a304ccdd3a12d..51ee6f38a5a0be 100644 --- a/deps/cares/src/lib/ares_parse_naptr_reply.c +++ b/deps/cares/src/lib/ares_parse_naptr_reply.c @@ -63,8 +63,8 @@ int ares_parse_naptr_reply(const unsigned char *abuf, int alen_int, if (rr == NULL) { /* Shouldn't be possible */ - status = ARES_EBADRESP; - goto done; + status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (ares_dns_rr_get_class(rr) != ARES_CLASS_IN || @@ -75,8 +75,8 @@ int ares_parse_naptr_reply(const unsigned char *abuf, int alen_int, /* Allocate storage for this NAPTR answer appending it to the list */ naptr_curr = ares_malloc_data(ARES_DATATYPE_NAPTR_REPLY); if (naptr_curr == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Link in the record */ @@ -94,28 +94,28 @@ int ares_parse_naptr_reply(const unsigned char *abuf, int alen_int, naptr_curr->flags = (unsigned char *)ares_strdup( ares_dns_rr_get_str(rr, ARES_RR_NAPTR_FLAGS)); if (naptr_curr->flags == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* XXX: Why is this unsigned char * ? */ naptr_curr->service = (unsigned char *)ares_strdup( ares_dns_rr_get_str(rr, ARES_RR_NAPTR_SERVICES)); if (naptr_curr->service == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* XXX: Why is this unsigned char * ? */ naptr_curr->regexp = (unsigned char *)ares_strdup( ares_dns_rr_get_str(rr, ARES_RR_NAPTR_REGEXP)); if (naptr_curr->regexp == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } naptr_curr->replacement = ares_strdup(ares_dns_rr_get_str(rr, ARES_RR_NAPTR_REPLACEMENT)); if (naptr_curr->replacement == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } diff --git a/deps/cares/src/lib/ares_parse_ns_reply.c b/deps/cares/src/lib/ares_parse_ns_reply.c index 18fda82f412174..762353964e246d 100644 --- a/deps/cares/src/lib/ares_parse_ns_reply.c +++ b/deps/cares/src/lib/ares_parse_ns_reply.c @@ -73,16 +73,16 @@ int ares_parse_ns_reply(const unsigned char *abuf, int alen_int, /* Response structure */ hostent = ares_malloc(sizeof(*hostent)); if (hostent == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } memset(hostent, 0, sizeof(*hostent)); hostent->h_addr_list = ares_malloc(sizeof(*hostent->h_addr_list)); if (hostent->h_addr_list == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } hostent->h_addr_list[0] = NULL; hostent->h_addrtype = AF_INET; @@ -91,19 +91,19 @@ int ares_parse_ns_reply(const unsigned char *abuf, int alen_int, /* Fill in hostname */ status = ares_dns_record_query_get(dnsrec, 0, &hostname, NULL, NULL); if (status != ARES_SUCCESS) { - goto done; + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } hostent->h_name = ares_strdup(hostname); if (hostent->h_name == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Preallocate the maximum number + 1 */ hostent->h_aliases = ares_malloc((ancount + 1) * sizeof(*hostent->h_aliases)); if (hostent->h_aliases == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } memset(hostent->h_aliases, 0, (ancount + 1) * sizeof(*hostent->h_aliases)); @@ -113,8 +113,8 @@ int ares_parse_ns_reply(const unsigned char *abuf, int alen_int, if (rr == NULL) { /* Shouldn't be possible */ - status = ARES_EBADRESP; - goto done; + status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (ares_dns_rr_get_class(rr) != ARES_CLASS_IN || @@ -124,8 +124,8 @@ int ares_parse_ns_reply(const unsigned char *abuf, int alen_int, hostname = ares_dns_rr_get_str(rr, ARES_RR_NS_NSDNAME); if (hostname == NULL) { - status = ARES_EBADRESP; - goto done; + status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } hostent->h_aliases[nscount] = ares_strdup(hostname); diff --git a/deps/cares/src/lib/ares_parse_ptr_reply.c b/deps/cares/src/lib/ares_parse_ptr_reply.c index 6ee20f722e3d01..3f8cc122b0c421 100644 --- a/deps/cares/src/lib/ares_parse_ptr_reply.c +++ b/deps/cares/src/lib/ares_parse_ptr_reply.c @@ -105,8 +105,8 @@ ares_status_t ares_parse_ptr_reply_dnsrec(const ares_dns_record_t *dnsrec, if (rr == NULL) { /* Shouldn't be possible */ - status = ARES_EBADRESP; - goto done; + status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (ares_dns_rr_get_class(rr) != ARES_CLASS_IN) { @@ -117,8 +117,8 @@ ares_status_t ares_parse_ptr_reply_dnsrec(const ares_dns_record_t *dnsrec, if (ares_dns_rr_get_type(rr) == ARES_REC_TYPE_CNAME) { ptrname = ares_dns_rr_get_str(rr, ARES_RR_CNAME_CNAME); if (ptrname == NULL) { - status = ARES_EBADRESP; - goto done; + status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } } @@ -145,8 +145,8 @@ ares_status_t ares_parse_ptr_reply_dnsrec(const ares_dns_record_t *dnsrec, /* Save most recent PTR record as the hostname */ hostname = ares_dns_rr_get_str(rr, ARES_RR_PTR_DNAME); if (hostname == NULL) { - status = ARES_EBADRESP; - goto done; + status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* Append as an alias */ @@ -168,8 +168,8 @@ ares_status_t ares_parse_ptr_reply_dnsrec(const ares_dns_record_t *dnsrec, /* Fill in hostname */ hostent->h_name = ares_strdup(hostname); if (hostent->h_name == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } done: diff --git a/deps/cares/src/lib/ares_parse_soa_reply.c b/deps/cares/src/lib/ares_parse_soa_reply.c index 2777dbcb0bbe11..d471471aad8b1d 100644 --- a/deps/cares/src/lib/ares_parse_soa_reply.c +++ b/deps/cares/src/lib/ares_parse_soa_reply.c @@ -62,8 +62,8 @@ int ares_parse_soa_reply(const unsigned char *abuf, int alen_int, if (rr == NULL) { /* Shouldn't be possible */ - status = ARES_EBADRESP; - goto done; + status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (ares_dns_rr_get_class(rr) != ARES_CLASS_IN || @@ -74,8 +74,8 @@ int ares_parse_soa_reply(const unsigned char *abuf, int alen_int, /* allocate result struct */ soa = ares_malloc_data(ARES_DATATYPE_SOA_REPLY); if (soa == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } soa->serial = ares_dns_rr_get_u32(rr, ARES_RR_SOA_SERIAL); @@ -85,13 +85,13 @@ int ares_parse_soa_reply(const unsigned char *abuf, int alen_int, soa->minttl = ares_dns_rr_get_u32(rr, ARES_RR_SOA_MINIMUM); soa->nsname = ares_strdup(ares_dns_rr_get_str(rr, ARES_RR_SOA_MNAME)); if (soa->nsname == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } soa->hostmaster = ares_strdup(ares_dns_rr_get_str(rr, ARES_RR_SOA_RNAME)); if (soa->hostmaster == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } break; } diff --git a/deps/cares/src/lib/ares_parse_srv_reply.c b/deps/cares/src/lib/ares_parse_srv_reply.c index f27bcce7330eb0..438737b79ac90a 100644 --- a/deps/cares/src/lib/ares_parse_srv_reply.c +++ b/deps/cares/src/lib/ares_parse_srv_reply.c @@ -64,8 +64,8 @@ int ares_parse_srv_reply(const unsigned char *abuf, int alen_int, if (rr == NULL) { /* Shouldn't be possible */ - status = ARES_EBADRESP; - goto done; + status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (ares_dns_rr_get_class(rr) != ARES_CLASS_IN || @@ -76,8 +76,8 @@ int ares_parse_srv_reply(const unsigned char *abuf, int alen_int, /* Allocate storage for this SRV answer appending it to the list */ srv_curr = ares_malloc_data(ARES_DATATYPE_SRV_REPLY); if (srv_curr == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Link in the record */ @@ -96,8 +96,8 @@ int ares_parse_srv_reply(const unsigned char *abuf, int alen_int, srv_curr->host = ares_strdup(ares_dns_rr_get_str(rr, ARES_RR_SRV_TARGET)); if (srv_curr->host == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } diff --git a/deps/cares/src/lib/ares_parse_txt_reply.c b/deps/cares/src/lib/ares_parse_txt_reply.c index 85c3644b8cbf34..2555734c7df033 100644 --- a/deps/cares/src/lib/ares_parse_txt_reply.c +++ b/deps/cares/src/lib/ares_parse_txt_reply.c @@ -59,8 +59,8 @@ static int ares__parse_txt_reply(const unsigned char *abuf, size_t alen, if (rr == NULL) { /* Shouldn't be possible */ - status = ARES_EBADRESP; - goto done; + status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* XXX: Why Chaos? */ @@ -74,8 +74,8 @@ static int ares__parse_txt_reply(const unsigned char *abuf, size_t alen, txt_curr = ares_malloc_data(ex ? ARES_DATATYPE_TXT_EXT : ARES_DATATYPE_TXT_REPLY); if (txt_curr == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Link in the record */ @@ -95,8 +95,8 @@ static int ares__parse_txt_reply(const unsigned char *abuf, size_t alen, txt_curr->txt = ares_malloc(ptr_len + 1); if (txt_curr->txt == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } memcpy(txt_curr->txt, ptr, ptr_len); txt_curr->txt[ptr_len] = 0; diff --git a/deps/cares/src/lib/ares_parse_uri_reply.c b/deps/cares/src/lib/ares_parse_uri_reply.c index bff7023f78a29a..5966b946969e2a 100644 --- a/deps/cares/src/lib/ares_parse_uri_reply.c +++ b/deps/cares/src/lib/ares_parse_uri_reply.c @@ -64,8 +64,8 @@ int ares_parse_uri_reply(const unsigned char *abuf, int alen_int, if (rr == NULL) { /* Shouldn't be possible */ - status = ARES_EBADRESP; - goto done; + status = ARES_EBADRESP; /* LCOV_EXCL_LINE: DefensiveCoding */ + goto done; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (ares_dns_rr_get_class(rr) != ARES_CLASS_IN || @@ -76,8 +76,8 @@ int ares_parse_uri_reply(const unsigned char *abuf, int alen_int, /* Allocate storage for this URI answer appending it to the list */ uri_curr = ares_malloc_data(ARES_DATATYPE_URI_REPLY); if (uri_curr == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Link in the record */ diff --git a/deps/cares/src/lib/ares_platform.c b/deps/cares/src/lib/ares_platform.c index 58a50198713da8..cd1470f832f67d 100644 --- a/deps/cares/src/lib/ares_platform.c +++ b/deps/cares/src/lib/ares_platform.c @@ -31,7 +31,7 @@ #include "ares_platform.h" #include "ares_private.h" -#if defined(WIN32) && !defined(MSDOS) +#if defined(_WIN32) && !defined(MSDOS) # define V_PLATFORM_WIN32s 0 # define V_PLATFORM_WIN32_WINDOWS 1 @@ -78,7 +78,7 @@ win_platform ares__getplatform(void) } } -#endif /* WIN32 && ! MSDOS */ +#endif /* _WIN32 && ! MSDOS */ #if defined(_WIN32_WCE) diff --git a/deps/cares/src/lib/ares_platform.h b/deps/cares/src/lib/ares_platform.h index 44b2c036443c52..df07f77a493190 100644 --- a/deps/cares/src/lib/ares_platform.h +++ b/deps/cares/src/lib/ares_platform.h @@ -29,7 +29,7 @@ #include "ares_setup.h" -#if defined(WIN32) && !defined(MSDOS) +#if defined(_WIN32) && !defined(MSDOS) typedef enum { WIN_UNKNOWN, diff --git a/deps/cares/src/lib/ares_private.h b/deps/cares/src/lib/ares_private.h index 6d9fc117712d8a..1fc4fda045baa5 100644 --- a/deps/cares/src/lib/ares_private.h +++ b/deps/cares/src/lib/ares_private.h @@ -27,14 +27,6 @@ #ifndef __ARES_PRIVATE_H #define __ARES_PRIVATE_H -/* - * Define WIN32 when build target is Win32 API - */ - -#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) -# define WIN32 -#endif - #ifdef HAVE_NETINET_IN_H # include #endif @@ -56,7 +48,7 @@ */ #define CARES_INADDR_CAST(type, var) ((type)((void *)var)) -#if defined(WIN32) && !defined(WATT32) +#if defined(USE_WINSOCK) # define WIN_NS_9X "System\\CurrentControlSet\\Services\\VxD\\MSTCP" # define WIN_NS_NT_KEY "System\\CurrentControlSet\\Services\\Tcpip\\Parameters" @@ -427,11 +419,6 @@ ares_status_t ares__expand_name_validated(const unsigned char *encoded, const unsigned char *abuf, size_t alen, char **s, size_t *enclen, ares_bool_t is_hostname); -ares_status_t ares__expand_name_for_response(const unsigned char *encoded, - const unsigned char *abuf, - size_t alen, char **s, - size_t *enclen, - ares_bool_t is_hostname); ares_status_t ares_expand_string_ex(const unsigned char *encoded, const unsigned char *abuf, size_t alen, unsigned char **s, size_t *enclen); diff --git a/deps/cares/src/lib/ares_process.c b/deps/cares/src/lib/ares_process.c index 0d8f3ca9ed0b58..6e50902b71d8f2 100644 --- a/deps/cares/src/lib/ares_process.c +++ b/deps/cares/src/lib/ares_process.c @@ -87,19 +87,19 @@ static void invoke_server_state_cb(const struct server_state *server, buf = ares__buf_create(); if (buf == NULL) { - return; + return; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ares_get_server_addr(server, buf); if (status != ARES_SUCCESS) { - ares__buf_destroy(buf); - return; + ares__buf_destroy(buf); /* LCOV_EXCL_LINE: OutOfMemory */ + return; /* LCOV_EXCL_LINE: OutOfMemory */ } server_string = ares__buf_finish_str(buf, NULL); buf = NULL; if (server_string == NULL) { - return; + return; /* LCOV_EXCL_LINE: OutOfMemory */ } channel->server_state_cb(server_string, success, flags, @@ -116,7 +116,7 @@ static void server_increment_failures(struct server_state *server, node = ares__slist_node_find(channel->servers, server); if (node == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } server->consec_failures++; @@ -138,7 +138,7 @@ static void server_set_good(struct server_state *server, ares_bool_t used_tcp) node = ares__slist_node_find(channel->servers, server); if (node == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (server->consec_failures > 0) { @@ -195,7 +195,7 @@ static void processfds(ares_channel_t *channel, fd_set *read_fds, ares_timeval_t now; if (channel == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } ares__channel_lock(channel); @@ -412,7 +412,7 @@ static int socket_list_append(ares_socket_t **socketlist, ares_socket_t fd, ares_socket_t *new_list = ares_realloc(socketlist, new_alloc * sizeof(*new_list)); if (new_list == NULL) { - return 0; + return 0; /* LCOV_EXCL_LINE: OutOfMemory */ } *alloc_cnt = new_alloc; *socketlist = new_list; @@ -432,7 +432,7 @@ static ares_socket_t *channel_socket_list(const ares_channel_t *channel, *num = 0; if (out == NULL) { - return NULL; + return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ } for (snode = ares__slist_node_first(channel->servers); snode != NULL; @@ -449,7 +449,7 @@ static ares_socket_t *channel_socket_list(const ares_channel_t *channel, } if (!socket_list_append(&out, conn->fd, &alloc_cnt, num)) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } } } @@ -652,7 +652,7 @@ static ares_status_t rewrite_without_edns(ares_dns_record_t *qdnsrec, /* Rewrite the DNS message */ status = ares_dns_write(qdnsrec, &msg, &msglen); if (status != ARES_SUCCESS) { - goto done; + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } ares_free(query->qbuf); @@ -893,7 +893,7 @@ static struct server_state *ares__failover_server(ares_channel_t *channel) /* Defensive code against no servers being available on the channel. */ if (first_server == NULL) { - return NULL; + return NULL; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* If no servers have failures, then prefer the first server in the list. */ @@ -939,7 +939,7 @@ static ares_status_t ares__append_tcpbuf(struct server_state *server, status = ares__buf_append_be16(server->tcp_send, (unsigned short)query->qlen); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } return ares__buf_append(server->tcp_send, query->qbuf, query->qlen); } @@ -952,7 +952,7 @@ static size_t ares__calc_query_timeout(const struct query *query) size_t num_servers = ares__slist_len(channel->servers); if (num_servers == 0) { - return 0; + return 0; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* For each trip through the entire server list, we want to double the @@ -1132,6 +1132,7 @@ ares_status_t ares__send_query(struct query *query, const ares_timeval_t *now) query->node_queries_by_timeout = ares__slist_insert(channel->queries_by_timeout, query); if (!query->node_queries_by_timeout) { + /* LCOV_EXCL_START: OutOfMemory */ end_query(channel, query, ARES_ENOMEM, NULL); /* Only safe to kill connection if it was new, otherwise it should be * cleaned up by another process later */ @@ -1139,6 +1140,7 @@ ares_status_t ares__send_query(struct query *query, const ares_timeval_t *now) ares__close_connection(conn); } return ARES_ENOMEM; + /* LCOV_EXCL_STOP */ } /* Keep track of queries bucketed by connection, so we can process errors @@ -1148,6 +1150,7 @@ ares_status_t ares__send_query(struct query *query, const ares_timeval_t *now) ares__llist_insert_last(conn->queries_to_conn, query); if (query->node_queries_to_conn == NULL) { + /* LCOV_EXCL_START: OutOfMemory */ end_query(channel, query, ARES_ENOMEM, NULL); /* Only safe to kill connection if it was new, otherwise it should be * cleaned up by another process later */ @@ -1155,6 +1158,7 @@ ares_status_t ares__send_query(struct query *query, const ares_timeval_t *now) ares__close_connection(conn); } return ARES_ENOMEM; + /* LCOV_EXCL_STOP */ } query->conn = conn; diff --git a/deps/cares/src/lib/ares_qcache.c b/deps/cares/src/lib/ares_qcache.c index 087518d7b80864..e03d069222655d 100644 --- a/deps/cares/src/lib/ares_qcache.c +++ b/deps/cares/src/lib/ares_qcache.c @@ -48,7 +48,7 @@ static char *ares__qcache_calc_key(const ares_dns_record_t *dnsrec) ares_dns_flags_t flags; if (dnsrec == NULL || buf == NULL) { - return NULL; + return NULL; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* Format is OPCODE|FLAGS[|QTYPE1|QCLASS1|QNAME1]... */ @@ -56,12 +56,12 @@ static char *ares__qcache_calc_key(const ares_dns_record_t *dnsrec) status = ares__buf_append_str( buf, ares_dns_opcode_tostr(ares_dns_record_get_opcode(dnsrec))); if (status != ARES_SUCCESS) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ares__buf_append_byte(buf, '|'); if (status != ARES_SUCCESS) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } flags = ares_dns_record_get_flags(dnsrec); @@ -69,13 +69,13 @@ static char *ares__qcache_calc_key(const ares_dns_record_t *dnsrec) if (flags & ARES_FLAG_RD) { status = ares__buf_append_str(buf, "rd"); if (status != ARES_SUCCESS) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } } if (flags & ARES_FLAG_CD) { status = ares__buf_append_str(buf, "cd"); if (status != ARES_SUCCESS) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -87,32 +87,32 @@ static char *ares__qcache_calc_key(const ares_dns_record_t *dnsrec) status = ares_dns_record_query_get(dnsrec, i, &name, &qtype, &qclass); if (status != ARES_SUCCESS) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: DefensiveCoding */ } status = ares__buf_append_byte(buf, '|'); if (status != ARES_SUCCESS) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ares__buf_append_str(buf, ares_dns_rec_type_tostr(qtype)); if (status != ARES_SUCCESS) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ares__buf_append_byte(buf, '|'); if (status != ARES_SUCCESS) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ares__buf_append_str(buf, ares_dns_class_tostr(qclass)); if (status != ARES_SUCCESS) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ares__buf_append_byte(buf, '|'); if (status != ARES_SUCCESS) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } /* On queries, a '.' may be appended to the name to indicate an explicit @@ -125,15 +125,17 @@ static char *ares__qcache_calc_key(const ares_dns_record_t *dnsrec) status = ares__buf_append(buf, (const unsigned char *)name, name_len); if (status != ARES_SUCCESS) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } } return ares__buf_finish_str(buf, NULL); +/* LCOV_EXCL_START: OutOfMemory */ fail: ares__buf_destroy(buf); return NULL; +/* LCOV_EXCL_STOP */ } static void ares__qcache_expire(ares__qcache_t *cache, @@ -194,7 +196,7 @@ static void ares__qcache_entry_destroy_cb(void *arg) { ares__qcache_entry_t *entry = arg; if (entry == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } ares_free(entry->key); @@ -211,21 +213,21 @@ ares_status_t ares__qcache_create(ares_rand_state *rand_state, cache = ares_malloc_zero(sizeof(*cache)); if (cache == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } cache->cache = ares__htable_strvp_create(NULL); if (cache->cache == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } cache->expire = ares__slist_create(rand_state, ares__qcache_entry_sort_cb, ares__qcache_entry_destroy_cb); if (cache->expire == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } cache->max_ttl = max_ttl; @@ -350,18 +352,18 @@ static ares_status_t ares__qcache_insert(ares__qcache_t *qcache, ttl = ares__qcache_calc_minttl(dnsrec); } + if (ttl > qcache->max_ttl) { + ttl = qcache->max_ttl; + } + /* Don't cache something that is already expired */ if (ttl == 0) { return ARES_EREFUSED; } - if (ttl > qcache->max_ttl) { - ttl = qcache->max_ttl; - } - entry = ares_malloc_zero(sizeof(*entry)); if (entry == NULL) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } entry->dnsrec = dnsrec; @@ -374,19 +376,20 @@ static ares_status_t ares__qcache_insert(ares__qcache_t *qcache, * want to cache it */ entry->key = ares__qcache_calc_key_frombuf(qbuf, qlen); if (entry->key == NULL) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } if (!ares__htable_strvp_insert(qcache->cache, entry->key, entry)) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } if (ares__slist_insert(qcache->expire, entry) == NULL) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } return ARES_SUCCESS; +/* LCOV_EXCL_START: OutOfMemory */ fail: if (entry != NULL && entry->key != NULL) { ares__htable_strvp_remove(qcache->cache, entry->key); @@ -394,6 +397,7 @@ static ares_status_t ares__qcache_insert(ares__qcache_t *qcache, ares_free(entry); } return ARES_ENOMEM; +/* LCOV_EXCL_STOP */ } ares_status_t ares_qcache_fetch(ares_channel_t *channel, @@ -417,8 +421,8 @@ ares_status_t ares_qcache_fetch(ares_channel_t *channel, key = ares__qcache_calc_key(dnsrec); if (key == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } entry = ares__htable_strvp_get_direct(channel->qcache->cache, key); diff --git a/deps/cares/src/lib/ares_query.c b/deps/cares/src/lib/ares_query.c index 0eea80e7fc1e59..35214bc4a5b627 100644 --- a/deps/cares/src/lib/ares_query.c +++ b/deps/cares/src/lib/ares_query.c @@ -76,11 +76,13 @@ static ares_status_t ares_query_int(ares_channel_t *channel, const char *name, ares_query_dnsrec_arg_t *qquery = NULL; if (channel == NULL || name == NULL || callback == NULL) { + /* LCOV_EXCL_START: DefensiveCoding */ status = ARES_EFORMERR; if (callback != NULL) { callback(arg, status, 0, NULL); } return status; + /* LCOV_EXCL_STOP */ } if (!(channel->flags & ARES_FLAG_NORECURSE)) { @@ -91,16 +93,18 @@ static ares_status_t ares_query_int(ares_channel_t *channel, const char *name, &dnsrec, name, dnsclass, type, 0, flags, (size_t)(channel->flags & ARES_FLAG_EDNS) ? channel->ednspsz : 0); if (status != ARES_SUCCESS) { - callback(arg, status, 0, NULL); - return status; + callback(arg, status, 0, NULL); /* LCOV_EXCL_LINE: OutOfMemory */ + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } qquery = ares_malloc(sizeof(*qquery)); if (qquery == NULL) { + /* LCOV_EXCL_START: OutOfMemory */ status = ARES_ENOMEM; callback(arg, status, 0, NULL); ares_dns_record_destroy(dnsrec); return status; + /* LCOV_EXCL_STOP */ } qquery->callback = callback; @@ -142,8 +146,8 @@ void ares_query(ares_channel_t *channel, const char *name, int dnsclass, carg = ares__dnsrec_convert_arg(callback, arg); if (carg == NULL) { - callback(arg, ARES_ENOMEM, 0, NULL, 0); - return; + callback(arg, ARES_ENOMEM, 0, NULL, 0); /* LCOV_EXCL_LINE: OutOfMemory */ + return; /* LCOV_EXCL_LINE: OutOfMemory */ } ares_query_dnsrec(channel, name, (ares_dns_class_t)dnsclass, diff --git a/deps/cares/src/lib/ares_rand.c b/deps/cares/src/lib/ares_rand.c index bf3a695c9c248e..e36cbc67d70dea 100644 --- a/deps/cares/src/lib/ares_rand.c +++ b/deps/cares/src/lib/ares_rand.c @@ -56,17 +56,20 @@ typedef struct ares_rand_rc4 { static unsigned int ares_u32_from_ptr(void *addr) { + /* LCOV_EXCL_START: FallbackCode */ if (sizeof(void *) == 8) { return (unsigned int)((((ares_uint64_t)addr >> 32) & 0xFFFFFFFF) | ((ares_uint64_t)addr & 0xFFFFFFFF)); } return (unsigned int)((size_t)addr & 0xFFFFFFFF); + /* LCOV_EXCL_STOP */ } /* initialize an rc4 key as the last possible fallback. */ static void ares_rc4_generate_key(ares_rand_rc4 *rc4_state, unsigned char *key, size_t key_len) { + /* LCOV_EXCL_START: FallbackCode */ size_t i; size_t len = 0; unsigned int data; @@ -99,10 +102,12 @@ static void ares_rc4_generate_key(ares_rand_rc4 *rc4_state, unsigned char *key, for (i = len; i < key_len; i++) { key[i] = (unsigned char)(rand() % 256); /* LCOV_EXCL_LINE */ } + /* LCOV_EXCL_STOP */ } static void ares_rc4_init(ares_rand_rc4 *rc4_state) { + /* LCOV_EXCL_START: FallbackCode */ unsigned char key[ARES_RC4_KEY_LEN]; size_t i; size_t j; @@ -120,6 +125,7 @@ static void ares_rc4_init(ares_rand_rc4 *rc4_state) rc4_state->i = 0; rc4_state->j = 0; + /* LCOV_EXCL_STOP */ } /* Just outputs the key schedule, no need to XOR with any data since we have @@ -127,6 +133,7 @@ static void ares_rc4_init(ares_rand_rc4 *rc4_state) static void ares_rc4_prng(ares_rand_rc4 *rc4_state, unsigned char *buf, size_t len) { + /* LCOV_EXCL_START: FallbackCode */ unsigned char *S = rc4_state->S; size_t i = rc4_state->i; size_t j = rc4_state->j; @@ -142,6 +149,7 @@ static void ares_rc4_prng(ares_rand_rc4 *rc4_state, unsigned char *buf, rc4_state->i = i; rc4_state->j = j; + /* LCOV_EXCL_STOP */ } struct ares_rand_state { @@ -187,6 +195,7 @@ static ares_bool_t ares__init_rand_engine(ares_rand_state *state) #endif #if defined(CARES_RANDOM_FILE) + /* LCOV_EXCL_START: FallbackCode */ if (!(state->bad_backends & ARES_RAND_FILE)) { state->type = ARES_RAND_FILE; state->state.rand_file = fopen(CARES_RANDOM_FILE, "rb"); @@ -195,14 +204,18 @@ static ares_bool_t ares__init_rand_engine(ares_rand_state *state) return ARES_TRUE; } } + /* LCOV_EXCL_STOP */ + /* Fall-Thru on failure to RC4 */ #endif + /* LCOV_EXCL_START: FallbackCode */ state->type = ARES_RAND_RC4; ares_rc4_init(&state->state.rc4); + /* LCOV_EXCL_STOP */ /* Currently cannot fail */ - return ARES_TRUE; + return ARES_TRUE; /* LCOV_EXCL_LINE: UntestablePath */ } ares_rand_state *ares__init_rand_state(void) @@ -215,8 +228,8 @@ ares_rand_state *ares__init_rand_state(void) } if (!ares__init_rand_engine(state)) { - ares_free(state); - return NULL; + ares_free(state); /* LCOV_EXCL_LINE: UntestablePath */ + return NULL; /* LCOV_EXCL_LINE: UntestablePath */ } return state; @@ -225,24 +238,28 @@ ares_rand_state *ares__init_rand_state(void) static void ares__clear_rand_state(ares_rand_state *state) { if (!state) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } switch (state->type) { case ARES_RAND_OS: break; + /* LCOV_EXCL_START: FallbackCode */ case ARES_RAND_FILE: fclose(state->state.rand_file); break; case ARES_RAND_RC4: break; + /* LCOV_EXCL_STOP */ } } static void ares__reinit_rand(ares_rand_state *state) { + /* LCOV_EXCL_START: UntestablePath */ ares__clear_rand_state(state); ares__init_rand_engine(state); + /* LCOV_EXCL_STOP */ } void ares__destroy_rand_state(ares_rand_state *state) @@ -296,6 +313,8 @@ static void ares__rand_bytes_fetch(ares_rand_state *state, unsigned char *buf, break; #endif + /* LCOV_EXCL_START: FallbackCode */ + case ARES_RAND_FILE: while (1) { size_t rv = fread(buf + bytes_read, 1, len - bytes_read, @@ -314,11 +333,14 @@ static void ares__rand_bytes_fetch(ares_rand_state *state, unsigned char *buf, case ARES_RAND_RC4: ares_rc4_prng(&state->state.rc4, buf, len); return; + + /* LCOV_EXCL_STOP */ + } /* If we didn't return before we got here, that means we had a critical rand * failure and need to reinitialized */ - ares__reinit_rand(state); + ares__reinit_rand(state); /* LCOV_EXCL_LINE: UntestablePath */ } } diff --git a/deps/cares/src/lib/ares_search.c b/deps/cares/src/lib/ares_search.c index 4fd909cd4f8b9f..7403de1674dabc 100644 --- a/deps/cares/src/lib/ares_search.c +++ b/deps/cares/src/lib/ares_search.c @@ -57,7 +57,7 @@ struct search_query { static void squery_free(struct search_query *squery) { if (squery == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } ares__strsplit_free(squery->names, squery->names_cnt); ares_dns_record_destroy(squery->dnsrec); @@ -87,7 +87,7 @@ static ares_status_t ares_search_next(ares_channel_t *channel, /* Misuse check */ if (squery->next_name_idx >= squery->names_cnt) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } status = ares_dns_record_query_set_name( @@ -200,8 +200,8 @@ ares_status_t ares__search_name_list(const ares_channel_t *channel, list_len = 1; list = ares_malloc_zero(sizeof(*list) * list_len); if (list == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } list[0] = alias; alias = NULL; @@ -215,12 +215,12 @@ ares_status_t ares__search_name_list(const ares_channel_t *channel, list_len = 1; list = ares_malloc_zero(sizeof(*list) * list_len); if (list == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } list[0] = ares_strdup(name); if (list[0] == NULL) { - status = ARES_ENOMEM; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } else { status = ARES_SUCCESS; } @@ -322,8 +322,8 @@ static ares_status_t ares_search_int(ares_channel_t *channel, */ squery = ares_malloc_zero(sizeof(*squery)); if (squery == NULL) { - status = ARES_ENOMEM; - goto fail; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } squery->channel = channel; @@ -331,8 +331,8 @@ static ares_status_t ares_search_int(ares_channel_t *channel, /* Duplicate DNS record since, name will need to be rewritten */ squery->dnsrec = ares_dns_record_duplicate(dnsrec); if (squery->dnsrec == NULL) { - status = ARES_ENOMEM; - goto fail; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } squery->callback = callback; @@ -456,7 +456,7 @@ ares_status_t ares_search_dnsrec(ares_channel_t *channel, ares_status_t status; if (channel == NULL || dnsrec == NULL || callback == NULL) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } ares__channel_lock(channel); @@ -498,7 +498,7 @@ ares_status_t ares__lookup_hostaliases(const ares_channel_t *channel, ares__llist_node_t *node; if (channel == NULL || name == NULL || alias == NULL) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } *alias = NULL; @@ -521,8 +521,8 @@ ares_status_t ares__lookup_hostaliases(const ares_channel_t *channel, buf = ares__buf_create(); if (buf == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ares__buf_load_file(hostaliases, buf); @@ -581,8 +581,8 @@ ares_status_t ares__lookup_hostaliases(const ares_channel_t *channel, *alias = ares_strdup(fqdn); if (*alias == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } /* Good! */ diff --git a/deps/cares/src/lib/ares_send.c b/deps/cares/src/lib/ares_send.c index 8bbc6e758b476c..800edce63dcd44 100644 --- a/deps/cares/src/lib/ares_send.c +++ b/deps/cares/src/lib/ares_send.c @@ -77,8 +77,8 @@ static ares_status_t ares_send_dnsrec_int(ares_channel_t *channel, /* Allocate space for query and allocated fields. */ query = ares_malloc(sizeof(struct query)); if (!query) { - callback(arg, ARES_ENOMEM, 0, NULL); - return ARES_ENOMEM; + callback(arg, ARES_ENOMEM, 0, NULL); /* LCOV_EXCL_LINE: OutOfMemory */ + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } memset(query, 0, sizeof(*query)); @@ -121,18 +121,22 @@ static ares_status_t ares_send_dnsrec_int(ares_channel_t *channel, query->node_all_queries = ares__llist_insert_last(channel->all_queries, query); if (query->node_all_queries == NULL) { + /* LCOV_EXCL_START: OutOfMemory */ callback(arg, ARES_ENOMEM, 0, NULL); ares__free_query(query); return ARES_ENOMEM; + /* LCOV_EXCL_STOP */ } /* Keep track of queries bucketed by qid, so we can process DNS * responses quickly. */ if (!ares__htable_szvp_insert(channel->queries_by_qid, query->qid, query)) { + /* LCOV_EXCL_START: OutOfMemory */ callback(arg, ARES_ENOMEM, 0, NULL); ares__free_query(query); return ARES_ENOMEM; + /* LCOV_EXCL_STOP */ } /* Perform the first query action. */ @@ -152,7 +156,7 @@ ares_status_t ares_send_dnsrec(ares_channel_t *channel, ares_status_t status; if (channel == NULL) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } ares__channel_lock(channel); @@ -189,10 +193,12 @@ void ares_send(ares_channel_t *channel, const unsigned char *qbuf, int qlen, carg = ares__dnsrec_convert_arg(callback, arg); if (carg == NULL) { + /* LCOV_EXCL_START: OutOfMemory */ status = ARES_ENOMEM; ares_dns_record_destroy(dnsrec); callback(arg, (int)status, 0, NULL, 0); return; + /* LCOV_EXCL_STOP */ } ares_send_dnsrec(channel, dnsrec, ares__dnsrec_convert_cb, carg, NULL); diff --git a/deps/cares/src/lib/ares_setup.h b/deps/cares/src/lib/ares_setup.h index 0387f3e35f7577..ea66b1115bf885 100644 --- a/deps/cares/src/lib/ares_setup.h +++ b/deps/cares/src/lib/ares_setup.h @@ -26,14 +26,6 @@ #ifndef HEADER_CARES_SETUP_H #define HEADER_CARES_SETUP_H -/* - * Define WIN32 when build target is Win32 API - */ - -#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) -# define WIN32 -#endif - /* * Include configuration script results or hand-crafted * configuration file for platforms which lack config tool. @@ -43,7 +35,7 @@ # include "ares_config.h" #else -# ifdef WIN32 +# ifdef _WIN32 # include "config-win32.h" # endif @@ -163,7 +155,7 @@ # define HAVE_UNISTD_H 1 # endif -# if !defined(HAVE_SYS_UIO_H) && !defined(WIN32) && !defined(MSDOS) +# if !defined(HAVE_SYS_UIO_H) && !defined(_WIN32) && !defined(MSDOS) # define HAVE_SYS_UIO_H # endif diff --git a/deps/cares/src/lib/ares_str.c b/deps/cares/src/lib/ares_str.c index 44a5e452fb880f..db0a12bd2fda8a 100644 --- a/deps/cares/src/lib/ares_str.c +++ b/deps/cares/src/lib/ares_str.c @@ -56,7 +56,7 @@ char *ares_strdup(const char *s1) /* Don't see how this is possible */ if (len == SIZE_MAX) { - return NULL; + return NULL; /* LCOV_EXCL_LINE: DefensiveCoding */ } out = ares_malloc(len + 1); @@ -77,7 +77,7 @@ size_t ares_strcpy(char *dest, const char *src, size_t dest_size) size_t len = 0; if (dest == NULL || dest_size == 0) { - return 0; + return 0; /* LCOV_EXCL_LINE: DefensiveCoding */ } len = ares_strlen(src); @@ -116,7 +116,7 @@ void ares__str_rtrim(char *str) size_t i; if (str == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } len = ares_strlen(str); @@ -134,7 +134,7 @@ void ares__str_ltrim(char *str) size_t len; if (str == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } for (i = 0; str[i] != 0 && ares__isspace(str[i]); i++) { @@ -262,7 +262,7 @@ ares_bool_t ares__is_hostname(const char *str) size_t i; if (str == NULL) { - return ARES_FALSE; + return ARES_FALSE; /* LCOV_EXCL_LINE: DefensiveCoding */ } for (i = 0; str[i] != 0; i++) { diff --git a/deps/cares/src/lib/ares_strsplit.c b/deps/cares/src/lib/ares_strsplit.c index 395bf1ebb9a5ec..432a2d6cebbbbb 100644 --- a/deps/cares/src/lib/ares_strsplit.c +++ b/deps/cares/src/lib/ares_strsplit.c @@ -52,19 +52,19 @@ char **ares__strsplit_duplicate(char **elms, size_t num_elm) char **out; if (elms == NULL || num_elm == 0) { - return NULL; + return NULL; /* LCOV_EXCL_LINE: DefensiveCoding */ } out = ares_malloc_zero(sizeof(*elms) * num_elm); if (out == NULL) { - return NULL; + return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ } for (i = 0; i < num_elm; i++) { out[i] = ares_strdup(elms[i]); if (out[i] == NULL) { - ares__strsplit_free(out, num_elm); - return NULL; + ares__strsplit_free(out, num_elm); /* LCOV_EXCL_LINE: OutOfMemory */ + return NULL; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -82,7 +82,7 @@ char **ares__strsplit(const char *in, const char *delms, size_t *num_elm) size_t idx = 0; if (in == NULL || delms == NULL || num_elm == NULL) { - return NULL; + return NULL; /* LCOV_EXCL_LINE: DefensiveCoding */ } *num_elm = 0; @@ -108,8 +108,8 @@ char **ares__strsplit(const char *in, const char *delms, size_t *num_elm) out = ares_malloc_zero(cnt * sizeof(*out)); if (out == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } for (node = ares__llist_node_first(llist); node != NULL; diff --git a/deps/cares/src/lib/ares_sysconfig.c b/deps/cares/src/lib/ares_sysconfig.c index d56ee22e08884d..32f8b7f8ba1c08 100644 --- a/deps/cares/src/lib/ares_sysconfig.c +++ b/deps/cares/src/lib/ares_sysconfig.c @@ -71,12 +71,7 @@ #include "ares_platform.h" #include "ares_private.h" -#ifdef WATT32 -# undef WIN32 /* Redefined in MingW/MSVC headers */ -#endif - - -#ifdef WIN32 +#if defined(USE_WINSOCK) /* * get_REG_SZ() * @@ -1012,7 +1007,7 @@ static ares_status_t ares_sysconfig_apply(ares_channel_t *channel, char **temp = ares__strsplit_duplicate(sysconfig->domains, sysconfig->ndomains); if (temp == NULL) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } ares__strsplit_free(channel->domains, channel->ndomains); @@ -1023,7 +1018,7 @@ static ares_status_t ares_sysconfig_apply(ares_channel_t *channel, if (sysconfig->lookups && !(channel->optmask & ARES_OPT_LOOKUPS)) { char *temp = ares_strdup(sysconfig->lookups); if (temp == NULL) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } ares_free(channel->lookups); @@ -1034,7 +1029,7 @@ static ares_status_t ares_sysconfig_apply(ares_channel_t *channel, struct apattern *temp = ares_malloc(sizeof(*channel->sortlist) * sysconfig->nsortlist); if (temp == NULL) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } memcpy(temp, sysconfig->sortlist, sizeof(*channel->sortlist) * sysconfig->nsortlist); @@ -1044,7 +1039,7 @@ static ares_status_t ares_sysconfig_apply(ares_channel_t *channel, channel->nsort = sysconfig->nsortlist; } - if (sysconfig->ndots && !(channel->optmask & ARES_OPT_NDOTS)) { + if (!(channel->optmask & ARES_OPT_NDOTS)) { channel->ndots = sysconfig->ndots; } @@ -1074,7 +1069,7 @@ ares_status_t ares__init_by_sysconfig(ares_channel_t *channel) memset(&sysconfig, 0, sizeof(sysconfig)); -#ifdef _WIN32 +#if defined(USE_WINSOCK) status = ares__init_sysconfig_windows(&sysconfig); #elif defined(__MVS__) status = ares__init_sysconfig_mvs(&sysconfig); diff --git a/deps/cares/src/lib/ares_sysconfig_files.c b/deps/cares/src/lib/ares_sysconfig_files.c index 5771a581db5ef1..f71043000a43a9 100644 --- a/deps/cares/src/lib/ares_sysconfig_files.c +++ b/deps/cares/src/lib/ares_sysconfig_files.c @@ -103,7 +103,7 @@ static ares_bool_t sortlist_append(struct apattern **sortlist, size_t *nsort, newsort = ares_realloc(*sortlist, (*nsort + 1) * sizeof(*newsort)); if (newsort == NULL) { - return ARES_FALSE; + return ARES_FALSE; /* LCOV_EXCL_LINE: OutOfMemory */ } *sortlist = newsort; @@ -223,7 +223,7 @@ ares_status_t ares__parse_sortlist(struct apattern **sortlist, size_t *nsort, ares__llist_node_t *node = NULL; if (sortlist == NULL || nsort == NULL || str == NULL) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (*sortlist != NULL) { @@ -262,8 +262,8 @@ ares_status_t ares__parse_sortlist(struct apattern **sortlist, size_t *nsort, } if (!sortlist_append(sortlist, nsort, &pat)) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -371,7 +371,7 @@ static ares_status_t config_lookup(ares_sysconfig_t *sysconfig, ares_free(sysconfig->lookups); sysconfig->lookups = ares_strdup(lookupstr); if (sysconfig->lookups == NULL) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -462,7 +462,7 @@ ares_status_t ares__sysconfig_set_options(ares_sysconfig_t *sysconfig, status = process_option(sysconfig, valbuf); /* Out of memory is the only fatal condition */ if (status == ARES_ENOMEM) { - goto done; + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -484,7 +484,7 @@ ares_status_t ares__init_by_environment(ares_sysconfig_t *sysconfig) if (localdomain) { char *temp = ares_strdup(localdomain); if (temp == NULL) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } status = config_search(sysconfig, temp, 1); ares_free(temp); diff --git a/deps/cares/src/lib/ares_sysconfig_mac.c b/deps/cares/src/lib/ares_sysconfig_mac.c index 302bd0d3449171..6ec499e59f56b5 100644 --- a/deps/cares/src/lib/ares_sysconfig_mac.c +++ b/deps/cares/src/lib/ares_sysconfig_mac.c @@ -52,7 +52,10 @@ # include # include # include "thirdparty/apple/dnsinfo.h" -# include +# include +# if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 /* MacOS 10.8 */ +# include +# endif # include "ares.h" # include "ares_private.h" @@ -77,8 +80,14 @@ static void dnsinfo_destroy(dnsinfo_t *dnsinfo) static ares_status_t dnsinfo_init(dnsinfo_t **dnsinfo_out) { - dnsinfo_t *dnsinfo = NULL; - ares_status_t status = ARES_SUCCESS; + dnsinfo_t *dnsinfo = NULL; + ares_status_t status = ARES_SUCCESS; + size_t i; + const char *searchlibs[] = { + "/usr/lib/libSystem.dylib", + "/System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration", + NULL + }; if (dnsinfo_out == NULL) { status = ARES_EFORMERR; @@ -88,22 +97,34 @@ static ares_status_t dnsinfo_init(dnsinfo_t **dnsinfo_out) *dnsinfo_out = NULL; dnsinfo = ares_malloc_zero(sizeof(*dnsinfo)); - if (dnsinfo == NULL) { status = ARES_ENOMEM; goto done; } - dnsinfo->handle = dlopen("/usr/lib/libSystem.dylib", RTLD_LAZY | RTLD_NOLOAD); - if (dnsinfo->handle == NULL) { - status = ARES_ESERVFAIL; - goto done; + for (i=0; searchlibs[i] != NULL; i++) { + dnsinfo->handle = dlopen(searchlibs[i], RTLD_LAZY /* | RTLD_NOLOAD */); + if (dnsinfo->handle == NULL) { + /* Fail, loop */ + continue; + } + + dnsinfo->dns_configuration_copy = + dlsym(dnsinfo->handle, "dns_configuration_copy"); + + dnsinfo->dns_configuration_free = + dlsym(dnsinfo->handle, "dns_configuration_free"); + + if (dnsinfo->dns_configuration_copy != NULL && + dnsinfo->dns_configuration_free != NULL) { + break; + } + + /* Fail, loop */ + dlclose(dnsinfo->handle); + dnsinfo->handle = NULL; } - dnsinfo->dns_configuration_copy = - dlsym(dnsinfo->handle, "dns_configuration_copy"); - dnsinfo->dns_configuration_free = - dlsym(dnsinfo->handle, "dns_configuration_free"); if (dnsinfo->dns_configuration_copy == NULL || dnsinfo->dns_configuration_free == NULL) { @@ -141,13 +162,19 @@ static ares_status_t read_resolver(const dns_resolver_t *resolver, unsigned short port = 0; ares_status_t status = ARES_SUCCESS; +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 /* MacOS 10.8 */ /* XXX: resolver->domain is for domain-specific servers. When we implement * this support, we'll want to use this. But for now, we're going to - * skip any servers which set this since we can't properly route. */ + * skip any servers which set this since we can't properly route. + * MacOS used to use this setting for a different purpose in the + * past however, so on versions of MacOS < 10.8 just ignore this + * completely. */ if (resolver->domain != NULL) { return ARES_SUCCESS; } +#endif +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 /* MacOS 10.8 */ /* Check to see if DNS server should be used, base this on if the server is * reachable or can be reachable automatically if we send traffic that * direction. */ @@ -156,6 +183,7 @@ static ares_status_t read_resolver(const dns_resolver_t *resolver, kSCNetworkReachabilityFlagsConnectionOnTraffic))) { return ARES_SUCCESS; } +#endif /* NOTE: it doesn't look like resolver->flags is relevant */ @@ -219,7 +247,8 @@ static ares_status_t read_resolver(const dns_resolver_t *resolver, * - resolver->timeout appears unused, always 0, so we ignore this * - resolver->service_identifier doesn't appear relevant to us * - resolver->cid also isn't relevant - * - resolver->if_index we don't need, if_name is used instead. + * - resolver->if_name we won't use since it isn't available in MacOS 10.8 + * or earlier, use resolver->if_index instead to then lookup the name. */ /* XXX: resolver->search_order appears like it might be relevant, we might @@ -233,6 +262,8 @@ static ares_status_t read_resolver(const dns_resolver_t *resolver, struct ares_addr addr; unsigned short addrport; const struct sockaddr *sockaddr; + char if_name_str[256] = ""; + const char *if_name; /* UBSAN alignment workaround to fetch memory address */ memcpy(&sockaddr, resolver->nameserver + i, sizeof(sockaddr)); @@ -262,8 +293,11 @@ static ares_status_t read_resolver(const dns_resolver_t *resolver, if (addrport == 0) { addrport = port; } + + if_name = ares__if_indextoname(resolver->if_index, if_name_str, + sizeof(if_name_str)); status = ares__sconfig_append(&sysconfig->sconfig, &addr, addrport, - addrport, resolver->if_name); + addrport, if_name); if (status != ARES_SUCCESS) { return status; } @@ -280,7 +314,6 @@ static ares_status_t read_resolvers(dns_resolver_t **resolvers, int nresolvers, for (i = 0; status == ARES_SUCCESS && i < nresolvers; i++) { const dns_resolver_t *resolver_ptr; - dns_resolver_t resolver; /* UBSAN doesn't like that this is unaligned, lets use memcpy to get the * address. Equivalent to: @@ -288,10 +321,7 @@ static ares_status_t read_resolvers(dns_resolver_t **resolvers, int nresolvers, */ memcpy(&resolver_ptr, resolvers + i, sizeof(resolver_ptr)); - /* UBSAN. If the pointer is misaligned, try to use memcpy to get the data - * into a new structure that is hopefully aligned properly */ - memcpy(&resolver, resolver_ptr, sizeof(resolver)); - status = read_resolver(&resolver, sysconfig); + status = read_resolver(resolver_ptr, sysconfig); } return status; diff --git a/deps/cares/src/lib/ares_update_servers.c b/deps/cares/src/lib/ares_update_servers.c index 8075b1d1c0d3bc..77ed7dd25032eb 100644 --- a/deps/cares/src/lib/ares_update_servers.c +++ b/deps/cares/src/lib/ares_update_servers.c @@ -67,11 +67,11 @@ static ares_bool_t ares__addr_match(const struct ares_addr *addr1, const struct ares_addr *addr2) { if (addr1 == NULL && addr2 == NULL) { - return ARES_TRUE; + return ARES_TRUE; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (addr1 == NULL || addr2 == NULL) { - return ARES_FALSE; + return ARES_FALSE; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (addr1->family != addr2->family) { @@ -102,7 +102,7 @@ ares_bool_t ares__subnet_match(const struct ares_addr *addr, size_t i; if (addr == NULL || subnet == NULL) { - return ARES_FALSE; + return ARES_FALSE; /* LCOV_EXCL_LINE: DefensiveCoding */ } if (addr->family != subnet->family) { @@ -115,7 +115,7 @@ ares_bool_t ares__subnet_match(const struct ares_addr *addr, len = 4; if (netmask > 32) { - return ARES_FALSE; + return ARES_FALSE; /* LCOV_EXCL_LINE: DefensiveCoding */ } } else if (addr->family == AF_INET6) { addr_ptr = (const unsigned char *)&addr->addr.addr6; @@ -123,10 +123,10 @@ ares_bool_t ares__subnet_match(const struct ares_addr *addr, len = 16; if (netmask > 128) { - return ARES_FALSE; + return ARES_FALSE; /* LCOV_EXCL_LINE: DefensiveCoding */ } } else { - return ARES_FALSE; + return ARES_FALSE; /* LCOV_EXCL_LINE: DefensiveCoding */ } for (i = 0; i < len && netmask > 0; i++) { @@ -380,7 +380,7 @@ ares_status_t ares__sconfig_append(ares__llist_t **sconfig, ares_status_t status; if (sconfig == NULL || addr == NULL) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } /* Silently skip blacklisted IPv6 servers. */ @@ -390,14 +390,14 @@ ares_status_t ares__sconfig_append(ares__llist_t **sconfig, s = ares_malloc_zero(sizeof(*s)); if (s == NULL) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } if (*sconfig == NULL) { *sconfig = ares__llist_create(ares_free); if (*sconfig == NULL) { - status = ARES_ENOMEM; - goto fail; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -422,8 +422,8 @@ ares_status_t ares__sconfig_append(ares__llist_t **sconfig, } if (ares__llist_insert_last(*sconfig, s) == NULL) { - status = ARES_ENOMEM; - goto fail; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } return ARES_SUCCESS; @@ -491,7 +491,7 @@ ares_status_t ares__sconfig_append_fromstr(ares__llist_t **sconfig, status = ares__sconfig_append(sconfig, &s.addr, s.udp_port, s.tcp_port, s.ll_iface); if (status != ARES_SUCCESS) { - goto done; + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -585,7 +585,7 @@ static ares_status_t ares__server_create(ares_channel_t *channel, struct server_state *server = ares_malloc_zero(sizeof(*server)); if (server == NULL) { - return ARES_ENOMEM; + return ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ } server->idx = idx; @@ -612,32 +612,32 @@ static ares_status_t ares__server_create(ares_channel_t *channel, server->tcp_parser = ares__buf_create(); if (server->tcp_parser == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } server->tcp_send = ares__buf_create(); if (server->tcp_send == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } server->connections = ares__llist_create(NULL); if (server->connections == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } if (ares__slist_insert(channel->servers, server) == NULL) { - status = ARES_ENOMEM; - goto done; + status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */ + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ARES_SUCCESS; done: if (status != ARES_SUCCESS) { - ares__destroy_server(server); + ares__destroy_server(server); /* LCOV_EXCL_LINE: OutOfMemory */ } return status; @@ -708,7 +708,7 @@ ares_status_t ares__servers_update(ares_channel_t *channel, ares_bool_t list_changed = ARES_FALSE; if (channel == NULL) { - return ARES_EFORMERR; + return ARES_EFORMERR; /* LCOV_EXCL_LINE: DefensiveCoding */ } ares__channel_lock(channel); @@ -796,7 +796,7 @@ static ares_status_t s = ares__llist_create(ares_free); if (s == NULL) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } for (node = servers; node != NULL; node = node->next) { @@ -809,7 +809,7 @@ static ares_status_t sconfig = ares_malloc_zero(sizeof(*sconfig)); if (sconfig == NULL) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } sconfig->addr.family = node->family; @@ -822,17 +822,19 @@ static ares_status_t } if (ares__llist_insert_last(s, sconfig) == NULL) { - ares_free(sconfig); - goto fail; + ares_free(sconfig); /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } } *llist = s; return ARES_SUCCESS; +/* LCOV_EXCL_START: OutOfMemory */ fail: ares__llist_destroy(s); return ARES_ENOMEM; +/* LCOV_EXCL_STOP */ } static ares_status_t ares_addr_port_node_to_server_config_llist( @@ -845,7 +847,7 @@ static ares_status_t ares_addr_port_node_to_server_config_llist( s = ares__llist_create(ares_free); if (s == NULL) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } for (node = servers; node != NULL; node = node->next) { @@ -858,7 +860,7 @@ static ares_status_t ares_addr_port_node_to_server_config_llist( sconfig = ares_malloc_zero(sizeof(*sconfig)); if (sconfig == NULL) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } sconfig->addr.family = node->family; @@ -874,17 +876,19 @@ static ares_status_t ares_addr_port_node_to_server_config_llist( sconfig->udp_port = (unsigned short)node->udp_port; if (ares__llist_insert_last(s, sconfig) == NULL) { - ares_free(sconfig); - goto fail; + ares_free(sconfig); /* LCOV_EXCL_LINE: OutOfMemory */ + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } } *llist = s; return ARES_SUCCESS; +/* LCOV_EXCL_START: OutOfMemory */ fail: ares__llist_destroy(s); return ARES_ENOMEM; +/* LCOV_EXCL_STOP */ } ares_status_t ares_in_addr_to_server_config_llist(const struct in_addr *servers, @@ -898,7 +902,7 @@ ares_status_t ares_in_addr_to_server_config_llist(const struct in_addr *servers, s = ares__llist_create(ares_free); if (s == NULL) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } for (i = 0; servers != NULL && i < nservers; i++) { @@ -906,7 +910,7 @@ ares_status_t ares_in_addr_to_server_config_llist(const struct in_addr *servers, sconfig = ares_malloc_zero(sizeof(*sconfig)); if (sconfig == NULL) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } sconfig->addr.family = AF_INET; @@ -914,16 +918,18 @@ ares_status_t ares_in_addr_to_server_config_llist(const struct in_addr *servers, sizeof(sconfig->addr.addr.addr4)); if (ares__llist_insert_last(s, sconfig) == NULL) { - goto fail; + goto fail; /* LCOV_EXCL_LINE: OutOfMemory */ } } *llist = s; return ARES_SUCCESS; +/* LCOV_EXCL_START: OutOfMemory */ fail: ares__llist_destroy(s); return ARES_ENOMEM; +/* LCOV_EXCL_STOP */ } /* Write out the details of a server to a buffer */ @@ -937,7 +943,7 @@ ares_status_t ares_get_server_addr(const struct server_state *server, if (server->addr.family == AF_INET6) { status = ares__buf_append_byte(buf, '['); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -945,37 +951,37 @@ ares_status_t ares_get_server_addr(const struct server_state *server, status = ares__buf_append_str(buf, addr); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } if (server->addr.family == AF_INET6) { status = ares__buf_append_byte(buf, ']'); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } } /* :port */ status = ares__buf_append_byte(buf, ':'); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ares__buf_append_num_dec(buf, server->udp_port, 0); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } /* %iface */ if (ares_strlen(server->ll_iface)) { status = ares__buf_append_byte(buf, '%'); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } status = ares__buf_append_str(buf, server->ll_iface); if (status != ARES_SUCCESS) { - return status; + return status; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -1195,7 +1201,7 @@ char *ares_get_servers_csv(const ares_channel_t *channel) buf = ares__buf_create(); if (buf == NULL) { - goto done; + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } for (node = ares__slist_node_first(channel->servers); node != NULL; @@ -1206,13 +1212,13 @@ char *ares_get_servers_csv(const ares_channel_t *channel) if (ares__buf_len(buf)) { status = ares__buf_append_byte(buf, ','); if (status != ARES_SUCCESS) { - goto done; + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } status = ares_get_server_addr(server, buf); if (status != ARES_SUCCESS) { - goto done; + goto done; /* LCOV_EXCL_LINE: OutOfMemory */ } } @@ -1229,7 +1235,7 @@ void ares_set_server_state_callback(ares_channel_t *channel, ares_server_state_callback cb, void *data) { if (channel == NULL) { - return; + return; /* LCOV_EXCL_LINE: DefensiveCoding */ } channel->server_state_cb = cb; channel->server_state_cb_data = data; diff --git a/deps/cares/src/lib/config-win32.h b/deps/cares/src/lib/config-win32.h index 50d77313675b6e..a55cf9e2dbbe3f 100644 --- a/deps/cares/src/lib/config-win32.h +++ b/deps/cares/src/lib/config-win32.h @@ -88,7 +88,7 @@ #define HAVE_IPHLPAPI_H 1 /* Define if you have header file */ -#ifndef __WATCOMC__ +#if !defined(__WATCOMC__) && !defined(WATT32) # define HAVE_NETIOAPI_H 1 #endif @@ -207,7 +207,12 @@ /* Specifics for the Watt-32 tcp/ip stack. */ #ifdef WATT32 -# define SOCKET int +# undef RECV_TYPE_ARG1 +# define RECV_TYPE_ARG1 int +# undef SEND_TYPE_ARG1 +# define SEND_TYPE_ARG1 int +# undef RECVFROM_TYPE_ARG1 +# define RECVFROM_TYPE_ARG1 int # define NS_INADDRSZ 4 # define HAVE_ARPA_NAMESER_H 1 # define HAVE_ARPA_INET_H 1 @@ -219,9 +224,12 @@ # define HAVE_PF_INET6 1 # define HAVE_STRUCT_IN6_ADDR 1 # define HAVE_STRUCT_SOCKADDR_IN6 1 +# define HAVE_WRITEV 1 # undef HAVE_WINSOCK_H # undef HAVE_WINSOCK2_H # undef HAVE_WS2TCPIP_H +# undef HAVE_IPHLPAPI_H +# undef HAVE_NETIOAPI_H #endif /* Threading support enabled */ @@ -342,7 +350,8 @@ # define HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID 1 #endif -#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0600) && !defined(__WATCOMC__) +#if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0600) && \ + !defined(__WATCOMC__) && !defined(WATT32) /* Define if you have if_nametoindex() */ # define HAVE_IF_NAMETOINDEX 1 /* Define if you have if_indextoname() */ diff --git a/deps/cares/src/lib/setup_once.h b/deps/cares/src/lib/setup_once.h index a6168c9aed5365..649d6ac4d61523 100644 --- a/deps/cares/src/lib/setup_once.h +++ b/deps/cares/src/lib/setup_once.h @@ -75,11 +75,6 @@ # include #endif -#ifdef WIN32 -# include -# include -#endif - #ifdef HAVE_UNISTD_H # include #endif diff --git a/deps/cares/src/lib/thirdparty/apple/dnsinfo.h b/deps/cares/src/lib/thirdparty/apple/dnsinfo.h index d5a0e70e2f3126..d92a1d80305ddf 100644 --- a/deps/cares/src/lib/thirdparty/apple/dnsinfo.h +++ b/deps/cares/src/lib/thirdparty/apple/dnsinfo.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2006, 2008, 2009, 2011-2013, 2015-2018 Apple Inc. All rights reserved. + * Copyright (c) 2004-2006, 2008, 2009, 2011 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -28,14 +28,15 @@ * These routines provide access to the systems DNS configuration */ -#include +#include #include #include #include #include #include +#include -#define DNSINFO_VERSION 20170629 +#define DNSINFO_VERSION 20111104 #define DEFAULT_SEARCH_ORDER 200000 /* search order for the "default" resolver domain name */ @@ -72,23 +73,17 @@ typedef struct { DNS_VAR(uint32_t, search_order); /* search_order */ DNS_VAR(uint32_t, if_index); DNS_VAR(uint32_t, flags); +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1080 /* MacOS 10.8 */ + DNS_VAR(uint32_t, reserved[6]); +#else DNS_VAR(uint32_t, reach_flags); /* SCNetworkReachabilityFlags */ - DNS_VAR(uint32_t, service_identifier); - DNS_PTR(char *, cid); /* configuration identifer */ - DNS_PTR(char *, if_name); /* if_index interface name */ + DNS_VAR(uint32_t, reserved[5]); +#endif } dns_resolver_t; #pragma pack() -#define DNS_RESOLVER_FLAGS_REQUEST_A_RECORDS 0x0002 /* always requesting for A dns records in queries */ -#define DNS_RESOLVER_FLAGS_REQUEST_AAAA_RECORDS 0x0004 /* always requesting for AAAA dns records in queries */ - -#define DNS_RESOLVER_FLAGS_REQUEST_ALL_RECORDS \ - (DNS_RESOLVER_FLAGS_REQUEST_A_RECORDS | DNS_RESOLVER_FLAGS_REQUEST_AAAA_RECORDS) - -#define DNS_RESOLVER_FLAGS_SCOPED 0x1000 /* configuration is for scoped questions */ -#define DNS_RESOLVER_FLAGS_SERVICE_SPECIFIC 0x2000 /* configuration is service-specific */ -#define DNS_RESOLVER_FLAGS_SUPPLEMENTAL 0x4000 /* supplemental match configuration */ +#define DNS_RESOLVER_FLAGS_SCOPED 1 /* configuration is for scoped questions */ #pragma pack(4) @@ -97,10 +92,7 @@ typedef struct { DNS_PTR(dns_resolver_t **, resolver); DNS_VAR(int32_t, n_scoped_resolver); /* "scoped" resolver configurations */ DNS_PTR(dns_resolver_t **, scoped_resolver); - DNS_VAR(uint64_t, generation); - DNS_VAR(int32_t, n_service_specific_resolver); - DNS_PTR(dns_resolver_t **, service_specific_resolver); - DNS_VAR(uint32_t, version); + DNS_VAR(uint32_t, reserved[5]); } dns_config_t; #pragma pack() @@ -111,17 +103,19 @@ __BEGIN_DECLS * DNS configuration access APIs */ const char * -dns_configuration_notify_key (void) API_AVAILABLE(macos(10.4), ios(2.0)); +dns_configuration_notify_key (void) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0); dns_config_t * -dns_configuration_copy (void) API_AVAILABLE(macos(10.4), ios(2.0)); +dns_configuration_copy (void) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0); void -dns_configuration_free (dns_config_t *config) API_AVAILABLE(macos(10.4), ios(2.0)); +dns_configuration_free (dns_config_t *config) __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_2_0); +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 void _dns_configuration_ack (dns_config_t *config, - const char *bundle_id) API_AVAILABLE(macos(10.8), ios(6.0)); + const char *bundle_id) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_6_0); +#endif __END_DECLS diff --git a/deps/cares/src/lib/windows_port.c b/deps/cares/src/lib/windows_port.c index d5f0ad3abf608b..5395f203601e09 100644 --- a/deps/cares/src/lib/windows_port.c +++ b/deps/cares/src/lib/windows_port.c @@ -11,7 +11,7 @@ /* only do the following on windows */ -#if (defined(WIN32) || defined(WATT32)) && !defined(MSDOS) +#if defined(_WIN32) && !defined(MSDOS) # ifdef __WATCOMC__ /* diff --git a/deps/cares/src/tools/adig.c b/deps/cares/src/tools/adig.c index 66c118844e8c7e..e0d5c915aa5e7c 100644 --- a/deps/cares/src/tools/adig.c +++ b/deps/cares/src/tools/adig.c @@ -62,11 +62,6 @@ #include "ares_getopt.h" -#ifdef WATT32 -# undef WIN32 /* Redefined in MingW headers */ -#endif - - typedef struct { ares_bool_t is_help; struct ares_options options; diff --git a/deps/cares/src/tools/ahost.c b/deps/cares/src/tools/ahost.c index bbcd2b1d633c32..8d74d5d848291f 100644 --- a/deps/cares/src/tools/ahost.c +++ b/deps/cares/src/tools/ahost.c @@ -27,7 +27,7 @@ #include "ares_setup.h" -#if !defined(WIN32) || defined(WATT32) +#if !defined(_WIN32) || defined(WATT32) # include # include # include diff --git a/test/parallel/test-dns.js b/test/parallel/test-dns.js index 5b00a3d86c0d3b..63e1b77ab139b6 100644 --- a/test/parallel/test-dns.js +++ b/test/parallel/test-dns.js @@ -415,7 +415,7 @@ assert.throws(() => { (answer) => Object.assign({ domain }, answer) ), }), port, address); - }, cases.length * 2)); + }, cases.length)); server.bind(0, common.mustCall(() => { const address = server.address();