commit 33d2ff5aa8b0bee2ba886857db4acfa9126e8b6d
parent 2f0e3f574f74e85f2a38aebc141f3d6fbc380910
Author: sin <sin@2f30.org>
Date: Sat, 28 Feb 2015 15:30:25 +0000
Add ttyname_r() check
Diffstat:
1 file changed, 13 insertions(+), 0 deletions(-)
diff --git a/include/unistd.h b/include/unistd.h
@@ -96,6 +96,17 @@ __fortify_read(int fd, void *buf, size_t n)
}
static inline __attribute__ ((always_inline))
+int
+__fortify_ttyname_r(int fd, char *name, size_t n)
+{
+ size_t bos = __builtin_object_size(name, 0);
+
+ if (n > bos)
+ __builtin_trap();
+ return ttyname_r(fd, name, n);
+}
+
+static inline __attribute__ ((always_inline))
ssize_t
__fortify_write(int fd, const void *buf, size_t n)
{
@@ -126,6 +137,8 @@ __fortify_write(int fd, const void *buf, size_t n)
#define pread(fd, buf, n, offset) __fortify_pread(fd, buf, n, offset)
#undef read
#define read(fd, buf, n) __fortify_read(fd, buf, n)
+#undef ttyname_r
+#define ttyname_r(fd, name, n) __fortify_ttyname_r(fd, name, n)
#undef write
#define write(fd, buf, n) __fortify_write(fd, buf, n)