From 46480bb9a1569eaf156012f33e3e7e8c3de18f87 Mon Sep 17 00:00:00 2001 From: Mark Salisbury Date: Fri, 15 Jun 2012 18:05:11 +0200 Subject: SSPI related code: Unicode support for WinCE SSPI related code now compiles with ANSI and WCHAR versions of security methods (WinCE requires WCHAR versions of methods). Pulled UTF8 to WCHAR conversion methods out of idn_win32.c into their own file. curl_sasl.c - include curl_memory.h to use correct memory functions. getenv.c and telnet.c - WinCE compatibility fix With some committer adjustments --- lib/curl_ntlm_msgs.c | 61 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 26 deletions(-) (limited to 'lib/curl_ntlm_msgs.c') diff --git a/lib/curl_ntlm_msgs.c b/lib/curl_ntlm_msgs.c index 5789a24c7..0fd34cb80 100644 --- a/lib/curl_ntlm_msgs.c +++ b/lib/curl_ntlm_msgs.c @@ -89,6 +89,7 @@ #include "curl_base64.h" #include "curl_ntlm_core.h" #include "curl_gethostname.h" +#include "curl_multibyte.h" #include "curl_memory.h" #define BUILDING_CURL_NTLM_MSGS_C @@ -394,7 +395,6 @@ CURLcode Curl_ntlm_create_type1_message(const char *userp, SecBufferDesc desc; SECURITY_STATUS status; ULONG attrs; - const char *dest = ""; const char *user; const char *domain = ""; size_t userlen = 0; @@ -431,12 +431,22 @@ CURLcode Curl_ntlm_create_type1_message(const char *userp, */ ntlm->p_identity = &ntlm->identity; memset(ntlm->p_identity, 0, sizeof(*ntlm->p_identity)); +#ifdef UNICODE + if((ntlm->identity.User = Curl_convert_UTF8_to_wchar(user)) == NULL) + return CURLE_OUT_OF_MEMORY; +#else if((ntlm->identity.User = (unsigned char *)strdup(user)) == NULL) return CURLE_OUT_OF_MEMORY; +#endif ntlm->identity.UserLength = (unsigned long)userlen; +#ifdef UNICODE + if((ntlm->identity.Password = Curl_convert_UTF8_to_wchar(passwdp)) == NULL) + return CURLE_OUT_OF_MEMORY; +#else if((ntlm->identity.Password = (unsigned char *)strdup(passwdp)) == NULL) return CURLE_OUT_OF_MEMORY; +#endif ntlm->identity.PasswordLength = (unsigned long)passwdlen; if((ntlm->identity.Domain = malloc(domlen + 1)) == NULL) @@ -450,10 +460,10 @@ CURLcode Curl_ntlm_create_type1_message(const char *userp, else ntlm->p_identity = NULL; - status = s_pSecFn->AcquireCredentialsHandleA(NULL, (void *)"NTLM", - SECPKG_CRED_OUTBOUND, NULL, - ntlm->p_identity, NULL, NULL, - &ntlm->handle, &tsDummy); + status = s_pSecFn->AcquireCredentialsHandle(NULL, TEXT("NTLM"), + SECPKG_CRED_OUTBOUND, NULL, + ntlm->p_identity, NULL, NULL, + &ntlm->handle, &tsDummy); if(status != SEC_E_OK) return CURLE_OUT_OF_MEMORY; @@ -464,15 +474,15 @@ CURLcode Curl_ntlm_create_type1_message(const char *userp, buf.BufferType = SECBUFFER_TOKEN; buf.pvBuffer = ntlmbuf; - status = s_pSecFn->InitializeSecurityContextA(&ntlm->handle, NULL, - (void *)dest, - ISC_REQ_CONFIDENTIALITY | - ISC_REQ_REPLAY_DETECT | - ISC_REQ_CONNECTION, - 0, SECURITY_NETWORK_DREP, - NULL, 0, - &ntlm->c_handle, &desc, - &attrs, &tsDummy); + status = s_pSecFn->InitializeSecurityContext(&ntlm->handle, NULL, + TEXT(""), + ISC_REQ_CONFIDENTIALITY | + ISC_REQ_REPLAY_DETECT | + ISC_REQ_CONNECTION, + 0, SECURITY_NETWORK_DREP, + NULL, 0, + &ntlm->c_handle, &desc, + &attrs, &tsDummy); if(status == SEC_I_COMPLETE_AND_CONTINUE || status == SEC_I_CONTINUE_NEEDED) @@ -615,7 +625,6 @@ CURLcode Curl_ntlm_create_type3_message(struct SessionHandle *data, size_t size; #ifdef USE_WINDOWS_SSPI - const char *dest = ""; SecBuffer type_2; SecBuffer type_3; SecBufferDesc type_2_desc; @@ -640,17 +649,17 @@ CURLcode Curl_ntlm_create_type3_message(struct SessionHandle *data, type_3.pvBuffer = ntlmbuf; type_3.cbBuffer = NTLM_BUFSIZE; - status = s_pSecFn->InitializeSecurityContextA(&ntlm->handle, - &ntlm->c_handle, - (void *)dest, - ISC_REQ_CONFIDENTIALITY | - ISC_REQ_REPLAY_DETECT | - ISC_REQ_CONNECTION, - 0, SECURITY_NETWORK_DREP, - &type_2_desc, - 0, &ntlm->c_handle, - &type_3_desc, - &attrs, &tsDummy); + status = s_pSecFn->InitializeSecurityContext(&ntlm->handle, + &ntlm->c_handle, + TEXT(""), + ISC_REQ_CONFIDENTIALITY | + ISC_REQ_REPLAY_DETECT | + ISC_REQ_CONNECTION, + 0, SECURITY_NETWORK_DREP, + &type_2_desc, + 0, &ntlm->c_handle, + &type_3_desc, + &attrs, &tsDummy); if(status != SEC_E_OK) return CURLE_RECV_ERROR; -- cgit v1.2.3