1
0
mirror of https://github.com/microsoft/DirectXTex synced 2024-11-09 14:30:05 +00:00

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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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)