From e83d9c4233892f9dc5105bbadfde1e558e98c324 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sun, 27 Mar 2016 18:29:41 +0200 Subject: [PATCH] Added patch to fix IStream::Read() return value for partial reads. --- patches/patchinstall.sh | 16 ++++++ ...eam-Read-return-value-for-partial-re.patch | 56 +++++++++++++++++++ patches/shlwapi-IStream_fnRead/definition | 1 + 3 files changed, 73 insertions(+) create mode 100644 patches/shlwapi-IStream_fnRead/0001-shlwapi-Fix-IStream-Read-return-value-for-partial-re.patch create mode 100644 patches/shlwapi-IStream_fnRead/definition diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index e6696e5e..bebb0da7 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -317,6 +317,7 @@ patch_enable_all () enable_shell32_UNIXFS_get_unix_path="$1" enable_shell32_UnixFS="$1" enable_shlwapi_AssocGetPerceivedType="$1" + enable_shlwapi_IStream_fnRead="$1" enable_shlwapi_SHMapHandle="$1" enable_shlwapi_UrlCombine="$1" enable_stdole32_idl_Typelib="$1" @@ -1128,6 +1129,9 @@ patch_enable () shlwapi-AssocGetPerceivedType) enable_shlwapi_AssocGetPerceivedType="$2" ;; + shlwapi-IStream_fnRead) + enable_shlwapi_IStream_fnRead="$2" + ;; shlwapi-SHMapHandle) enable_shlwapi_SHMapHandle="$2" ;; @@ -6528,6 +6532,18 @@ if test "$enable_shlwapi_AssocGetPerceivedType" -eq 1; then ) >> "$patchlist" fi +# Patchset shlwapi-IStream_fnRead +# | +# | Modified files: +# | * dlls/shlwapi/istream.c, dlls/shlwapi/tests/istream.c +# | +if test "$enable_shlwapi_IStream_fnRead" -eq 1; then + patch_apply shlwapi-IStream_fnRead/0001-shlwapi-Fix-IStream-Read-return-value-for-partial-re.patch + ( + echo '+ { "Dmitry Timoshkov", "shlwapi: Fix IStream::Read() return value for partial reads.", 1 },'; + ) >> "$patchlist" +fi + # Patchset shlwapi-SHMapHandle # | # | Modified files: diff --git a/patches/shlwapi-IStream_fnRead/0001-shlwapi-Fix-IStream-Read-return-value-for-partial-re.patch b/patches/shlwapi-IStream_fnRead/0001-shlwapi-Fix-IStream-Read-return-value-for-partial-re.patch new file mode 100644 index 00000000..85efa4fd --- /dev/null +++ b/patches/shlwapi-IStream_fnRead/0001-shlwapi-Fix-IStream-Read-return-value-for-partial-re.patch @@ -0,0 +1,56 @@ +From 7c8ff77dc75904e59427b65f18c7c9d97f3831a4 Mon Sep 17 00:00:00 2001 +From: Dmitry Timoshkov +Date: Sun, 27 Mar 2016 17:29:34 +0800 +Subject: shlwapi: Fix IStream::Read() return value for partial reads. + +--- + dlls/shlwapi/istream.c | 2 +- + dlls/shlwapi/tests/istream.c | 15 ++++++++++++++- + 2 files changed, 15 insertions(+), 2 deletions(-) + +diff --git a/dlls/shlwapi/istream.c b/dlls/shlwapi/istream.c +index e641995..946d2c8 100644 +--- a/dlls/shlwapi/istream.c ++++ b/dlls/shlwapi/istream.c +@@ -130,7 +130,7 @@ static HRESULT WINAPI IStream_fnRead(IStream *iface, void* pv, ULONG cb, ULONG* + } + if (pcbRead) + *pcbRead = dwRead; +- return S_OK; ++ return dwRead == cb ? S_OK : S_FALSE; + } + + /************************************************************************** +diff --git a/dlls/shlwapi/tests/istream.c b/dlls/shlwapi/tests/istream.c +index 48a292a..c9cf62f 100644 +--- a/dlls/shlwapi/tests/istream.c ++++ b/dlls/shlwapi/tests/istream.c +@@ -247,11 +247,24 @@ static void test_stream_read_write(IStream *stream, DWORD mode) + } + else + { +-todo_wine + ok(ret == S_FALSE, "expected S_FALSE, got %#x (access %#x, written %u)\n", ret, mode, written); + ok(count == 0, "expected 0, got %u\n", count); + } + ++ ret = stream->lpVtbl->Seek(stream, start, STREAM_SEEK_SET, NULL); ++ ok(ret == S_OK, "Seek error %#x\n", ret); ++ ++ count = 0xdeadbeaf; ++ ret = stream->lpVtbl->Read(stream, buf, 0, &count); ++ ok(ret == S_OK, "IStream_Read error %#x (access %#x, written %u)\n", ret, mode, written); ++ ok(count == 0, "expected 0, got %u\n", count); ++ ++ count = 0xdeadbeaf; ++ ret = stream->lpVtbl->Read(stream, buf, sizeof(buf), &count); ++ ok(ret == S_FALSE, "expected S_FALSE, got %#x (access %#x, written %u)\n", ret, mode, written); ++ ok(count == written, "expected %u, got %u\n", written, count); ++ if (count) ++ ok(buf[0] == 0x5e && buf[1] == 0xa7, "expected 5ea7, got %02x%02x\n", buf[0], buf[1]); + } + + static void test_SHCreateStreamOnFileA(DWORD mode, DWORD stgm) +-- +2.7.1 + diff --git a/patches/shlwapi-IStream_fnRead/definition b/patches/shlwapi-IStream_fnRead/definition new file mode 100644 index 00000000..bb140241 --- /dev/null +++ b/patches/shlwapi-IStream_fnRead/definition @@ -0,0 +1 @@ +Fixes: Fix IStream::Read() return value for partial reads