Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/libs/prx/libkernel/Socket/src/Udp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ int APS5_VABI listen_nid_postfix(int descriptor, int backlog) {
int APS5_VABI accept_nid_postfix(int descriptor, void* address, std::uint32_t* length) {
const auto listener = Lookup(descriptor);
if (!listener) return -1;
if (listener->type != 1 || (address && !length)) return Fail(22);
if (listener->type != 1) return Fail(45);
if (address && !length) return Fail(22);
sockaddr_storage peer{};
socklen_t size = sizeof(peer);
const auto native = ::accept(listener->value, address ? reinterpret_cast<sockaddr*>(&peer) : nullptr,
Expand Down
2 changes: 2 additions & 0 deletions core/libs/tests/GuestTcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ int main() {
Require(bind_nid_postfix(listener, address.data(), address.size()) == 0);
Require(bind_nid_postfix(listener, address.data(), address.size()) == -1 && *__error_nid_postfix() == 22);
Require(listen_nid_postfix(listener, 4) == 0);
std::array<std::uint8_t, 16> invalid_peer{};
Require(accept_nid_postfix(listener, invalid_peer.data(), nullptr) == -1 && *__error_nid_postfix() == 22);
std::uint32_t address_size = address.size();
Require(getsockname_nid_postfix(listener, address.data(), &address_size) == 0);
Require(address_size == 16 && (address[2] != 0 || address[3] != 0));
Expand Down
3 changes: 3 additions & 0 deletions core/libs/tests/GuestUdp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ int APS5_VABI ioctl_nid_postfix(int, std::uint64_t, void*);
std::int64_t APS5_VABI sendto_nid_postfix(int, const void*, std::uint64_t, int, const void*, std::uint32_t);
std::int64_t APS5_VABI recvfrom_nid_postfix(int, void*, std::uint64_t, int, void*, std::uint32_t*);
int APS5_VABI close_nid_postfix(int);
int APS5_VABI accept_nid_postfix(int, void*, std::uint32_t*);
const char* APS5_VABI inet_ntop_nid_postfix(int, const void*, char*, std::uint32_t);
int APS5_VABI inet_pton_nid_postfix(int, const char*, void*);
int* APS5_VABI __error_nid_postfix();
Expand All @@ -42,6 +43,7 @@ int main() {
const int receiver = socket_nid_postfix(2, 2, 0);
const int sender = socket_nid_postfix(2, 2, 17);
Require(receiver >= 0 && sender >= 0 && receiver != sender);
Require(accept_nid_postfix(receiver, nullptr, nullptr) == -1 && *__error_nid_postfix() == 45);
std::array<unsigned char, 16> destination{16, 2, 0, 0, 127, 0, 0, 1};
Require(bind_nid_postfix(receiver, destination.data(), destination.size()) == 0);
std::uint32_t size = destination.size();
Expand Down Expand Up @@ -121,6 +123,7 @@ int main() {
Require(recvmsg_nid_postfix(receiver, nullptr, 0) == -1 && *__error_nid_postfix() == 14);
Require(close_nid_postfix(receiver) == 0);
Require(close_nid_postfix(receiver) == -1 && *__error_nid_postfix() == 9);
Require(accept_nid_postfix(receiver, nullptr, nullptr) == -1 && *__error_nid_postfix() == 9);
Require(ioctl_nid_postfix(receiver, 0x4004667f, &queued) == -1);
Require(close_nid_postfix(sender) == 0);
unsigned char parsed[16]{};
Expand Down
Loading