mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-11-04 13:07:32 +00:00
fix(png): bound transparency chunk detection to the input
This commit is contained in:
1 parent
c9da0f93cf
commit
b5903e80da
3 files changed
+14
-1
No files matched your search
@@ -138,9 +138,9 @@ std::optional<Header> ParseHeader(std::span<const std::uint8_t> png) {
|
||||
while (png.size() - offset >= CHUNK_OVERHEAD) {
|
||||
const std::uint32_t length = readBigEndian32(&png[offset]);
|
||||
const std::uint8_t* type = &png[offset + 4];
|
||||
if (length > png.size() - offset - CHUNK_OVERHEAD) break;
|
||||
if (isChunkType(type, "tRNS")) header.hasTransparency = true;
|
||||
if (isChunkType(type, "tRNS") || isChunkType(type, "IDAT") || isChunkType(type, "IEND")) break;
|
||||
if (length > png.size() - offset - CHUNK_OVERHEAD) break;
|
||||
offset += CHUNK_OVERHEAD + length;
|
||||
}
|
||||
return header;
|
||||
|
||||
Reference in new issue
Block a user