diff options
Diffstat (limited to 'include/unistd.h')
| -rw-r--r-- | include/unistd.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/include/unistd.h b/include/unistd.h index 7a49da0..d019b51 100644 --- a/include/unistd.h +++ b/include/unistd.h | |||
| @@ -96,6 +96,28 @@ __fortify_read(int fd, void *buf, size_t n) | |||
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | static inline __attribute__ ((always_inline)) | 98 | static inline __attribute__ ((always_inline)) |
| 99 | ssize_t | ||
| 100 | __fortify_readlink(const char *path, char *buf, size_t n) | ||
| 101 | { | ||
| 102 | size_t bos = __builtin_object_size(buf, 0); | ||
| 103 | |||
| 104 | if (n > bos) | ||
| 105 | __builtin_trap(); | ||
| 106 | return readlink(path, buf, n); | ||
| 107 | } | ||
| 108 | |||
| 109 | static inline __attribute__ ((always_inline)) | ||
| 110 | ssize_t | ||
| 111 | __fortify_readlinkat(int fd, const char *path, char *buf, size_t n) | ||
| 112 | { | ||
| 113 | size_t bos = __builtin_object_size(buf, 0); | ||
| 114 | |||
| 115 | if (n > bos) | ||
| 116 | __builtin_trap(); | ||
| 117 | return readlinkat(fd, path, buf, n); | ||
| 118 | } | ||
| 119 | |||
| 120 | static inline __attribute__ ((always_inline)) | ||
| 99 | int | 121 | int |
| 100 | __fortify_ttyname_r(int fd, char *name, size_t n) | 122 | __fortify_ttyname_r(int fd, char *name, size_t n) |
| 101 | { | 123 | { |
| @@ -137,6 +159,10 @@ __fortify_write(int fd, const void *buf, size_t n) | |||
| 137 | #define pread(fd, buf, n, offset) __fortify_pread(fd, buf, n, offset) | 159 | #define pread(fd, buf, n, offset) __fortify_pread(fd, buf, n, offset) |
| 138 | #undef read | 160 | #undef read |
| 139 | #define read(fd, buf, n) __fortify_read(fd, buf, n) | 161 | #define read(fd, buf, n) __fortify_read(fd, buf, n) |
| 162 | #undef readlink | ||
| 163 | #define readlink(path, buf, n) __fortify_readlink(path, buf, n) | ||
| 164 | #undef readlinkat | ||
| 165 | #define readlinkat(fd, path, buf, n) __fortify_readlinkat(fd, path, buf, n) | ||
| 140 | #undef ttyname_r | 166 | #undef ttyname_r |
| 141 | #define ttyname_r(fd, name, n) __fortify_ttyname_r(fd, name, n) | 167 | #define ttyname_r(fd, name, n) __fortify_ttyname_r(fd, name, n) |
| 142 | #undef write | 168 | #undef write |
