From 049e548aea8efbc46c0dda7a43e2ccc07cd99bc2 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Tue, 12 Nov 2024 17:31:27 +0100 Subject: [PATCH] Simplified patches for new cURL version. --- build.sh | 3 +- patch/curl_tool_doswin.diff | 74 +++--------------------------------- patch/curl_tool_operate.diff | 25 ++++++++++++ 3 files changed, 32 insertions(+), 70 deletions(-) create mode 100644 patch/curl_tool_operate.diff diff --git a/build.sh b/build.sh index 5803115..9f40907 100644 --- a/build.sh +++ b/build.sh @@ -342,9 +342,10 @@ patch -p1 -b < "${BASE_DIR}/patch/curl_getenv.diff" patch -p1 -b < "${BASE_DIR}/patch/curl_threads.diff" patch -p1 -b < "${BASE_DIR}/patch/curl_tool_doswin.diff" patch -p1 -b < "${BASE_DIR}/patch/curl_tool_getparam.diff" +patch -p1 -b < "${BASE_DIR}/patch/curl_tool_operate.diff" patch -p1 -b < "${BASE_DIR}/patch/curl_tool_parsecfg.diff" patch -p1 -b < "${BASE_DIR}/patch/curl_tool_util.diff" -CFLAGS="-march=${MY_MARCH} -mtune=${MY_MTUNE} -I${DEPS_DIR}/include" CPPFLAGS="-DNDEBUG -D_WIN32_WINNT=0x0501 -DNGHTTP2_STATICLIB -DNGHTTP3_STATICLIB -DNGTCP2_STATICLIB -DUNICODE -D_UNICODE" LDFLAGS="-mconsole -Wl,--trace -static -no-pthread -L${DEPS_DIR}/lib" LIBS="-liconv -lcrypt32 -lwinmm -lbrotlicommon" PKG_CONFIG_PATH="${DEPS_DIR}/lib/pkgconfig" ./configure --enable-static --disable-shared --enable-windows-unicode --disable-pthreads --disable-libcurl-option --disable-openssl-auto-load-config --with-zlib --with-zstd --with-brotli --with-openssl --with-librtmp --with-libssh2 --with-nghttp2="${DEPS_DIR}" --with-ngtcp2="${DEPS_DIR}" --with-nghttp3="${DEPS_DIR}" --with-libidn2 --without-ca-bundle +CFLAGS="-march=${MY_MARCH} -mtune=${MY_MTUNE} -I${DEPS_DIR}/include" CPPFLAGS="-DNDEBUG -D_WIN32_WINNT=0x0501 -DNGHTTP2_STATICLIB -DNGHTTP3_STATICLIB -DNGTCP2_STATICLIB -DUNICODE -D_UNICODE" LDFLAGS="-mconsole -Wl,--trace -static -no-pthread -L${DEPS_DIR}/lib" LIBS="-liconv -lcrypt32 -lwinmm -lbrotlicommon" PKG_CONFIG_PATH="${DEPS_DIR}/lib/pkgconfig" ./configure --enable-static --disable-shared --enable-windows-unicode --disable-pthreads --disable-libcurl-option --disable-openssl-auto-load-config --enable-ca-search-safe --with-zlib --with-zstd --with-brotli --with-openssl --with-librtmp --with-libssh2 --with-nghttp2="${DEPS_DIR}" --with-ngtcp2="${DEPS_DIR}" --with-nghttp3="${DEPS_DIR}" --with-libidn2 --without-ca-bundle make V=1 strip -s src/curl.exe popd diff --git a/patch/curl_tool_doswin.diff b/patch/curl_tool_doswin.diff index 7d303a2..77033e2 100644 --- a/patch/curl_tool_doswin.diff +++ b/patch/curl_tool_doswin.diff @@ -1,75 +1,11 @@ - src/tool_doswin.c | 60 +++++++++++++++++++++++++++++++++++++++---------------- - 1 file changed, 43 insertions(+), 17 deletions(-) + src/tool_doswin.c | 8 ++++++++ + 1 file changed, 8 insertions(+) diff --git a/src/tool_doswin.c b/src/tool_doswin.c -index 70b263113..399d49a7b 100644 +index 70b263113..28489a521 100644 --- a/src/tool_doswin.c +++ b/src/tool_doswin.c -@@ -586,28 +586,46 @@ char **__crt0_glob_function(char *arg) - * For WinXP and later search order actually depends on registry value: - * HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\SafeProcessSearchMode - */ -+static BOOL check_file_exists(const TCHAR *filename) -+{ -+ const DWORD attr = GetFileAttributes(filename); -+ return (attr != INVALID_FILE_ATTRIBUTES) && (!(attr & FILE_ATTRIBUTE_DIRECTORY)); -+} -+ -+static char *execpath(const TCHAR *filename) -+{ -+ static const size_t BUFFSIZE = 512; -+ TCHAR filebuffer[BUFFSIZE]; -+ unsigned long len = GetModuleFileName(0, filebuffer, BUFFSIZE); -+ if((len > 0) && (len < BUFFSIZE)) { -+ TCHAR *lastdirchar = _tcsrchr(filebuffer, TEXT('\\')); -+ if(lastdirchar) { -+ *lastdirchar = TEXT('\0'); -+ } -+ if (_tcslen(filebuffer) + _tcslen(filename) + 2U < BUFFSIZE) { -+ _tcscat(filebuffer, TEXT("\\")); -+ _tcscat(filebuffer, filename); -+ if (check_file_exists(filebuffer)) { -+#ifdef UNICODE -+ return curlx_convert_wchar_to_UTF8(filebuffer); -+#else -+ return strdup(filebuffer); -+#endif -+ } -+ } -+ } -+ return NULL; -+} -+ - CURLcode FindWin32CACert(struct OperationConfig *config, - const TCHAR *bundle_file) - { -- CURLcode result = CURLE_OK; -- DWORD res_len; -- TCHAR buf[PATH_MAX]; -- TCHAR *ptr = NULL; -- -- buf[0] = TEXT('\0'); -- -- res_len = SearchPath(NULL, bundle_file, NULL, PATH_MAX, buf, &ptr); -- if(res_len > 0) { -- char *mstr = curlx_convert_tchar_to_UTF8(buf); -- Curl_safefree(config->cacert); -- if(mstr) -- config->cacert = strdup(mstr); -- curlx_unicodefree(mstr); -- if(!config->cacert) -- result = CURLE_OUT_OF_MEMORY; -+ char *cacert = execpath(bundle_file); -+ if (cacert) { -+ config->cacert = cacert; - } - -- return result; -+ return CURLE_OK; - } - #endif - -@@ -739,6 +757,8 @@ bool tool_isVistaOrGreater; +@@ -739,6 +739,8 @@ bool tool_isVistaOrGreater; CURLcode win32_init(void) { @@ -78,7 +14,7 @@ index 70b263113..399d49a7b 100644 /* curlx_verify_windows_version must be called during init at least once because it has its own initialization routine. */ if(curlx_verify_windows_version(6, 0, 0, PLATFORM_WINNT, -@@ -753,6 +773,12 @@ CURLcode win32_init(void) +@@ -753,6 +755,12 @@ CURLcode win32_init(void) init_terminal(); #endif diff --git a/patch/curl_tool_operate.diff b/patch/curl_tool_operate.diff new file mode 100644 index 0000000..4763085 --- /dev/null +++ b/patch/curl_tool_operate.diff @@ -0,0 +1,25 @@ + src/tool_operate.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/src/tool_operate.c b/src/tool_operate.c +index a1212c9dd..d88fa3242 100644 +--- a/src/tool_operate.c ++++ b/src/tool_operate.c +@@ -3007,11 +3007,15 @@ static CURLcode cacertpaths(struct OperationConfig *config) + #ifdef _WIN32 + if(!env) { + #if defined(CURL_CA_SEARCH_SAFE) +- char *cacert = NULL; +- FILE *cafile = Curl_execpath("curl-ca-bundle.crt", &cacert); ++ TCHAR *cacert = NULL; ++ FILE *cafile = Curl_execpath(TEXT("curl-ca-bundle.crt"), &cacert); + if(cafile) { + fclose(cafile); ++#ifdef UNICODE ++ config->cacert = curlx_convert_wchar_to_UTF8(cacert); ++#else + config->cacert = strdup(cacert); ++#endif + } + #elif !defined(CURL_WINDOWS_UWP) && !defined(CURL_DISABLE_CA_SEARCH) + result = FindWin32CACert(config, TEXT("curl-ca-bundle.crt"));