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.
The
size
argument toFileDesc::read()
is not checked against the length of the buffer, solibc::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.