From 8bad21c07349e96f896e4bc66bade9964cb7d1bf Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 29 Nov 2017 12:20:19 +0100 Subject: [PATCH] Update cURL to v7.57.0 (#3179) * curl: modify patches in preparation for cURL v7.57.0 While at it, squash them into one, because there is really no good reason to apply a patch that uses the executable path for anchoring the relocation first, only to immediately modify it to use the dll path instead. Signed-off-by: Johannes Schindelin * curl: new version v7.57.0 Signed-off-by: Johannes Schindelin --- .../0001-Make-cURL-relocatable.patch | 121 +++++++++++++----- ...table-base-from-.dll-instead-of-.exe.patch | 121 ------------------ mingw-w64-curl/PKGBUILD | 11 +- 3 files changed, 90 insertions(+), 163 deletions(-) delete mode 100644 mingw-w64-curl/0002-cURL-Get-relocatable-base-from-.dll-instead-of-.exe.patch diff --git a/mingw-w64-curl/0001-Make-cURL-relocatable.patch b/mingw-w64-curl/0001-Make-cURL-relocatable.patch index f3e573cb2f..1f7b055c74 100644 --- a/mingw-w64-curl/0001-Make-cURL-relocatable.patch +++ b/mingw-w64-curl/0001-Make-cURL-relocatable.patch @@ -1,24 +1,36 @@ -From a8f6e04613d0a90f754685518119e3004b126318 Mon Sep 17 00:00:00 2001 +From 48afa450c9e8e87f736ace18be55ef65360905f0 Mon Sep 17 00:00:00 2001 From: Ray Donnelly Date: Wed, 22 Feb 2017 11:03:04 +0100 -Subject: [PATCH 1/3] Make cURL relocatable +Subject: [PATCH] Make cURL relocatable +This adds the ability to specify CA_BUNDLE paths that are relative to +the MSYS2 pseudo-root directory. + +To make it truly relocatable, we use the path to the *cURL library* +instead of the path to the current .exe to determine the location of the +pseudo-root directory (allowing the .exe file to live completely outside +of the MSYS2 system, e.g. in $HOME/bin). This requires Win32 API +available in Windows XP & 2003 and later, well within the Windows +versions supported by Cygwin (and therefore MSys2). + +Original-patch-by: Ray Donnelly +Signed-off-by: Johannes Schindelin --- configure.ac | 1 + - lib/Makefile.inc | 4 +- + lib/Makefile.inc | 5 +- lib/curl_config.h.in | 3 + - lib/pathtools.c | 499 +++++++++++++++++++++++++++++++++++++++++++++++++++ - lib/pathtools.h | 49 +++++ + lib/pathtools.c | 533 +++++++++++++++++++++++++++++++++++++++++++++++++++ + lib/pathtools.h | 53 +++++ lib/url.c | 16 ++ - 6 files changed, 570 insertions(+), 2 deletions(-) + 6 files changed, 609 insertions(+), 2 deletions(-) create mode 100644 lib/pathtools.c create mode 100644 lib/pathtools.h diff --git a/configure.ac b/configure.ac -index 1e76c49..17f477a 100644 +index a72a612fb..09c477454 100755 --- a/configure.ac +++ b/configure.ac -@@ -3186,6 +3186,7 @@ if test "xyes" = "x$longlong"; then +@@ -3373,6 +3373,7 @@ if test "xyes" = "x$longlong"; then ]) fi @@ -27,29 +39,30 @@ index 1e76c49..17f477a 100644 # check for ssize_t AC_CHECK_TYPE(ssize_t, , diff --git a/lib/Makefile.inc b/lib/Makefile.inc -index 19f5800..d8eb6d5 100644 ---- curl-7.56.0/lib/Makefile.inc.orig 2017-10-06 17:33:35.163103800 +0200 -+++ curl-7.56.0/lib/Makefile.inc 2017-10-06 17:35:48.306143200 +0200 -@@ -54,7 +54,7 @@ +index 0a88b8eb8..b7c8a6ba1 100644 +--- a/lib/Makefile.inc ++++ b/lib/Makefile.inc +@@ -54,7 +54,7 @@ LIB_CFILES = file.c timeval.c base64.c hostip.c progress.c formdata.c \ http_ntlm.c curl_ntlm_wb.c curl_ntlm_core.c curl_sasl.c rand.c \ curl_multibyte.c hostcheck.c conncache.c pipeline.c dotdot.c \ x509asn1.c http2.c smb.c curl_endian.c curl_des.c system_win32.c \ -- mime.c -+ mime.c pathtools.c +- mime.c sha256.c setopt.c ++ mime.c sha256.c setopt.c pathtools.c LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h \ formdata.h cookie.h http.h sendf.h ftp.h url.h dict.h if2ip.h \ -@@ -73,7 +73,7 @@ +@@ -73,7 +73,8 @@ LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h \ curl_sasl.h curl_multibyte.h hostcheck.h conncache.h \ curl_setup_once.h multihandle.h setup-vms.h pipeline.h dotdot.h \ x509asn1.h http2.h sigpipe.h smb.h curl_endian.h curl_des.h \ -- curl_printf.h system_win32.h rand.h mime.h -+ curl_printf.h pathtools.h system_win32.h rand.h mime.h +- curl_printf.h system_win32.h rand.h mime.h curl_sha256.h setopt.h ++ curl_printf.h system_win32.h rand.h mime.h curl_sha256.h setopt.h \ ++ pathtools.h LIB_RCFILES = libcurl.rc diff --git a/lib/curl_config.h.in b/lib/curl_config.h.in -index 60e9d23..4bddddd 100644 +index 3a3368b9b..1f63fed4c 100644 --- a/lib/curl_config.h.in +++ b/lib/curl_config.h.in @@ -9,6 +9,9 @@ @@ -64,10 +77,10 @@ index 60e9d23..4bddddd 100644 diff --git a/lib/pathtools.c b/lib/pathtools.c new file mode 100644 -index 0000000..81ffa7e +index 000000000..c66df924b --- /dev/null +++ b/lib/pathtools.c -@@ -0,0 +1,499 @@ +@@ -0,0 +1,533 @@ +/* + .Some useful path tools. + .ASCII only for now. @@ -96,7 +109,7 @@ index 0000000..81ffa7e +#define IMPLEMENT_SYS_GET_EXECUTABLE_PATH + +#if defined(IMPLEMENT_SYS_GET_EXECUTABLE_PATH) -+#if defined(__linux__) || defined(__CYGWIN__) || defined(__MSYS__) ++#if defined(__linux__) +/* Nothing needed, unistd.h is enough. */ +#elif defined(__APPLE__) +#include @@ -402,6 +415,40 @@ index 0000000..81ffa7e + return result_size; +} + ++#if defined(_WIN32) ++int ++get_dll_path(char * result, unsigned long max_size) ++{ ++ HMODULE handle; ++ char * p; ++ int ret; ++ ++ if (!GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | ++ GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, ++ (LPCSTR) &get_dll_path, &handle)) ++ { ++ return -1; ++ } ++ ++ ret = GetModuleFileNameA(handle, result, max_size); ++ if (ret == 0 || ret == (int)max_size) ++ { ++ return -1; ++ } ++ ++ /* Early conversion to unix slashes instead of more changes ++ everywhere else .. */ ++ result[ret] = '\0'; ++ p = result - 1; ++ while ((p = strchr (p + 1, '\\')) != NULL) ++ { ++ *p = '/'; ++ } ++ ++ return ret; ++} ++#endif ++ +char const * +strip_n_prefix_folders(char const * path, size_t n) +{ @@ -569,10 +616,10 @@ index 0000000..81ffa7e +} diff --git a/lib/pathtools.h b/lib/pathtools.h new file mode 100644 -index 0000000..a8a2928 +index 000000000..d4ff40f8a --- /dev/null +++ b/lib/pathtools.h -@@ -0,0 +1,49 @@ +@@ -0,0 +1,53 @@ +/* + .Some useful path tools. + .ASCII only for now. @@ -603,6 +650,10 @@ index 0000000..a8a2928 + if IMPLEMENT_SYS_GET_EXECUTABLE_PATH is defined, otherwise uses argv0. */ +int get_executable_path(char const * argv0, char * result, ssize_t max_size); + ++#if defined(_WIN32) ++int get_dll_path(char * result, unsigned long max_size); ++#endif ++ +/* Where possible, in-place removes occourances of '.' and 'path/..' */ +void simplify_path(char * path); + @@ -623,40 +674,40 @@ index 0000000..a8a2928 + +#endif /* PATHTOOLS_H */ diff --git a/lib/url.c b/lib/url.c -index b8f7cfb..a84ff75 100644 +index 47f69c9f1..e39638cec 100644 --- a/lib/url.c +++ b/lib/url.c -@@ -119,6 +119,9 @@ bool curl_win32_idn_to_ascii(const char *in, char **out); - #include "pipeline.h" +@@ -121,6 +121,9 @@ bool curl_win32_idn_to_ascii(const char *in, char **out); #include "dotdot.h" #include "strdup.h" + #include "setopt.h" +#if defined(__MINGW32__) +#include "pathtools.h" +#endif + /* The last 3 #include files should be in this order */ #include "curl_printf.h" - #include "curl_memory.h" -@@ -574,7 +577,20 @@ CURLcode Curl_init_userdefined(struct UserDefined *set) +@@ -490,7 +493,20 @@ CURLcode Curl_init_userdefined(struct UserDefined *set) /* This is our preferred CA cert bundle/path since install time */ #if defined(CURL_CA_BUNDLE) +#if defined(__MINGW32__) + const size_t path_max = PATH_MAX; + char relocated[path_max]; -+ get_executable_path(NULL, &relocated, path_max); -+ strip_n_suffix_folders(&relocated, 1); -+ strncat(&relocated, "/", path_max); -+ char * relative = get_relative_path(CURL_BINDIR, CURL_CA_BUNDLE); ++ get_dll_path(relocated, path_max); ++ strip_n_suffix_folders(relocated, 1); ++ strncat(relocated, "/", path_max); ++ char *relative = get_relative_path(CURL_BINDIR, CURL_CA_BUNDLE); + strncat(relocated, relative, path_max); + simplify_path(relocated); -+ result = setstropt(&set->str[STRING_SSL_CAFILE_ORIG], (char *) relocated); ++ result = Curl_setstropt(&set->str[STRING_SSL_CAFILE_ORIG], relocated); + free((void*)relative); +#else - result = setstropt(&set->str[STRING_SSL_CAFILE_ORIG], CURL_CA_BUNDLE); + result = Curl_setstropt(&set->str[STRING_SSL_CAFILE_ORIG], CURL_CA_BUNDLE); +#endif /* defined(__MINGW32__) */ if(result) return result; #endif -- -2.11.1.windows.1.dirty +2.15.0.windows.1 diff --git a/mingw-w64-curl/0002-cURL-Get-relocatable-base-from-.dll-instead-of-.exe.patch b/mingw-w64-curl/0002-cURL-Get-relocatable-base-from-.dll-instead-of-.exe.patch deleted file mode 100644 index d3ecf1f4f7..0000000000 --- a/mingw-w64-curl/0002-cURL-Get-relocatable-base-from-.dll-instead-of-.exe.patch +++ /dev/null @@ -1,121 +0,0 @@ -From d3188584136bb1b5f45cab97e7e10281f3cb3124 Mon Sep 17 00:00:00 2001 -From: Johannes Schindelin -Date: Sat, 9 Jan 2016 12:35:03 +0000 -Subject: [PATCH 2/3] cURL: Get relocatable base from .dll instead of .exe - -Currently, cURL uses the path to the current executable to figure out -where the certificates are. This works as long as all executables are in -/mingw64/bin/ (or /mingw32/bin/). - -However, the entire point of having a DLL with a linkable .dll.a is to -be able to use it in executables that other people build. For example, -if an .exe lives in %HOME%\bin, the path used by our libcurl to look up -the certificates is all wrong. - -Same problem with Git for Windows: its executables are hidden away from -the user, in the /mingw64/libexec/git-core/ directory. So the path to -the certificates is all wrong again. - -So let's just use the path to the *cURL library* instead of the path to -the current .exe. This requires Win32 API available in Windows XP & 2003 -and later, well within the Windows versions supported by Cygwin (and -therefore MSys2). - -Reported by David Ebbo. - -Signed-off-by: Johannes Schindelin ---- - lib/pathtools.c | 36 +++++++++++++++++++++++++++++++++++- - lib/pathtools.h | 4 ++++ - lib/url.c | 6 +++--- - 3 files changed, 42 insertions(+), 4 deletions(-) - -diff --git a/lib/pathtools.c b/lib/pathtools.c -index 81ffa7e..c66df92 100644 ---- a/lib/pathtools.c -+++ b/lib/pathtools.c -@@ -26,7 +26,7 @@ - #define IMPLEMENT_SYS_GET_EXECUTABLE_PATH - - #if defined(IMPLEMENT_SYS_GET_EXECUTABLE_PATH) --#if defined(__linux__) || defined(__CYGWIN__) || defined(__MSYS__) -+#if defined(__linux__) - /* Nothing needed, unistd.h is enough. */ - #elif defined(__APPLE__) - #include -@@ -332,6 +332,40 @@ get_executable_path(char const * argv0, char * result, ssize_t max_size) - return result_size; - } - -+#if defined(_WIN32) -+int -+get_dll_path(char * result, unsigned long max_size) -+{ -+ HMODULE handle; -+ char * p; -+ int ret; -+ -+ if (!GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | -+ GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, -+ (LPCSTR) &get_dll_path, &handle)) -+ { -+ return -1; -+ } -+ -+ ret = GetModuleFileNameA(handle, result, max_size); -+ if (ret == 0 || ret == (int)max_size) -+ { -+ return -1; -+ } -+ -+ /* Early conversion to unix slashes instead of more changes -+ everywhere else .. */ -+ result[ret] = '\0'; -+ p = result - 1; -+ while ((p = strchr (p + 1, '\\')) != NULL) -+ { -+ *p = '/'; -+ } -+ -+ return ret; -+} -+#endif -+ - char const * - strip_n_prefix_folders(char const * path, size_t n) - { -diff --git a/lib/pathtools.h b/lib/pathtools.h -index a8a2928..d4ff40f 100644 ---- a/lib/pathtools.h -+++ b/lib/pathtools.h -@@ -28,6 +28,10 @@ void sanitise_path(char * path); - if IMPLEMENT_SYS_GET_EXECUTABLE_PATH is defined, otherwise uses argv0. */ - int get_executable_path(char const * argv0, char * result, ssize_t max_size); - -+#if defined(_WIN32) -+int get_dll_path(char * result, unsigned long max_size); -+#endif -+ - /* Where possible, in-place removes occourances of '.' and 'path/..' */ - void simplify_path(char * path); - -diff --git a/lib/url.c b/lib/url.c -index a84ff75..e054d59 100644 ---- a/lib/url.c -+++ b/lib/url.c -@@ -580,9 +580,9 @@ CURLcode Curl_init_userdefined(struct UserDefined *set) - #if defined(__MINGW32__) - const size_t path_max = PATH_MAX; - char relocated[path_max]; -- get_executable_path(NULL, &relocated, path_max); -- strip_n_suffix_folders(&relocated, 1); -- strncat(&relocated, "/", path_max); -+ get_dll_path(relocated, path_max); -+ strip_n_suffix_folders(relocated, 1); -+ strncat(relocated, "/", path_max); - char * relative = get_relative_path(CURL_BINDIR, CURL_CA_BUNDLE); - strncat(relocated, relative, path_max); - simplify_path(relocated); --- -2.11.1.windows.1.dirty - diff --git a/mingw-w64-curl/PKGBUILD b/mingw-w64-curl/PKGBUILD index 15db0c2ba8..4dbc701788 100644 --- a/mingw-w64-curl/PKGBUILD +++ b/mingw-w64-curl/PKGBUILD @@ -12,7 +12,7 @@ fi _realname=curl pkgbase=mingw-w64-${_realname} pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}${_namesuff}" -pkgver=7.56.1 +pkgver=7.57.0 pkgrel=1 pkgdesc="Command line tool and library for transferring data with URLs. (mingw-w64)" arch=('any') @@ -40,12 +40,10 @@ if [ -n "${_namesuff}" ]; then fi options=('staticlibs') source=("${url}/download/${_realname}-${pkgver}.tar.bz2"{,.asc} - "0001-Make-cURL-relocatable.patch" - "0002-cURL-Get-relocatable-base-from-.dll-instead-of-.exe.patch") -sha256sums=('2594670367875e7d87b0f129b5e4690150780884d90244ba0fe3e74a778b5f90' + "0001-Make-cURL-relocatable.patch") +sha256sums=('c92fe31a348eae079121b73884065e600c533493eb50f1f6cee9c48a3f454826' 'SKIP' - '3008bbfa20f2b23d57db0c4b844af877bd0ad50be7a06148ff5b7b7dc0386f1e' - '604b34b5ca9b3520a83a23959f943e330c1ef36b50ee377f8210b59be3e5f62b') + '93f636b569ba9089dd8280afefa48e4cf9c1fc5a5142bcc08ff181379231d2a4') validpgpkeys=('914C533DF9B2ADA2204F586D78E11C6B279D5C91' # Daniel Stenberg '27EDEAF22F3ABCEB50DB9A125CC908FDB71E12C2' '4461EAF0F8E9097F48AF0555F9FEAFF9D34A1BDB') @@ -54,7 +52,6 @@ prepare() { cd "${_realname}-${pkgver}" rm -f lib/pathtools.h lib/pathtools.c > /dev/null 2>&1 || true patch -p1 -i "${srcdir}/0001-Make-cURL-relocatable.patch" - patch -p1 -i "${srcdir}/0002-cURL-Get-relocatable-base-from-.dll-instead-of-.exe.patch" autoreconf -vfi }