From ee0924b86e091ca04486e3dd83721fcfbb15ecde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Sun, 14 Nov 2021 21:11:44 +0100 Subject: [PATCH] openssl: synchronize pathtools MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Markus Mützel --- mingw-w64-openssl/PKGBUILD | 6 +-- mingw-w64-openssl/pathtools.c | 92 ++++++++++++++++++++++++++++------- mingw-w64-openssl/pathtools.h | 3 ++ 3 files changed, 81 insertions(+), 20 deletions(-) diff --git a/mingw-w64-openssl/PKGBUILD b/mingw-w64-openssl/PKGBUILD index 56ee3bc038..79a8673829 100644 --- a/mingw-w64-openssl/PKGBUILD +++ b/mingw-w64-openssl/PKGBUILD @@ -6,7 +6,7 @@ pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}") _ver=1.1.1m # use a pacman compatible version scheme pkgver=${_ver/[a-z]/.${_ver//[0-9.]/}} -pkgrel=1 +pkgrel=2 arch=('any') mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64') pkgdesc="The Open Source toolkit for Secure Sockets Layer and Transport Layer Security (mingw-w64)" @@ -25,8 +25,8 @@ source=(https://www.openssl.org/source/${_realname}-${_ver}.tar.gz{,.asc} 'openssl-1.1.1-mingw-arm.patch') sha256sums=('f89199be8b23ca45fc7cb9f1d8d3ee67312318286ad030f5316aca6462db6c96' 'SKIP' - '6f1016e6647b6340fdceefaf24ff391f4c0ea3c785ddf70c9794ca2356797888' - '6ce4dcf4ef6c4bce48dbcb6f1b5226baf79f74ac76719fb0c06419a0aadb37a3' + '703cd0cb74e714f9e66d26de11c109dd76fab07e723af8dde56a35ea65102e5f' + '4f9d325265ef6f4e90ad637dea41afa6995388c921fe961ad5dc895aca10318b' 'ca847be6a50c30db96a3323d51e09691c3d302f7d85f3eb61fabe1f08c223659' 'd41fad88631e7b8d2a56662f2166ea97ecbc6369f2ad3eac415182bc9ac9f308') diff --git a/mingw-w64-openssl/pathtools.c b/mingw-w64-openssl/pathtools.c index cecc85aa0c..d8d509be46 100644 --- a/mingw-w64-openssl/pathtools.c +++ b/mingw-w64-openssl/pathtools.c @@ -466,13 +466,11 @@ split_path_list(char const * path_list, char split_char, char *** arr) return path_count; } -char * -get_relocated_path_list(char const * from, char const * to_path_list) +static char * +get_relocated_path_list_ref(char const * from, char const * to_path_list, char *ref_path) { - char exe_path[MAX_PATH]; char * temp; - get_executable_path (NULL, &exe_path[0], sizeof (exe_path) / sizeof (exe_path[0])); - if ((temp = strrchr (exe_path, '/')) != NULL) + if ((temp = strrchr (ref_path, '/')) != NULL) { temp[1] = '\0'; } @@ -487,16 +485,16 @@ get_relocated_path_list(char const * from, char const * to_path_list) } size_t count = split_path_list (to_path_list, split_char, &arr); int result_size = 1 + (count - 1); /* count - 1 is for ; delim. */ - size_t exe_path_size = strlen (exe_path); + size_t ref_path_size = strlen (ref_path); size_t i; /* Space required is: - count * (exe_path_size + strlen (rel_to_datadir)) + count * (ref_path_size + strlen (rel_to_datadir)) rel_to_datadir upper bound is: (count * strlen (from)) + (3 * num_slashes (from)) + strlen(arr[i]) + 1. .. pathalogically num_slashes (from) is strlen (from) (from = ////////) */ - size_t space_required = (count * (exe_path_size + 4 * strlen (from))) + count - 1; + size_t space_required = (count * (ref_path_size + 4 * strlen (from))) + count - 1; for (i = 0; i < count; ++i) { space_required += strlen (arr[i]); @@ -509,7 +507,7 @@ get_relocated_path_list(char const * from, char const * to_path_list) char * rel_to_datadir = get_relative_path (from, arr[i]); scratch[0] = '\0'; arr[i] = scratch; - strcat (scratch, exe_path); + strcat (scratch, ref_path); strcat (scratch, rel_to_datadir); simplify_path (arr[i]); size_t arr_i_size = strlen (arr[i]); @@ -538,20 +536,60 @@ get_relocated_path_list(char const * from, char const * to_path_list) return result; } +char * +get_relocated_path_list(char const *from, char const *to_path_list) +{ + char exe_path[MAX_PATH]; + get_executable_path (NULL, &exe_path[0], sizeof (exe_path) / sizeof (exe_path[0])); + + return get_relocated_path_list_ref(from, to_path_list, exe_path); +} + +char * +get_relocated_path_list_lib(char const *from, char const *to_path_list) +{ + char dll_path[PATH_MAX]; + get_dll_path (&dll_path[0], sizeof(dll_path)/sizeof(dll_path[0])); + + return get_relocated_path_list_ref(from, to_path_list, dll_path); +} + +static char * +single_path_relocation_ref(const char *from, const char *to, char *ref_path) +{ +#if defined(__MINGW32__) + if (strrchr (ref_path, '/') != NULL) + { + strrchr (ref_path, '/')[1] = '\0'; + } + char * rel_to_datadir = get_relative_path (from, to); + strcat (ref_path, rel_to_datadir); + simplify_path (&ref_path[0]); + return malloc_copy_string(ref_path); +#else + return malloc_copy_string(to); +#endif +} + char * single_path_relocation(const char *from, const char *to) { #if defined(__MINGW32__) char exe_path[PATH_MAX]; get_executable_path (NULL, &exe_path[0], sizeof(exe_path)/sizeof(exe_path[0])); - if (strrchr (exe_path, '/') != NULL) - { - strrchr (exe_path, '/')[1] = '\0'; - } - char * rel_to_datadir = get_relative_path (from, to); - strcat (exe_path, rel_to_datadir); - simplify_path (&exe_path[0]); - return malloc_copy_string(exe_path); + return single_path_relocation_ref(from, to, exe_path); +#else + return malloc_copy_string(to); +#endif +} + +char * +single_path_relocation_lib(const char *from, const char *to) +{ +#if defined(__MINGW32__) + char dll_path[PATH_MAX]; + get_dll_path (&dll_path[0], sizeof(dll_path)/sizeof(dll_path[0])); + return single_path_relocation_ref(from, to, dll_path); #else return malloc_copy_string(to); #endif @@ -576,3 +614,23 @@ pathlist_relocation(const char *from_path, const char *to_path_list) return (to_path_list); #endif } + +char * +pathlist_relocation_lib(const char *from_path, const char *to_path_list) +{ +#if defined(__MINGW32__) + static char stored_path[PATH_MAX]; + static int stored = 0; + if (stored == 0) + { + char const * relocated = get_relocated_path_list_lib(from_path, to_path_list); + strncpy (stored_path, relocated, PATH_MAX); + stored_path[PATH_MAX-1] = '\0'; + free ((void *)relocated); + stored = 1; + } + return stored_path; +#else + return (to_path_list); +#endif +} diff --git a/mingw-w64-openssl/pathtools.h b/mingw-w64-openssl/pathtools.h index b01fab0067..08423a999e 100644 --- a/mingw-w64-openssl/pathtools.h +++ b/mingw-w64-openssl/pathtools.h @@ -50,8 +50,11 @@ strip_n_suffix_folders(char * path, size_t n); char const * get_relocated_path (char const * from, char const * to, char const * actual_from); char * get_relocated_path_list(char const * from, char const * to_path_list); +char * get_relocated_path_list_lib(char const * from, char const * to_path_list); char * single_path_relocation(const char *from, const char *to); +char * single_path_relocation_lib(const char *from, const char *to); char * pathlist_relocation(const char *from_path, const char *to_path_list); +char * pathlist_relocation_lib(const char *from_path, const char *to_path_list); #endif /* PATHTOOLS_H */