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

ensure that partial reads from recv don't trip up rendering #469

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

Conversation

woodpeck
Copy link
Contributor

It is not guaranteed that recv will always return the number of bytes you have asked for; it can return fewer bytes which should not be treated as an error. This is a rare issue but I have actually encountered it on a (virtualised) system. Review requested though - unsure if I have the logic watertight.

while (1) {
rx.fd = fd;
rx.events = POLLIN;
s = poll(&rx, 1, timeout * 1000);

if (s > 0) {
bzero(&resp, sizeof(struct protocol));
ret = recv(fd, &resp, sizeof(struct protocol_v2), 0);
ret = recv(fd, &resp + already_read, want - already_read, 0);

Check notice

Code scanning / Flawfinder

Function accepts input from outside program (CWE-20). Note

input/recv:Function accepts input from outside program (CWE-20).
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