summaryrefslogtreecommitdiff
path: root/debug/readlink_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/readlink_chk.c
parent61062f56304750c367c5c1533351621353c112a7 (diff)
(__getcwd_chk): Always fail if the buffer is too small.
Diffstat (limited to 'debug/readlink_chk.c')
-rw-r--r--debug/readlink_chk.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/debug/readlink_chk.c b/debug/readlink_chk.c
index 662041957a..d8d61dc699 100644
--- a/debug/readlink_chk.c
+++ b/debug/readlink_chk.c
@@ -27,15 +27,12 @@
ssize_t
__readlink_chk (const char *path, void *buf, size_t len, size_t buflen)
{
- /* In case LEN 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. */
+ if (len > buflen)
+ __chk_fail ();
+
#ifdef HAVE_INLINED_SYSCALLS
- int n = INLINE_SYSCALL (readlink, 3, path, buf, MIN (len, buflen + 1));
+ return INLINE_SYSCALL (readlink, 3, path, buf, MIN (len, buflen + 1));
#else
- int n = __readlink (path, buf, MIN (len, buflen + 1));
+ return __readlink (path, buf, MIN (len, buflen + 1));
#endif
- if (n > 0 && (size_t) n > buflen)
- __chk_fail ();
- return n;
}