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

fix(net): Fix the WinError 10014 #954

Merged
merged 8 commits into from
Nov 30, 2023
Merged

Conversation

ZengGengSen
Copy link
Contributor

When sendto_v4 and sendto_v6 are called,
the error WinError 10014 is raised, caused
by passing the wrong sockaddr_len

Note: WSAEFAULT(10014), Bad address.
The system detected an invalid pointer
address in attempting to use a pointer
argument of a call. This error occurs
if an application passes an invalid
pointer value, or if the length of the
buffer is too small. For instance, if
the length of an argument, which is a
sockaddr structure, is smaller than
the sizeof(sockaddr).

ZengGengSen and others added 4 commits November 24, 2023 10:16
    When sendto_v4 and sendto_v6 are called,
    the error WinError 10014 is raised, caused
    by passing the wrong sockaddr_len

    Note: WSAEFAULT(10014), Bad address.
        The system detected an invalid pointer
        address in attempting to use a pointer
        argument of a call. This error occurs
        if an application passes an invalid
        pointer value, or if the length of the
        buffer is too small. For instance, if
        the length of an argument, which is a
        sockaddr structure, is smaller than
        the sizeof(sockaddr).
    1. remove the space in sento_v6
    2. Explicitly declares the conversion type c::socklen_t
    add `()` to call sizeof function
@sunfishcode
Copy link
Member

Thanks!

Would you be able to add a testcase that shows the failure here?

Or, do you have any guess as to why the net_v4_sendto and net_v6_sendto tests in tests/net/connect_bind_send.rs don't catch this?

@sunfishcode
Copy link
Member

I've now figured out why the existing tests don't fail. They were only testing on stream sockets, where the sendto destination address is ignored. I've now added tests using datagram sockets, and can confirm that they fail without this patch, and pass with it.

@sunfishcode
Copy link
Member

Thanks for finding and fixing this bug!

@sunfishcode sunfishcode merged commit 7d1e2ef into bytecodealliance:main Nov 30, 2023
44 checks passed
@sunfishcode
Copy link
Member

This is now released in rustix 0.38.26.

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.

2 participants