Rebase against 34652f37e443a9e7698f66d13df3b4811b1c0cc3.

This commit is contained in:
Alistair Leslie-Hughes 2021-03-26 10:38:20 +11:00
parent f20c33fa04
commit 0547bb4578
3 changed files with 89 additions and 70 deletions

View File

@ -51,7 +51,7 @@ usage()
# Get the upstream commit sha
upstream_commit()
{
echo "12cfe6826773708e3b15f73b9674ccb959000d8b"
echo "34652f37e443a9e7698f66d13df3b4811b1c0cc3"
}
# Show version information

View File

@ -1,17 +1,18 @@
From 8e48978fab82ddf03bf80cde19495a528e1f82ae Mon Sep 17 00:00:00 2001
From 8348f9700da32b1d21f7fab70697ce65414ade4b Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Fri, 16 Dec 2016 18:08:51 +0800
Subject: windowscodecs: Tolerate partial reads in the IFD metadata loader.
Subject: [PATCH] windowscodecs: Tolerate partial reads in the IFD metadata
loader.
---
dlls/windowscodecs/metadatahandler.c | 47 +++++++++++++++---------------------
1 file changed, 20 insertions(+), 27 deletions(-)
dlls/windowscodecs/metadatahandler.c | 51 ++++++++++++----------------
1 file changed, 22 insertions(+), 29 deletions(-)
diff --git a/dlls/windowscodecs/metadatahandler.c b/dlls/windowscodecs/metadatahandler.c
index 571f8b5..d066306 100644
index 128514f6a31..847a097d479 100644
--- a/dlls/windowscodecs/metadatahandler.c
+++ b/dlls/windowscodecs/metadatahandler.c
@@ -777,7 +777,7 @@ static int tag_to_vt(SHORT tag)
@@ -716,7 +716,7 @@ static int tag_to_vt(SHORT tag)
static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
MetadataItem *item, BOOL native_byte_order)
{
@ -20,70 +21,88 @@ index 571f8b5..d066306 100644
SHORT type;
LARGE_INTEGER pos;
HRESULT hr;
@@ -819,7 +819,7 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
@@ -750,7 +750,7 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
{
item->value.vt |= VT_VECTOR;
item->value.caub.cElems = count;
- item->value.caub.pElems = HeapAlloc(GetProcessHeap(), 0, count);
+ item->value.caub.pElems = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count);
memcpy(item->value.caub.pElems, data, count);
}
break;
@@ -758,7 +758,7 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
item->value.vt |= VT_VECTOR;
item->value.u.caub.cElems = count;
- item->value.u.caub.pElems = HeapAlloc(GetProcessHeap(), 0, count);
+ item->value.u.caub.pElems = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count);
if (!item->value.u.caub.pElems) return E_OUTOFMEMORY;
item->value.caub.cElems = count;
- item->value.caub.pElems = HeapAlloc(GetProcessHeap(), 0, count);
+ item->value.caub.pElems = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count);
if (!item->value.caub.pElems) return E_OUTOFMEMORY;
pos.QuadPart = value;
@@ -829,9 +829,8 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
HeapFree(GetProcessHeap(), 0, item->value.u.caub.pElems);
@@ -768,9 +768,8 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
HeapFree(GetProcessHeap(), 0, item->value.caub.pElems);
return hr;
}
- hr = IStream_Read(input, item->value.u.caub.pElems, count, &bytesread);
- hr = IStream_Read(input, item->value.caub.pElems, count, &bytesread);
- if (bytesread != count) hr = E_FAIL;
- if (hr != S_OK)
+ hr = IStream_Read(input, item->value.u.caub.pElems, count, NULL);
+ hr = IStream_Read(input, item->value.caub.pElems, count, NULL);
+ if (FAILED(hr))
{
HeapFree(GetProcessHeap(), 0, item->value.u.caub.pElems);
HeapFree(GetProcessHeap(), 0, item->value.caub.pElems);
return hr;
@@ -864,7 +863,7 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
@@ -793,7 +792,7 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
{
item->value.vt |= VT_VECTOR;
item->value.caui.cElems = count;
- item->value.caui.pElems = HeapAlloc(GetProcessHeap(), 0, count * 2);
+ item->value.caui.pElems = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count * 2);
memcpy(item->value.caui.pElems, data, count * 2);
for (i = 0; i < count; i++)
SWAP_USHORT(item->value.caui.pElems[i]);
@@ -803,7 +802,7 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
item->value.vt |= VT_VECTOR;
item->value.u.caui.cElems = count;
- item->value.u.caui.pElems = HeapAlloc(GetProcessHeap(), 0, count * 2);
+ item->value.u.caui.pElems = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count * 2);
if (!item->value.u.caui.pElems) return E_OUTOFMEMORY;
item->value.caui.cElems = count;
- item->value.caui.pElems = HeapAlloc(GetProcessHeap(), 0, count * 2);
+ item->value.caui.pElems = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count * 2);
if (!item->value.caui.pElems) return E_OUTOFMEMORY;
pos.QuadPart = value;
@@ -874,9 +873,8 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
HeapFree(GetProcessHeap(), 0, item->value.u.caui.pElems);
@@ -813,9 +812,8 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
HeapFree(GetProcessHeap(), 0, item->value.caui.pElems);
return hr;
}
- hr = IStream_Read(input, item->value.u.caui.pElems, count * 2, &bytesread);
- hr = IStream_Read(input, item->value.caui.pElems, count * 2, &bytesread);
- if (bytesread != count * 2) hr = E_FAIL;
- if (hr != S_OK)
+ hr = IStream_Read(input, item->value.u.caui.pElems, count * 2, NULL);
+ hr = IStream_Read(input, item->value.caui.pElems, count * 2, NULL);
+ if (FAILED(hr))
{
HeapFree(GetProcessHeap(), 0, item->value.u.caui.pElems);
HeapFree(GetProcessHeap(), 0, item->value.caui.pElems);
return hr;
@@ -897,7 +895,7 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
@@ -836,7 +834,7 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
item->value.vt |= VT_VECTOR;
item->value.u.caul.cElems = count;
- item->value.u.caul.pElems = HeapAlloc(GetProcessHeap(), 0, count * 4);
+ item->value.u.caul.pElems = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count * 4);
if (!item->value.u.caul.pElems) return E_OUTOFMEMORY;
item->value.caul.cElems = count;
- item->value.caul.pElems = HeapAlloc(GetProcessHeap(), 0, count * 4);
+ item->value.caul.pElems = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count * 4);
if (!item->value.caul.pElems) return E_OUTOFMEMORY;
pos.QuadPart = value;
@@ -907,9 +905,8 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
HeapFree(GetProcessHeap(), 0, item->value.u.caul.pElems);
@@ -846,9 +844,8 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
HeapFree(GetProcessHeap(), 0, item->value.caul.pElems);
return hr;
}
- hr = IStream_Read(input, item->value.u.caul.pElems, count * 4, &bytesread);
- hr = IStream_Read(input, item->value.caul.pElems, count * 4, &bytesread);
- if (bytesread != count * 4) hr = E_FAIL;
- if (hr != S_OK)
+ hr = IStream_Read(input, item->value.u.caul.pElems, count * 4, NULL);
+ hr = IStream_Read(input, item->value.caul.pElems, count * 4, NULL);
+ if (FAILED(hr))
{
HeapFree(GetProcessHeap(), 0, item->value.u.caul.pElems);
HeapFree(GetProcessHeap(), 0, item->value.caul.pElems);
return hr;
@@ -935,8 +932,7 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
@@ -874,8 +871,7 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
hr = IStream_Seek(input, pos, SEEK_SET, NULL);
if (FAILED(hr)) return hr;
@ -92,70 +111,70 @@ index 571f8b5..d066306 100644
+ hr = IStream_Read(input, &ull, sizeof(ull), NULL);
if (hr != S_OK) return hr;
item->value.u.uhVal.QuadPart = ull;
@@ -954,7 +950,7 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
item->value.uhVal.QuadPart = ull;
@@ -893,7 +889,7 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
{
item->value.vt |= VT_VECTOR;
item->value.u.cauh.cElems = count;
- item->value.u.cauh.pElems = HeapAlloc(GetProcessHeap(), 0, count * 8);
+ item->value.u.cauh.pElems = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count * 8);
if (!item->value.u.cauh.pElems) return E_OUTOFMEMORY;
item->value.cauh.cElems = count;
- item->value.cauh.pElems = HeapAlloc(GetProcessHeap(), 0, count * 8);
+ item->value.cauh.pElems = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count * 8);
if (!item->value.cauh.pElems) return E_OUTOFMEMORY;
pos.QuadPart = value;
@@ -964,9 +960,8 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
HeapFree(GetProcessHeap(), 0, item->value.u.cauh.pElems);
@@ -903,9 +899,8 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
HeapFree(GetProcessHeap(), 0, item->value.cauh.pElems);
return hr;
}
- hr = IStream_Read(input, item->value.u.cauh.pElems, count * 8, &bytesread);
- hr = IStream_Read(input, item->value.cauh.pElems, count * 8, &bytesread);
- if (bytesread != count * 8) hr = E_FAIL;
- if (hr != S_OK)
+ hr = IStream_Read(input, item->value.u.cauh.pElems, count * 8, NULL);
+ hr = IStream_Read(input, item->value.cauh.pElems, count * 8, NULL);
+ if (FAILED(hr))
{
HeapFree(GetProcessHeap(), 0, item->value.u.cauh.pElems);
HeapFree(GetProcessHeap(), 0, item->value.cauh.pElems);
return hr;
@@ -984,7 +979,7 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
@@ -923,7 +918,7 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
}
break;
case IFD_ASCII:
- item->value.u.pszVal = HeapAlloc(GetProcessHeap(), 0, count + 1);
+ item->value.u.pszVal = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count + 1);
if (!item->value.u.pszVal) return E_OUTOFMEMORY;
- item->value.pszVal = HeapAlloc(GetProcessHeap(), 0, count + 1);
+ item->value.pszVal = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count + 1);
if (!item->value.pszVal) return E_OUTOFMEMORY;
if (count <= 4)
@@ -1002,9 +997,8 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
HeapFree(GetProcessHeap(), 0, item->value.u.pszVal);
@@ -941,9 +936,8 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
HeapFree(GetProcessHeap(), 0, item->value.pszVal);
return hr;
}
- hr = IStream_Read(input, item->value.u.pszVal, count, &bytesread);
- hr = IStream_Read(input, item->value.pszVal, count, &bytesread);
- if (bytesread != count) hr = E_FAIL;
- if (hr != S_OK)
+ hr = IStream_Read(input, item->value.u.pszVal, count, NULL);
+ hr = IStream_Read(input, item->value.pszVal, count, NULL);
+ if (FAILED(hr))
{
HeapFree(GetProcessHeap(), 0, item->value.u.pszVal);
HeapFree(GetProcessHeap(), 0, item->value.pszVal);
return hr;
@@ -1019,7 +1013,7 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
@@ -958,7 +952,7 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
break;
}
- item->value.u.blob.pBlobData = HeapAlloc(GetProcessHeap(), 0, count);
+ item->value.u.blob.pBlobData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count);
if (!item->value.u.blob.pBlobData) return E_OUTOFMEMORY;
- item->value.blob.pBlobData = HeapAlloc(GetProcessHeap(), 0, count);
+ item->value.blob.pBlobData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, count);
if (!item->value.blob.pBlobData) return E_OUTOFMEMORY;
item->value.u.blob.cbSize = count;
@@ -1038,9 +1032,8 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
HeapFree(GetProcessHeap(), 0, item->value.u.blob.pBlobData);
item->value.blob.cbSize = count;
@@ -977,9 +971,8 @@ static HRESULT load_IFD_entry(IStream *input, const struct IFD_entry *entry,
HeapFree(GetProcessHeap(), 0, item->value.blob.pBlobData);
return hr;
}
- hr = IStream_Read(input, item->value.u.blob.pBlobData, count, &bytesread);
- hr = IStream_Read(input, item->value.blob.pBlobData, count, &bytesread);
- if (bytesread != count) hr = E_FAIL;
- if (hr != S_OK)
+ hr = IStream_Read(input, item->value.u.blob.pBlobData, count, NULL);
+ hr = IStream_Read(input, item->value.blob.pBlobData, count, NULL);
+ if (FAILED(hr))
{
HeapFree(GetProcessHeap(), 0, item->value.u.blob.pBlobData);
HeapFree(GetProcessHeap(), 0, item->value.blob.pBlobData);
return hr;
--
2.9.0
2.30.2

View File

@ -1 +1 @@
12cfe6826773708e3b15f73b9674ccb959000d8b
34652f37e443a9e7698f66d13df3b4811b1c0cc3