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

Add an assertion to unix_term::read_bytes to prevent reading past the end of a buffer #225

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bmoxb
Copy link

@bmoxb bmoxb commented Nov 6, 2024

The (marked safe) read_bytes function makes a call to the unsafe function libc::read. If read_bytes were to be called with a count value larger than the length of buf, the call to libc::read would be undefined behaviour and unsafe. All current callsites of read_bytes appear OK, but adding an assertion would ensure that all possible calls to read_bytes will be safe. If you would prefer to avoid a runtime assertion, I would suggest marking read_bytes as unsafe instead.

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

Successfully merging this pull request may close these issues.

1 participant