From fe70bb7f1ecae8566b48ae7aa5396beb67c82ad8 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 8 Mar 2025 00:11:51 -0500 Subject: [PATCH] libroot/unistd: Fix write truncating return values of _kern_write. ssize_t is 64-bit on 64-bit architectures, if we truncate to int then values above 2GB will be seen as negative and errors instead of the successes they are. Seems to fix #16861. --- src/system/libroot/posix/unistd/write.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/system/libroot/posix/unistd/write.c b/src/system/libroot/posix/unistd/write.c index 5776ea861a..f92afbd15e 100644 --- a/src/system/libroot/posix/unistd/write.c +++ b/src/system/libroot/posix/unistd/write.c @@ -21,7 +21,7 @@ ssize_t write(int fd, void const *buffer, size_t bufferSize) { - int status = _kern_write(fd, -1, buffer, bufferSize); + ssize_t status = _kern_write(fd, -1, buffer, bufferSize); RETURN_AND_SET_ERRNO_TEST_CANCEL(status); }