Skip to content

Commit

Permalink
Use c-ares 1.13
Browse files Browse the repository at this point in the history
  • Loading branch information
rui-mo committed Aug 19, 2024
1 parent acef163 commit 62db265
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 3 deletions.
9 changes: 6 additions & 3 deletions CMake/resolve_dependency_modules/c-ares.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
# limitations under the License.
include_guard(GLOBAL)

set(VELOX_CARES_BUILD_VERSION cares-1_17_2)
set(VELOX_CARES_BUILD_VERSION cares-1_13_0)
set(VELOX_CARES_BUILD_SHA256_CHECKSUM
444b7dbf33cb6e8a764d069e3485cbaaa28386d60eace6988275c3cb9534d300)
7c48c57706a38691041920e705d2a04426ad9c68d40edd600685323f214b2d57)
string(
CONCAT VELOX_CARES_SOURCE_URL
"https://github.com/c-ares/c-ares/archive/refs/tags/"
Expand All @@ -29,7 +29,10 @@ FetchContent_Declare(
c-ares
URL ${VELOX_CARES_SOURCE_URL}
URL_HASH ${VELOX_CARES_BUILD_SHA256_CHECKSUM}
OVERRIDE_FIND_PACKAGE EXCLUDE_FROM_ALL SYSTEM)
PATCH_COMMAND
git init && git apply
${CMAKE_CURRENT_LIST_DIR}/c-ares/c-ares-random-file.patch
OVERRIDE_FIND_PACKAGE EXCLUDE_FROM_ALL SYSTEM)

set(CARES_STATIC ON)
set(CARES_INSTALL ON)
Expand Down
73 changes: 73 additions & 0 deletions CMake/resolve_dependency_modules/c-ares/c-ares-random-file.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 364b6c7c..c96a5b6c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -333,6 +333,8 @@ SET (CMAKE_EXTRA_INCLUDE_FILES)
SET (CMAKE_REQUIRED_DEFINITIONS)
SET (CMAKE_REQUIRED_LIBRARIES)

+find_file(CARES_RANDOM_FILE urandom /dev)
+mark_as_advanced(CARES_RANDOM_FILE)

################################################################################
# recv, recvfrom, send, getnameinfo, gethostname
diff --git a/ares_config.h.cmake b/ares_config.h.cmake
index 0cb2f6ae..b5da36d3 100644
--- a/ares_config.h.cmake
+++ b/ares_config.h.cmake
@@ -338,7 +338,7 @@
#cmakedefine NEED_MEMORY_H

/* a suitable file/device to read random data from */
-#cmakedefine RANDOM_FILE
+#cmakedefine CARES_RANDOM_FILE "@CARES_RANDOM_FILE@"

/* Define to the type qualifier pointed by arg 5 for recvfrom. */
#define RECVFROM_QUAL_ARG5 @RECVFROM_QUAL_ARG5@
diff --git a/ares_init.c b/ares_init.c
index f7b700bf..29bb9784 100644
--- a/ares_init.c
+++ b/ares_init.c
@@ -2376,8 +2376,8 @@ static void randomize_key(unsigned char* key,int key_data_len)
randomized = 1;
}
#else /* !WIN32 */
-#ifdef RANDOM_FILE
- FILE *f = fopen(RANDOM_FILE, "rb");
+#ifdef CARES_RANDOM_FILE
+ FILE *f = fopen(CARES_RANDOM_FILE, "rb");
if(f) {
counter = aresx_uztosi(fread(key, 1, key_data_len, f));
fclose(f);
diff --git a/configure.ac b/configure.ac
index 7e86ad67..ffdcfdf7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -829,22 +829,22 @@ dnl Check for user-specified random device
AC_ARG_WITH(random,
AC_HELP_STRING([--with-random=FILE],
[read randomness from FILE (default=/dev/urandom)]),
- [ RANDOM_FILE="$withval" ],
+ [ CARES_RANDOM_FILE="$withval" ],
[
dnl Check for random device. If we're cross compiling, we can't
dnl check, and it's better to assume it doesn't exist than it is
dnl to fail on AC_CHECK_FILE or later.
if test "$cross_compiling" = "no"; then
- AC_CHECK_FILE("/dev/urandom", [ RANDOM_FILE="/dev/urandom"] )
+ AC_CHECK_FILE("/dev/urandom", [ CARES_RANDOM_FILE="/dev/urandom"] )
else
AC_MSG_WARN([cannot check for /dev/urandom while cross compiling; assuming none])
fi

]
)
-if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then
- AC_SUBST(RANDOM_FILE)
- AC_DEFINE_UNQUOTED(RANDOM_FILE, "$RANDOM_FILE",
+if test -n "$CARES_RANDOM_FILE" && test X"$CARES_RANDOM_FILE" != Xno ; then
+ AC_SUBST(CARES_RANDOM_FILE)
+ AC_DEFINE_UNQUOTED(CARES_RANDOM_FILE, "$CARES_RANDOM_FILE",
[a suitable file/device to read random data from])
fi

0 comments on commit 62db265

Please sign in to comment.