mirror of
https://github.com/reactos/reactos.git
synced 2024-08-12 06:06:27 +00:00
Sync to Wine-0_9_4:
Thomas Weidenmueller <wine-patches@reactsoft.com> - urlmon: Correctly fix IStream::Read. Don't dereference a possible NULL pointer. - urlmon: Fix call to ReadFile. The BytesRead parameter passed to ReadFile may never be NULL. Jacek Caban <jacek@codeweavers.com> - urlmon: Added handling of BINDF_FROMURLMON in file protocol. - urlmon: Added some tests and fixes of file protocol. - urlmon: Fix BindToStorage test. svn path=/trunk/; revision=20355
This commit is contained in:
parent
d852648be4
commit
bb28b4d54c
|
@ -401,7 +401,7 @@ static HRESULT get_callback(IBindCtx *pbc, IBindStatusCallback **callback)
|
|||
|
||||
hres = IBindCtx_GetObjectParam(pbc, wszBSCBHolder, (IUnknown**)callback);
|
||||
if(FAILED(hres))
|
||||
return INET_E_DATA_NOT_AVAILABLE;
|
||||
return MK_E_SYNTAX;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
|
|
@ -110,7 +110,9 @@ static HRESULT WINAPI FileProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl
|
|||
LARGE_INTEGER size;
|
||||
DWORD len;
|
||||
LPWSTR url, mime = NULL;
|
||||
LPCWSTR file_name;
|
||||
WCHAR null_char = 0;
|
||||
BOOL first_call = FALSE;
|
||||
HRESULT hres;
|
||||
|
||||
static const WCHAR wszFile[] = {'f','i','l','e',':'};
|
||||
|
@ -134,33 +136,42 @@ static HRESULT WINAPI FileProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl
|
|||
return hres;
|
||||
}
|
||||
|
||||
hres = FindMimeFromData(NULL, url, NULL, 0, NULL, 0, &mime, 0);
|
||||
if(SUCCEEDED(hres))
|
||||
IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_DIRECTBIND, mime);
|
||||
if(!(grfBINDF & BINDF_FROMURLMON))
|
||||
IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_DIRECTBIND, NULL);
|
||||
|
||||
if(!This->file) {
|
||||
first_call = TRUE;
|
||||
|
||||
IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_SENDINGREQUEST, &null_char);
|
||||
|
||||
This->file = CreateFileW(url+sizeof(wszFile)/sizeof(WCHAR), GENERIC_READ, FILE_SHARE_READ,
|
||||
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
file_name = url+sizeof(wszFile)/sizeof(WCHAR);
|
||||
if(file_name[0] == '/' && file_name[1] == '/' && file_name[2] == '/')
|
||||
file_name += 3;
|
||||
|
||||
This->file = CreateFileW(file_name, GENERIC_READ, FILE_SHARE_READ, NULL,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
|
||||
if(This->file == INVALID_HANDLE_VALUE) {
|
||||
This->file = NULL;
|
||||
IInternetProtocolSink_ReportResult(pOIProtSink, INET_E_RESOURCE_NOT_FOUND,
|
||||
GetLastError(), NULL);
|
||||
HeapFree(GetProcessHeap(), 0, url);
|
||||
CoTaskMemFree(mime);
|
||||
return INET_E_RESOURCE_NOT_FOUND;
|
||||
}
|
||||
|
||||
IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_CACHEFILENAMEAVAILABLE,
|
||||
url+sizeof(wszFile)/sizeof(WCHAR));
|
||||
if(mime)
|
||||
IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_MIMETYPEAVAILABLE, mime);
|
||||
IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
|
||||
IInternetProtocolSink_ReportProgress(pOIProtSink,
|
||||
BINDSTATUS_CACHEFILENAMEAVAILABLE, file_name);
|
||||
|
||||
hres = FindMimeFromData(NULL, url, NULL, 0, NULL, 0, &mime, 0);
|
||||
if(SUCCEEDED(hres)) {
|
||||
IInternetProtocolSink_ReportProgress(pOIProtSink,
|
||||
(grfBINDF & BINDF_FROMURLMON) ?
|
||||
BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE : BINDSTATUS_MIMETYPEAVAILABLE,
|
||||
mime);
|
||||
CoTaskMemFree(mime);
|
||||
}
|
||||
}
|
||||
|
||||
CoTaskMemFree(mime);
|
||||
HeapFree(GetProcessHeap(), 0, url);
|
||||
|
||||
if(GetFileSizeEx(This->file, &size))
|
||||
|
@ -168,6 +179,9 @@ static HRESULT WINAPI FileProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl
|
|||
BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION,
|
||||
size.u.LowPart, size.u.LowPart);
|
||||
|
||||
if(first_call)
|
||||
IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -225,6 +225,7 @@ static HRESULT WINAPI IStream_fnRead (IStream * iface,
|
|||
ULONG cb,
|
||||
ULONG* pcbRead)
|
||||
{
|
||||
ULONG dwBytesRead;
|
||||
IUMCacheStream *This = (IUMCacheStream *)iface;
|
||||
|
||||
TRACE("(%p)->(%p,0x%08lx,%p)\n",This, pv, cb, pcbRead);
|
||||
|
@ -232,7 +233,10 @@ static HRESULT WINAPI IStream_fnRead (IStream * iface,
|
|||
if ( !pv )
|
||||
return STG_E_INVALIDPOINTER;
|
||||
|
||||
if ( ! ReadFile( This->handle, pv, cb, pcbRead, NULL ) )
|
||||
if ( !pcbRead)
|
||||
pcbRead = &dwBytesRead;
|
||||
|
||||
if ( ! ReadFile( This->handle, pv, cb, (LPDWORD)pcbRead, NULL ) )
|
||||
return S_FALSE;
|
||||
|
||||
if (!*pcbRead)
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue