Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Set length when accepting on socket #4204

Merged
merged 1 commit into from
Nov 19, 2017
Merged

Conversation

A1kmm
Copy link

@A1kmm A1kmm commented Nov 19, 2017

Without this change, the sockaddr will be left unmodified and
uninitialised memory is interpreted as a sockaddr.

Without this change, the sockaddr will be left unmodified and
uninitialised memory is interpreted as a sockaddr.
@ahmadsalim ahmadsalim merged commit 1855f8b into idris-lang:master Nov 19, 2017
@ahmadsalim
Copy link

Thanks

@ahmadsalim
Copy link

@A1kmm Just to be sure, should it not be sizeof(struct sockaddr) instead?

@A1kmm
Copy link
Author

A1kmm commented Nov 20, 2017

sockaddr is polymorphic, in the sense that sockaddr is the base type and only has the common fields, and there are different types for different address families.

sockaddr_storage is defined to be big enough to handle any of the other address families (see
https://www.unix.com/man-page/posix/7posix/socket.h/ for details). The code allocates the buffer as sizeof(sockaddr_storage), so that is the most appropriate size to use.

@ahmadsalim
Copy link

Thanks for the response.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants