Skip to content

scte35, psi: guard bounds before trusting pointer/length fields - #185

Open
ChrisJr404 wants to merge 1 commit into
Comcast:masterfrom
ChrisJr404:fix/scte35-psi-bounds
Open

scte35, psi: guard bounds before trusting pointer/length fields#185
ChrisJr404 wants to merge 1 commit into
Comcast:masterfrom
ChrisJr404:fix/scte35-psi-bounds

Conversation

@ChrisJr404

Copy link
Copy Markdown

NewSCTE35 and NewPMT index into their input before checking it fits, so malformed data panics instead of returning an error.

Two failure modes, both found by fuzzing:

  • scte35.NewSCTE35 on empty input panics in psi.PointerField, which reads data[0] before the length check downstream runs. Added a len(data) < 1 guard so it returns ErrInvalidSCTE35Length like the other short-input cases.
  • psi.NewPMT panics with a slice-out-of-range when the section length field is larger than the buffer (and on empty input, again via PointerField). parseTables now checks the pointer field and each table length before slicing, mirroring the guards PmtAccumulatorDoneFunc already does in the same file, and returns ErrShortPayload.

Valid input decodes the same as before. Added TestNewSCTE35Truncated and TestNewPMTTruncated with the reproduced inputs (panic before, error after). go build/vet/test all pass.

NewSCTE35 and NewPMT both index into the input before checking it's long
enough. Empty input panics in psi.PointerField (reads data[0]), and a PMT
section length larger than the buffer slices past the end. Bounds-check
first and return the existing error types instead.
@CLAassistant

CLAassistant commented Aug 18, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants