summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMarcel Raad <Marcel.Raad@teamviewer.com>2020-07-23 21:28:14 +0200
committerMarcel Raad <Marcel.Raad@teamviewer.com>2020-07-27 10:42:38 +0200
commit0c6112a139c1133f7bdfc440903c0e5602c84d90 (patch)
tree3e7229f7e175db8c3a2bfea45cad93c38ed9e1b3 /lib
parent8829703b5a8d595457f3f4954cf09e6d6bae1523 (diff)
downloadcurl-0c6112a139c1133f7bdfc440903c0e5602c84d90.tar.gz
WIN32: stop forcing narrow-character API
Except where the results are only used for character output. getenv is not touched because it's part of the public API, and having it return UTF-8 instead of ANSI would be a breaking change. Fixes https://github.com/curl/curl/issues/5658 Fixes https://github.com/curl/curl/issues/5712 Closes https://github.com/curl/curl/pull/5718
Diffstat (limited to 'lib')
-rw-r--r--lib/rename.c15
-rw-r--r--lib/vtls/openssl.c3
-rw-r--r--lib/vtls/schannel.c2
3 files changed, 15 insertions, 5 deletions
diff --git a/lib/rename.c b/lib/rename.c
index bb170d3cc..fe5f95d0d 100644
--- a/lib/rename.c
+++ b/lib/rename.c
@@ -27,6 +27,7 @@
#if (!defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)) || \
defined(USE_ALTSVC)
+#include "curl_multibyte.h"
#include "timeval.h"
/* The last 3 #include files should be in this order */
@@ -39,17 +40,25 @@ int Curl_rename(const char *oldpath, const char *newpath)
{
#ifdef WIN32
/* rename() on Windows doesn't overwrite, so we can't use it here.
- MoveFileExA() will overwrite and is usually atomic, however it fails
+ MoveFileEx() will overwrite and is usually atomic, however it fails
when there are open handles to the file. */
const int max_wait_ms = 1000;
struct curltime start = Curl_now();
+ TCHAR *tchar_oldpath = curlx_convert_UTF8_to_tchar((char *)oldpath);
+ TCHAR *tchar_newpath = curlx_convert_UTF8_to_tchar((char *)newpath);
for(;;) {
timediff_t diff;
- if(MoveFileExA(oldpath, newpath, MOVEFILE_REPLACE_EXISTING))
+ if(MoveFileEx(tchar_oldpath, tchar_newpath, MOVEFILE_REPLACE_EXISTING)) {
+ curlx_unicodefree(tchar_oldpath);
+ curlx_unicodefree(tchar_newpath);
break;
+ }
diff = Curl_timediff(Curl_now(), start);
- if(diff < 0 || diff > max_wait_ms)
+ if(diff < 0 || diff > max_wait_ms) {
+ curlx_unicodefree(tchar_oldpath);
+ curlx_unicodefree(tchar_newpath);
return 1;
+ }
Sleep(1);
}
#else
diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c
index 2e9f900da..cc18b8c81 100644
--- a/lib/vtls/openssl.c
+++ b/lib/vtls/openssl.c
@@ -2825,7 +2825,8 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
if((SSL_CONN_CONFIG(verifypeer) || SSL_CONN_CONFIG(verifyhost)) &&
(SSL_SET_OPTION(native_ca_store))) {
X509_STORE *store = SSL_CTX_get_cert_store(backend->ctx);
- HCERTSTORE hStore = CertOpenSystemStoreA((HCRYPTPROV_LEGACY)NULL, "ROOT");
+ HCERTSTORE hStore = CertOpenSystemStore((HCRYPTPROV_LEGACY)NULL,
+ TEXT("ROOT"));
if(hStore) {
PCCERT_CONTEXT pContext = NULL;
diff --git a/lib/vtls/schannel.c b/lib/vtls/schannel.c
index 199652606..c685de2e1 100644
--- a/lib/vtls/schannel.c
+++ b/lib/vtls/schannel.c
@@ -448,7 +448,7 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
/* ALPN is only supported on Windows 8.1 / Server 2012 R2 and above.
Also it doesn't seem to be supported for Wine, see curl bug #983. */
BACKEND->use_alpn = conn->bits.tls_enable_alpn &&
- !GetProcAddress(GetModuleHandleA("ntdll"),
+ !GetProcAddress(GetModuleHandle(TEXT("ntdll")),
"wine_get_version") &&
Curl_verify_windows_version(6, 3, PLATFORM_WINNT,
VERSION_GREATER_THAN_EQUAL);