69 lines
2.1 KiB
Diff
69 lines
2.1 KiB
Diff
diff --git "a/D:\\_Sandbox\\curl\\curl-src\\src\\tool_doswin.c.orig" "b/D:\\_Sandbox\\curl\\curl-src\\src\\tool_doswin.c"
|
|
index 98e13bc..9f83c16 100644
|
|
--- "a/src/tool_doswin.c"
|
|
+++ "b/src/tool_doswin.c"
|
|
@@ -612,6 +612,37 @@ char **__crt0_glob_function(char *arg)
|
|
* 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)
|
|
@@ -627,22 +658,10 @@ CURLcode FindWin32CACert(struct OperationConfig *config,
|
|
if((curlinfo->features & CURL_VERSION_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 *cacert = execpath(bundle_file);
|
|
+ if (cacert) {
|
|
Curl_safefree(config->cacert);
|
|
-#ifdef UNICODE
|
|
- config->cacert = curlx_convert_wchar_to_UTF8(buf);
|
|
-#else
|
|
- config->cacert = strdup(buf);
|
|
-#endif
|
|
- if(!config->cacert)
|
|
- result = CURLE_OUT_OF_MEMORY;
|
|
+ config->cacert = cacert;
|
|
}
|
|
}
|
|
|