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

texconv: Fix PPM reader to avoid overread of buffer (#410)

This commit is contained in:
Chuck Walbourn 2023-11-08 18:20:40 -08:00 committed by GitHub
parent 6eca077e06
commit 53ba375fbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

1
.gitignore vendored
View File

@ -34,6 +34,7 @@ Profile
Release
x64
/Tests
/Testing
/wiki
/out
/CMakeUserPresets.json

View File

@ -202,16 +202,17 @@ HRESULT __cdecl LoadFromPortablePixMap(
while (ppmSize > 0 && (pixels < pixelEnd))
{
if (ppmSize < 3)
{
return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF);
}
*pixels++ = (255 * pData[0] / max)
| ((255 * pData[1] / max) << 8)
| ((255 * pData[2] / max) << 16)
| 0xff000000;
pData += 3;
if (ppmSize < 3)
{
return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF);
}
ppmSize -= 3;
}