diff options
Diffstat (limited to 'include/string.h')
| -rw-r--r-- | include/string.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/string.h b/include/string.h index 6d4b2d8..1fba9d9 100644 --- a/include/string.h +++ b/include/string.h | |||
| @@ -91,6 +91,17 @@ _FORTIFY_FN(memchr) void *memchr(const void * _FORTIFY_POS0 __d, int __c, size_t | |||
| 91 | return __builtin_memchr(__d, __c, __n); | 91 | return __builtin_memchr(__d, __c, __n); |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | __access(read_only, 1, 2) | ||
| 95 | _FORTIFY_FN(strchr) char *strchr(const char * _FORTIFY_POS0 __s, int __c) | ||
| 96 | { | ||
| 97 | size_t __b = __bos(__s, 0); | ||
| 98 | |||
| 99 | char* __r = __builtin_strchr(__s, __c); | ||
| 100 | if (__r - __s > __b) | ||
| 101 | __builtin_trap(); | ||
| 102 | return __r; | ||
| 103 | } | ||
| 104 | |||
| 94 | #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ | 105 | #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ |
| 95 | || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ | 106 | || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ |
| 96 | || defined(_BSD_SOURCE) | 107 | || defined(_BSD_SOURCE) |
