fortify-headers

standalone fortify-source implementation
git clone git://git.2f30.org/fortify-headers
Log | Files | Refs | README | LICENSE

commit 6156f7de8beff23762b207c02e5e96ac75b51a5c
parent fcec6e8280b6bcbaa915afd43c6ca552ccec4e87
Author: sin <sin@2f30.org>
Date:   Fri, 30 Jan 2015 16:37:07 +0000

Remove pwrite/write

Diffstat:
Minclude/unistd.h | 34----------------------------------
1 file changed, 0 insertions(+), 34 deletions(-)

diff --git a/include/unistd.h b/include/unistd.h @@ -23,21 +23,6 @@ __fortify_pread(int fd, void *buf, size_t n, off_t offset) return pread(fd, buf, n, offset); } -__errordecl(__pwrite_error, "pwrite: buffer overflow detected"); -static inline __attribute__ ((always_inline)) -ssize_t -__fortify_pwrite(int fd, void *buf, size_t n, off_t offset) -{ - size_t bos = __builtin_object_size(buf, 0); - - if (__builtin_constant_p(n) && n > bos) - __pwrite_error(); - - if (n > bos) - __builtin_trap(); - return pwrite(fd, buf, n, offset); -} - __errordecl(__read_error, "read: buffer overflow detected"); static inline __attribute__ ((always_inline)) ssize_t @@ -53,29 +38,10 @@ __fortify_read(int fd, void *buf, size_t n) return read(fd, buf, n); } -__errordecl(__write_error, "write: buffer overflow detected"); -static inline __attribute__ ((always_inline)) -ssize_t -__fortify_write(int fd, void *buf, size_t n) -{ - size_t bos = __builtin_object_size(buf, 0); - - if (__builtin_constant_p(n) && n > bos) - __write_error(); - - if (n > bos) - __builtin_trap(); - return write(fd, buf, n); -} - #undef pread #define pread(fd, buf, n, offset) __fortify_pread(fd, buf, n, offset) -#undef pwrite -#define pwrite(fd, buf, n, offset) __fortify_pwrite(fd, buf, n, offset) #undef read #define read(fd, buf, n) __fortify_read(fd, buf, n) -#undef write -#define write(fd, buf, n) __fortify_write(fd, buf, n) #endif