Skip to content

reject over-long read counts in Mp4parseIo read impl - #457

Open
Chandan3456 wants to merge 1 commit into
mozilla:masterfrom
Chandan3456:mp4parseio-read-count-guard
Open

Chandan3456 wants to merge 1 commit into
mozilla:masterfrom
Chandan3456:mp4parseio-read-count-guard

Conversation

@Chandan3456

Copy link
Copy Markdown

the Read impl for Mp4parseIo already refuses a buf longer than isize::MAX, but it hands the callback's return value straight back as Ok(rv as usize) once it's non-negative. a callback that reports more bytes than the buf.len() it was given breaks the Read contract that the count never exceeds the buffer, and the count then flows into Take/read_exact/read_to_end which trust it to stay in bounds (read_exact slices buf[n..], read_to_end grows by n). i noticed it reading the FFI shim right after the isize guard, where the second half of the same check was missing. this errors out when rv as usize > buf.len(), matching the existing guard, and adds a test with a callback that over-reports so the invalid count surfaces as an error instead of Ok.

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.

1 participant