aboutsummaryrefslogtreecommitdiff
path: root/hurd/fd-write.c
diff options
context:
space:
mode:
Diffstat (limited to 'hurd/fd-write.c')
-rw-r--r--hurd/fd-write.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/hurd/fd-write.c b/hurd/fd-write.c
index 7978807..fd7bcea 100644
--- a/hurd/fd-write.c
+++ b/hurd/fd-write.c
@@ -1,5 +1,5 @@
/* _hurd_fd_write -- write to a file descriptor; handles job control et al.
- Copyright (C) 1993-2024 Free Software Foundation, Inc.
+ Copyright (C) 1993-2025 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -34,9 +34,13 @@ _hurd_fd_write (struct hurd_fd *fd,
}
err = HURD_FD_PORT_USE_CANCEL (fd, _hurd_ctty_output (port, ctty, writefd));
+ if (err)
+ return err;
- if (! err)
- *nbytes = wrote;
+ if (__glibc_unlikely (wrote > *nbytes)) /* Sanity check for bogus server. */
+ return EGRATUITOUS;
- return err;
+ *nbytes = wrote;
+
+ return 0;
}