mirror of
https://github.com/microsoft/DirectXTex.git
synced 2025-07-09 11:40:14 +02:00
texconv: Fix PPM reader to avoid overread of buffer (#410)
This commit is contained in:
parent
6eca077e06
commit
53ba375fbf
1
.gitignore
vendored
1
.gitignore
vendored
@ -34,6 +34,7 @@ Profile
|
|||||||
Release
|
Release
|
||||||
x64
|
x64
|
||||||
/Tests
|
/Tests
|
||||||
|
/Testing
|
||||||
/wiki
|
/wiki
|
||||||
/out
|
/out
|
||||||
/CMakeUserPresets.json
|
/CMakeUserPresets.json
|
||||||
|
@ -202,16 +202,17 @@ HRESULT __cdecl LoadFromPortablePixMap(
|
|||||||
|
|
||||||
while (ppmSize > 0 && (pixels < pixelEnd))
|
while (ppmSize > 0 && (pixels < pixelEnd))
|
||||||
{
|
{
|
||||||
|
if (ppmSize < 3)
|
||||||
|
{
|
||||||
|
return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF);
|
||||||
|
}
|
||||||
|
|
||||||
*pixels++ = (255 * pData[0] / max)
|
*pixels++ = (255 * pData[0] / max)
|
||||||
| ((255 * pData[1] / max) << 8)
|
| ((255 * pData[1] / max) << 8)
|
||||||
| ((255 * pData[2] / max) << 16)
|
| ((255 * pData[2] / max) << 16)
|
||||||
| 0xff000000;
|
| 0xff000000;
|
||||||
|
|
||||||
pData += 3;
|
pData += 3;
|
||||||
if (ppmSize < 3)
|
|
||||||
{
|
|
||||||
return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF);
|
|
||||||
}
|
|
||||||
ppmSize -= 3;
|
ppmSize -= 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user