diff --git a/core/libs/prx/libkernel/Socket/src/Udp.cpp b/core/libs/prx/libkernel/Socket/src/Udp.cpp index 08e39685e..36980844d 100644 --- a/core/libs/prx/libkernel/Socket/src/Udp.cpp +++ b/core/libs/prx/libkernel/Socket/src/Udp.cpp @@ -596,7 +596,7 @@ int APS5_VABI setsockopt_nid_postfix(int descriptor, int level, int option, if (!socket) return -1; const int nativeOption = Option(option); if (level != 0xffff || nativeOption == -1) return Fail(42); - if (!value || length != sizeof(int)) return Fail(22); + if (!value || length < sizeof(int)) return Fail(22); return ::setsockopt(socket->value, SOL_SOCKET, nativeOption, static_cast(value), sizeof(int)) ? Fail(NativeError()) : 0; } diff --git a/core/libs/tests/GuestUdp.cpp b/core/libs/tests/GuestUdp.cpp index fb9acba81..c1b4db8b8 100644 --- a/core/libs/tests/GuestUdp.cpp +++ b/core/libs/tests/GuestUdp.cpp @@ -124,6 +124,12 @@ int main() { int option = 0; std::uint32_t optionSize = sizeof(option); Require(getsockopt_nid_postfix(sender, 0xffff, 0x20, &option, &optionSize) == 0 && option != 0); + for (const std::int64_t wide : {0, 1}) { + Require(setsockopt_nid_postfix(sender, 0xffff, 0x20, &wide, sizeof(wide)) == 0); + optionSize = sizeof(option); + Require(getsockopt_nid_postfix(sender, 0xffff, 0x20, &option, &optionSize) == 0 && (option != 0) == (wide != 0)); + } + Require(setsockopt_nid_postfix(sender, 0xffff, 0x20, &enabled, 2) == -1 && *__error_nid_postfix() == 22); Require(setsockopt_nid_postfix(sender, 0xffff, 12345, &enabled, sizeof(enabled)) == -1); Require(*__error_nid_postfix() == 42); const int unconnected = socket_nid_postfix(2, 2, 0);