Module: wine Branch: master Commit: b1ee49a74d80c86feb44382e3a54c139ca2e9ecc URL: http://source.winehq.org/git/wine.git/?a=commit;h=b1ee49a74d80c86feb44382e3a...
Author: Rob Shearman rob@codeweavers.com Date: Tue Jan 9 17:17:52 2007 +0000
ole32: ReadClassStm should return STG_E_READFAULT is not all of the data could be read, not S_FALSE.
Clear pclsid in case of errors. Add tests for ReadClassStm.
---
dlls/ole32/storage32.c | 5 ++++- dlls/ole32/tests/storage32.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletions(-)
diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c index 450d5cd..c575ce5 100644 --- a/dlls/ole32/storage32.c +++ b/dlls/ole32/storage32.c @@ -7930,13 +7930,16 @@ HRESULT WINAPI ReadClassStm(IStream *pSt if (!pStm || !pclsid) return E_INVALIDARG;
+ /* clear the output args */ + memcpy(pclsid, &CLSID_NULL, sizeof(*pclsid)); + res = IStream_Read(pStm,(void*)pclsid,sizeof(CLSID),&nbByte);
if (FAILED(res)) return res;
if (nbByte != sizeof(CLSID)) - return S_FALSE; + return STG_E_READFAULT; else return S_OK; } diff --git a/dlls/ole32/tests/storage32.c b/dlls/ole32/tests/storage32.c index 80b6cb0..663bc30 100644 --- a/dlls/ole32/tests/storage32.c +++ b/dlls/ole32/tests/storage32.c @@ -31,6 +31,8 @@
DEFINE_GUID( test_stg_cls, 0x88888888, 0x0425, 0x0000, 0,0,0,0,0,0,0,0);
+#define ok_ole_success(hr, func) ok(hr == S_OK, func " failed with error 0x%08x\n", hr) + static void test_hglobal_storage_stat(void) { ILockBytes *ilb = NULL; @@ -913,6 +915,36 @@ static void test_transact(void) ok( r == TRUE, "deleted file\n"); }
+static void test_ReadClassStm(void) +{ + CLSID clsid; + HRESULT hr; + IStream *pStream; + static const LARGE_INTEGER llZero; + + hr = ReadClassStm(NULL, &clsid); + ok(hr == E_INVALIDARG, "ReadClassStm should have returned E_INVALIDARG instead of 0x%08x\n", hr); + + hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream); + ok_ole_success(hr, "CreateStreamOnHGlobal"); + hr = WriteClassStm(pStream, &test_stg_cls); + ok_ole_success(hr, "WriteClassStm"); + + hr = ReadClassStm(pStream, NULL); + ok(hr == E_INVALIDARG, "ReadClassStm should have returned E_INVALIDARG instead of 0x%08x\n", hr); + + /* test not rewound stream */ + hr = ReadClassStm(pStream, &clsid); + ok(hr == STG_E_READFAULT, "ReadClassStm should have returned STG_E_READFAULT instead of 0x%08x\n", hr); + ok(IsEqualCLSID(&clsid, &CLSID_NULL), "clsid should have been zeroed\n"); + + hr = IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL); + ok_ole_success(hr, "IStream_Seek"); + hr = ReadClassStm(pStream, &clsid); + ok_ole_success(hr, "ReadClassStm"); + ok(IsEqualCLSID(&clsid, &test_stg_cls), "clsid should have been set to CLSID_WineTest\n"); +} + START_TEST(storage32) { test_hglobal_storage_stat(); @@ -923,4 +955,5 @@ START_TEST(storage32) test_storage_refcount(); test_streamenum(); test_transact(); + test_ReadClassStm(); }