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

Possible panic safety issue in StderrForwarder #1036

Open
daira opened this issue Apr 16, 2024 · 1 comment
Open

Possible panic safety issue in StderrForwarder #1036

daira opened this issue Apr 16, 2024 · 1 comment

Comments

@daira
Copy link

daira commented Apr 16, 2024

When auditing changes to cc, I found a theoretical panic safety issue at 227b770#diff-fbc116db4f047e6e29dac1fc3c5a5f1f759060e9558aff5707624841b57c5258R123-R128 . As an optimization, the code extends the length of the buffer to its capacity (which will cause it to include uninitialized data), and relies on it being set back to contain only initialized data in all code paths. If stderr.read panics and that panic is caught by a caller of forward_available, then the inner buffer of StderrForwarder will still contain uninitialized data. I don't think it is likely that this can be triggered maliciously, hence the public issue.

@NobodyXu
Copy link
Collaborator

Thanks, I think replacing it with RAII should fix it.
Would probably submit a PR later, but if you already have one, I'm happy to merge it

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

No branches or pull requests

2 participants