Commit 03bbb464 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

Don't try reading a PIDL in IPersistStream->Load if its size is 0.

Check the number of bytes read was correct. Small reorganization of error handling.
parent 9e4c409b
...@@ -870,17 +870,30 @@ static HRESULT WINAPI IPersistStream_fnLoad( ...@@ -870,17 +870,30 @@ static HRESULT WINAPI IPersistStream_fnLoad(
} }
IStream_AddRef (pLoadStream); IStream_AddRef (pLoadStream);
if(lpLinkHeader) if(!lpLinkHeader)
{ goto end;
if (SUCCEEDED(IStream_Read(pLoadStream, lpLinkHeader, LINK_HEADER_SIZE, &dwBytesRead)))
{ dwBytesRead = 0;
if ((lpLinkHeader->MagicStr == 0x0000004CL) && IsEqualIID(&lpLinkHeader->MagicGuid, &CLSID_ShellLink)) if (!(SUCCEEDED(IStream_Read(pLoadStream, lpLinkHeader, LINK_HEADER_SIZE, &dwBytesRead))))
goto end;
if (dwBytesRead != LINK_HEADER_SIZE)
goto end;
if ( (lpLinkHeader->MagicStr != 0x0000004CL) || !IsEqualIID(&lpLinkHeader->MagicGuid, &CLSID_ShellLink) )
goto end;
if(lpLinkHeader->PidlSize)
{ {
lpLinkHeader = HeapReAlloc(GetProcessHeap(), 0, lpLinkHeader, LINK_HEADER_SIZE+lpLinkHeader->PidlSize); lpLinkHeader = HeapReAlloc(GetProcessHeap(), 0, lpLinkHeader, LINK_HEADER_SIZE+lpLinkHeader->PidlSize);
if (lpLinkHeader) if (!lpLinkHeader)
{ goto end;
if (SUCCEEDED(IStream_Read(pLoadStream, &(lpLinkHeader->Pidl), lpLinkHeader->PidlSize, &dwBytesRead))) dwBytesRead = 0;
{ if (!(SUCCEEDED(IStream_Read(pLoadStream, &(lpLinkHeader->Pidl), lpLinkHeader->PidlSize, &dwBytesRead))))
goto end;
if(dwBytesRead != lpLinkHeader->PidlSize)
goto end;
if (pcheck (&lpLinkHeader->Pidl)) if (pcheck (&lpLinkHeader->Pidl))
{ {
This->pPidl = ILClone (&lpLinkHeader->Pidl); This->pPidl = ILClone (&lpLinkHeader->Pidl);
...@@ -888,6 +901,7 @@ static HRESULT WINAPI IPersistStream_fnLoad( ...@@ -888,6 +901,7 @@ static HRESULT WINAPI IPersistStream_fnLoad(
SHGetPathFromIDListA(&lpLinkHeader->Pidl, sTemp); SHGetPathFromIDListA(&lpLinkHeader->Pidl, sTemp);
This->sPath = heap_strdup( sTemp ); This->sPath = heap_strdup( sTemp );
} }
}
This->wHotKey = lpLinkHeader->wHotKey; This->wHotKey = lpLinkHeader->wHotKey;
FileTimeToSystemTime (&lpLinkHeader->Time1, &This->time1); FileTimeToSystemTime (&lpLinkHeader->Time1, &This->time1);
FileTimeToSystemTime (&lpLinkHeader->Time2, &This->time2); FileTimeToSystemTime (&lpLinkHeader->Time2, &This->time2);
...@@ -902,16 +916,8 @@ static HRESULT WINAPI IPersistStream_fnLoad( ...@@ -902,16 +916,8 @@ static HRESULT WINAPI IPersistStream_fnLoad(
pdump (This->pPidl); pdump (This->pPidl);
#endif #endif
ret = S_OK; ret = S_OK;
}
}
}
else
{
WARN("stream contains no link!\n");
}
}
}
end:
IStream_Release (pLoadStream); IStream_Release (pLoadStream);
pdump(This->pPidl); pdump(This->pPidl);
......
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