Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mkv: detect parent overrun after the header parsing #348

Merged
merged 1 commit into from
Jan 18, 2025

Conversation

sscobici
Copy link

Declaring a constant for EbmlElementHeader doesn't allow to use EbmlElementHeader::MIN_SIZE without specifying the scheme which I considered too complex for a constant. I can define it globally in the file or inside the Schema if you want. Currently it is a 2 with a comment

I added skipping of a byte to put reader position to the end of parent. Does it make sense, taking into consideration that it will be skipped later anyway?

For element header seeking I propose to rewind the stream to the parent_end vs header.pos, which should be similar to as everything was ok. Let me know your preference.

@pdeljanov
Copy link
Owner

Declaring a constant for EbmlElementHeader doesn't allow to use EbmlElementHeader::MIN_SIZE without specifying the scheme which I considered too complex for a constant. I can define it globally in the file or inside the Schema if you want. Currently it is a 2 with a comment

This should be pretty simple since everything is already parameterized by a schema, S. The min. size is really a property of EBML, and not the schema, however, we don't have any lower abstraction for an EBML header other than EbmlElementHeader<S>.

Did you try this?

impl<S: EbmlSchema> EbmlElementHeader<S> {
    /// Minimum EBML header size.
    pub const MIN_SIZE: u64 = 2;
    // ...
if parent_end - pos < EbmlElementHeader::<S>::MIN_SIZE {
    // ...

I added skipping of a byte to put reader position to the end of parent. Does it make sense, taking into consideration that it will be skipped later anyway?

The skip later will yield a debug message which is useful for indicating a strangely muxed file. I wouldn't call ignore_bytes so we can see this message.

For element header seeking I propose to rewind the stream to the parent_end vs header.pos, which should be similar to as everything was ok. Let me know your preference.

This is okay.

@pdeljanov pdeljanov merged commit 7aa86c1 into pdeljanov:dev-0.6 Jan 18, 2025
11 checks passed
@pdeljanov
Copy link
Owner

Thanks again!

@sscobici sscobici deleted the mp4-fix branch January 18, 2025 21:16
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