recvfrom: don't convert address if addrsize is 0 #1153
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix malformed address from being returned from
recvfrom
on connection oriented sockets: pass throughaddrsize
when it's 0. Additionally, setaddrsize
to 0 when it is unchanged as win32recvfrom
does not setaddrsize
on connection sockets.This behavior is not required by POSIX, but observed on at least "Linux, OS/X and OpenBSD" so I think we should adapt this behavior.
Perl depends on either this behavior or returning
getpeername
. To work around win32recvfrom
with Cygwin it setsaddrsize
to 0 when addrsize is unchanged:Perl/perl5@e122534#diff-400754cb38a9f79143e9a5b9248562cfde2ec692b374136149a4bef3d0fdbbac. For Win32 directly, it returns
getpeername
when size is unchanged: https://github.com/Perl/perl5/blob/8c2652c1d9709e58ccf726121d1d7bb04c96b354/win32/win32sck.c#L427-L441Perl's
t/io/socket.t
expectsrecvfrom
to return a 0 length src address when called on aPF_INET
socket.Perl/perl5#13101
ALSO, looking at
recvfrom_test.c
I'm not sure why other test was set to only run on Windows. I tested my new test on Windows and Linux.