Compare commits

...

14 Commits

10 changed files with 199 additions and 157 deletions

57
.github/workflows/build-curl.yml vendored Normal file
View File

@ -0,0 +1,57 @@
name: "CI/CD"
on:
push:
branches: ['**']
pull_request:
release:
types: [published]
jobs:
build:
name: Build cURL
runs-on: windows-2019
strategy:
matrix:
include:
- flavor: "x86"
msystem: "MINGW32"
toolchain: "i686"
- flavor: "x64"
msystem: "MINGW64"
toolchain: "x86_64"
steps:
- uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.msystem }}
update: true
install: mingw-w64-${{ matrix.toolchain }}-toolchain base-devel cmake zip
- uses: actions/checkout@v4
- shell: msys2 {0}
run: ./build.sh
- uses: actions/upload-artifact@v4
with:
name: curl-windows-${{ matrix.flavor }}
path: build/curl-*.zip
- uses: actions/upload-artifact@v4
with:
name: build-log-${{ matrix.flavor }}
path: build/curl_build-*.log
release:
name: release files
if: ${{ github.event_name == 'release' }}
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: curl-windows-*
path: artifacts
merge-multiple: true
- uses: Roang-zero1/github-upload-release-artifacts-action@v2
with:
args: artifacts/
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -5,13 +5,13 @@
# | (__| |_| | _ <| |___ # | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____| # \___|\___/|_| \_\_____|
set -e set -eo pipefail
trap 'read -p "Press any key..." x' EXIT trap 'read -p "Press any key..." x || true' EXIT
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# cURL version # cURL version
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
readonly MY_VERSION=8.10.0 readonly MY_VERSION=8.11.0
############################################################################### ###############################################################################
# PREPARATION # PREPARATION
@ -92,7 +92,7 @@ if [ "$(sed '/^$/d' "${LOCK_FILE}" | head -n1)" != "${SIGNATURE}" ] ; then
echo 'Error: Build process is already in progress !!!' echo 'Error: Build process is already in progress !!!'
exit 1 exit 1
else else
trap "rm -f \"${LOCK_FILE}\"; read -p \"Press any key...\" x" EXIT trap "{ rm -f \"${LOCK_FILE}\"; read -p \"Press any key...\" x; } || true" EXIT
fi fi
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -135,19 +135,19 @@ printf "\n==================== download ====================\n\n"
fetch_pkg "9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23" "${PKGS_DIR}/zlib.tar.gz" https://zlib.net/zlib-1.3.1.tar.gz fetch_pkg "9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23" "${PKGS_DIR}/zlib.tar.gz" https://zlib.net/zlib-1.3.1.tar.gz
fetch_pkg "8c29e06cf42aacc1eafc4077ae2ec6c6fcb96a626157e0593d5e82a34fd403c1" "${PKGS_DIR}/zstd.tar.gz" https://github.com/facebook/zstd/releases/download/v1.5.6/zstd-1.5.6.tar.gz fetch_pkg "8c29e06cf42aacc1eafc4077ae2ec6c6fcb96a626157e0593d5e82a34fd403c1" "${PKGS_DIR}/zstd.tar.gz" https://github.com/facebook/zstd/releases/download/v1.5.6/zstd-1.5.6.tar.gz
fetch_pkg "e720a6ca29428b803f4ad165371771f5398faba397edf6778837a18599ea13ff" "${PKGS_DIR}/brotli.tar.gz" https://github.com/google/brotli/archive/refs/tags/v1.1.0.tar.gz fetch_pkg "e720a6ca29428b803f4ad165371771f5398faba397edf6778837a18599ea13ff" "${PKGS_DIR}/brotli.tar.gz" https://github.com/google/brotli/archive/refs/tags/v1.1.0.tar.gz
fetch_pkg "e7e514ea033c290f09c7250dd43a845bc1e08066b793274f3ad3fe04c76a5206" "${PKGS_DIR}/openssl.tar.gz" https://github.com/quictls/openssl/archive/refs/tags/openssl-3.1.7-quic1.tar.gz fetch_pkg "78d675d94c0ac3a8b44073f0c2b373d948c5afd12b25c9e245262f563307a566" "${PKGS_DIR}/openssl.tar.gz" https://github.com/quictls/openssl/archive/refs/tags/openssl-3.3.0-quic1.tar.gz
fetch_pkg "c68e05989a93c002e3ba8df3baef0021c17099aa2123a9c096a5cc8e029caf95" "${PKGS_DIR}/rtmpdump.tar.gz" https://distfiles.macports.org/rtmpdump/f1b83c10d8beb43fcc70a6e88cf4325499f25857.tar.gz fetch_pkg "c68e05989a93c002e3ba8df3baef0021c17099aa2123a9c096a5cc8e029caf95" "${PKGS_DIR}/rtmpdump.tar.gz" https://distfiles.macports.org/rtmpdump/f1b83c10d8beb43fcc70a6e88cf4325499f25857.tar.gz
fetch_pkg "8f74213b56238c85a50a5329f77e06198771e70dd9a739779f4c02f65d971313" "${PKGS_DIR}/libiconv.tar.gz" https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.17.tar.gz fetch_pkg "8f74213b56238c85a50a5329f77e06198771e70dd9a739779f4c02f65d971313" "${PKGS_DIR}/libiconv.tar.gz" https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.17.tar.gz
fetch_pkg "ec1705b1e969b83a9f073144ec806151db88127f5e40fe5a94cb6c8fa48996a0" "${PKGS_DIR}/gettext.tar.gz" https://ftp.gnu.org/pub/gnu/gettext/gettext-0.22.5.tar.gz fetch_pkg "ec1705b1e969b83a9f073144ec806151db88127f5e40fe5a94cb6c8fa48996a0" "${PKGS_DIR}/gettext.tar.gz" https://ftp.gnu.org/pub/gnu/gettext/gettext-0.22.5.tar.gz
fetch_pkg "3736161e41e2693324deb38c26cfdc3efe6209d634ba4258db1cecff6a5ad461" "${PKGS_DIR}/libssh2.tar.gz" https://www.libssh2.org/download/libssh2-1.11.0.tar.gz fetch_pkg "d9ec76cbe34db98eec3539fe2c899d26b0c837cb3eb466a56b0f109cabf658f7" "${PKGS_DIR}/libssh2.tar.gz" https://www.libssh2.org/download/libssh2-1.11.1.tar.gz
fetch_pkg "9318a2cc00238f5dd6546212109fb833f977661321a2087f03034e25444d3dbb" "${PKGS_DIR}/nghttp2.tar.gz" https://github.com/nghttp2/nghttp2/releases/download/v1.63.0/nghttp2-1.63.0.tar.gz fetch_pkg "20e73f3cf9db3f05988996ac8b3a99ed529f4565ca91a49eb0550498e10621e8" "${PKGS_DIR}/nghttp2.tar.gz" https://github.com/nghttp2/nghttp2/releases/download/v1.64.0/nghttp2-1.64.0.tar.gz
fetch_pkg "13d68a48867d2eb0679b81e2e6e065de074abc64246fb11417c3e40988e5ff23" "${PKGS_DIR}/nghttp3.tar.gz" https://github.com/ngtcp2/nghttp3/releases/download/v1.5.0/nghttp3-1.5.0.tar.gz fetch_pkg "a1f92f113c10faca2014b004eb97be363674e23546eb72591c1ac3533f93cba0" "${PKGS_DIR}/nghttp3.tar.gz" https://github.com/ngtcp2/nghttp3/releases/download/v1.6.0/nghttp3-1.6.0.tar.gz
fetch_pkg "59dccb5c9a615eaf9de3e3cc3299134c22a88513b865b78a3e91d873c08a0664" "${PKGS_DIR}/ngtcp2.tar.gz" https://github.com/ngtcp2/ngtcp2/releases/download/v1.7.0/ngtcp2-1.7.0.tar.gz fetch_pkg "72b544d2509b8fb58c493f9d3d71fe93959f94bca48aa0c87ddd56bf61178cee" "${PKGS_DIR}/ngtcp2.tar.gz" https://github.com/ngtcp2/ngtcp2/releases/download/v1.8.1/ngtcp2-1.8.1.tar.gz
fetch_pkg "4c21a791b610b9519b9d0e12b8097bf2f359b12f8dd92647611a929e6bfd7d64" "${PKGS_DIR}/libidn2.tar.gz" https://ftp.gnu.org/gnu/libidn/libidn2-2.3.7.tar.gz fetch_pkg "4c21a791b610b9519b9d0e12b8097bf2f359b12f8dd92647611a929e6bfd7d64" "${PKGS_DIR}/libidn2.tar.gz" https://ftp.gnu.org/gnu/libidn/libidn2-2.3.7.tar.gz
fetch_pkg "1dcc9ceae8b128f3c0b3f654decd0e1e891afc6ff81098f227ef260449dae208" "${PKGS_DIR}/libpsl.tar.gz" https://github.com/rockdaboot/libpsl/releases/download/0.21.5/libpsl-0.21.5.tar.gz fetch_pkg "1dcc9ceae8b128f3c0b3f654decd0e1e891afc6ff81098f227ef260449dae208" "${PKGS_DIR}/libpsl.tar.gz" https://github.com/rockdaboot/libpsl/releases/download/0.21.5/libpsl-0.21.5.tar.gz
fetch_pkg "f1b553384dedbd87478449775546a358d6f5140c15cccc8fb574136fdc77329f" "${PKGS_DIR}/libgsasl.tar.gz" https://ftp.gnu.org/gnu/gsasl/libgsasl-1.10.0.tar.gz fetch_pkg "f1b553384dedbd87478449775546a358d6f5140c15cccc8fb574136fdc77329f" "${PKGS_DIR}/libgsasl.tar.gz" https://ftp.gnu.org/gnu/gsasl/libgsasl-1.10.0.tar.gz
fetch_pkg "58c9dcf73493ae9d181fd334b3b3987ff73124621565187ade237bff1064a716" "${PKGS_DIR}/curl.tar.gz" https://curl.se/download/curl-${MY_VERSION}.tar.gz fetch_pkg "264537d90e58d2b09dddc50944baf3c38e7089151c8986715e2aaeaaf2b8118f" "${PKGS_DIR}/curl.tar.gz" https://curl.se/download/curl-${MY_VERSION}.tar.gz
fetch_pkg "1bf458412568e134a4514f5e170a328d11091e071c7110955c9884ed87972ac9" "${PKGS_DIR}/cacert.pem" https://curl.se/ca/cacert-2024-07-02.pem fetch_pkg "189d3cf6d103185fba06d76c1af915263c6d42225481a1759e853b33ac857540" "${PKGS_DIR}/cacert.pem" https://curl.se/ca/cacert-2024-09-24.pem
fetch_pkg "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" "${PKGS_DIR}/manpage.html" https://curl.se/docs/manpage.html fetch_pkg "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" "${PKGS_DIR}/manpage.html" https://curl.se/docs/manpage.html
############################################################################### ###############################################################################
@ -290,7 +290,7 @@ readonly TCP2_DIR="${WORK_DIR}/ngtcp2"
rm -rf "${TCP2_DIR}" && mkdir "${TCP2_DIR}" rm -rf "${TCP2_DIR}" && mkdir "${TCP2_DIR}"
tar -xvf "${PKGS_DIR}/ngtcp2.tar.gz" --strip-components=1 -C "${TCP2_DIR}" tar -xvf "${PKGS_DIR}/ngtcp2.tar.gz" --strip-components=1 -C "${TCP2_DIR}"
pushd "${TCP2_DIR}" pushd "${TCP2_DIR}"
CFLAGS="-march=${MY_MARCH} -mtune=${MY_MTUNE} -DNDEBUG -D_WIN32_WINNT=0x0501 -I${DEPS_DIR}/include" LDFLAGS="-L${DEPS_DIR}/lib" OPENSSL_CFLAGS="-I${DEPS_DIR}/include" OPENSSL_LIBS="-L${DEPS_DIR}/lib -lssl -lcrypto -lws2_32 -lz" ZLIB_CFLAGS="-I${DEPS_DIR}/include" ZLIB_LIBS="-L${DEPS_DIR}/lib -lz" ./configure --prefix="${DEPS_DIR}" --enable-lib-only --with-openssl --disable-shared CFLAGS="-march=${MY_MARCH} -mtune=${MY_MTUNE} -DNDEBUG -D_WIN32_WINNT=0x0501 -I${DEPS_DIR}/include" LDFLAGS="-L${DEPS_DIR}/lib" OPENSSL_CFLAGS="-I${DEPS_DIR}/include" OPENSSL_LIBS="-L${DEPS_DIR}/lib -lssl -lcrypto -lws2_32 -lz -lcrypt32" ZLIB_CFLAGS="-I${DEPS_DIR}/include" ZLIB_LIBS="-L${DEPS_DIR}/lib -lz" ./configure --prefix="${DEPS_DIR}" --enable-lib-only --with-openssl --disable-shared
make && make install make && make install
popd popd
@ -342,8 +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_threads.diff"
patch -p1 -b < "${BASE_DIR}/patch/curl_tool_doswin.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_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_parsecfg.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 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 --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 make V=1
strip -s src/curl.exe strip -s src/curl.exe
popd popd

