Skip to content

fix: fix PNG chunk header bounds check in logo decoder#736

Open
Dollyerls wants to merge 1 commit into
tempoxyz:mainfrom
Dollyerls:fix/sync-logos-png-bounds
Open

fix: fix PNG chunk header bounds check in logo decoder#736
Dollyerls wants to merge 1 commit into
tempoxyz:mainfrom
Dollyerls:fix/sync-logos-png-bounds

Conversation

@Dollyerls

Copy link
Copy Markdown

Summary

decodePngPixels could read past the end of the buffer on a truncated or malformed PNG, silently corrupting the decode.

Problem

The chunk loop reads an 8-byte header — a 4-byte length followed by a 4-byte type (bytes[offset] through bytes[offset + 7]) — but the loop guard only guaranteed 4 bytes remained. Out-of-bounds Uint8Array reads return undefined, so the type field is decoded from garbage.

Change

Before After
while (offset < bytes.length - 4) { while (offset <= bytes.length - 8) {

offset <= bytes.length - 8 is the precise bound: it allows the last fully-present header (offset = length - 8, reading up to index length - 1) and rejects any position with fewer than 8 bytes left. Well-formed PNGs decode identically.

@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

@Dollyerls is attempting to deploy a commit to the Tempo Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the infra label Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant