crossterm-rs / crossterm

Cross platform terminal library rust
MIT License
3.28k stars 281 forks source link

Remove unsafe and unnecessary `size` argument from `FileDesc::read()` #821

Closed martinvonz closed 6 months ago

martinvonz commented 1 year ago

The size argument to FileDesc::read() is not checked against the length of the buffer, so libc::read() could end up writing past the buffer if we passed a size that's too large. However, we always pass exactly the size of the buffer, so that doesn't happen. Let's just remove the argument since it's not currently needed, thereby removing the risk of bugs if the function is used incorrectly by future callers.

This came up in review of unsafe Rust code at my company.

Shnatsel commented 8 months ago

Are there any blockers to merging this? Is there any way I can help expedite this PR?