Commit 3098e3c3 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

wininet: Address string should never be converted to UNICODE in status notifications.

parent 2544999e
...@@ -115,10 +115,19 @@ static void WINAPI internet_status_callback(HINTERNET internet, DWORD_PTR contex ...@@ -115,10 +115,19 @@ static void WINAPI internet_status_callback(HINTERNET internet, DWORD_PTR contex
report_progress(protocol, BINDSTATUS_FINDINGRESOURCE, (LPWSTR)status_info); report_progress(protocol, BINDSTATUS_FINDINGRESOURCE, (LPWSTR)status_info);
break; break;
case INTERNET_STATUS_CONNECTING_TO_SERVER: case INTERNET_STATUS_CONNECTING_TO_SERVER: {
TRACE("%p INTERNET_STATUS_CONNECTING_TO_SERVER\n", protocol); WCHAR *info;
report_progress(protocol, BINDSTATUS_CONNECTING, (LPWSTR)status_info);
TRACE("%p INTERNET_STATUS_CONNECTING_TO_SERVER %s\n", protocol, (const char*)status_info);
info = heap_strdupAtoW(status_info);
if(!info)
return;
report_progress(protocol, BINDSTATUS_CONNECTING, info);
heap_free(info);
break; break;
}
case INTERNET_STATUS_SENDING_REQUEST: case INTERNET_STATUS_SENDING_REQUEST:
TRACE("%p INTERNET_STATUS_SENDING_REQUEST\n", protocol); TRACE("%p INTERNET_STATUS_SENDING_REQUEST\n", protocol);
......
...@@ -159,6 +159,7 @@ static const test_data_t test_data[] = { ...@@ -159,6 +159,7 @@ static const test_data_t test_data[] = {
}; };
static INTERNET_STATUS_CALLBACK (WINAPI *pInternetSetStatusCallbackA)(HINTERNET ,INTERNET_STATUS_CALLBACK); static INTERNET_STATUS_CALLBACK (WINAPI *pInternetSetStatusCallbackA)(HINTERNET ,INTERNET_STATUS_CALLBACK);
static INTERNET_STATUS_CALLBACK (WINAPI *pInternetSetStatusCallbackW)(HINTERNET ,INTERNET_STATUS_CALLBACK);
static BOOL (WINAPI *pInternetGetSecurityInfoByURLA)(LPSTR,PCCERT_CHAIN_CONTEXT*,DWORD*); static BOOL (WINAPI *pInternetGetSecurityInfoByURLA)(LPSTR,PCCERT_CHAIN_CONTEXT*,DWORD*);
static int strcmp_wa(LPCWSTR strw, const char *stra) static int strcmp_wa(LPCWSTR strw, const char *stra)
...@@ -321,12 +322,16 @@ static VOID WINAPI callback( ...@@ -321,12 +322,16 @@ static VOID WINAPI callback(
trace("%04x:Callback %p 0x%lx INTERNET_STATUS_CONNECTING_TO_SERVER \"%s\" %d\n", trace("%04x:Callback %p 0x%lx INTERNET_STATUS_CONNECTING_TO_SERVER \"%s\" %d\n",
GetCurrentThreadId(), hInternet, dwContext, GetCurrentThreadId(), hInternet, dwContext,
(LPCSTR)lpvStatusInformation,dwStatusInformationLength); (LPCSTR)lpvStatusInformation,dwStatusInformationLength);
ok(dwStatusInformationLength == strlen(lpvStatusInformation)+1, "unexpected size %u\n",
dwStatusInformationLength);
*(LPSTR)lpvStatusInformation = '\0'; *(LPSTR)lpvStatusInformation = '\0';
break; break;
case INTERNET_STATUS_CONNECTED_TO_SERVER: case INTERNET_STATUS_CONNECTED_TO_SERVER:
trace("%04x:Callback %p 0x%lx INTERNET_STATUS_CONNECTED_TO_SERVER \"%s\" %d\n", trace("%04x:Callback %p 0x%lx INTERNET_STATUS_CONNECTED_TO_SERVER \"%s\" %d\n",
GetCurrentThreadId(), hInternet, dwContext, GetCurrentThreadId(), hInternet, dwContext,
(LPCSTR)lpvStatusInformation,dwStatusInformationLength); (LPCSTR)lpvStatusInformation,dwStatusInformationLength);
ok(dwStatusInformationLength == strlen(lpvStatusInformation)+1, "unexpected size %u\n",
dwStatusInformationLength);
*(LPSTR)lpvStatusInformation = '\0'; *(LPSTR)lpvStatusInformation = '\0';
break; break;
case INTERNET_STATUS_SENDING_REQUEST: case INTERNET_STATUS_SENDING_REQUEST:
...@@ -3595,19 +3600,27 @@ static void WINAPI cb(HINTERNET handle, DWORD_PTR context, DWORD status, LPVOID ...@@ -3595,19 +3600,27 @@ static void WINAPI cb(HINTERNET handle, DWORD_PTR context, DWORD status, LPVOID
trace("%p 0x%08lx %u %p 0x%08x\n", handle, context, status, info, size); trace("%p 0x%08lx %u %p 0x%08x\n", handle, context, status, info, size);
if (status == INTERNET_STATUS_REQUEST_COMPLETE) switch(status) {
{ case INTERNET_STATUS_REQUEST_COMPLETE:
trace("request handle: 0x%08lx\n", result->dwResult); trace("request handle: 0x%08lx\n", result->dwResult);
ctx->req = (HINTERNET)result->dwResult; ctx->req = (HINTERNET)result->dwResult;
SetEvent(ctx->event); SetEvent(ctx->event);
} break;
if (status == INTERNET_STATUS_HANDLE_CLOSING) case INTERNET_STATUS_HANDLE_CLOSING: {
{
DWORD type = INTERNET_HANDLE_TYPE_CONNECT_HTTP, size = sizeof(type); DWORD type = INTERNET_HANDLE_TYPE_CONNECT_HTTP, size = sizeof(type);
if (InternetQueryOption(handle, INTERNET_OPTION_HANDLE_TYPE, &type, &size)) if (InternetQueryOption(handle, INTERNET_OPTION_HANDLE_TYPE, &type, &size))
ok(type != INTERNET_HANDLE_TYPE_CONNECT_HTTP, "unexpected callback\n"); ok(type != INTERNET_HANDLE_TYPE_CONNECT_HTTP, "unexpected callback\n");
SetEvent(ctx->event); SetEvent(ctx->event);
break;
}
case INTERNET_STATUS_NAME_RESOLVED:
case INTERNET_STATUS_CONNECTING_TO_SERVER:
case INTERNET_STATUS_CONNECTED_TO_SERVER: {
char *str = info;
ok(str[0] && str[1], "Got string: %s\n", str);
ok(size == strlen(str)+1, "unexpected size %u\n", size);
}
} }
} }
...@@ -3619,6 +3632,10 @@ static void test_open_url_async(void) ...@@ -3619,6 +3632,10 @@ static void test_open_url_async(void)
struct context ctx; struct context ctx;
ULONG type; ULONG type;
/* Collect all existing persistent connections */
ret = InternetSetOptionA(NULL, INTERNET_OPTION_SETTINGS_CHANGED, NULL, 0);
ok(ret, "InternetSetOption(INTERNET_OPTION_END_BROWSER_SESSION) failed: %u\n", GetLastError());
ctx.req = NULL; ctx.req = NULL;
ctx.event = CreateEvent(NULL, TRUE, FALSE, "Z:_home_hans_jaman-installer.exe_ev1"); ctx.event = CreateEvent(NULL, TRUE, FALSE, "Z:_home_hans_jaman-installer.exe_ev1");
...@@ -3636,7 +3653,7 @@ static void test_open_url_async(void) ...@@ -3636,7 +3653,7 @@ static void test_open_url_async(void)
ok(!ret, "InternetSetOptionA failed\n"); ok(!ret, "InternetSetOptionA failed\n");
ok(error == ERROR_INTERNET_OPTION_NOT_SETTABLE, "got %u expected ERROR_INTERNET_OPTION_NOT_SETTABLE\n", error); ok(error == ERROR_INTERNET_OPTION_NOT_SETTABLE, "got %u expected ERROR_INTERNET_OPTION_NOT_SETTABLE\n", error);
pInternetSetStatusCallbackA(ses, cb); pInternetSetStatusCallbackW(ses, cb);
ResetEvent(ctx.event); ResetEvent(ctx.event);
req = InternetOpenUrl(ses, "http://test.winehq.org", NULL, 0, 0, (DWORD_PTR)&ctx); req = InternetOpenUrl(ses, "http://test.winehq.org", NULL, 0, 0, (DWORD_PTR)&ctx);
...@@ -4123,6 +4140,7 @@ START_TEST(http) ...@@ -4123,6 +4140,7 @@ START_TEST(http)
} }
pInternetSetStatusCallbackA = (void*)GetProcAddress(hdll, "InternetSetStatusCallbackA"); pInternetSetStatusCallbackA = (void*)GetProcAddress(hdll, "InternetSetStatusCallbackA");
pInternetSetStatusCallbackW = (void*)GetProcAddress(hdll, "InternetSetStatusCallbackW");
pInternetGetSecurityInfoByURLA = (void*)GetProcAddress(hdll, "InternetGetSecurityInfoByURLA"); pInternetGetSecurityInfoByURLA = (void*)GetProcAddress(hdll, "InternetGetSecurityInfoByURLA");
init_status_tests(); init_status_tests();
......
...@@ -298,62 +298,48 @@ static const char *debugstr_status_info(DWORD status, void *info) ...@@ -298,62 +298,48 @@ static const char *debugstr_status_info(DWORD status, void *info)
} }
} }
VOID INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR dwContext, void INTERNET_SendCallback(object_header_t *hdr, DWORD_PTR context, DWORD status, void *info, DWORD info_len)
DWORD dwInternetStatus, LPVOID lpvStatusInfo,
DWORD dwStatusInfoLength)
{ {
LPVOID lpvNewInfo = NULL; void *new_info = info;
if( !hdr->lpfnStatusCB ) if( !hdr->lpfnStatusCB )
return; return;
/* the IE5 version of wininet does not /* the IE5 version of wininet does not
send callbacks if dwContext is zero */ send callbacks if dwContext is zero */
if( !dwContext ) if(!context)
return; return;
lpvNewInfo = lpvStatusInfo; switch(status) {
if(hdr->dwInternalFlags & INET_CALLBACKW) { case INTERNET_STATUS_NAME_RESOLVED:
switch(dwInternetStatus) { case INTERNET_STATUS_CONNECTING_TO_SERVER:
case INTERNET_STATUS_NAME_RESOLVED: case INTERNET_STATUS_CONNECTED_TO_SERVER:
case INTERNET_STATUS_CONNECTING_TO_SERVER: new_info = heap_alloc(info_len);
case INTERNET_STATUS_CONNECTED_TO_SERVER: if(new_info)
lpvNewInfo = heap_strdupAtoW(lpvStatusInfo); memcpy(new_info, info, info_len);
dwStatusInfoLength *= sizeof(WCHAR); break;
break; case INTERNET_STATUS_RESOLVING_NAME:
case INTERNET_STATUS_RESOLVING_NAME: case INTERNET_STATUS_REDIRECT:
case INTERNET_STATUS_REDIRECT: if(hdr->dwInternalFlags & INET_CALLBACKW) {
lpvNewInfo = heap_strdupW(lpvStatusInfo); new_info = heap_strdupW(info);
break;
}
}else {
switch(dwInternetStatus)
{
case INTERNET_STATUS_NAME_RESOLVED:
case INTERNET_STATUS_CONNECTING_TO_SERVER:
case INTERNET_STATUS_CONNECTED_TO_SERVER:
lpvNewInfo = heap_alloc(strlen(lpvStatusInfo) + 1);
if (lpvNewInfo) strcpy(lpvNewInfo, lpvStatusInfo);
break; break;
case INTERNET_STATUS_RESOLVING_NAME: }else {
case INTERNET_STATUS_REDIRECT: new_info = heap_strdupWtoA(info);
lpvNewInfo = heap_strdupWtoA(lpvStatusInfo); info_len = strlen(new_info)+1;
dwStatusInfoLength /= sizeof(WCHAR);
break; break;
} }
} }
TRACE(" callback(%p) (%p (%p), %08lx, %d (%s), %s, %d)\n", TRACE(" callback(%p) (%p (%p), %08lx, %d (%s), %s, %d)\n",
hdr->lpfnStatusCB, hdr->hInternet, hdr, dwContext, dwInternetStatus, get_callback_name(dwInternetStatus), hdr->lpfnStatusCB, hdr->hInternet, hdr, context, status, get_callback_name(status),
debugstr_status_info(dwInternetStatus, lpvNewInfo), dwStatusInfoLength); debugstr_status_info(status, new_info), info_len);
hdr->lpfnStatusCB(hdr->hInternet, dwContext, dwInternetStatus, hdr->lpfnStatusCB(hdr->hInternet, context, status, new_info, info_len);
lpvNewInfo, dwStatusInfoLength);
TRACE(" end callback().\n"); TRACE(" end callback().\n");
if(lpvNewInfo != lpvStatusInfo) if(new_info != info)
heap_free(lpvNewInfo); heap_free(new_info);
} }
typedef struct { typedef struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment