servo / servo/html5ever

TendrilSink::ReadFrom should only use uninitialized bytes for Files

Open
#675 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

tendril
Dominant language
Rust
Stars
2.6k
Forks
288
Avg merge
2d 22h
Merged PRs (30d)
8

Description

The code:

            // FIXME: this exposes uninitialized bytes to a generic R type
            // this is fine for R=File which never reads these bytes,
            // but user-defined types might.
            // The standard library pushes zeros to `Vec<u8>` for that reason.
            unsafe {
                tendril.push_uninitialized(BUFFER_SIZE);
            }```
See also servo/tendril#4.

This seems icky, no? Couldn't one fix this with different code paths for R=File and any other R=io::Read?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the TendrilSink::ReadFrom implementation containing the shown push_uninitialized call, then read servo/tendril#4 for the related concern. Confirm how File differs from other io::Read implementations; done means user-defined readers cannot observe uninitialized bytes while the existing File behavior remains valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.