fortify-headers

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

commit 816ad6764b842f354e46da8a5e36558fbaeeb2ad
parent d8afaf63d24933f6e1706c4019155b8e09fe9d32
Author: sin <sin@2f30.org>
Date:   Wed, 25 Feb 2015 10:31:30 +0000

Add getlogin_r() check

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

diff --git a/include/unistd.h b/include/unistd.h @@ -39,6 +39,17 @@ __fortify_gethostname(char *name, size_t len) } static inline __attribute__ ((always_inline)) +int +__fortify_getlogin_r(char *name, size_t len) +{ + size_t bos = __builtin_object_size(name, 0); + + if (len > bos) + __builtin_trap(); + return getlogin_r(name, len); +} + +static inline __attribute__ ((always_inline)) ssize_t __fortify_pread(int fd, void *buf, size_t n, off_t offset) { @@ -77,6 +88,8 @@ __fortify_write(int fd, const void *buf, size_t n) #define getcwd(buf, len) __fortify_getcwd(buf, len) #undef gethostname #define gethostname(name, len) __fortify_gethostname(name, len) +#undef getlogin_r +#define getlogin_r(name, len) __fortify_getlogin_r(name, len) #undef pread #define pread(fd, buf, n, offset) __fortify_pread(fd, buf, n, offset) #undef read