aboutsummaryrefslogtreecommitdiff
path: root/debug/pread64_chk.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-03-01 00:42:41 +0000
committerUlrich Drepper <drepper@redhat.com>2005-03-01 00:42:41 +0000
commit8b8b797292218050ff191ccb90da498862afd0f2 (patch)
treeaf2f3e0fd794ea7430f73b688611dfab0d5d69d9 /debug/pread64_chk.c
parent61062f56304750c367c5c1533351621353c112a7 (diff)
downloadglibc-8b8b797292218050ff191ccb90da498862afd0f2.zip
glibc-8b8b797292218050ff191ccb90da498862afd0f2.tar.gz
glibc-8b8b797292218050ff191ccb90da498862afd0f2.tar.bz2
(__getcwd_chk): Always fail if the buffer is too small.
Diffstat (limited to 'debug/pread64_chk.c')
-rw-r--r--debug/pread64_chk.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/debug/pread64_chk.c b/debug/pread64_chk.c
index 5402e05..daea1d7 100644
--- a/debug/pread64_chk.c
+++ b/debug/pread64_chk.c
@@ -23,11 +23,8 @@
ssize_t
__pread64_chk (int fd, void *buf, size_t nbytes, off64_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 = __pread64 (fd, buf, offset, MIN (nbytes, buflen + 1));
- if (n > 0 && (size_t) n > buflen)
+ if (nbytes > buflen)
__chk_fail ();
- return n;
+
+ return __pread64 (fd, buf, offset, MIN (nbytes, buflen + 1));
}