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

Casting to wrong type #183

Closed
alexeys85 opened this issue Sep 30, 2022 · 3 comments
Closed

Casting to wrong type #183

alexeys85 opened this issue Sep 30, 2022 · 3 comments

Comments

@alexeys85
Copy link
Contributor

The return type of recv call is ssize_t, at least on linux, somewhere else it could be just int. And -1 return value indicates about error. But at least here:

sz = recv(sd, buf, len - 1, 0);

it casts to size_t which converts -1 to non error value.

@troglobit
Copy link
Owner

Nice catch! You say "at least here", I cannot seem to find any other cases of recv() and size_t, are you perhaps referring to uses of read() which stores result in int?

@alexeys85
Copy link
Contributor Author

Well, I haven't found this issue anywhere else as well, just wanted to say that where are could be more places for you to check :)
While at it, is it really necessary to force errno to be ECONNRESET in case of 0 or negative return value?

@troglobit
Copy link
Owner

OK, I see. Well then I didn't miss anything.

Re: ECONNRESET; yeah it was chosen to signal EOF (when recv() return 0) back to ipc_read(). On -1 it should return the errno of the syscall -- as you pointed out in this report.

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

No branches or pull requests

2 participants