diff options
| -rw-r--r-- | include/poll.h | 6 | ||||
| -rw-r--r-- | include/stdio.h | 26 | ||||
| -rw-r--r-- | include/stdlib.h | 15 | ||||
| -rw-r--r-- | include/string.h | 6 | ||||
| -rw-r--r-- | include/strings.h | 4 | ||||
| -rw-r--r-- | include/unistd.h | 39 | ||||
| -rw-r--r-- | include/wchar.h | 48 |
7 files changed, 144 insertions, 0 deletions
diff --git a/include/poll.h b/include/poll.h index 8e8de6c..8831f95 100644 --- a/include/poll.h +++ b/include/poll.h | |||
| @@ -31,6 +31,9 @@ extern "C" { | |||
| 31 | 31 | ||
| 32 | #undef poll | 32 | #undef poll |
| 33 | 33 | ||
| 34 | #if __has_builtin(__builtin_poll) | ||
| 35 | __diagnose_as_builtin(__builtin_poll, 1, 2, 3) | ||
| 36 | #endif | ||
| 34 | _FORTIFY_FN(poll) int poll(struct pollfd * _FORTIFY_POS0 __f, nfds_t __n, int __s) | 37 | _FORTIFY_FN(poll) int poll(struct pollfd * _FORTIFY_POS0 __f, nfds_t __n, int __s) |
| 35 | { | 38 | { |
| 36 | size_t __b = __bos(__f, 0); | 39 | size_t __b = __bos(__f, 0); |
| @@ -42,6 +45,9 @@ _FORTIFY_FN(poll) int poll(struct pollfd * _FORTIFY_POS0 __f, nfds_t __n, int __ | |||
| 42 | 45 | ||
| 43 | #if defined(_GNU_SOURCE) && !_REDIR_TIME64 | 46 | #if defined(_GNU_SOURCE) && !_REDIR_TIME64 |
| 44 | #undef ppoll | 47 | #undef ppoll |
| 48 | #if __has_builtin(__builtin_ppoll) | ||
| 49 | __diagnose_as_builtin(__builtin_ppoll, 1, 2, 3, 4) | ||
| 50 | #endif | ||
| 45 | _FORTIFY_FN(ppoll) int ppoll(struct pollfd * _FORTIFY_POS0 __f, nfds_t __n, | 51 | _FORTIFY_FN(ppoll) int ppoll(struct pollfd * _FORTIFY_POS0 __f, nfds_t __n, |
| 46 | const struct timespec *__s, const sigset_t *__m) | 52 | const struct timespec *__s, const sigset_t *__m) |
| 47 | { | 53 | { |
diff --git a/include/stdio.h b/include/stdio.h index 000a72d..582be4f 100644 --- a/include/stdio.h +++ b/include/stdio.h | |||
| @@ -40,12 +40,18 @@ extern "C" { | |||
| 40 | #undef vsprintf | 40 | #undef vsprintf |
| 41 | 41 | ||
| 42 | __access(read_only, 2) | 42 | __access(read_only, 2) |
| 43 | #if __has_builtin(__builtin_fdopen) | ||
| 44 | __diagnose_as_builtin(__builtin_fdopen, 1, 2) | ||
| 45 | #endif | ||
| 43 | _FORTIFY_FN(fdopen) FILE *fdopen(int __f, const char* _FORTIFY_POS0 __m) | 46 | _FORTIFY_FN(fdopen) FILE *fdopen(int __f, const char* _FORTIFY_POS0 __m) |
| 44 | { | 47 | { |
| 45 | return __orig_fdopen(__f, __m); | 48 | return __orig_fdopen(__f, __m); |
| 46 | } | 49 | } |
| 47 | 50 | ||
| 48 | __access(write_only, 1, 2) | 51 | __access(write_only, 1, 2) |
| 52 | #if __has_builtin(__builtin_fgets) | ||
| 53 | __diagnose_as_builtin(__builtin_fgets, 1, 2, 3) | ||
| 54 | #endif | ||
| 49 | _FORTIFY_FN(fgets) char *fgets(char * _FORTIFY_POS0 __s, int __n, FILE *__f) | 55 | _FORTIFY_FN(fgets) char *fgets(char * _FORTIFY_POS0 __s, int __n, FILE *__f) |
| 50 | { | 56 | { |
| 51 | size_t __b = __bos(__s, 0); | 57 | size_t __b = __bos(__s, 0); |
| @@ -56,6 +62,9 @@ _FORTIFY_FN(fgets) char *fgets(char * _FORTIFY_POS0 __s, int __n, FILE *__f) | |||
| 56 | } | 62 | } |
| 57 | 63 | ||
| 58 | __malloc(malloc (fclose, 1)) | 64 | __malloc(malloc (fclose, 1)) |
| 65 | #if __has_builtin(__builtin_fmemopen) | ||
| 66 | __diagnose_as_builtin(__builtin_fmemopen, 1, 2, 3) | ||
| 67 | #endif | ||
| 59 | _FORTIFY_FN(fmemopen) FILE *fmemopen(void* _FORTIFY_POS0 __b, size_t __s, const char* _FORTIFY_POS0 __m) | 68 | _FORTIFY_FN(fmemopen) FILE *fmemopen(void* _FORTIFY_POS0 __b, size_t __s, const char* _FORTIFY_POS0 __m) |
| 60 | { | 69 | { |
| 61 | return __orig_fmemopen(__b, __s, __m); | 70 | return __orig_fmemopen(__b, __s, __m); |
| @@ -64,12 +73,18 @@ _FORTIFY_FN(fmemopen) FILE *fmemopen(void* _FORTIFY_POS0 __b, size_t __s, const | |||
| 64 | __access(read_only, 1) | 73 | __access(read_only, 1) |
| 65 | __access(read_only, 2) | 74 | __access(read_only, 2) |
| 66 | __malloc(malloc (fclose, 1)) | 75 | __malloc(malloc (fclose, 1)) |
| 76 | #if __has_builtin(__builtin_fopen) | ||
| 77 | __diagnose_as_builtin(__builtin_fopen, 1, 2) | ||
| 78 | #endif | ||
| 67 | _FORTIFY_FN(fopen) FILE *fopen(const char* _FORTIFY_POS0 __p, const char* _FORTIFY_POS0 __m) | 79 | _FORTIFY_FN(fopen) FILE *fopen(const char* _FORTIFY_POS0 __p, const char* _FORTIFY_POS0 __m) |
| 68 | { | 80 | { |
| 69 | return __orig_fopen(__p, __m); | 81 | return __orig_fopen(__p, __m); |
| 70 | } | 82 | } |
| 71 | 83 | ||
| 72 | __access(write_only, 1) | 84 | __access(write_only, 1) |
| 85 | #if __has_builtin(__builtin_fread) | ||
| 86 | __diagnose_as_builtin(__builtin_fread, 1, 2, 3, 4) | ||
| 87 | #endif | ||
| 73 | _FORTIFY_FN(fread) size_t fread(void * _FORTIFY_POS0 __d, size_t __n, | 88 | _FORTIFY_FN(fread) size_t fread(void * _FORTIFY_POS0 __d, size_t __n, |
| 74 | size_t __m, FILE *__f) | 89 | size_t __m, FILE *__f) |
| 75 | { | 90 | { |
| @@ -83,6 +98,9 @@ _FORTIFY_FN(fread) size_t fread(void * _FORTIFY_POS0 __d, size_t __n, | |||
| 83 | } | 98 | } |
| 84 | 99 | ||
| 85 | __access(read_only, 1) | 100 | __access(read_only, 1) |
| 101 | #if __has_builtin(__builtin_fwrite) | ||
| 102 | __diagnose_as_builtin(__builtin_fwrite, 1, 2, 3, 4) | ||
| 103 | #endif | ||
| 86 | _FORTIFY_FN(fwrite) size_t fwrite(const void * _FORTIFY_POS0 __d, size_t __n, | 104 | _FORTIFY_FN(fwrite) size_t fwrite(const void * _FORTIFY_POS0 __d, size_t __n, |
| 87 | size_t __m, FILE *__f) | 105 | size_t __m, FILE *__f) |
| 88 | { | 106 | { |
| @@ -98,6 +116,9 @@ _FORTIFY_FN(fwrite) size_t fwrite(const void * _FORTIFY_POS0 __d, size_t __n, | |||
| 98 | __access(read_only, 1) | 116 | __access(read_only, 1) |
| 99 | __access(read_only, 2) | 117 | __access(read_only, 2) |
| 100 | __malloc(malloc (pclose, 1)) | 118 | __malloc(malloc (pclose, 1)) |
| 119 | #if __has_builtin(__builtin_popen) | ||
| 120 | __diagnose_as_builtin(__builtin_popen, 1, 2) | ||
| 121 | #endif | ||
| 101 | _FORTIFY_FN(popen) FILE *popen(const char* _FORTIFY_POS0 __c, const char* _FORTIFY_POS0 __t) | 122 | _FORTIFY_FN(popen) FILE *popen(const char* _FORTIFY_POS0 __c, const char* _FORTIFY_POS0 __t) |
| 102 | { | 123 | { |
| 103 | return __orig_popen(__c, __t); | 124 | return __orig_popen(__c, __t); |
| @@ -106,6 +127,9 @@ _FORTIFY_FN(popen) FILE *popen(const char* _FORTIFY_POS0 __c, const char* _FORTI | |||
| 106 | #ifndef __clang__ /* FIXME */ | 127 | #ifndef __clang__ /* FIXME */ |
| 107 | #undef tmpfile | 128 | #undef tmpfile |
| 108 | __malloc(malloc (fclose, 1)) | 129 | __malloc(malloc (fclose, 1)) |
| 130 | #if __has_builtin(__builtin_tmpfile) | ||
| 131 | __diagnose_as_builtin(__builtin_tmpfile) | ||
| 132 | #endif | ||
| 109 | _FORTIFY_FN(tmpfile) FILE *tmpfile(void) | 133 | _FORTIFY_FN(tmpfile) FILE *tmpfile(void) |
| 110 | { | 134 | { |
| 111 | return __orig_tmpfile(); | 135 | return __orig_tmpfile(); |
| @@ -162,6 +186,8 @@ _FORTIFY_FN(vsprintf) int vsprintf(char * _FORTIFY_POS0 __s, const char *__f, | |||
| 162 | * have the __chk variants, we'd need to implement a body with intermediate | 186 | * have the __chk variants, we'd need to implement a body with intermediate |
| 163 | * variables within the macro, which means more non-portable mess | 187 | * variables within the macro, which means more non-portable mess |
| 164 | * 3) not implementing these under clang, which is what we do for now | 188 | * 3) not implementing these under clang, which is what we do for now |
| 189 | * | ||
| 190 | * TODO: add __diagnose_as_builtin | ||
| 165 | */ | 191 | */ |
| 166 | 192 | ||
| 167 | #undef snprintf | 193 | #undef snprintf |
diff --git a/include/stdlib.h b/include/stdlib.h index 734f0e6..d3cd863 100644 --- a/include/stdlib.h +++ b/include/stdlib.h | |||
| @@ -43,6 +43,9 @@ extern "C" { | |||
| 43 | __malloc(malloc (free, 1)) | 43 | __malloc(malloc (free, 1)) |
| 44 | __alloc_size(1) | 44 | __alloc_size(1) |
| 45 | __warn_unused_result | 45 | __warn_unused_result |
| 46 | #if __has_builtin(__builtin_malloc) | ||
| 47 | __diagnose_as_builtin(__builtin_malloc, 1) | ||
| 48 | #endif | ||
| 46 | _FORTIFY_FN(malloc) void *malloc(size_t __s) | 49 | _FORTIFY_FN(malloc) void *malloc(size_t __s) |
| 47 | { | 50 | { |
| 48 | return __orig_malloc(__s); | 51 | return __orig_malloc(__s); |
| @@ -50,6 +53,9 @@ _FORTIFY_FN(malloc) void *malloc(size_t __s) | |||
| 50 | 53 | ||
| 51 | __alloc_size(2) | 54 | __alloc_size(2) |
| 52 | __warn_unused_result | 55 | __warn_unused_result |
| 56 | #if __has_builtin(__builtin_realloc) | ||
| 57 | __diagnose_as_builtin(__builtin_realloc, 1, 2) | ||
| 58 | #endif | ||
| 53 | _FORTIFY_FN(realloc) void *realloc(void *__p, size_t __s) | 59 | _FORTIFY_FN(realloc) void *realloc(void *__p, size_t __s) |
| 54 | { | 60 | { |
| 55 | return __orig_realloc(__p, __s); | 61 | return __orig_realloc(__p, __s); |
| @@ -57,6 +63,9 @@ _FORTIFY_FN(realloc) void *realloc(void *__p, size_t __s) | |||
| 57 | 63 | ||
| 58 | __alloc_size(1, 2) | 64 | __alloc_size(1, 2) |
| 59 | __warn_unused_result | 65 | __warn_unused_result |
| 66 | #if __has_builtin(__builtin_calloc) | ||
| 67 | __diagnose_as_builtin(__builtin_calloc, 1, 2) | ||
| 68 | #endif | ||
| 60 | _FORTIFY_FN(calloc) void *calloc(size_t __n, size_t __s) | 69 | _FORTIFY_FN(calloc) void *calloc(size_t __n, size_t __s) |
| 61 | { | 70 | { |
| 62 | return __orig_calloc(__n, __s); | 71 | return __orig_calloc(__n, __s); |
| @@ -66,6 +75,9 @@ _FORTIFY_FN(calloc) void *calloc(size_t __n, size_t __s) | |||
| 66 | #undef reallocarray | 75 | #undef reallocarray |
| 67 | __alloc_size (2, 3) | 76 | __alloc_size (2, 3) |
| 68 | __warn_unused_result | 77 | __warn_unused_result |
| 78 | #if __has_builtin(__builtin_reallocarray) | ||
| 79 | __diagnose_as_builtin(__builtin_reallocarray, 1, 2, 3) | ||
| 80 | #endif | ||
| 69 | _FORTIFY_FN(reallocarray) void* reallocarray(void* __p, size_t __n, size_t __s) | 81 | _FORTIFY_FN(reallocarray) void* reallocarray(void* __p, size_t __n, size_t __s) |
| 70 | { | 82 | { |
| 71 | return __orig_reallocarray(__p, __n, __s); | 83 | return __orig_reallocarray(__p, __n, __s); |
| @@ -76,6 +88,9 @@ _FORTIFY_FN(reallocarray) void* reallocarray(void* __p, size_t __n, size_t __s) | |||
| 76 | #if (defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)) && !defined(__clang__) | 88 | #if (defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)) && !defined(__clang__) |
| 77 | #undef realpath | 89 | #undef realpath |
| 78 | __warning_if(__p == NULL, "'realpath' called with path set to `NULL`; did you invert the arguments?") | 90 | __warning_if(__p == NULL, "'realpath' called with path set to `NULL`; did you invert the arguments?") |
| 91 | #if __has_builtin(__builtin_realpath) | ||
| 92 | __diagnose_as_builtin(__builtin_realpath, 1, 2) | ||
| 93 | #endif | ||
| 79 | _FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r) | 94 | _FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r) |
| 80 | { | 95 | { |
| 81 | #ifndef PATH_MAX | 96 | #ifndef PATH_MAX |
diff --git a/include/string.h b/include/string.h index 2735b55..8a440e4 100644 --- a/include/string.h +++ b/include/string.h | |||
| @@ -257,6 +257,9 @@ _FORTIFY_FN(mempcpy) void *mempcpy(void * _FORTIFY_POS0 __d, | |||
| 257 | #undef strlcpy | 257 | #undef strlcpy |
| 258 | __access (read_write, 1) | 258 | __access (read_write, 1) |
| 259 | __access (read_only, 2, 3) | 259 | __access (read_only, 2, 3) |
| 260 | #if __has_builtin(__builtin_strlcat) | ||
| 261 | __diagnose_as_builtin(__builtin_strlcat, 1, 2, 3) | ||
| 262 | #endif | ||
| 260 | _FORTIFY_FN(strlcat) size_t strlcat(char * _FORTIFY_POS0 __d, | 263 | _FORTIFY_FN(strlcat) size_t strlcat(char * _FORTIFY_POS0 __d, |
| 261 | const char *__s, size_t __n) | 264 | const char *__s, size_t __n) |
| 262 | { | 265 | { |
| @@ -269,6 +272,9 @@ _FORTIFY_FN(strlcat) size_t strlcat(char * _FORTIFY_POS0 __d, | |||
| 269 | 272 | ||
| 270 | __access (write_only, 1) | 273 | __access (write_only, 1) |
| 271 | __access (read_only, 2, 3) | 274 | __access (read_only, 2, 3) |
| 275 | #if __has_builtin(__builtin_strlcpy) | ||
| 276 | __diagnose_as_builtin(__builtin_strlcpy, 1, 2, 3) | ||
| 277 | #endif | ||
| 272 | _FORTIFY_FN(strlcpy) size_t strlcpy(char * _FORTIFY_POS0 __d, | 278 | _FORTIFY_FN(strlcpy) size_t strlcpy(char * _FORTIFY_POS0 __d, |
| 273 | const char *__s, size_t __n) | 279 | const char *__s, size_t __n) |
| 274 | { | 280 | { |
diff --git a/include/strings.h b/include/strings.h index 8b99ccd..c91715d 100644 --- a/include/strings.h +++ b/include/strings.h | |||
| @@ -33,6 +33,10 @@ extern "C" { | |||
| 33 | #undef bzero | 33 | #undef bzero |
| 34 | __access(write_only, 2, 3) | 34 | __access(write_only, 2, 3) |
| 35 | __access(read_only, 1, 3) | 35 | __access(read_only, 1, 3) |
| 36 | #if __has_builtin(__builtin_bcopy) && !defined(__clang__) | ||
| 37 | // parameter 1 of function '__orig_bcopy' has type 'const void *', but parameter 1 of function '__builtin_bcopy' has type 'void *' | ||
| 38 | __diagnose_as_builtin(__builtin_bcopy, 1, 2, 3) | ||
| 39 | #endif | ||
| 36 | _FORTIFY_FN(bcopy) void bcopy(const void * _FORTIFY_POS0 __s, | 40 | _FORTIFY_FN(bcopy) void bcopy(const void * _FORTIFY_POS0 __s, |
| 37 | void * _FORTIFY_POS0 __d, size_t __n) | 41 | void * _FORTIFY_POS0 __d, size_t __n) |
| 38 | { | 42 | { |
diff --git a/include/unistd.h b/include/unistd.h index 57f0d0c..38c7c9b 100644 --- a/include/unistd.h +++ b/include/unistd.h | |||
| @@ -42,6 +42,9 @@ extern "C" { | |||
| 42 | #undef write | 42 | #undef write |
| 43 | 43 | ||
| 44 | __access(write_only, 2, 3) | 44 | __access(write_only, 2, 3) |
| 45 | #if __has_builtin(__builtin_confstr) | ||
| 46 | __diagnose_as_builtin(__builtin_confstr, 1, 2, 3) | ||
| 47 | #endif | ||
| 45 | _FORTIFY_FN(confstr) size_t confstr(int __n, char * _FORTIFY_POS0 __s, size_t __l) | 48 | _FORTIFY_FN(confstr) size_t confstr(int __n, char * _FORTIFY_POS0 __s, size_t __l) |
| 46 | { | 49 | { |
| 47 | size_t __b = __bos(__s, 0); | 50 | size_t __b = __bos(__s, 0); |
| @@ -53,6 +56,9 @@ _FORTIFY_FN(confstr) size_t confstr(int __n, char * _FORTIFY_POS0 __s, size_t __ | |||
| 53 | } | 56 | } |
| 54 | 57 | ||
| 55 | __access(write_only, 1, 2) | 58 | __access(write_only, 1, 2) |
| 59 | #if __has_builtin(__builtin_getcwd) | ||
| 60 | __diagnose_as_builtin(__builtin_getcwd, 1, 2) | ||
| 61 | #endif | ||
| 56 | _FORTIFY_FN(getcwd) char *getcwd(char * _FORTIFY_POS0 __s, size_t __l) | 62 | _FORTIFY_FN(getcwd) char *getcwd(char * _FORTIFY_POS0 __s, size_t __l) |
| 57 | { | 63 | { |
| 58 | size_t __b = __bos(__s, 0); | 64 | size_t __b = __bos(__s, 0); |
| @@ -65,6 +71,9 @@ _FORTIFY_FN(getcwd) char *getcwd(char * _FORTIFY_POS0 __s, size_t __l) | |||
| 65 | #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) | 71 | #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) |
| 66 | #undef getdomainname | 72 | #undef getdomainname |
| 67 | __access(write_only, 1, 2) | 73 | __access(write_only, 1, 2) |
| 74 | #if __has_builtin(__builtin_getdomainname) | ||
| 75 | __diagnose_as_builtin(__builtin_getdomainname, 1, 2) | ||
| 76 | #endif | ||
| 68 | _FORTIFY_FN(getdomainname) int getdomainname(char * _FORTIFY_POS0 __s, size_t __l) | 77 | _FORTIFY_FN(getdomainname) int getdomainname(char * _FORTIFY_POS0 __s, size_t __l) |
| 69 | { | 78 | { |
| 70 | size_t __b = __bos(__s, 0); | 79 | size_t __b = __bos(__s, 0); |
| @@ -75,6 +84,9 @@ _FORTIFY_FN(getdomainname) int getdomainname(char * _FORTIFY_POS0 __s, size_t __ | |||
| 75 | } | 84 | } |
| 76 | #endif | 85 | #endif |
| 77 | 86 | ||
| 87 | #if __has_builtin(__builtin_getgroups) | ||
| 88 | __diagnose_as_builtin(__builtin_getgroups, 1, 2) | ||
| 89 | #endif | ||
| 78 | _FORTIFY_FN(getgroups) int getgroups(int __l, gid_t * _FORTIFY_POS0 __s) | 90 | _FORTIFY_FN(getgroups) int getgroups(int __l, gid_t * _FORTIFY_POS0 __s) |
| 79 | { | 91 | { |
| 80 | size_t __b = __bos(__s, 0); | 92 | size_t __b = __bos(__s, 0); |
| @@ -85,6 +97,9 @@ _FORTIFY_FN(getgroups) int getgroups(int __l, gid_t * _FORTIFY_POS0 __s) | |||
| 85 | } | 97 | } |
| 86 | 98 | ||
| 87 | __access(write_only, 1, 2) | 99 | __access(write_only, 1, 2) |
| 100 | #if __has_builtin(__builtin_gethostname) | ||
| 101 | __diagnose_as_builtin(__builtin_gethostname, 1, 2) | ||
| 102 | #endif | ||
| 88 | _FORTIFY_FN(gethostname) int gethostname(char * _FORTIFY_POS0 __s, size_t __l) | 103 | _FORTIFY_FN(gethostname) int gethostname(char * _FORTIFY_POS0 __s, size_t __l) |
| 89 | { | 104 | { |
| 90 | size_t __b = __bos(__s, 0); | 105 | size_t __b = __bos(__s, 0); |
| @@ -95,6 +110,9 @@ _FORTIFY_FN(gethostname) int gethostname(char * _FORTIFY_POS0 __s, size_t __l) | |||
| 95 | } | 110 | } |
| 96 | 111 | ||
| 97 | __access(write_only, 1, 2) | 112 | __access(write_only, 1, 2) |
| 113 | #if __has_builtin(__builtin_getlogin_r) | ||
| 114 | __diagnose_as_builtin(__builtin_getlogin_r, 1, 2) | ||
| 115 | #endif | ||
| 98 | _FORTIFY_FN(getlogin_r) int getlogin_r(char * _FORTIFY_POS0 __s, size_t __l) | 116 | _FORTIFY_FN(getlogin_r) int getlogin_r(char * _FORTIFY_POS0 __s, size_t __l) |
| 99 | { | 117 | { |
| 100 | size_t __b = __bos(__s, 0); | 118 | size_t __b = __bos(__s, 0); |
| @@ -104,6 +122,9 @@ _FORTIFY_FN(getlogin_r) int getlogin_r(char * _FORTIFY_POS0 __s, size_t __l) | |||
| 104 | return __orig_getlogin_r(__s, __l); | 122 | return __orig_getlogin_r(__s, __l); |
| 105 | } | 123 | } |
| 106 | 124 | ||
| 125 | #if __has_builtin(__builtin_pread) | ||
| 126 | __diagnose_as_builtin(__builtin_pread, 1, 2, 3, 4) | ||
| 127 | #endif | ||
| 107 | _FORTIFY_FN(pread) ssize_t pread(int __f, void * _FORTIFY_POS0 __s, | 128 | _FORTIFY_FN(pread) ssize_t pread(int __f, void * _FORTIFY_POS0 __s, |
| 108 | size_t __n, off_t __o) | 129 | size_t __n, off_t __o) |
| 109 | { | 130 | { |
| @@ -115,6 +136,9 @@ _FORTIFY_FN(pread) ssize_t pread(int __f, void * _FORTIFY_POS0 __s, | |||
| 115 | } | 136 | } |
| 116 | 137 | ||
| 117 | __access(write_only, 2, 3) | 138 | __access(write_only, 2, 3) |
| 139 | #if __has_builtin(__builtin_read) | ||
| 140 | __diagnose_as_builtin(__builtin_read, 1, 2, 3) | ||
| 141 | #endif | ||
| 118 | _FORTIFY_FN(read) ssize_t read(int __f, void * _FORTIFY_POS0 __s, size_t __n) | 142 | _FORTIFY_FN(read) ssize_t read(int __f, void * _FORTIFY_POS0 __s, size_t __n) |
| 119 | { | 143 | { |
| 120 | size_t __b = __bos(__s, 0); | 144 | size_t __b = __bos(__s, 0); |
| @@ -125,6 +149,9 @@ _FORTIFY_FN(read) ssize_t read(int __f, void * _FORTIFY_POS0 __s, size_t __n) | |||
| 125 | } | 149 | } |
| 126 | 150 | ||
| 127 | __access(write_only, 2, 3) | 151 | __access(write_only, 2, 3) |
| 152 | #if __has_builtin(__builtin_readlink) | ||
| 153 | __diagnose_as_builtin(__builtin_readlink, 1, 2, 3) | ||
| 154 | #endif | ||
| 128 | _FORTIFY_FN(readlink) ssize_t readlink(const char *__p, | 155 | _FORTIFY_FN(readlink) ssize_t readlink(const char *__p, |
| 129 | char * _FORTIFY_POS0 __s, size_t __n) | 156 | char * _FORTIFY_POS0 __s, size_t __n) |
| 130 | { | 157 | { |
| @@ -136,6 +163,9 @@ _FORTIFY_FN(readlink) ssize_t readlink(const char *__p, | |||
| 136 | } | 163 | } |
| 137 | 164 | ||
| 138 | __access(write_only, 3, 4) | 165 | __access(write_only, 3, 4) |
| 166 | #if __has_builtin(__builtin_readlinkat) | ||
| 167 | __diagnose_as_builtin(__builtin_readlinkat, 1, 2, 3, 4) | ||
| 168 | #endif | ||
| 139 | _FORTIFY_FN(readlinkat) ssize_t readlinkat(int __f, const char *__p, | 169 | _FORTIFY_FN(readlinkat) ssize_t readlinkat(int __f, const char *__p, |
| 140 | char * _FORTIFY_POS0 __s, size_t __n) | 170 | char * _FORTIFY_POS0 __s, size_t __n) |
| 141 | { | 171 | { |
| @@ -147,6 +177,9 @@ _FORTIFY_FN(readlinkat) ssize_t readlinkat(int __f, const char *__p, | |||
| 147 | } | 177 | } |
| 148 | 178 | ||
| 149 | __access(write_only, 2, 3) | 179 | __access(write_only, 2, 3) |
| 180 | #if __has_builtin(__builtin_ttyname_r) | ||
| 181 | __diagnose_as_builtin(__builtin_ttyname_r, 1, 2, 3) | ||
| 182 | #endif | ||
| 150 | _FORTIFY_FN(ttyname_r) int ttyname_r(int __f, char * _FORTIFY_POS0 __s, | 183 | _FORTIFY_FN(ttyname_r) int ttyname_r(int __f, char * _FORTIFY_POS0 __s, |
| 151 | size_t __n) | 184 | size_t __n) |
| 152 | { | 185 | { |
| @@ -158,6 +191,9 @@ _FORTIFY_FN(ttyname_r) int ttyname_r(int __f, char * _FORTIFY_POS0 __s, | |||
| 158 | } | 191 | } |
| 159 | 192 | ||
| 160 | __access(read_only, 2, 3) | 193 | __access(read_only, 2, 3) |
| 194 | #if __has_builtin(__builtin_write) | ||
| 195 | __diagnose_as_builtin(__builtin_write, 1, 2, 3) | ||
| 196 | #endif | ||
| 161 | _FORTIFY_FN(write) ssize_t write(int __f, const void * _FORTIFY_POS0 __s, | 197 | _FORTIFY_FN(write) ssize_t write(int __f, const void * _FORTIFY_POS0 __s, |
| 162 | size_t __n) | 198 | size_t __n) |
| 163 | { | 199 | { |
| @@ -168,6 +204,9 @@ _FORTIFY_FN(write) ssize_t write(int __f, const void * _FORTIFY_POS0 __s, | |||
| 168 | return __orig_write(__f, __s, __n); | 204 | return __orig_write(__f, __s, __n); |
| 169 | } | 205 | } |
| 170 | 206 | ||
| 207 | #if __has_builtin(__builtin_pwrite) | ||
| 208 | __diagnose_as_builtin(__builtin_pwrite, 1, 2, 3, 4) | ||
| 209 | #endif | ||
| 171 | _FORTIFY_FN(pwrite) ssize_t pwrite(int __f, const void * _FORTIFY_POS0 __s, | 210 | _FORTIFY_FN(pwrite) ssize_t pwrite(int __f, const void * _FORTIFY_POS0 __s, |
| 172 | size_t __n, off_t __o) | 211 | size_t __n, off_t __o) |
| 173 | { | 212 | { |
diff --git a/include/wchar.h b/include/wchar.h index dc73fab..e696ddf 100644 --- a/include/wchar.h +++ b/include/wchar.h | |||
| @@ -56,6 +56,9 @@ extern "C" { | |||
| 56 | #undef wmemmove | 56 | #undef wmemmove |
| 57 | #undef wmemset | 57 | #undef wmemset |
| 58 | 58 | ||
| 59 | #if __has_builtin(__builtin_fgetws) | ||
| 60 | __diagnose_as_builtin(__builtin_fgetws, 1, 2, 3) | ||
| 61 | #endif | ||
| 59 | _FORTIFY_FN(fgetws) wchar_t *fgetws(wchar_t * _FORTIFY_POS0 __s, | 62 | _FORTIFY_FN(fgetws) wchar_t *fgetws(wchar_t * _FORTIFY_POS0 __s, |
| 60 | int __n, FILE *__f) | 63 | int __n, FILE *__f) |
| 61 | { | 64 | { |
| @@ -69,6 +72,9 @@ _FORTIFY_FN(fgetws) wchar_t *fgetws(wchar_t * _FORTIFY_POS0 __s, | |||
| 69 | #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ | 72 | #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ |
| 70 | || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) | 73 | || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) |
| 71 | #undef mbsnrtowcs | 74 | #undef mbsnrtowcs |
| 75 | #if __has_builtin(__builtin_mbsnrtowcs) | ||
| 76 | __diagnose_as_builtin(__builtin_mbsnrtowcs, 1, 2, 3, 4, 5) | ||
| 77 | #endif | ||
| 72 | _FORTIFY_FN(mbsnrtowcs) size_t mbsnrtowcs(wchar_t * _FORTIFY_POS0 __d, | 78 | _FORTIFY_FN(mbsnrtowcs) size_t mbsnrtowcs(wchar_t * _FORTIFY_POS0 __d, |
| 73 | const char **__s, size_t __n, | 79 | const char **__s, size_t __n, |
| 74 | size_t __wn, mbstate_t *__st) | 80 | size_t __wn, mbstate_t *__st) |
| @@ -90,6 +96,9 @@ _FORTIFY_FN(mbsnrtowcs) size_t mbsnrtowcs(wchar_t * _FORTIFY_POS0 __d, | |||
| 90 | } | 96 | } |
| 91 | #endif | 97 | #endif |
| 92 | 98 | ||
| 99 | #if __has_builtin(__builtin_mbsrtowcs) | ||
| 100 | __diagnose_as_builtin(__builtin_mbsrtowcs, 1, 2, 3, 4) | ||
| 101 | #endif | ||
| 93 | _FORTIFY_FN(mbsrtowcs) size_t mbsrtowcs(wchar_t * _FORTIFY_POS0 __d, | 102 | _FORTIFY_FN(mbsrtowcs) size_t mbsrtowcs(wchar_t * _FORTIFY_POS0 __d, |
| 94 | const char **__s, size_t __wn, | 103 | const char **__s, size_t __wn, |
| 95 | mbstate_t *__st) | 104 | mbstate_t *__st) |
| @@ -104,6 +113,9 @@ _FORTIFY_FN(mbsrtowcs) size_t mbsrtowcs(wchar_t * _FORTIFY_POS0 __d, | |||
| 104 | return __r; | 113 | return __r; |
| 105 | } | 114 | } |
| 106 | 115 | ||
| 116 | #if __has_builtin(__builtin_mbstowcs) | ||
| 117 | __diagnose_as_builtin(__builtin_mbstowcs, 1, 2, 3) | ||
| 118 | #endif | ||
| 107 | _FORTIFY_FN(mbstowcs) size_t mbstowcs(wchar_t * _FORTIFY_POS0 __ws, | 119 | _FORTIFY_FN(mbstowcs) size_t mbstowcs(wchar_t * _FORTIFY_POS0 __ws, |
| 108 | const char *__s, size_t __wn) | 120 | const char *__s, size_t __wn) |
| 109 | { | 121 | { |
| @@ -116,6 +128,9 @@ _FORTIFY_FN(mbstowcs) size_t mbstowcs(wchar_t * _FORTIFY_POS0 __ws, | |||
| 116 | 128 | ||
| 117 | /* FIXME clang */ | 129 | /* FIXME clang */ |
| 118 | #ifndef __clang__ | 130 | #ifndef __clang__ |
| 131 | #if __has_builtin(__builtin_wcrtomb) | ||
| 132 | __diagnose_as_builtin(__builtin_wcrtomb, 1, 2, 3) | ||
| 133 | #endif | ||
| 119 | _FORTIFY_FN(wcrtomb) size_t wcrtomb(char * __s, wchar_t __w, mbstate_t *__st) | 134 | _FORTIFY_FN(wcrtomb) size_t wcrtomb(char * __s, wchar_t __w, mbstate_t *__st) |
| 120 | { | 135 | { |
| 121 | if (__s && MB_LEN_MAX > __bos(__s, 2)) { | 136 | if (__s && MB_LEN_MAX > __bos(__s, 2)) { |
| @@ -134,6 +149,9 @@ _FORTIFY_FN(wcrtomb) size_t wcrtomb(char * __s, wchar_t __w, mbstate_t *__st) | |||
| 134 | } | 149 | } |
| 135 | #endif | 150 | #endif |
| 136 | 151 | ||
| 152 | #if __has_builtin(__builtin_wcscat) | ||
| 153 | __diagnose_as_builtin(__builtin_wcscat, 1, 2) | ||
| 154 | #endif | ||
| 137 | _FORTIFY_FN(wcscat) wchar_t *wcscat(wchar_t * _FORTIFY_POS0 __d, | 155 | _FORTIFY_FN(wcscat) wchar_t *wcscat(wchar_t * _FORTIFY_POS0 __d, |
| 138 | const wchar_t *__s) | 156 | const wchar_t *__s) |
| 139 | { | 157 | { |
| @@ -144,6 +162,9 @@ _FORTIFY_FN(wcscat) wchar_t *wcscat(wchar_t * _FORTIFY_POS0 __d, | |||
| 144 | return __orig_wcscat(__d, __s); | 162 | return __orig_wcscat(__d, __s); |
| 145 | } | 163 | } |
| 146 | 164 | ||
| 165 | #if __has_builtin(__builtin_wcscpy) | ||
| 166 | __diagnose_as_builtin(__builtin_wcscpy, 1, 2) | ||
| 167 | #endif | ||
| 147 | _FORTIFY_FN(wcscpy) wchar_t *wcscpy(wchar_t * _FORTIFY_POS0 __d, | 168 | _FORTIFY_FN(wcscpy) wchar_t *wcscpy(wchar_t * _FORTIFY_POS0 __d, |
| 148 | const wchar_t *__s) | 169 | const wchar_t *__s) |
| 149 | { | 170 | { |
| @@ -154,6 +175,9 @@ _FORTIFY_FN(wcscpy) wchar_t *wcscpy(wchar_t * _FORTIFY_POS0 __d, | |||
| 154 | return __orig_wcscpy(__d, __s); | 175 | return __orig_wcscpy(__d, __s); |
| 155 | } | 176 | } |
| 156 | 177 | ||
| 178 | #if __has_builtin(__builtin_wcsncat) | ||
| 179 | __diagnose_as_builtin(__builtin_wcsncat, 1, 2, 3) | ||
| 180 | #endif | ||
| 157 | _FORTIFY_FN(wcsncat) wchar_t *wcsncat(wchar_t * _FORTIFY_POS0 __d, | 181 | _FORTIFY_FN(wcsncat) wchar_t *wcsncat(wchar_t * _FORTIFY_POS0 __d, |
| 158 | const wchar_t *__s, size_t __n) | 182 | const wchar_t *__s, size_t __n) |
| 159 | { | 183 | { |
| @@ -171,6 +195,9 @@ _FORTIFY_FN(wcsncat) wchar_t *wcsncat(wchar_t * _FORTIFY_POS0 __d, | |||
| 171 | return __orig_wcsncat(__d, __s, __n); | 195 | return __orig_wcsncat(__d, __s, __n); |
| 172 | } | 196 | } |
| 173 | 197 | ||
| 198 | #if __has_builtin(__builtin_wcsncpy) | ||
| 199 | __diagnose_as_builtin(__builtin_wcsncpy, 1, 2, 3) | ||
| 200 | #endif | ||
| 174 | _FORTIFY_FN(wcsncpy) wchar_t *wcsncpy(wchar_t * _FORTIFY_POS0 __d, | 201 | _FORTIFY_FN(wcsncpy) wchar_t *wcsncpy(wchar_t * _FORTIFY_POS0 __d, |
| 175 | const wchar_t *__s, size_t __n) | 202 | const wchar_t *__s, size_t __n) |
| 176 | { | 203 | { |
| @@ -184,6 +211,9 @@ _FORTIFY_FN(wcsncpy) wchar_t *wcsncpy(wchar_t * _FORTIFY_POS0 __d, | |||
| 184 | #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ | 211 | #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ |
| 185 | || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) | 212 | || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) |
| 186 | #undef wcsnrtombs | 213 | #undef wcsnrtombs |
| 214 | #if __has_builtin(__builtin_wcsnrtombs) | ||
| 215 | __diagnose_as_builtin(__builtin_wcsnrtombs, 1, 2, 3, 4, 5) | ||
| 216 | #endif | ||
| 187 | _FORTIFY_FN(wcsnrtombs) size_t wcsnrtombs(char * _FORTIFY_POS0 __d, | 217 | _FORTIFY_FN(wcsnrtombs) size_t wcsnrtombs(char * _FORTIFY_POS0 __d, |
| 188 | const wchar_t **__s, size_t __wn, | 218 | const wchar_t **__s, size_t __wn, |
| 189 | size_t __n, mbstate_t *__st) | 219 | size_t __n, mbstate_t *__st) |
| @@ -205,6 +235,9 @@ _FORTIFY_FN(wcsnrtombs) size_t wcsnrtombs(char * _FORTIFY_POS0 __d, | |||
| 205 | } | 235 | } |
| 206 | #endif | 236 | #endif |
| 207 | 237 | ||
| 238 | #if __has_builtin(__builtin_wcsrtombs) | ||
| 239 | __diagnose_as_builtin(__builtin_wcsrtombs, 1, 2, 3, 4) | ||
| 240 | #endif | ||
| 208 | _FORTIFY_FN(wcsrtombs) size_t wcsrtombs(char * _FORTIFY_POS0 __d, | 241 | _FORTIFY_FN(wcsrtombs) size_t wcsrtombs(char * _FORTIFY_POS0 __d, |
| 209 | const wchar_t **__s, size_t __n, | 242 | const wchar_t **__s, size_t __n, |
| 210 | mbstate_t *__st) | 243 | mbstate_t *__st) |
| @@ -219,6 +252,9 @@ _FORTIFY_FN(wcsrtombs) size_t wcsrtombs(char * _FORTIFY_POS0 __d, | |||
| 219 | } | 252 | } |
| 220 | 253 | ||
| 221 | __access(write_only, 1, 3) | 254 | __access(write_only, 1, 3) |
| 255 | #if __has_builtin(__builtin_wcstombs) | ||
| 256 | __diagnose_as_builtin(__builtin_wcstombs, 1, 2, 3) | ||
| 257 | #endif | ||
| 222 | _FORTIFY_FN(wcstombs) size_t wcstombs(char * _FORTIFY_POS0 __s, | 258 | _FORTIFY_FN(wcstombs) size_t wcstombs(char * _FORTIFY_POS0 __s, |
| 223 | const wchar_t *__ws, size_t __n) | 259 | const wchar_t *__ws, size_t __n) |
| 224 | { | 260 | { |
| @@ -229,6 +265,9 @@ _FORTIFY_FN(wcstombs) size_t wcstombs(char * _FORTIFY_POS0 __s, | |||
| 229 | return __orig_wcstombs(__s, __ws, __n); | 265 | return __orig_wcstombs(__s, __ws, __n); |
| 230 | } | 266 | } |
| 231 | 267 | ||
| 268 | #if __has_builtin(__builtin_wctomb) | ||
| 269 | __diagnose_as_builtin(__builtin_wctomb, 1, 2) | ||
| 270 | #endif | ||
| 232 | _FORTIFY_FN(wctomb) int wctomb(char * _FORTIFY_POS0 __s, wchar_t __w) | 271 | _FORTIFY_FN(wctomb) int wctomb(char * _FORTIFY_POS0 __s, wchar_t __w) |
| 233 | { | 272 | { |
| 234 | size_t __b = __bos(__s, 0); | 273 | size_t __b = __bos(__s, 0); |
| @@ -238,6 +277,9 @@ _FORTIFY_FN(wctomb) int wctomb(char * _FORTIFY_POS0 __s, wchar_t __w) | |||
| 238 | return __orig_wctomb(__s, __w); | 277 | return __orig_wctomb(__s, __w); |
| 239 | } | 278 | } |
| 240 | 279 | ||
| 280 | #if __has_builtin(__builtin_wmemcpy) | ||
| 281 | __diagnose_as_builtin(__builtin_wmemcpy, 1, 2, 3) | ||
| 282 | #endif | ||
| 241 | _FORTIFY_FN(wmemcpy) wchar_t *wmemcpy(wchar_t * _FORTIFY_POS0 __d, | 283 | _FORTIFY_FN(wmemcpy) wchar_t *wmemcpy(wchar_t * _FORTIFY_POS0 __d, |
| 242 | const wchar_t *__s, size_t __n) | 284 | const wchar_t *__s, size_t __n) |
| 243 | { | 285 | { |
| @@ -248,6 +290,9 @@ _FORTIFY_FN(wmemcpy) wchar_t *wmemcpy(wchar_t * _FORTIFY_POS0 __d, | |||
| 248 | return __orig_wmemcpy(__d, __s, __n); | 290 | return __orig_wmemcpy(__d, __s, __n); |
| 249 | } | 291 | } |
| 250 | 292 | ||
| 293 | #if __has_builtin(__builtin_wmemmove) | ||
| 294 | __diagnose_as_builtin(__builtin_wmemmove, 1, 2, 3) | ||
| 295 | #endif | ||
| 251 | _FORTIFY_FN(wmemmove) wchar_t *wmemmove(wchar_t * _FORTIFY_POS0 __d, | 296 | _FORTIFY_FN(wmemmove) wchar_t *wmemmove(wchar_t * _FORTIFY_POS0 __d, |
| 252 | const wchar_t *__s, size_t __n) | 297 | const wchar_t *__s, size_t __n) |
| 253 | { | 298 | { |
| @@ -258,6 +303,9 @@ _FORTIFY_FN(wmemmove) wchar_t *wmemmove(wchar_t * _FORTIFY_POS0 __d, | |||
| 258 | return __orig_wmemmove(__d, __s, __n); | 303 | return __orig_wmemmove(__d, __s, __n); |
| 259 | } | 304 | } |
| 260 | 305 | ||
| 306 | #if __has_builtin(__builtin_wmemset) | ||
| 307 | __diagnose_as_builtin(__builtin_wmemset, 1, 2, 3) | ||
| 308 | #endif | ||
| 261 | _FORTIFY_FN(wmemset) wchar_t *wmemset(wchar_t * _FORTIFY_POS0 __s, | 309 | _FORTIFY_FN(wmemset) wchar_t *wmemset(wchar_t * _FORTIFY_POS0 __s, |
| 262 | wchar_t __c, size_t __n) | 310 | wchar_t __c, size_t __n) |
| 263 | { | 311 | { |
