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

Should the spec allow enqueueing on-the-go instead of storing them until the input is exhausted? #52

Open
saschanaz opened this issue Mar 22, 2023 · 5 comments
Labels
clarification Standard could be clearer

Comments

@saschanaz
Copy link
Member

saschanaz commented Mar 22, 2023

https://wicg.github.io/compression/#decompress-and-enqueue-a-chunk

Per the spec it's a must to complete the conversion first and then do the enqueue, but would it be bad to enqueue as soon as each output buffer is filled?

Not that there's any important reason to do that, just curious. Maybe enqueuing all at once (as the spec says) makes sure more consistent behavior among implementations, as impls with smaller buffer might enqueue things before error while others with larger buffer might enqueue nothing.

@ricea
Copy link
Collaborator

ricea commented Mar 23, 2023

This actually protects against a use-after-free attack where the buffer is transferred away in the middle of being decompressed. Calling enqueue can result in executing user JavaScript. Maybe there should be a note about that.

It also ensures consistent and robust behaviour if JavaScript attempts to modify the buffer in the middle of decompression.

@ricea
Copy link
Collaborator

ricea commented Sep 27, 2024

Making a copy of the input data before converting it would also be safe, and would be preferable for an implementation that does thread offloading. I'd be interested in changing the wording to make either approach valid.

@annevk
Copy link
Member

annevk commented Sep 27, 2024

How is either implementation not valid today? Would it be observable? (Note https://infra.spec.whatwg.org/#algorithm-conformance in particular.)

@ricea
Copy link
Collaborator

ricea commented Oct 4, 2024

Yes, I think @annevk is correct. The key point for conformance is that the output represents the results of decompressing the contents of buffer as it was when step 2 was run. Copying buffer and decompressing it in pieces later is a valid implementation.

There should probably be a comment in the spec about why it is important to capture buffer at a single moment in time. Volunteers welcome.

Okay to close this issue?

@annevk
Copy link
Member

annevk commented Oct 4, 2024

If you think there should be a comment, we should probably keep this issue to track that.

@annevk annevk added the clarification Standard could be clearer label Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarification Standard could be clearer
Development

No branches or pull requests

3 participants