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
4 changes: 1 addition & 3 deletions core/libs/prx/libkernel/File/src/Stdio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,9 +760,7 @@ std::int64_t APS5_VABI _read_nid_postfix(int descriptor, void* buffer, std::size
}

int64_t APS5_VABI write_nid_postfix(int d, const char* str, int64_t size) {
if (size < 0) {
APS5_INVALID_ARG_EX;
}
if (size < 0) return PosixFailure(GUEST_EINVAL);
if (GuestSockets::IsOpen(d)) return GuestSockets::Write(d, str, static_cast<std::size_t>(size));
if (str == nullptr && size != 0) return PosixFailure(GUEST_EFAULT);
const char emptyBuffer = 0;
Expand Down
2 changes: 2 additions & 0 deletions core/libs/tests/GuestFilesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ int main() {
int descriptors[2] = {-1, -1};
Require(pipe_nid_postfix(descriptors) == 0 && descriptors[0] >= 0 && descriptors[1] >= 0);
const char payload[] = {'A', '\0', '\r', '\n', '\x1a', 'Z'};
Require(write_nid_postfix(descriptors[1], payload, static_cast<std::size_t>(-1)) == -1 && *__error_nid_postfix() == 22);
Require(write_nid_postfix(-1, payload, static_cast<std::size_t>(INT64_MAX) + 1) == -1 && *__error_nid_postfix() == 22);
Require(write_nid_postfix(descriptors[1], payload, sizeof(payload)) == sizeof(payload));
Require(close_nid_postfix(descriptors[1]) == 0);
char received[sizeof(payload)]{};
Expand Down
Loading