deps: update c-ares to v1.32.2

PR-URL: https://github.com/nodejs/node/pull/53865
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Node.js GitHub Bot authored and GitHub committed 2024-07-24 14:08:45 +00:00
1 parent 2208948e1b
commit c79a6741e0
17 files changed
+762 -286

No files matched your search

+2 -2
View File
@@ -12,7 +12,7 @@ INCLUDE (CheckCSourceCompiles)
INCLUDE (CheckStructHasMember)
INCLUDE (CheckLibraryExists)
PROJECT (c-ares LANGUAGES C VERSION "1.32.1" )
PROJECT (c-ares LANGUAGES C VERSION "1.32.2" )
# 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 "19:1:17")
SET (CARES_LIB_VERSIONINFO "19:2:17")
OPTION (CARES_STATIC "Build as a static library" OFF)
+24
View File
@@ -1,3 +1,27 @@
## c-ares version 1.32.2 - July 15 2024
This is a bugfix release.
Bugfixes:
* Windows: rework EventThread AFD code for better stability.
[PR #811](https://github.com/c-ares/c-ares/pull/811)
* Windows: If an IP address was detected to have changed, it could lead to a
crash due to a bad pointer. Regression introduced in 1.31.0.
[59e3a1f4](https://github.com/c-ares/c-ares/commit/59e3a1f4)
* Windows: use `QueryPerformanceCounters()` instead of `GetTickCount64()` for
better time accuracy (~15ms -> ~1us).
* Windows 32bit config change callback needs to be tagged as `stdcall` otherwise
could result in a crash.
[5c2bab35](https://github.com/c-ares/c-ares/commit/5c2bab35)
* Tests that need accurate timing should not depend on internal symbols as there
are C++ equivalents in `std::chrono`.
[PR #809](https://github.com/c-ares/c-ares/pull/809)
* Kqueue (MacOS, \*BSD): If the open socket count exceeded 8 (unlikely), it
would try to allocate a new buffer that was too small.
[5aad7981](https://github.com/c-ares/c-ares/commit/5aad7981)
## c-ares version 1.32.1 - July 7 2024
This is a bugfix release.
+1 -1
View File
@@ -1,6 +1,6 @@
# aminclude_static.am generated automatically by Autoconf
# from AX_AM_MACROS_STATIC on Sun Jul 7 10:45:53 EDT 2024
# from AX_AM_MACROS_STATIC on Mon Jul 15 09:00:09 EDT 2024
# Code coverage
+11 -11
View File
@@ -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.32.1.
# Generated by GNU Autoconf 2.72 for c-ares 1.32.2.
#
# Report bugs to <c-ares mailing list: http://lists.haxx.se/listinfo/c-ares>.
#
@@ -614,8 +614,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='c-ares'
PACKAGE_TARNAME='c-ares'
PACKAGE_VERSION='1.32.1'
PACKAGE_STRING='c-ares 1.32.1'
PACKAGE_VERSION='1.32.2'
PACKAGE_STRING='c-ares 1.32.2'
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.32.1 to adapt to many kinds of systems.
'configure' configures c-ares 1.32.2 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.32.1:";;
short | recursive ) echo "Configuration of c-ares 1.32.2:";;
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.32.1
c-ares configure 1.32.2
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.32.1, which was
It was created by c-ares $as_me 1.32.2, 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="19:1:17"
CARES_VERSION_INFO="19:2:17"
@@ -5999,7 +5999,7 @@ fi
# Define the identity of the package.
PACKAGE='c-ares'
VERSION='1.32.1'
VERSION='1.32.2'
printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h
@@ -26339,7 +26339,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by c-ares $as_me 1.32.1, which was
This file was extended by c-ares $as_me 1.32.2, which was
generated by GNU Autoconf 2.72. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -26407,7 +26407,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config='$ac_cs_config_escaped'
ac_cs_version="\\
c-ares config.status 1.32.1
c-ares config.status 1.32.2
configured by $0, generated by GNU Autoconf 2.72,
with options \\"\$ac_cs_config\\"
+2 -2
View File
@@ -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.32.1],
AC_INIT([c-ares], [1.32.2],
[c-ares mailing list: http://lists.haxx.se/listinfo/c-ares])
CARES_VERSION_INFO="19:1:17"
CARES_VERSION_INFO="19:2:17"
dnl This flag accepts an argument of the form current[:revision[:age]]. So,
dnl passing -version-info 3:12:1 sets current to 3, revision to 12, and age to
dnl 1.
+2 -2
View File
@@ -32,11 +32,11 @@
#define ARES_VERSION_MAJOR 1
#define ARES_VERSION_MINOR 32
#define ARES_VERSION_PATCH 1
#define ARES_VERSION_PATCH 2
#define ARES_VERSION \
((ARES_VERSION_MAJOR << 16) | (ARES_VERSION_MINOR << 8) | \
(ARES_VERSION_PATCH))
#define ARES_VERSION_STR "1.32.1"
#define ARES_VERSION_STR "1.32.2"
#define CARES_HAVE_ARES_LIBRARY_INIT 1
#define CARES_HAVE_ARES_LIBRARY_CLEANUP 1
+1 -1
View File
@@ -15,7 +15,7 @@
@SET_MAKE@
# aminclude_static.am generated automatically by Autoconf
# from AX_AM_MACROS_STATIC on Sun Jul 7 10:45:53 EDT 2024
# from AX_AM_MACROS_STATIC on Mon Jul 15 09:00:09 EDT 2024
# Copyright (C) The c-ares project and its contributors
# SPDX-License-Identifier: MIT
+17 -4
View File
@@ -30,11 +30,24 @@
void ares__tvnow(ares_timeval_t *now)
{
/* GetTickCount64() is available on Windows Vista and higher */
ULONGLONG milliseconds = GetTickCount64();
/* QueryPerformanceCounters() has been around since Windows 2000, though
* significant fixes were made in later versions. Documentation states
* 1 microsecond or better resolution with a rollover not less than 100 years.
* This differs from GetTickCount{64}() which has a resolution between 10 and
* 16 ms. */
LARGE_INTEGER freq;
LARGE_INTEGER current;
now->sec = (ares_int64_t)milliseconds / 1000;
now->usec = (unsigned int)(milliseconds % 1000) * 1000;
/* Not sure how long it takes to get the frequency, I see it recommended to
* cache it */
QueryPerformanceFrequency(&freq);
QueryPerformanceCounter(&current);
now->sec = current.QuadPart / freq.QuadPart;
/* We want to prevent overflows so we get the remainder, then multiply to
* microseconds before dividing */
now->usec = (unsigned int)(((current.QuadPart % freq.QuadPart) * 1000000) /
freq.QuadPart);
}
#elif defined(HAVE_CLOCK_GETTIME_MONOTONIC)
+15 -3
View File
@@ -38,7 +38,17 @@ void ares_destroy(ares_channel_t *channel)
return;
}
/* Disable configuration change monitoring */
/* Mark as being shutdown */
ares__channel_lock(channel);
channel->sys_up = ARES_FALSE;
ares__channel_unlock(channel);
/* Disable configuration change monitoring. We can't hold a lock because
* some cleanup routines, such as on Windows, are synchronous operations.
* What we've observed is a system config change event was triggered right
* at shutdown time and it tries to take the channel lock and the destruction
* waits for that event to complete before it continues so we get a channel
* lock deadlock at shutdown if we hold a lock during this process. */
if (channel->optmask & ARES_OPT_EVENT_THREAD) {
ares_event_thread_t *e = channel->sock_state_cb_data;
if (e && e->configchg) {
@@ -47,14 +57,16 @@ void ares_destroy(ares_channel_t *channel)
}
}
/* Wait for reinit thread to exit if there was one pending */
/* Wait for reinit thread to exit if there was one pending, can't be
* holding a lock as the thread may take locks. */
if (channel->reinit_thread != NULL) {
void *rv;
ares__thread_join(channel->reinit_thread, &rv);
channel->reinit_thread = NULL;
}
/* Lock because callbacks will be triggered */
/* Lock because callbacks will be triggered, and any system-generated
* callbacks need to hold a channel lock. */
ares__channel_lock(channel);
/* Destroy all queries */
+6 -5
View File
@@ -237,9 +237,10 @@ void ares_event_configchg_destroy(ares_event_configchg_t *configchg)
# ifndef __WATCOMC__
static void ares_event_configchg_ip_cb(PVOID CallerContext,
PMIB_IPINTERFACE_ROW Row,
MIB_NOTIFICATION_TYPE NotificationType)
static void NETIOAPI_API_
ares_event_configchg_ip_cb(PVOID CallerContext,
PMIB_IPINTERFACE_ROW Row,
MIB_NOTIFICATION_TYPE NotificationType)
{
ares_event_configchg_t *configchg = CallerContext;
(void)Row;
@@ -303,8 +304,8 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg,
* that didn't get triggered either.
*/
if (NotifyIpInterfaceChange(
AF_UNSPEC, (PIPINTERFACE_CHANGE_CALLBACK)ares_event_configchg_ip_cb,
*configchg, FALSE, &c->ifchg_hnd) != NO_ERROR) {
AF_UNSPEC, ares_event_configchg_ip_cb,
c, FALSE, &c->ifchg_hnd) != NO_ERROR) {
status = ARES_ESERVFAIL;
goto done;
}
+6 -3
View File
@@ -93,7 +93,7 @@ static ares_bool_t ares_evsys_kqueue_init(ares_event_thread_t *e)
kq->nchanges_alloc = 8;
kq->changelist =
ares_malloc_zero(sizeof(*kq->changelist) * kq->nchanges_alloc);
ares_malloc_zero(kq->nchanges_alloc * sizeof(*kq->changelist));
if (kq->changelist == NULL) {
ares_evsys_kqueue_destroy(e);
return ARES_FALSE;
@@ -123,8 +123,11 @@ static void ares_evsys_kqueue_enqueue(ares_evsys_kqueue_t *kq, int fd,
if (kq->nchanges > kq->nchanges_alloc) {
kq->nchanges_alloc <<= 1;
kq->changelist = ares_realloc_zero(kq->changelist, kq->nchanges_alloc >> 1,
kq->nchanges_alloc);
kq->changelist = ares_realloc_zero(
kq->changelist,
(kq->nchanges_alloc >> 1) * sizeof(*kq->changelist),
kq->nchanges_alloc * sizeof(*kq->changelist)
);
}
EV_SET(&kq->changelist[idx], fd, filter, flags, 0, 0, 0);
+40 -19
View File
@@ -262,6 +262,35 @@ static void ares_event_process_updates(ares_event_thread_t *e)
}
}
static void ares_event_thread_cleanup(ares_event_thread_t *e)
{
/* Manually free any updates that weren't processed */
if (e->ev_updates != NULL) {
ares__llist_node_t *node;
while ((node = ares__llist_node_first(e->ev_updates)) != NULL) {
ares_event_destroy_cb(ares__llist_node_claim(node));
}
ares__llist_destroy(e->ev_updates);
e->ev_updates = NULL;
}
if (e->ev_sock_handles != NULL) {
ares__htable_asvp_destroy(e->ev_sock_handles);
e->ev_sock_handles = NULL;
}
if (e->ev_cust_handles != NULL) {
ares__htable_vpvp_destroy(e->ev_cust_handles);
e->ev_cust_handles = NULL;
}
if (e->ev_sys != NULL && e->ev_sys->destroy != NULL) {
e->ev_sys->destroy(e);
e->ev_sys = NULL;
}
}
static void *ares_event_thread(void *arg)
{
ares_event_thread_t *e = arg;
@@ -296,14 +325,16 @@ static void *ares_event_thread(void *arg)
ares__thread_mutex_lock(e->mutex);
}
/* Lets cleanup while we're in the thread itself */
ares_event_thread_cleanup(e);
ares__thread_mutex_unlock(e->mutex);
return NULL;
}
static void ares_event_thread_destroy_int(ares_event_thread_t *e)
{
ares__llist_node_t *node;
/* Wake thread and tell it to shutdown if it exists */
ares__thread_mutex_lock(e->mutex);
if (e->isup) {
@@ -314,26 +345,14 @@ static void ares_event_thread_destroy_int(ares_event_thread_t *e)
/* Wait for thread to shutdown */
if (e->thread) {
ares__thread_join(e->thread, NULL);
void *rv = NULL;
ares__thread_join(e->thread, &rv);
e->thread = NULL;
}
/* Manually free any updates that weren't processed */
while ((node = ares__llist_node_first(e->ev_updates)) != NULL) {
ares_event_destroy_cb(ares__llist_node_claim(node));
}
ares__llist_destroy(e->ev_updates);
e->ev_updates = NULL;
ares__htable_asvp_destroy(e->ev_sock_handles);
e->ev_sock_handles = NULL;
ares__htable_vpvp_destroy(e->ev_cust_handles);
e->ev_cust_handles = NULL;
if (e->ev_sys && e->ev_sys->destroy) {
e->ev_sys->destroy(e);
}
/* If the event thread ever got to the point of starting, this is a no-op
* as it runs this same cleanup when it shuts down */
ares_event_thread_cleanup(e);
ares__thread_mutex_destroy(e->mutex);
e->mutex = NULL;
@@ -350,6 +369,8 @@ void ares_event_thread_destroy(ares_channel_t *channel)
}
ares_event_thread_destroy_int(e);
channel->sock_state_cb_data = NULL;
channel->sock_state_cb = NULL;
}
static const ares_event_sys_t *ares_event_fetch_sys(ares_evsys_t evsys)
+570 -221
View File
File diff suppressed because it is too large. Load diff
+50 -8
View File
@@ -67,17 +67,53 @@ typedef VOID(NTAPI *PIO_APC_ROUTINE)(PVOID ApcContext,
# define STATUS_CANCELLED ((NTSTATUS)0xC0000120L)
# define STATUS_NOT_FOUND ((NTSTATUS)0xC0000225L)
typedef struct _UNICODE_STRING {
USHORT Length;
USHORT MaximumLength;
LPCWSTR Buffer;
} UNICODE_STRING, *PUNICODE_STRING;
typedef struct _OBJECT_ATTRIBUTES {
ULONG Length;
HANDLE RootDirectory;
PUNICODE_STRING ObjectName;
ULONG Attributes;
PVOID SecurityDescriptor;
PVOID SecurityQualityOfService;
} OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;
# ifndef FILE_OPEN
# define FILE_OPEN 0x00000001UL
# endif
/* Not sure what headers might have these */
# define IOCTL_AFD_POLL 0x00012024
# define AFD_POLL_RECEIVE 0x0001
# define AFD_POLL_RECEIVE_EXPEDITED 0x0002
# define AFD_POLL_SEND 0x0004
# define AFD_POLL_DISCONNECT 0x0008
# define AFD_POLL_ABORT 0x0010
# define AFD_POLL_LOCAL_CLOSE 0x0020
# define AFD_POLL_ACCEPT 0x0080
# define AFD_POLL_CONNECT_FAIL 0x0100
# define AFD_POLL_RECEIVE_BIT 0
# define AFD_POLL_RECEIVE (1 << AFD_POLL_RECEIVE_BIT)
# define AFD_POLL_RECEIVE_EXPEDITED_BIT 1
# define AFD_POLL_RECEIVE_EXPEDITED (1 << AFD_POLL_RECEIVE_EXPEDITED_BIT)
# define AFD_POLL_SEND_BIT 2
# define AFD_POLL_SEND (1 << AFD_POLL_SEND_BIT)
# define AFD_POLL_DISCONNECT_BIT 3
# define AFD_POLL_DISCONNECT (1 << AFD_POLL_DISCONNECT_BIT)
# define AFD_POLL_ABORT_BIT 4
# define AFD_POLL_ABORT (1 << AFD_POLL_ABORT_BIT)
# define AFD_POLL_LOCAL_CLOSE_BIT 5
# define AFD_POLL_LOCAL_CLOSE (1 << AFD_POLL_LOCAL_CLOSE_BIT)
# define AFD_POLL_CONNECT_BIT 6
# define AFD_POLL_CONNECT (1 << AFD_POLL_CONNECT_BIT)
# define AFD_POLL_ACCEPT_BIT 7
# define AFD_POLL_ACCEPT (1 << AFD_POLL_ACCEPT_BIT)
# define AFD_POLL_CONNECT_FAIL_BIT 8
# define AFD_POLL_CONNECT_FAIL (1 << AFD_POLL_CONNECT_FAIL_BIT)
# define AFD_POLL_QOS_BIT 9
# define AFD_POLL_QOS (1 << AFD_POLL_QOS_BIT)
# define AFD_POLL_GROUP_QOS_BIT 10
# define AFD_POLL_GROUP_QOS (1 << AFD_POLL_GROUP_QOS_BIT)
# define AFD_NUM_POLL_EVENTS 11
# define AFD_POLL_ALL ((1 << AFD_NUM_POLL_EVENTS) - 1)
typedef struct _AFD_POLL_HANDLE_INFO {
HANDLE Handle;
@@ -101,6 +137,12 @@ typedef NTSTATUS(NTAPI *NtDeviceIoControlFile_t)(
PIO_STATUS_BLOCK IoStatusBlock, ULONG IoControlCode, PVOID InputBuffer,
ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength);
typedef NTSTATUS(NTAPI *NtCreateFile_t)(
PHANDLE FileHandle, ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes, PIO_STATUS_BLOCK IoStatusBlock,
PLARGE_INTEGER AllocationSize, ULONG FileAttributes, ULONG ShareAccess,
ULONG CreateDisposition, ULONG CreateOptions, PVOID EaBuffer, ULONG EaLength);
/* On UWP/Windows Store, these definitions aren't there for some reason */
# ifndef SIO_BSP_HANDLE_POLL
# define SIO_BSP_HANDLE_POLL 0x4800001D
+6 -2
View File
@@ -280,6 +280,9 @@ int ares_init_options(ares_channel_t **channelptr,
return ARES_ENOMEM;
}
/* We are in a good state */
channel->sys_up = ARES_TRUE;
/* One option where zero is valid, so set default value here */
channel->ndots = 1;
@@ -437,8 +440,9 @@ ares_status_t ares_reinit(ares_channel_t *channel)
ares__channel_lock(channel);
/* If a reinit is already in process, lets not do it again */
if (channel->reinit_pending) {
/* If a reinit is already in process, lets not do it again. Or if we are
* shutting down, skip. */
if (!channel->sys_up || channel->reinit_pending) {
ares__channel_unlock(channel);
return ARES_SUCCESS;
}
+6
View File
@@ -385,6 +385,12 @@ struct ares_channeldata {
* exit. */
ares_bool_t reinit_pending;
ares__thread_t *reinit_thread;
/* Whether the system is up or not. This is mainly to prevent deadlocks
* and access violations during the cleanup process. Some things like
* system config changes might get triggered and we need a flag to make
* sure we don't take action. */
ares_bool_t sys_up;
};
/* Does the domain end in ".onion" or ".onion."? Case-insensitive. */
+3 -2
View File
@@ -356,10 +356,11 @@ static ares_bool_t get_DNS_Windows(char **outptr)
* compute the resulting total metric, just as Windows routing will do.
* Then, sort all the addresses found by the metric.
*/
for (ipaDNSAddr = ipaaEntry->FirstDnsServerAddress; ipaDNSAddr;
for (ipaDNSAddr = ipaaEntry->FirstDnsServerAddress; ipaDNSAddr != NULL;
ipaDNSAddr = ipaDNSAddr->Next) {
char ipaddr[INET6_ADDRSTRLEN] = "";
namesrvr.sa = ipaDNSAddr->Address.lpSockaddr;
namesrvr.sa = ipaDNSAddr->Address.lpSockaddr;
if (namesrvr.sa->sa_family == AF_INET) {
if ((namesrvr.sa4->sin_addr.S_un.S_addr == INADDR_ANY) ||