summaryrefslogtreecommitdiff
path: root/debug/pread_chk.c
diff options
context:
space:
mode:
Diffstat (limited to 'debug/pread_chk.c')
-rw-r--r--debug/pread_chk.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/debug/pread_chk.c b/debug/pread_chk.c
index 6dfa2ab499..483b5d03ca 100644
--- a/debug/pread_chk.c
+++ b/debug/pread_chk.c
@@ -23,11 +23,8 @@
ssize_t
__pread_chk (int fd, void *buf, size_t nbytes, off_t offset, size_t buflen)
{
- /* In case NBYTES is greater than BUFLEN, we read BUFLEN+1 bytes.
- This might overflow the buffer but the damage is reduced to just
- one byte. And the program will terminate right away. */
- ssize_t n = __pread (fd, buf, offset, MIN (nbytes, buflen + 1));
- if (n > 0 && (size_t) n > buflen)
+ if (nbytes > buflen)
__chk_fail ();
- return n;
+
+ return __pread (fd, buf, offset, MIN (nbytes, buflen + 1));
}