---
hurd/fd-write.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/hurd/fd-write.c b/hurd/fd-write.c
index 2dc2eedf..7d138c2c 100644
--- a/hurd/fd-write.c
+++ b/hurd/fd-write.c
@@ -16,6 +16,7 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
+#include <stdint.h>
#include <errno.h>
#include <unistd.h>
#include <hurd.h>
@@ -27,17 +28,23 @@ _hurd_fd_write (struct hurd_fd *fd,
{
error_t err;
vm_size_t wrote;
+ size_t wbytes;
+ if (*nbytes > INT32_MAX)
+ wbytes = INT32_MAX;
+ else
+ wbytes = *nbytes;
error_t writefd (io_t port)
{
- return __io_write (port, buf, *nbytes, offset, &wrote);
+ return __io_write (port, buf, wbytes, offset, &wrote);
}
err = HURD_FD_PORT_USE_CANCEL (fd, _hurd_ctty_output (port, ctty, writefd));
if (err)
return err;
- if (__glibc_unlikely (wrote > *nbytes)) /* Sanity check for bogus
server. */
+ if (__glibc_unlikely (wrote > wbytes)) /* Sanity check for bogus
server. */
return EGRATUITOUS;
*nbytes = wrote;
--
2.47.3