View File

@ -17,7 +17,7 @@ index 49a2e50..dbf2642 100644
+#if defined(_WIN32) +#if defined(_WIN32)
+static wchar_t *GetEnv(const wchar_t *variable) +static wchar_t *GetEnv(const wchar_t *variable)
{ {
-#if defined(_WIN32_WCE) || defined(CURL_WINDOWS_APP) || \ -#if defined(_WIN32_WCE) || defined(CURL_WINDOWS_UWP) || \
- defined(__ORBIS__) || defined(__PROSPERO__) /* PlayStation 4 and 5 */ - defined(__ORBIS__) || defined(__PROSPERO__) /* PlayStation 4 and 5 */
- (void)variable; - (void)variable;
- return NULL; - return NULL;
@ -62,7 +62,7 @@ index 49a2e50..dbf2642 100644
+ +
+char *curl_getenv(const char *variable) +char *curl_getenv(const char *variable)
+{ +{
+#if defined(_WIN32_WCE) || defined(CURL_WINDOWS_APP) || \ +#if defined(_WIN32_WCE) || defined(CURL_WINDOWS_UWP) || \
+ defined(__ORBIS__) || defined(__PROSPERO__) /* PlayStation 4 and 5 */ + defined(__ORBIS__) || defined(__PROSPERO__) /* PlayStation 4 and 5 */
+ (void)variable; + (void)variable;
+ return NULL; + return NULL;
@ -80,7 +80,7 @@ index 49a2e50..dbf2642 100644
+ return value; + return value;
#else #else
char *env = getenv(variable); char *env = getenv(variable);
return (env && env[0])?strdup(env):NULL; return (env && env[0]) ? strdup(env) : NULL;
#endif #endif
} }
- -

View File

@ -1,74 +1,11 @@
src/tool_doswin.c | 57 ++++++++++++++++++++++++++++++++++++++++--------------- src/tool_doswin.c | 8 ++++++++
1 file changed, 42 insertions(+), 15 deletions(-) 1 file changed, 8 insertions(+)
diff --git a/src/tool_doswin.c b/src/tool_doswin.c diff --git a/src/tool_doswin.c b/src/tool_doswin.c
index 38ef0a0..8e976e9 100644 index 70b263113..28489a521 100644
--- a/src/tool_doswin.c --- a/src/tool_doswin.c
+++ b/src/tool_doswin.c +++ b/src/tool_doswin.c
@@ -615,6 +615,37 @@ char **__crt0_glob_function(char *arg) @@ -739,6 +739,8 @@ bool tool_isVistaOrGreater;
* 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,
curl_sslbackend backend,
const TCHAR *bundle_file)
@@ -634,21 +665,9 @@ CURLcode FindWin32CACert(struct OperationConfig *config,
*/
if(feature_ssl && backend != CURLSSLBACKEND_SCHANNEL) {
- 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;
}
}
#endif
@@ -785,6 +804,8 @@ bool tool_isVistaOrGreater;
CURLcode win32_init(void) CURLcode win32_init(void)
{ {
@ -77,7 +14,7 @@ index 38ef0a0..8e976e9 100644
/* curlx_verify_windows_version must be called during init at least once /* curlx_verify_windows_version must be called during init at least once
because it has its own initialization routine. */ because it has its own initialization routine. */
if(curlx_verify_windows_version(6, 0, 0, PLATFORM_WINNT, if(curlx_verify_windows_version(6, 0, 0, PLATFORM_WINNT,
@@ -799,6 +820,12 @@ CURLcode win32_init(void) @@ -753,6 +755,12 @@ CURLcode win32_init(void)
init_terminal(); init_terminal();
#endif #endif

View File

@ -1,10 +1,7 @@
src/tool_getparam.c | 9 +++++++++ diff --git "a/src/tool_getparam.c" "b/src/tool_getparam.c"
1 file changed, 9 insertions(+) index 1231b3bd6..434e9ddd3 100644
--- "a/src/tool_getparam.c"
diff --git a/src/tool_getparam.c b/src/tool_getparam.c +++ "b/src/tool_getparam.c"
index be41aa35d..b1b032b9f 100644
--- a/src/tool_getparam.c
+++ b/src/tool_getparam.c
@@ -23,6 +23,10 @@ @@ -23,6 +23,10 @@
***************************************************************************/ ***************************************************************************/
#include "tool_setup.h" #include "tool_setup.h"
@ -16,7 +13,7 @@ index be41aa35d..b1b032b9f 100644
#include "strcase.h" #include "strcase.h"
#include "curlx.h" #include "curlx.h"
@@ -551,8 +555,13 @@ static void cleanarg(argv_item_t str) @@ -554,8 +558,13 @@ static void cleanarg(argv_item_t str)
* argument out so that the username:password is not displayed in the * argument out so that the username:password is not displayed in the
* system process list */ * system process list */
if(str) { if(str) {

View File

@ -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"));

View File

@ -1,53 +1,11 @@
src/tool_parsecfg.c | 42 ++++++++++++++++-------------------------- src/tool_parsecfg.c | 16 +++++++++-------
1 file changed, 16 insertions(+), 26 deletions(-) 1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/tool_parsecfg.c b/src/tool_parsecfg.c diff --git a/src/tool_parsecfg.c b/src/tool_parsecfg.c
index 6da5a9250..e6f7ad786 100644 index d79e869f0..93eb2a428 100644
--- a/src/tool_parsecfg.c --- a/src/tool_parsecfg.c
+++ b/src/tool_parsecfg.c +++ b/src/tool_parsecfg.c
@@ -45,29 +45,20 @@ static const char *unslashquote(const char *line, char *param); @@ -57,7 +57,7 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
static bool my_get_line(FILE *fp, struct curlx_dynbuf *, bool *error);
#ifdef _WIN32
-static FILE *execpath(const char *filename, char **pathp)
+static FILE *execpath(const TCHAR *filename)
{
- static char filebuffer[512];
- /* Get the filename of our executable. GetModuleFileName is already declared
- * via inclusions done in setup header file. We assume that we are using
- * the ASCII version here.
- */
- unsigned long len = GetModuleFileNameA(0, filebuffer, sizeof(filebuffer));
- if(len > 0 && len < sizeof(filebuffer)) {
- /* We got a valid filename - get the directory part */
- char *lastdirchar = strrchr(filebuffer, '\\');
+ 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) {
- size_t remaining;
- *lastdirchar = 0;
- /* If we have enough space, build the RC filename */
- remaining = sizeof(filebuffer) - strlen(filebuffer);
- if(strlen(filename) < remaining - 1) {
- FILE *f;
- msnprintf(lastdirchar, remaining, "%s%s", DIR_CHAR, filename);
- *pathp = filebuffer;
- f = fopen(filebuffer, FOPEN_READTEXT);
- return f;
- }
+ *lastdirchar = TEXT('\0');
+ }
+ if (_tcslen(filebuffer) + _tcslen(filename) + 2U < BUFFSIZE) {
+ _tcscat(filebuffer, TEXT("\\"));
+ _tcscat(filebuffer, filename);
+ return _tfopen(filebuffer, TEXT(FOPEN_READTEXT));
}
}
@@ -87,7 +78,7 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
if(!filename) { if(!filename) {
/* NULL means load .curlrc from homedir! */ /* NULL means load .curlrc from homedir! */
@ -56,21 +14,26 @@ index 6da5a9250..e6f7ad786 100644
if(curlrc) { if(curlrc) {
file = fopen(curlrc, FOPEN_READTEXT); file = fopen(curlrc, FOPEN_READTEXT);
if(!file) { if(!file) {
@@ -98,14 +89,13 @@ int parseconfig(const char *filename, struct GlobalConfig *global) @@ -68,14 +68,16 @@ int parseconfig(const char *filename, struct GlobalConfig *global)
} }
#ifdef _WIN32 /* Windows */ #ifdef _WIN32 /* Windows */
else { else {
- char *fullp; - char *fullp;
+ TCHAR *fullp;
/* check for .curlrc then _curlrc in the dir of the executable */ /* check for .curlrc then _curlrc in the dir of the executable */
- file = execpath(".curlrc", &fullp); - file = Curl_execpath(".curlrc", &fullp);
+ file = execpath(TEXT(".curlrc") /*,&fullp*/); - if(!file)
if(!file) - file = Curl_execpath("_curlrc", &fullp);
- file = execpath("_curlrc", &fullp); + file = Curl_execpath(TEXT(".curlrc"), &fullp);
+ file = execpath(TEXT("_curlrc") /*,&fullp*/);
if(file) if(file)
/* this is the filename we read from */ - /* this is the filename we read from */
- filename = fullp; - filename = fullp;
+ filename = ".curlrc"; + filename = ".curlrc";
+ else {
+ file = Curl_execpath(TEXT("_curlrc"), &fullp);
+ if(file)
+ filename = "_curlrc";
+ }
} }
#endif #endif
} }

63
patch/curl_tool_util.diff Normal file
View File

@ -0,0 +1,63 @@
src/tool_util.c | 33 +++++++++++++--------------------
src/tool_util.h | 2 +-
2 files changed, 14 insertions(+), 21 deletions(-)
diff --git a/src/tool_util.c b/src/tool_util.c
index e657dacf0..7044ca008 100644
--- a/src/tool_util.c
+++ b/src/tool_util.c
@@ -191,28 +191,21 @@ int tool_ftruncate64(int fd, curl_off_t where)
#endif /* USE_TOOL_FTRUNCATE */
#ifdef _WIN32
-FILE *Curl_execpath(const char *filename, char **pathp)
+#define BUFFSIZE 512U
+FILE *Curl_execpath(const TCHAR *filename, TCHAR **pathp)
{
- static char filebuffer[512];
- unsigned long len;
- /* Get the filename of our executable. GetModuleFileName is already declared
- * via inclusions done in setup header file. We assume that we are using
- * the ASCII version here.
- */
- len = GetModuleFileNameA(0, filebuffer, sizeof(filebuffer));
- if(len > 0 && len < sizeof(filebuffer)) {
- /* We got a valid filename - get the directory part */
- char *lastdirchar = strrchr(filebuffer, DIR_CHAR[0]);
+ static TCHAR filebuffer[BUFFSIZE];
+ unsigned long len = GetModuleFileName(0, filebuffer, BUFFSIZE);
+ if((len > 0) && (len < BUFFSIZE)) {
+ TCHAR *lastdirchar = _tcsrchr(filebuffer, TEXT('\\'));
if(lastdirchar) {
- size_t remaining;
- *lastdirchar = 0;
- /* If we have enough space, build the RC filename */
- remaining = sizeof(filebuffer) - strlen(filebuffer);
- if(strlen(filename) < remaining - 1) {
- msnprintf(lastdirchar, remaining, "%s%s", DIR_CHAR, filename);
- *pathp = filebuffer;
- return fopen(filebuffer, FOPEN_READTEXT);
- }
+ *lastdirchar = TEXT('\0');
+ }
+ if (_tcslen(filebuffer) + _tcslen(filename) + 2U < BUFFSIZE) {
+ _tcscat(filebuffer, TEXT("\\"));
+ _tcscat(filebuffer, filename);
+ *pathp = filebuffer;
+ return _tfopen(filebuffer, TEXT(FOPEN_READTEXT));
}
}
diff --git a/src/tool_util.h b/src/tool_util.h
index 9fec7e873..93d7ef9fc 100644
--- a/src/tool_util.h
+++ b/src/tool_util.h
@@ -40,7 +40,7 @@ int struplocompare(const char *p1, const char *p2);
int struplocompare4sort(const void *p1, const void *p2);
#ifdef _WIN32
-FILE *Curl_execpath(const char *filename, char **pathp);
+FILE *Curl_execpath(const TCHAR *filename, TCHAR **pathp);
#endif
#endif /* HEADER_CURL_TOOL_UTIL_H */

View File

@ -1,16 +1,14 @@
lib/nghttp2_time.c | 40 ++++++++++------------------------------ lib/nghttp2_time.c | 38 ++++++++++----------------------------
1 file changed, 10 insertions(+), 30 deletions(-) 1 file changed, 10 insertions(+), 28 deletions(-)
diff --git a/lib/nghttp2_time.c b/lib/nghttp2_time.c diff --git a/lib/nghttp2_time.c b/lib/nghttp2_time.c
index 947b544..db18869 100644 index 148ccfdc..355b225a 100644
--- a/lib/nghttp2_time.c --- a/lib/nghttp2_time.c
+++ b/lib/nghttp2_time.c +++ b/lib/nghttp2_time.c
@@ -28,36 +28,16 @@ @@ -30,34 +30,16 @@
# include <windows.h>
#endif /* HAVE_WINDOWS_H */ #include <time.h>
-#include <time.h>
-
-#if !defined(HAVE_GETTICKCOUNT64) || defined(__CYGWIN__) -#if !defined(HAVE_GETTICKCOUNT64) || defined(__CYGWIN__)
-static uint64_t time_now_sec(void) { -static uint64_t time_now_sec(void) {
- time_t t = time(NULL); - time_t t = time(NULL);
@ -30,7 +28,7 @@ index 947b544..db18869 100644
-#if defined(HAVE_GETTICKCOUNT64) && !defined(__CYGWIN__) -#if defined(HAVE_GETTICKCOUNT64) && !defined(__CYGWIN__)
-uint64_t nghttp2_time_now_sec(void) { return GetTickCount64() / 1000; } -uint64_t nghttp2_time_now_sec(void) { return GetTickCount64() / 1000; }
-#elif defined(HAVE_CLOCK_GETTIME) && defined(HAVE_DECL_CLOCK_MONOTONIC) && \ -#elif defined(HAVE_CLOCK_GETTIME) && defined(HAVE_DECL_CLOCK_MONOTONIC) && \
- HAVE_DECL_CLOCK_MONOTONIC - HAVE_DECL_CLOCK_MONOTONIC
-uint64_t nghttp2_time_now_sec(void) { -uint64_t nghttp2_time_now_sec(void) {
- struct timespec tp; - struct timespec tp;
- int rv = clock_gettime(CLOCK_MONOTONIC, &tp); - int rv = clock_gettime(CLOCK_MONOTONIC, &tp);

View File

@ -2,10 +2,10 @@
1 file changed, 3 insertions(+), 1 deletion(-) 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/session.c b/src/session.c diff --git a/src/session.c b/src/session.c
index a4d602b..e653f1d 100644 index 2d77b05..79809cc 100644
--- a/src/session.c --- a/src/session.c
+++ b/src/session.c +++ b/src/session.c
@@ -66,6 +66,8 @@ @@ -68,6 +68,8 @@
#undef libssh2_usec_t #undef libssh2_usec_t
#endif #endif
@ -14,7 +14,7 @@ index a4d602b..e653f1d 100644
/* libssh2_default_alloc /* libssh2_default_alloc
*/ */
static static
@@ -602,7 +604,7 @@ int _libssh2_wait_socket(LIBSSH2_SESSION *session, time_t start_time) @@ -628,7 +630,7 @@ int _libssh2_wait_socket(LIBSSH2_SESSION *session, time_t start_time)
(seconds_to_next == 0 || (seconds_to_next == 0 ||
ms_to_next > session->api_timeout)) { ms_to_next > session->api_timeout)) {
time_t now = time(NULL); time_t now = time(NULL);