crossterm icon indicating copy to clipboard operation
crossterm copied to clipboard

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

Open martinvonz opened this issue 2 years ago • 0 comments

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.

martinvonz avatar Sep 18 '23 17:09 martinvonz