-
Notifications
You must be signed in to change notification settings - Fork 64
read_mp4 can expose uninitialised data to third party code (unsound) #172
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
Comments
Thanks for filing this. I wasn't aware of that pitfall for Read, but now that I've re-read the trait's documentation I understand this can happen. In this particular case:
So this problem can't happen in practice in this code. However, it's easy to address by initializing the buffer in the "mp4parse_fallible" path and seems worth doing since otherwise allocate_read_buf should be marked unsafe as you mentioned. |
…te_read_buf. Also delete vec_reserve, which is completely unused. Closes mozilla#172.
…e_read_buf. Also delete vec_reserve, which is completely unused. Closes mozilla#172.
…e_read_buf. Also delete vec_reserve, which is completely unused. Closes mozilla#172.
…e_read_buf. Also delete vec_reserve, which is completely unused. Closes #172.
read_mp4
callsread_moov
which callsread_pssh
which callsread_buf
which callsallocate_read_buf
and passes its result toRead::read
.mp4parse-rust/mp4parse/src/lib.rs
Lines 2320 to 2321 in 26e614b
But the trait
Read
is not unsafe, and it is never guaranteed to limit itself to writing to its single argumentbuf
, and the result ofallocate_read_buf
is a vector of uninitialised bytes (that function should be unsafe, btw).There were discussions about introducing a new unsafe trait in libstd to signal that a
Read
implementation doesn't read in the writer it's supposed to write to, I don't know what became of it but I just found out about rust-lang/rust#42788 which seems related.The text was updated successfully, but these errors were encountered: