Skip to content

Fix the buffer length may cause a read error #162

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

Merged
merged 1 commit into from
Sep 8, 2022

Conversation

linD026
Copy link
Collaborator

@linD026 linD026 commented Sep 7, 2022

Since The length of the message buffer is BUF_LEN. When writing the BUF_LEN length of the string it will overwrite the last character (usually it is '\0' from the initialization). And, because the read operation uses the character in the message buffer ('\0') to stop the read loop. It will cause the read operation will read out of the message buffer when the length parameter of read() is not lower than or equal to BUF_LEN.


Related discussion:

Since The length of the message buffer is BUF_LEN. When writing the
BUF_LEN length of the string it will overwrite the last character
(usually it is '\0' from the initialization). And, because the read
operation uses the character in the message buffer ('\0') to stop the
read loop. It will cause the read operation will read out of the
message buffer when the length parameter of read() is not lower than
or equal to BUF_LEN. So add one more byte space to avoid this problem.
@jserv jserv merged commit d79fdc8 into sysprog21:master Sep 8, 2022
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.

2 participants