Commit Graph

1116 Commits

Author SHA1 Message Date
Zebediah Figura 4a56c41462 ws2_32: Build without -DWINE_NO_LONG_TYPES.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-07 10:58:20 +01:00
Zebediah Figura 2895f0fd22 ws2_32: Avoid an unnecessary goto.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-07 10:58:18 +01:00
Bastien Orivel d6ea38f32d ws2_32: Fix setsockopt(TCP_NODELAY) when optlen is less than 4.
According to MSDN [1], the `TCP_NODELAY` parameter should be of type
`BOOL` which is 4 bytes. Due to a bug [2] in rustc passing a byte
instead of an int, any program written in rust that tries to set that
option on a socket will fail with a "Invalid parameter supplied" error.

Turns out that setsockopt on linux does not want optlen to be less than
4 bytes [3].

Windows' behavior is the following:
- For optlen <= 0, return SOCKET_ERROR and set last error to WSAEFAULT
- For optlen > 0, ignore the optlen value and set the TCP_NODELAY value
  to one if the first byte of the given optvalue is not 0.

This will fix any rust program using the hyper library to do HTTP
requests.

[1]: https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-tcp-socket-options
[2]: 44593aeb13/library/std/src/sys/windows/net.rs (L470)
[3]: d58071a8a7/net/ipv4/tcp.c (L3419-L3420)

Signed-off-by: Bastien Orivel <eijebong@bananium.fr>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-04 09:46:07 +01:00
Alex Henrie 6daef74f67 ws2_32: Fix memory leaks on error paths in unix_gethostby* (scan-build).
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-02 18:43:10 +01:00
Alex Henrie 978df2e031 ws2_32: Fix memory leak on error path in get_local_ips (cppcheck).
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-02 18:43:10 +01:00
Zebediah Figura a6cbdb7de8 ws2_32: Return WSAEFAULT instead of WSAEINVAL from WSAStartup() if "data" is NULL.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-01 18:23:18 +01:00
Zebediah Figura 5efc6369eb ws2_32: Return 65467 or 0 in the iMaxUdpDg field.
Depending on reported winsock version.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-01 18:23:18 +01:00
Zebediah Figura 699643c427 ws2_32: Return 32767 or 0 in the iMaxSockets field.
Depending on reported winsock version.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50352
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-01 18:23:18 +01:00
Zebediah Figura e078f69881 ws2_32: Cap the negotiated winsock version to 1.1 or 2.2.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-01 18:23:18 +01:00
Zebediah Figura 864bef4f8d ws2_32: Always fill the WSADATA structure in WSAStartup().
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-01 18:23:18 +01:00
Zebediah Figura 155449c5d1 ws2_32/tests: Add tests for WSAStartup().
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-01 18:23:18 +01:00
Fabian Maurer 0959b2acc7 ws2_32/tests: Avoid "misleading indentation" warnings.
Signed-off-by: Fabian Maurer <dark.shadow4@web.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-31 18:38:54 +01:00
Alexandre Julliard f0cd33c69e include: Add support for defining Win32 types as 'long' where possible.
Add -DWINE_NO_LONG_TYPES to modules that still have compilation
warnings with long types.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-27 20:38:22 +01:00
Zebediah Figura c0d20bb3c0 ws2_32: Cast the WSAPoll() timeout to LONGLONG before multiplying.
This is not particularly likely to overflow, but there is no harm in being
careful.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-14 19:26:26 +01:00
Zebediah Figura 894679ced8 ws2_32: Cast timeval fields to LONGLONG before multiplying.
WXWORK passes 300 seconds, which overflows 32-bit multiplication.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52383
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-14 19:26:22 +01:00
Zebediah Figura 51e5995d47 server: Avoid reporting POLLOUT on connection failure in poll_single_socket().
Ideally we should be using sock_get_poll_events() and sock_poll_event() instead,
but that seems like an overly risky change for this late in code freeze.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51442
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-07 11:57:00 +01:00
Zebediah Figura 575e632d08 ws2_32: Trace the address bound to in bind().
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-06 11:34:55 +01:00
Zebediah Figura 9632048c68 server: Set the event in IOCTL_AFD_EVENT_SELECT if the socket becomes signaled.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52335
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-06 11:34:47 +01:00
Zebediah Figura 131f913527 ws2_32/tests: Test whether WSAEventSelect() modifies the event state.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-06 11:34:43 +01:00
Jinoh Kang 9ef5c9c009 server: Reselect only after dequeueing async request.
Otherwise, async_waiting() returns 0, leading the socket object to
believe that the previous async request has not yet been acknowledged.
This results in I/O hang for subsequent reads (until shutdown).

