1
0
mirror of https://github.com/microsoft/DirectXTex synced 2024-11-24 13:20:13 +00:00

Read legacy files with a DDS_HEADER size of 24 (#400)

This commit is contained in:
Nicholas Hayes 2023-10-04 11:17:15 -06:00 committed by GitHub
parent e8c45a15ab
commit cb5279f10e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -341,9 +341,17 @@ namespace
auto pHeader = reinterpret_cast<const DDS_HEADER*>(static_cast<const uint8_t*>(pSource) + sizeof(uint32_t));
// Verify header to validate DDS file
if (pHeader->size != sizeof(DDS_HEADER))
if (flags & DDS_FLAGS_PERMISSIVE)
{
return E_FAIL;
if (pHeader->size != 24 /* Known variant */
&& pHeader->size != sizeof(DDS_HEADER))
{
return HRESULT_E_NOT_SUPPORTED;
}
}
else if (pHeader->size != sizeof(DDS_HEADER))
{
return HRESULT_E_NOT_SUPPORTED;
}
if (flags & DDS_FLAGS_PERMISSIVE)
@ -368,7 +376,8 @@ namespace
if ((pHeader->ddspf.flags & DDS_FOURCC)
&& (MAKEFOURCC('D', 'X', '1', '0') == pHeader->ddspf.fourCC))
{
if (pHeader->ddspf.size != sizeof(DDS_PIXELFORMAT))
if (pHeader->size != sizeof(DDS_HEADER)
|| pHeader->ddspf.size != sizeof(DDS_PIXELFORMAT))
{
// We do not accept legacy DX9 'known variants' for modern "DX10" extension header files.
return E_FAIL;