diff options
| author | jvoisin | 2023-09-27 21:52:06 +0200 |
|---|---|---|
| committer | jvoisin | 2023-09-27 23:00:20 +0200 |
| commit | 2ccfced2116d00e6ddf3aa6f10cfacab5a863c76 (patch) | |
| tree | 31262a2870dedeaac1170deacb043b02011bc44c /include | |
| parent | 75b95fa25df74fcd0498bf59e3524f20f594755d (diff) | |
Add an option to make use of compiler-provided _chk builtins
Diffstat (limited to 'include')
| -rw-r--r-- | include/stdio.h | 9 | ||||
| -rw-r--r-- | include/string.h | 60 |
2 files changed, 69 insertions, 0 deletions
diff --git a/include/stdio.h b/include/stdio.h index 582be4f..25e7ad2 100644 --- a/include/stdio.h +++ b/include/stdio.h | |||
| @@ -145,11 +145,15 @@ __diagnose_as_builtin(__builtin_vsnprintf, 1, 2, 3, 4) | |||
| 145 | _FORTIFY_FN(vsnprintf) int vsnprintf(char * _FORTIFY_POS0 __s, size_t __n, | 145 | _FORTIFY_FN(vsnprintf) int vsnprintf(char * _FORTIFY_POS0 __s, size_t __n, |
| 146 | const char *__f, __builtin_va_list __v) | 146 | const char *__f, __builtin_va_list __v) |
| 147 | { | 147 | { |
| 148 | #if __has_builtin(__builtin___vsnprintf_chk) && USE_NATIVE_CHK | ||
| 149 | return __builtin___vsnprintf_chk(__s, __n, _FORTIFY_SOURCE, __bos(__s, 0), __f, __v,); | ||
| 150 | #else | ||
| 148 | size_t __b = __bos(__s, 0); | 151 | size_t __b = __bos(__s, 0); |
| 149 | 152 | ||
| 150 | if (__n > __b) | 153 | if (__n > __b) |
| 151 | __builtin_trap(); | 154 | __builtin_trap(); |
| 152 | return __orig_vsnprintf(__s, __n, __f, __v); | 155 | return __orig_vsnprintf(__s, __n, __f, __v); |
| 156 | #endif | ||
| 153 | } | 157 | } |
| 154 | 158 | ||
| 155 | __format(printf, 2, 0) | 159 | __format(printf, 2, 0) |
| @@ -161,6 +165,9 @@ __diagnose_as_builtin(__builtin_vsprintf, 1, 2, 3) | |||
| 161 | _FORTIFY_FN(vsprintf) int vsprintf(char * _FORTIFY_POS0 __s, const char *__f, | 165 | _FORTIFY_FN(vsprintf) int vsprintf(char * _FORTIFY_POS0 __s, const char *__f, |
| 162 | __builtin_va_list __v) | 166 | __builtin_va_list __v) |
| 163 | { | 167 | { |
| 168 | #if __has_builtin(__builtin___vsnprintf_chk) && USE_NATIVE_CHK | ||
| 169 | return __builtin___vsprintf_chk(__s, _FORTIFY_SOURCE, __bos(__s, 0), __f, __v,); | ||
| 170 | #else | ||
| 164 | size_t __b = __bos(__s, 0); | 171 | size_t __b = __bos(__s, 0); |
| 165 | int __r; | 172 | int __r; |
| 166 | 173 | ||
| @@ -172,8 +179,10 @@ _FORTIFY_FN(vsprintf) int vsprintf(char * _FORTIFY_POS0 __s, const char *__f, | |||
| 172 | __r = __orig_vsprintf(__s, __f, __v); | 179 | __r = __orig_vsprintf(__s, __f, __v); |
| 173 | } | 180 | } |
| 174 | return __r; | 181 | return __r; |
| 182 | #endif | ||
| 175 | } | 183 | } |
| 176 | 184 | ||
| 185 | |||
| 177 | #if __has_builtin(__builtin_va_arg_pack) | 186 | #if __has_builtin(__builtin_va_arg_pack) |
| 178 | 187 | ||
| 179 | /* clang is missing __builtin_va_arg_pack, so we cannot use these impls | 188 | /* clang is missing __builtin_va_arg_pack, so we cannot use these impls |
diff --git a/include/string.h b/include/string.h index 8a440e4..e681181 100644 --- a/include/string.h +++ b/include/string.h | |||
| @@ -47,6 +47,9 @@ _FORTIFY_FN(memcpy) void *memcpy(void * _FORTIFY_POS0 __od, | |||
| 47 | const void * _FORTIFY_POS0 __os, size_t __n) | 47 | const void * _FORTIFY_POS0 __os, size_t __n) |
| 48 | __error_if((__bos(__od, 0) < __n), "'memcpy' called with `n` bigger than the size of `d`.") | 48 | __error_if((__bos(__od, 0) < __n), "'memcpy' called with `n` bigger than the size of `d`.") |
| 49 | { | 49 | { |
| 50 | #if __has_builtin(__builtin___memcpy_chk) && USE_NATIVE_CHK | ||
| 51 | return __builtin___memcpy_chk(__od, __os, __n, __bos(__od, 0)); | ||
| 52 | #else | ||
| 50 | size_t __bd = __bos(__od, 0); | 53 | size_t __bd = __bos(__od, 0); |
| 51 | size_t __bs = __bos(__os, 0); | 54 | size_t __bs = __bos(__os, 0); |
| 52 | char *__d = (char *)__od; | 55 | char *__d = (char *)__od; |
| @@ -57,6 +60,7 @@ __error_if((__bos(__od, 0) < __n), "'memcpy' called with `n` bigger than the siz | |||
| 57 | if (__n > __bd || __n > __bs) | 60 | if (__n > __bd || __n > __bs) |
| 58 | __builtin_trap(); | 61 | __builtin_trap(); |
| 59 | return __builtin_memcpy(__od, __os, __n); | 62 | return __builtin_memcpy(__od, __os, __n); |
| 63 | #endif | ||
| 60 | } | 64 | } |
| 61 | 65 | ||
| 62 | __access(write_only, 1, 3) | 66 | __access(write_only, 1, 3) |
| @@ -67,12 +71,16 @@ __diagnose_as_builtin(__builtin_memmove, 1, 2, 3) | |||
| 67 | _FORTIFY_FN(memmove) void *memmove(void * _FORTIFY_POS0 __d, | 71 | _FORTIFY_FN(memmove) void *memmove(void * _FORTIFY_POS0 __d, |
| 68 | const void * _FORTIFY_POS0 __s, size_t __n) | 72 | const void * _FORTIFY_POS0 __s, size_t __n) |
| 69 | { | 73 | { |
| 74 | #if __has_builtin(__builtin___memmove_chk) && USE_NATIVE_CHK | ||
| 75 | return __builtin___memcpy_chk(__d, __s, __n, __bos(__d, 0)); | ||
| 76 | #else | ||
| 70 | size_t __bd = __bos(__d, 0); | 77 | size_t __bd = __bos(__d, 0); |
| 71 | size_t __bs = __bos(__s, 0); | 78 | size_t __bs = __bos(__s, 0); |
| 72 | 79 | ||
| 73 | if (__n > __bd || __n > __bs) | 80 | if (__n > __bd || __n > __bs) |
| 74 | __builtin_trap(); | 81 | __builtin_trap(); |
| 75 | return __orig_memmove(__d, __s, __n); | 82 | return __orig_memmove(__d, __s, __n); |
| 83 | #endif | ||
| 76 | } | 84 | } |
| 77 | 85 | ||
| 78 | __access(write_only, 1, 3) | 86 | __access(write_only, 1, 3) |
| @@ -82,11 +90,15 @@ __diagnose_as_builtin(__builtin_memset, 1, 2, 3) | |||
| 82 | _FORTIFY_FN(memset) void *memset(void * _FORTIFY_POS0 __d, int __c, size_t __n) | 90 | _FORTIFY_FN(memset) void *memset(void * _FORTIFY_POS0 __d, int __c, size_t __n) |
| 83 | __warning_if(__c != 0 && __n == 0, "'memset' will set `0` bytes; did you invert the arguments?") | 91 | __warning_if(__c != 0 && __n == 0, "'memset' will set `0` bytes; did you invert the arguments?") |
| 84 | { | 92 | { |
| 93 | #if __has_builtin(__builtin___memset_chk) && USE_NATIVE_CHK | ||
| 94 | return __builtin___memset_chk(__d, __c, __n, __bos(__d, 0)); | ||
| 95 | #else | ||
| 85 | size_t __b = __bos(__d, 0); | 96 | size_t __b = __bos(__d, 0); |
| 86 | 97 | ||
| 87 | if (__n > __b) | 98 | if (__n > __b) |
| 88 | __builtin_trap(); | 99 | __builtin_trap(); |
| 89 | return __builtin_memset(__d, __c, __n); | 100 | return __builtin_memset(__d, __c, __n); |
| 101 | #endif | ||
| 90 | } | 102 | } |
| 91 | 103 | ||
| 92 | __access(read_only, 1, 3) | 104 | __access(read_only, 1, 3) |
| @@ -95,33 +107,45 @@ __diagnose_as_builtin(__builtin_memchr, 1, 2, 3) | |||
| 95 | #endif | 107 | #endif |
| 96 | _FORTIFY_FN(memchr) void *memchr(const void * _FORTIFY_POS0 __d, int __c, size_t __n) | 108 | _FORTIFY_FN(memchr) void *memchr(const void * _FORTIFY_POS0 __d, int __c, size_t __n) |
| 97 | { | 109 | { |
| 110 | #if __has_builtin(__builtin___memchr_chk) && USE_NATIVE_CHK | ||
| 111 | return __builtin___memchr_chk(__d, __c, __n, __bos(__d, 0)); | ||
| 112 | #else | ||
| 98 | size_t __b = __bos(__d, 0); | 113 | size_t __b = __bos(__d, 0); |
| 99 | 114 | ||
| 100 | if (__n > __b) | 115 | if (__n > __b) |
| 101 | __builtin_trap(); | 116 | __builtin_trap(); |
| 102 | return __builtin_memchr(__d, __c, __n); | 117 | return __builtin_memchr(__d, __c, __n); |
| 118 | #endif | ||
| 103 | } | 119 | } |
| 104 | 120 | ||
| 105 | __access(read_only, 1, 2) | 121 | __access(read_only, 1, 2) |
| 106 | _FORTIFY_FN(strchr) char *strchr(const char * _FORTIFY_POS0 __s, int __c) | 122 | _FORTIFY_FN(strchr) char *strchr(const char * _FORTIFY_POS0 __s, int __c) |
| 107 | { | 123 | { |
| 124 | #if __has_builtin(__builtin___strchr_chk) && USE_NATIVE_CHK | ||
| 125 | return __builtin___strchr_chk(__s, __c, __bos(__s, 0)); | ||
| 126 | #else | ||
| 108 | size_t __b = __bos(__s, 0); | 127 | size_t __b = __bos(__s, 0); |
| 109 | 128 | ||
| 110 | char* __r = __builtin_strchr(__s, __c); | 129 | char* __r = __builtin_strchr(__s, __c); |
| 111 | if (__r - __s > __b) | 130 | if (__r - __s > __b) |
| 112 | __builtin_trap(); | 131 | __builtin_trap(); |
| 113 | return __r; | 132 | return __r; |
| 133 | #endif | ||
| 114 | } | 134 | } |
| 115 | 135 | ||
| 116 | __access(read_only, 1, 2) | 136 | __access(read_only, 1, 2) |
| 117 | _FORTIFY_FN(strrchr) char *strrchr(const char * _FORTIFY_POS0 __s, int __c) | 137 | _FORTIFY_FN(strrchr) char *strrchr(const char * _FORTIFY_POS0 __s, int __c) |
| 118 | { | 138 | { |
| 139 | #if __has_builtin(__builtin___strrchr_chk) && USE_NATIVE_CHK | ||
| 140 | return __builtin___strrchr_chk(__s, __c, __bos(__s, 0)); | ||
| 141 | #else | ||
| 119 | size_t __b = __bos(__s, 0); | 142 | size_t __b = __bos(__s, 0); |
| 120 | 143 | ||
| 121 | char* __r = __builtin_strrchr(__s, __c); | 144 | char* __r = __builtin_strrchr(__s, __c); |
| 122 | if (__r - __s > __b) | 145 | if (__r - __s > __b) |
| 123 | __builtin_trap(); | 146 | __builtin_trap(); |
| 124 | return __r; | 147 | return __r; |
| 148 | #endif | ||
| 125 | } | 149 | } |
| 126 | 150 | ||
| 127 | #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ | 151 | #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ |
| @@ -135,6 +159,9 @@ __diagnose_as_builtin(__builtin_stpcpy, 1, 2) | |||
| 135 | #endif | 159 | #endif |
| 136 | _FORTIFY_FN(stpcpy) char *stpcpy(char * _FORTIFY_POS0 __d, const char *__s) | 160 | _FORTIFY_FN(stpcpy) char *stpcpy(char * _FORTIFY_POS0 __d, const char *__s) |
| 137 | { | 161 | { |
| 162 | #if __has_builtin(__builtin___stpcpy_chk) && USE_NATIVE_CHK | ||
| 163 | return __builtin___stpcpy_chk(__d, __s, __bos(__d, 0)); | ||
| 164 | #else | ||
| 138 | size_t __n = strlen(__s) + 1; | 165 | size_t __n = strlen(__s) + 1; |
| 139 | 166 | ||
| 140 | if (__fh_overlap(__d, __s, __n)) | 167 | if (__fh_overlap(__d, __s, __n)) |
| @@ -144,6 +171,7 @@ _FORTIFY_FN(stpcpy) char *stpcpy(char * _FORTIFY_POS0 __d, const char *__s) | |||
| 144 | if (__n > __b) | 171 | if (__n > __b) |
| 145 | __builtin_trap(); | 172 | __builtin_trap(); |
| 146 | return __orig_stpcpy(__d, __s); | 173 | return __orig_stpcpy(__d, __s); |
| 174 | #endif | ||
| 147 | } | 175 | } |
| 148 | 176 | ||
| 149 | #undef stpncpy | 177 | #undef stpncpy |
| @@ -155,6 +183,9 @@ __diagnose_as_builtin(__builtin_stpncpy, 1, 2, 3) | |||
| 155 | _FORTIFY_FN(stpncpy) char *stpncpy(char * _FORTIFY_POS0 __d, const char *__s, | 183 | _FORTIFY_FN(stpncpy) char *stpncpy(char * _FORTIFY_POS0 __d, const char *__s, |
| 156 | size_t __n) | 184 | size_t __n) |
| 157 | { | 185 | { |
| 186 | #if __has_builtin(__builtin___stpncpy_chk) && USE_NATIVE_CHK | ||
| 187 | return __builtin___stpncpy_chk(__d, __s, __n, __bos(__d, 0)); | ||
| 188 | #else | ||
| 158 | if (__fh_overlap(__d, __s, __n)) | 189 | if (__fh_overlap(__d, __s, __n)) |
| 159 | __builtin_trap(); | 190 | __builtin_trap(); |
| 160 | 191 | ||
| @@ -162,6 +193,7 @@ _FORTIFY_FN(stpncpy) char *stpncpy(char * _FORTIFY_POS0 __d, const char *__s, | |||
| 162 | if (__n > __b && strlen(__s) + 1 > __b) | 193 | if (__n > __b && strlen(__s) + 1 > __b) |
| 163 | __builtin_trap(); | 194 | __builtin_trap(); |
| 164 | return __orig_stpncpy(__d, __s, __n); | 195 | return __orig_stpncpy(__d, __s, __n); |
| 196 | #endif | ||
| 165 | } | 197 | } |
| 166 | #endif | 198 | #endif |
| 167 | 199 | ||
| @@ -172,11 +204,15 @@ __diagnose_as_builtin(__builtin_strcat, 1, 2) | |||
| 172 | #endif | 204 | #endif |
| 173 | _FORTIFY_FN(strcat) char *strcat(char * _FORTIFY_POS0 __d, const char *__s) | 205 | _FORTIFY_FN(strcat) char *strcat(char * _FORTIFY_POS0 __d, const char *__s) |
| 174 | { | 206 | { |
| 207 | #if __has_builtin(__builtin___strcat_chk) && USE_NATIVE_CHK | ||
| 208 | return __builtin___strcat_chk(__d, __s, __bos(__d, 0)); | ||
| 209 | #else | ||
| 175 | size_t __b = __bos(__d, 0); | 210 | size_t __b = __bos(__d, 0); |
| 176 | 211 | ||
| 177 | if (strlen(__s) + strlen(__d) + 1 > __b) | 212 | if (strlen(__s) + strlen(__d) + 1 > __b) |
| 178 | __builtin_trap(); | 213 | __builtin_trap(); |
| 179 | return __orig_strcat(__d, __s); | 214 | return __orig_strcat(__d, __s); |
| 215 | #endif | ||
| 180 | } | 216 | } |
| 181 | 217 | ||
| 182 | __access (write_only, 1) | 218 | __access (write_only, 1) |
| @@ -186,6 +222,9 @@ __diagnose_as_builtin(__builtin_strcpy, 1, 2) | |||
| 186 | #endif | 222 | #endif |
| 187 | _FORTIFY_FN(strcpy) char *strcpy(char * _FORTIFY_POS0 __d, const char *__s) | 223 | _FORTIFY_FN(strcpy) char *strcpy(char * _FORTIFY_POS0 __d, const char *__s) |
| 188 | { | 224 | { |
| 225 | #if __has_builtin(__builtin___strcpy_chk) && USE_NATIVE_CHK | ||
| 226 | return __builtin___strcpy_chk(__d, __s, __bos(__d, 0)); | ||
| 227 | #else | ||
| 189 | size_t __n = strlen(__s) + 1; | 228 | size_t __n = strlen(__s) + 1; |
| 190 | 229 | ||
| 191 | if (__fh_overlap(__d, __s, __n)) | 230 | if (__fh_overlap(__d, __s, __n)) |
| @@ -195,6 +234,7 @@ _FORTIFY_FN(strcpy) char *strcpy(char * _FORTIFY_POS0 __d, const char *__s) | |||
| 195 | if (__n > __b) | 234 | if (__n > __b) |
| 196 | __builtin_trap(); | 235 | __builtin_trap(); |
| 197 | return __orig_strcpy(__d, __s); | 236 | return __orig_strcpy(__d, __s); |
| 237 | #endif | ||
| 198 | } | 238 | } |
| 199 | 239 | ||
| 200 | __access (read_write, 1) | 240 | __access (read_write, 1) |
| @@ -205,6 +245,9 @@ __diagnose_as_builtin(__builtin_strncat, 1, 2, 3) | |||
| 205 | _FORTIFY_FN(strncat) char *strncat(char * _FORTIFY_POS0 __d, const char *__s, | 245 | _FORTIFY_FN(strncat) char *strncat(char * _FORTIFY_POS0 __d, const char *__s, |
| 206 | size_t __n) | 246 | size_t __n) |
| 207 | { | 247 | { |
| 248 | #if __has_builtin(__builtin___strncat_chk) && USE_NATIVE_CHK | ||
| 249 | return __builtin___strncat_chk(__d, __s, __n, __bos(__d, 0)); | ||
| 250 | #else | ||
| 208 | size_t __b = __bos(__d, 0); | 251 | size_t __b = __bos(__d, 0); |
| 209 | 252 | ||
| 210 | if (__n > __b) { | 253 | if (__n > __b) { |
| @@ -214,6 +257,7 @@ _FORTIFY_FN(strncat) char *strncat(char * _FORTIFY_POS0 __d, const char *__s, | |||
| 214 | __builtin_trap(); | 257 | __builtin_trap(); |
| 215 | } | 258 | } |
| 216 | return __orig_strncat(__d, __s, __n); | 259 | return __orig_strncat(__d, __s, __n); |
| 260 | #endif | ||
| 217 | } | 261 | } |
| 218 | 262 | ||
| 219 | __access (write_only, 1) | 263 | __access (write_only, 1) |
| @@ -224,6 +268,9 @@ __diagnose_as_builtin(__builtin_strncpy, 1, 2, 3) | |||
| 224 | _FORTIFY_FN(strncpy) char *strncpy(char * _FORTIFY_POS0 __d, | 268 | _FORTIFY_FN(strncpy) char *strncpy(char * _FORTIFY_POS0 __d, |
| 225 | const char *__s, size_t __n) | 269 | const char *__s, size_t __n) |
| 226 | { | 270 | { |
| 271 | #if __has_builtin(__builtin___strncpy_chk) && USE_NATIVE_CHK | ||
| 272 | return __builtin___strncpy_chk(__d, __s, __n, __bos(__d, 0)); | ||
| 273 | #else | ||
| 227 | if (__fh_overlap(__d, __s, __n)) | 274 | if (__fh_overlap(__d, __s, __n)) |
| 228 | __builtin_trap(); | 275 | __builtin_trap(); |
| 229 | 276 | ||
| @@ -231,6 +278,7 @@ _FORTIFY_FN(strncpy) char *strncpy(char * _FORTIFY_POS0 __d, | |||
| 231 | if (__n > __b) | 278 | if (__n > __b) |
| 232 | __builtin_trap(); | 279 | __builtin_trap(); |
| 233 | return __orig_strncpy(__d, __s, __n); | 280 | return __orig_strncpy(__d, __s, __n); |
| 281 | #endif | ||
| 234 | } | 282 | } |
| 235 | 283 | ||
| 236 | #ifdef _GNU_SOURCE | 284 | #ifdef _GNU_SOURCE |
| @@ -243,12 +291,16 @@ __diagnose_as_builtin(__builtin_mempcpy, 1, 2, 3) | |||
| 243 | _FORTIFY_FN(mempcpy) void *mempcpy(void * _FORTIFY_POS0 __d, | 291 | _FORTIFY_FN(mempcpy) void *mempcpy(void * _FORTIFY_POS0 __d, |
| 244 | const void * _FORTIFY_POS0 __s, size_t __n) | 292 | const void * _FORTIFY_POS0 __s, size_t __n) |
| 245 | { | 293 | { |
| 294 | #if __has_builtin(__builtin___mempcpy_chk) && USE_NATIVE_CHK | ||
| 295 | return __builtin___mempcpy_chk(__d, __s, __n, __bos(__d, 0)); | ||
| 296 | #else | ||
| 246 | size_t __bd = __bos(__d, 0); | 297 | size_t __bd = __bos(__d, 0); |
| 247 | size_t __bs = __bos(__s, 0); | 298 | size_t __bs = __bos(__s, 0); |
| 248 | 299 | ||
| 249 | if (__n > __bd || __n > __bs) | 300 | if (__n > __bd || __n > __bs) |
| 250 | __builtin_trap(); | 301 | __builtin_trap(); |
| 251 | return __orig_mempcpy(__d, __s, __n); | 302 | return __orig_mempcpy(__d, __s, __n); |
| 303 | #endif | ||
| 252 | } | 304 | } |
| 253 | #endif | 305 | #endif |
| 254 | 306 | ||
| @@ -263,11 +315,15 @@ __diagnose_as_builtin(__builtin_strlcat, 1, 2, 3) | |||
| 263 | _FORTIFY_FN(strlcat) size_t strlcat(char * _FORTIFY_POS0 __d, | 315 | _FORTIFY_FN(strlcat) size_t strlcat(char * _FORTIFY_POS0 __d, |
| 264 | const char *__s, size_t __n) | 316 | const char *__s, size_t __n) |
| 265 | { | 317 | { |
| 318 | #if __has_builtin(__builtin___strlcat_chk) && USE_NATIVE_CHK | ||
| 319 | return __builtin___strlcat_chk(__d, __s, __n, __bos(__d, 0)); | ||
| 320 | #else | ||
| 266 | size_t __b = __bos(__d, 0); | 321 | size_t __b = __bos(__d, 0); |
| 267 | 322 | ||
| 268 | if (__n > __b) | 323 | if (__n > __b) |
| 269 | __builtin_trap(); | 324 | __builtin_trap(); |
| 270 | return __orig_strlcat(__d, __s, __n); | 325 | return __orig_strlcat(__d, __s, __n); |
| 326 | #endif | ||
| 271 | } | 327 | } |
| 272 | 328 | ||
| 273 | __access (write_only, 1) | 329 | __access (write_only, 1) |
| @@ -278,11 +334,15 @@ __diagnose_as_builtin(__builtin_strlcpy, 1, 2, 3) | |||
| 278 | _FORTIFY_FN(strlcpy) size_t strlcpy(char * _FORTIFY_POS0 __d, | 334 | _FORTIFY_FN(strlcpy) size_t strlcpy(char * _FORTIFY_POS0 __d, |
| 279 | const char *__s, size_t __n) | 335 | const char *__s, size_t __n) |
| 280 | { | 336 | { |
| 337 | #if __has_builtin(__builtin___strlcpy_chk) && USE_NATIVE_CHK | ||
| 338 | return __builtin___strlcpy_chk(__d, __s, __n, __bos(__d, 0)); | ||
| 339 | #else | ||
| 281 | size_t __b = __bos(__d, 0); | 340 | size_t __b = __bos(__d, 0); |
| 282 | 341 | ||
| 283 | if (__n > __b) | 342 | if (__n > __b) |
| 284 | __builtin_trap(); | 343 | __builtin_trap(); |
| 285 | return __orig_strlcpy(__d, __s, __n); | 344 | return __orig_strlcpy(__d, __s, __n); |
| 345 | #endif | ||
| 286 | } | 346 | } |
| 287 | #endif | 347 | #endif |
| 288 | 348 | ||