Also, async_destroy() calls async_reselect() only after removing the
async request from the queue.  Make async_set_result() consistent with
this behaviour.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52332
Signed-off-by: Jinoh Kang <jinoh.kang.kr@gmail.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-04 18:49:32 +01:00
Jinoh Kang 62e0afda1e ws2_32/tests: Add a test for simultaneous WSARecv().
Signed-off-by: Jinoh Kang <jinoh.kang.kr@gmail.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-04 18:49:24 +01:00
Zebediah Figura 45b9dccb70 ws2_32: Do not assume that an fd_set is bounded by FD_SETSIZE.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52302
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-30 23:09:45 +01:00
Zebediah Figura 40494359cb ws2_32: Don't bother checking sockets against the input write or except sets.
We only need to check the input set for CLOSE. For all other flags we can
guarantee that the socket was included in a unique input set.

E.g. the presence of WRITE in the output flags implies that the socket must have
been in the "write" set to begin with.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-30 23:09:45 +01:00
Zebediah Figura b4609ec199 ws2_32/tests: Test selecting the same socket twice.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-30 23:09:45 +01:00
Zebediah Figura 9d7f41e702 ws2_32/tests: Increase tolerance in a timing test.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-30 23:09:45 +01:00
Zebediah Figura b1a2238a10 server: Reselect the socket returned from accept_socket().
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52024
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-30 23:09:45 +01:00
Zebediah Figura 4c617058a2 ws2_32/tests: Test that the socket returned from accept() inherits event selection parameters.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-30 23:09:45 +01:00
Zebediah Figura 9947a8d0de ws2_32: Correctly null-terminate the addrinfo chain.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52288
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-29 21:48:26 +01:00
Torge Matthies 566668882e ws2_32/tests: Test short fd_set with select().
Signed-off-by: Torge Matthies <openglfreak@googlemail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-26 14:03:42 +01:00
Torge Matthies ae0209a336 ws2_32: Don't read more than necessary from the inputs in select().
.NET Framework / old .NET Core seems to allocate not more space than
necessary for the fd_set inputs, so if the allocation fell on the edge
of the end of the heap, Wine tried to read past it.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52259
Signed-off-by: Torge Matthies <openglfreak@googlemail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-26 14:00:49 +01:00
Connor McAdams 2f9f126a6e ws2_32: Return WSAEINVAL from GetAddrInfoExOverlappedResult if overlapped is NULL.
Signed-off-by: Connor McAdams <cmcadams@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-15 20:44:29 +01:00
Zebediah Figura 7747bf9551 ntdll: Make the afd_transmit_params structure WoW64-compatible.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-10 22:00:17 +01:00
Zebediah Figura b3fd1ca20e ntdll: Handle WoW64 translation in IOCTL_AFD_WINE_SENDMSG.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-10 22:00:17 +01:00
Zebediah Figura 6697759b99 ntdll: Make the afd_recvmsg_params structure WoW64-compatible.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-10 22:00:17 +01:00
Zebediah Figura 6fe23ed8c3 ntdll: Do not fill the IOSB in NtDeviceIoControlFile() if the NT status denotes error.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-10 22:00:17 +01:00
Alexandre Julliard b3ca48f39c configure: Assume that sys/time.h is available on Unix.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-09 18:43:51 +01:00
Alexandre Julliard a7ac3de3b3 configure: Assume that sys/socket.h is available on Unix.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-09 18:43:51 +01:00
Alexandre Julliard d3de3c584a ws2_32: Implement Wow64 entry points in the Unix library.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-07 16:19:48 +01:00
Alexandre Julliard 74045dc812 ws2_32: Fix a potential buffer overflow in the Unix interface.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-07 16:19:48 +01:00
Hans Leidekker 7c39ce0a6c ws2_32: Implement AI_DNS_ONLY using DNS APIs.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52133
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-30 22:07:21 +01:00
Huw Davies 6fdae1979b configure: Stop checking for poll.h and sys/poll.h - always use poll.h.
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-31 17:56:54 +01:00
Alex Henrie 04f78cb5d0 ws2_32/tests: Correct name of IPV6_V6ONLY socket option in messages.
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-19 11:33:05 +02:00
Alex Henrie a990e25bf0 ws2_32: Set WSAEFAULT if the bind address is null.
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-18 18:34:22 +02:00
Alex Henrie 63110f9879 ws2_32: Clear last error in WSASocketW.
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-18 18:34:18 +02:00
Zebediah Figura 3d521bc7b9 ws2_32: Close the new socket handle on CF_DEFER.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-08 11:28:01 +02:00
Alexandre Julliard 97479d3d32 ntdll: Move some exception definitions to winternl.h.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-07 13:52:42 +02:00
Alexandre Julliard 5a19769245 configure: Remove no longer needed poll() checks.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-04 15:26:24 +02:00
Alex Henrie f45bc4f238 ws2_32: Hook up IP_RECVTOS.
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-29 21:38:12 +02:00
Alex Henrie 0853573caf ws2_32: Hook up IP_RECVTTL.
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-29 21:38:12 +02:00
Alex Henrie 77f07a0da2 ws2_32/tests: Add tests for IPv4 control messages.
IP_PKTINFO already had tests, but it doesn't hurt to add a few more.
IP_RECVTTL and IP_RECVTCLASS didn't have any tests.

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-29 21:38:12 +02:00