-
-
Notifications
You must be signed in to change notification settings - Fork 170
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
sockaddr definition #489
Comments
You should never use sockaddr for storage; it's only for interface. Use sockaddr_in or sockaddr_storage. |
I think you are correct. I am currently porting a rather large networking library, and
I guess the original authors wrongly used Thanks! |
was it once considered acceptable to use sockaddr as storage? No. That's the whole purpose of sockaddr_storage. It's large enough to hold any type that socket functions which take a sockaddr* as a parameter. It would be reasonable libctru to make sockaddr as large as sockaddr_in since that's the only socket type it supports. |
In socket.h,
sockaddr
is defined as follows:However, according to Linux man pages, it should be defined as follows:
This can cause out-of-bounds memory access when casting between
sockaddr
andsockaddr_in
, which is often done. For reference, here is howsockaddr_in
is defined in libctru in.h :I am no socket expert, so I'm not sure if this is intended or not.
Thank you!
The text was updated successfully, but these errors were encountered: