Commit 7c037c82 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

urlmon: Don't allow direct sink callbacks when reporting data.

parent 059848c5
...@@ -915,34 +915,20 @@ static HRESULT WINAPI ProtocolSinkHandler_ReportProgress(IInternetProtocolSink * ...@@ -915,34 +915,20 @@ static HRESULT WINAPI ProtocolSinkHandler_ReportProgress(IInternetProtocolSink *
return S_OK; return S_OK;
} }
static HRESULT WINAPI ProtocolSinkHandler_ReportData(IInternetProtocolSink *iface, static HRESULT report_data(BindProtocol *This)
DWORD bscf, ULONG progress, ULONG progress_max)
{ {
BindProtocol *This = impl_from_IInternetProtocolSinkHandler(iface); DWORD bscf = This->bscf;
HRESULT hres;
TRACE("(%p)->(%x %u %u)\n", This, bscf, progress, progress_max);
This->bscf = bscf;
This->progress = progress;
This->progress_max = progress_max;
if(!This->protocol_sink)
return S_OK;
if((This->pi & PI_MIMEVERIFICATION) && !This->reported_mime) { if((This->pi & PI_MIMEVERIFICATION) && !This->reported_mime) {
BYTE buf[BUFFER_SIZE]; BYTE buf[BUFFER_SIZE];
DWORD read = 0; DWORD read = 0;
LPWSTR mime; LPWSTR mime;
HRESULT hres;
do { do {
read = 0; read = 0;
if(is_apartment_thread(This))
This->continue_call++;
hres = IInternetProtocol_Read(This->protocol, buf, hres = IInternetProtocol_Read(This->protocol, buf,
sizeof(buf)-This->buf_size, &read); sizeof(buf)-This->buf_size, &read);
if(is_apartment_thread(This))
This->continue_call--;
if(FAILED(hres) && hres != E_PENDING) if(FAILED(hres) && hres != E_PENDING)
return hres; return hres;
...@@ -995,7 +981,34 @@ static HRESULT WINAPI ProtocolSinkHandler_ReportData(IInternetProtocolSink *ifac ...@@ -995,7 +981,34 @@ static HRESULT WINAPI ProtocolSinkHandler_ReportData(IInternetProtocolSink *ifac
if(!This->protocol_sink) if(!This->protocol_sink)
return S_OK; return S_OK;
return IInternetProtocolSink_ReportData(This->protocol_sink, bscf, progress, progress_max); return IInternetProtocolSink_ReportData(This->protocol_sink, bscf, This->progress, This->progress_max);
}
static HRESULT WINAPI ProtocolSinkHandler_ReportData(IInternetProtocolSink *iface,
DWORD bscf, ULONG progress, ULONG progress_max)
{
BindProtocol *This = impl_from_IInternetProtocolSinkHandler(iface);
HRESULT hres;
TRACE("(%p)->(%x %u %u)\n", This, bscf, progress, progress_max);
This->bscf = bscf;
This->progress = progress;
This->progress_max = progress_max;
if(!This->protocol_sink)
return S_OK;
if(is_apartment_thread(This))
This->continue_call++;
hres = report_data(This);
if(is_apartment_thread(This)) {
This->continue_call--;
process_tasks(This);
}
return hres;
} }
static HRESULT handle_redirect(BindProtocol *This, const WCHAR *url) static HRESULT handle_redirect(BindProtocol *This, const WCHAR *url)
......
...@@ -161,7 +161,7 @@ static DWORD prot_read, filter_state, http_post_test, thread_id; ...@@ -161,7 +161,7 @@ static DWORD prot_read, filter_state, http_post_test, thread_id;
static BOOL security_problem, test_async_req, impl_protex; static BOOL security_problem, test_async_req, impl_protex;
static BOOL async_read_pending, mimefilter_test, direct_read, wait_for_switch, emulate_prot, short_read, test_abort; static BOOL async_read_pending, mimefilter_test, direct_read, wait_for_switch, emulate_prot, short_read, test_abort;
static BOOL empty_file, no_mime, bind_from_cache, file_with_hash, reuse_protocol_thread; static BOOL empty_file, no_mime, bind_from_cache, file_with_hash, reuse_protocol_thread;
static BOOL no_aggregation; static BOOL no_aggregation, result_from_lock;
enum { enum {
STATE_CONNECTING, STATE_CONNECTING,
...@@ -1168,6 +1168,16 @@ static HRESULT WINAPI ProtocolSink_ReportData(IInternetProtocolSink *iface, DWOR ...@@ -1168,6 +1168,16 @@ static HRESULT WINAPI ProtocolSink_ReportData(IInternetProtocolSink *iface, DWOR
} }
} }
if(result_from_lock) {
SET_EXPECT(LockRequest);
hres = IInternetProtocol_LockRequest(binding_protocol, 0);
ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
CHECK_CALLED(LockRequest);
/* ReportResult is called before ReportData returns */
SET_EXPECT(ReportResult);
}
rec_depth--; rec_depth--;
return S_OK; return S_OK;
} }
...@@ -1911,6 +1921,12 @@ static void protocol_start(IInternetProtocolSink *pOIProtSink, IInternetBindInfo ...@@ -1911,6 +1921,12 @@ static void protocol_start(IInternetProtocolSink *pOIProtSink, IInternetBindInfo
else else
CHECK_CALLED(ReportData); CHECK_CALLED(ReportData);
if(result_from_lock) {
/* set in ProtocolSink_ReportData */
CHECK_CALLED(ReportResult);
return;
}
if(tested_protocol == ITS_TEST) { if(tested_protocol == ITS_TEST) {
SET_EXPECT(ReportData); SET_EXPECT(ReportData);
hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_BEGINDOWNLOADDATA, NULL); hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_BEGINDOWNLOADDATA, NULL);
...@@ -2202,6 +2218,11 @@ static HRESULT WINAPI ProtocolEmul_LockRequest(IInternetProtocolEx *iface, DWORD ...@@ -2202,6 +2218,11 @@ static HRESULT WINAPI ProtocolEmul_LockRequest(IInternetProtocolEx *iface, DWORD
{ {
CHECK_EXPECT(LockRequest); CHECK_EXPECT(LockRequest);
ok(dwOptions == 0, "dwOptions=%x\n", dwOptions); ok(dwOptions == 0, "dwOptions=%x\n", dwOptions);
if(result_from_lock) {
HRESULT hres;
hres = IInternetProtocolSink_ReportResult(binding_sink, S_OK, ERROR_SUCCESS, NULL);
ok(hres == S_OK, "ReportResult failed: %08x, expected E_FAIL\n", hres);
}
return S_OK; return S_OK;
} }
...@@ -2688,6 +2709,7 @@ static IClassFactory mimefilter_cf = { &MimeFilterCFVtbl }; ...@@ -2688,6 +2709,7 @@ static IClassFactory mimefilter_cf = { &MimeFilterCFVtbl };
#define TEST_NOMIME 0x2000 #define TEST_NOMIME 0x2000
#define TEST_FROMCACHE 0x4000 #define TEST_FROMCACHE 0x4000
#define TEST_DISABLEAUTOREDIRECT 0x8000 #define TEST_DISABLEAUTOREDIRECT 0x8000
#define TEST_RESULTFROMLOCK 0x10000
static void register_filter(BOOL do_register) static void register_filter(BOOL do_register)
{ {
...@@ -2744,6 +2766,7 @@ static void init_test(int prot, DWORD flags) ...@@ -2744,6 +2766,7 @@ static void init_test(int prot, DWORD flags)
impl_protex = (flags & TEST_IMPLPROTEX) != 0; impl_protex = (flags & TEST_IMPLPROTEX) != 0;
empty_file = (flags & TEST_EMPTY) != 0; empty_file = (flags & TEST_EMPTY) != 0;
bind_from_cache = (flags & TEST_FROMCACHE) != 0; bind_from_cache = (flags & TEST_FROMCACHE) != 0;
result_from_lock = (flags & TEST_RESULTFROMLOCK) != 0;
file_with_hash = FALSE; file_with_hash = FALSE;
security_problem = FALSE; security_problem = FALSE;
reuse_protocol_thread = FALSE; reuse_protocol_thread = FALSE;
...@@ -4131,16 +4154,18 @@ static void test_binding(int prot, DWORD grf_pi, DWORD test_flags) ...@@ -4131,16 +4154,18 @@ static void test_binding(int prot, DWORD grf_pi, DWORD test_flags)
CHECK_CALLED(ReportData); /* Set in ReportResult */ CHECK_CALLED(ReportData); /* Set in ReportResult */
ok( WaitForSingleObject(event_complete, 90000) == WAIT_OBJECT_0, "wait timed out\n" ); ok( WaitForSingleObject(event_complete, 90000) == WAIT_OBJECT_0, "wait timed out\n" );
}else { }else {
if(mimefilter_test) if(!result_from_lock) {
SET_EXPECT(MimeFilter_LockRequest); if(mimefilter_test)
else SET_EXPECT(MimeFilter_LockRequest);
SET_EXPECT(LockRequest); else
hres = IInternetProtocol_LockRequest(protocol, 0); SET_EXPECT(LockRequest);
ok(hres == S_OK, "LockRequest failed: %08x\n", hres); hres = IInternetProtocol_LockRequest(protocol, 0);
if(mimefilter_test) ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
CHECK_CALLED(MimeFilter_LockRequest); if(mimefilter_test)
else CHECK_CALLED(MimeFilter_LockRequest);
CHECK_CALLED(LockRequest); else
CHECK_CALLED(LockRequest);
}
if(mimefilter_test) if(mimefilter_test)
SET_EXPECT(MimeFilter_UnlockRequest); SET_EXPECT(MimeFilter_UnlockRequest);
...@@ -4284,7 +4309,7 @@ START_TEST(protocol) ...@@ -4284,7 +4309,7 @@ START_TEST(protocol)
test_CreateBinding(); test_CreateBinding();
no_aggregation = FALSE; no_aggregation = FALSE;
bindf &= ~BINDF_FROMURLMON; bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_NOWRITECACHE | BINDF_PULLDATA;
trace("Testing file binding (mime verification, emulate prot)...\n"); trace("Testing file binding (mime verification, emulate prot)...\n");
test_binding(FILE_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT); test_binding(FILE_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT);
trace("Testing http binding (mime verification, emulate prot)...\n"); trace("Testing http binding (mime verification, emulate prot)...\n");
...@@ -4307,6 +4332,8 @@ START_TEST(protocol) ...@@ -4307,6 +4332,8 @@ START_TEST(protocol)
test_binding(HTTP_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_DIRECT_READ); test_binding(HTTP_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_DIRECT_READ);
trace("Testing http binding (mime verification, emulate prot, abort)...\n"); trace("Testing http binding (mime verification, emulate prot, abort)...\n");
test_binding(HTTP_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_ABORT); test_binding(HTTP_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_ABORT);
trace("Testing its binding (mime verification, emulate prot, apartment thread)...\n");
test_binding(ITS_TEST, PI_MIMEVERIFICATION | PI_APARTMENTTHREADED, TEST_EMULATEPROT | TEST_RESULTFROMLOCK);
if(pCreateUri) { if(pCreateUri) {
trace("Testing file binding (use IUri, mime verification, emulate prot)...\n"); trace("Testing file binding (use IUri, mime verification, emulate prot)...\n");
test_binding(FILE_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_USEIURI); test_binding(FILE_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_USEIURI);
......
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