File curl-8.7.1-fix-finding-cacert.patch of Package mingw64-curl

diff --git a/src/tool_doswin.c b/src/tool_doswin.c
index 171b063..3c940b3 100644
--- a/src/tool_doswin.c
+++ b/src/tool_doswin.c
@@ -422,6 +422,25 @@ static SANITIZEcode msdosify(char **const sanitized, const char *file_name,
 }
 #endif /* MSDOS */
 
+static char *
+get_root_path(const char *root_path, int size)
+{
+  if (GetModuleFileName(NULL, root_path, size) == 0)
+    return NULL;
+  char *p = strstr(root_path, "\\bin\\");
+  if (p)
+    *p = '\0';
+  return root_path;
+}
+
+BOOL file_exists(LPCTSTR szPath)
+{
+  DWORD dwAttrib = GetFileAttributes(szPath);
+
+  return (dwAttrib != INVALID_FILE_ATTRIBUTES && 
+         !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
+}
+
 /*
 Rename file_name if it is a reserved dos device name.
 
@@ -592,6 +611,21 @@ CURLcode FindWin32CACert(struct OperationConfig *config,
   TCHAR buf[PATH_MAX];
   TCHAR *ptr = NULL;
 
+  if (get_root_path(buf, sizeof(buf))) {
+    if (strcat_s(buf, sizeof(buf), "/etc/pki/tls/certs/") ||
+        strcat_s(buf, sizeof(buf), bundle_file))
+      return CURLE_OUT_OF_MEMORY;
+    if (file_exists(buf)) {
+      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;
+      return result;
+    }
+  }
   buf[0] = TEXT('\0');
 
   res_len = SearchPath(NULL, bundle_file, NULL, PATH_MAX, buf, &ptr);
openSUSE Build Service is sponsored by