Missing offset boundary check in TGA reader (#429)

This commit is contained in:
Chuck Walbourn
2023-12-28 23:30:25 -08:00
committed by GitHub
parent dd5517fd06
commit eb594ad36c

View File

@@ -1658,7 +1658,7 @@ HRESULT DirectX::LoadFromTGAMemory(
return hr;
if (offset > size)
return E_FAIL;
return HRESULT_E_INVALID_DATA;
size_t paletteOffset = 0;
uint8_t palette[256 * 4] = {};
@@ -1832,6 +1832,9 @@ HRESULT DirectX::LoadFromTGAFile(
if (FAILED(hr))
return hr;
if (offset > len)
return HRESULT_E_INVALID_DATA;
// Read the pixels
auto const remaining = len - offset;
if (remaining == 0)