diff options
Diffstat (limited to 'debug/read_chk.c')
-rw-r--r-- | debug/read_chk.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/debug/read_chk.c b/debug/read_chk.c index 88404ed205..f738c48d6b 100644 --- a/debug/read_chk.c +++ b/debug/read_chk.c @@ -27,15 +27,12 @@ ssize_t __read_chk (int fd, void *buf, size_t nbytes, 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. */ + if (nbytes > buflen) + __chk_fail (); + #ifdef HAVE_INLINED_SYSCALLS - ssize_t n = INLINE_SYSCALL (read, 3, fd, buf, MIN (nbytes, buflen + 1)); + return = INLINE_SYSCALL (read, 3, fd, buf, nbytes); #else - ssize_t n = __read (fd, buf, MIN (nbytes, buflen + 1)); + return = __read (fd, buf, nbytes); #endif - if (n > 0 && (size_t) n > buflen) - __chk_fail (); - return n; } |