diff options
Diffstat (limited to 'include/string.h')
| -rw-r--r-- | include/string.h | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/include/string.h b/include/string.h index a41c669..a6965b2 100644 --- a/include/string.h +++ b/include/string.h | |||
| @@ -51,8 +51,8 @@ __error_if((__bos(__od, 0) < __n), "'memcpy' called with `n` bigger than the siz | |||
| 51 | #if __has_builtin(__builtin___memcpy_chk) && USE_NATIVE_CHK | 51 | #if __has_builtin(__builtin___memcpy_chk) && USE_NATIVE_CHK |
| 52 | return __builtin___memcpy_chk(__od, __os, __n, __bos(__od, 0)); | 52 | return __builtin___memcpy_chk(__od, __os, __n, __bos(__od, 0)); |
| 53 | #else | 53 | #else |
| 54 | size_t __bd = __bos(__od, 0); | 54 | __fh_size_t __bd = __bos(__od, 0); |
| 55 | size_t __bs = __bos(__os, 0); | 55 | __fh_size_t __bs = __bos(__os, 0); |
| 56 | char *__d = (char *)__od; | 56 | char *__d = (char *)__od; |
| 57 | const char *__s = (const char *)__os; | 57 | const char *__s = (const char *)__os; |
| 58 | 58 | ||
| @@ -75,8 +75,8 @@ _FORTIFY_FN(memmove) void *memmove(void * _FORTIFY_POS0 __d, | |||
| 75 | #if __has_builtin(__builtin___memmove_chk) && USE_NATIVE_CHK | 75 | #if __has_builtin(__builtin___memmove_chk) && USE_NATIVE_CHK |
| 76 | return __builtin___memmove_chk(__d, __s, __n, __bos(__d, 0)); | 76 | return __builtin___memmove_chk(__d, __s, __n, __bos(__d, 0)); |
| 77 | #else | 77 | #else |
| 78 | size_t __bd = __bos(__d, 0); | 78 | __fh_size_t __bd = __bos(__d, 0); |
| 79 | size_t __bs = __bos(__s, 0); | 79 | __fh_size_t __bs = __bos(__s, 0); |
| 80 | 80 | ||
| 81 | if (__n > __bd || __n > __bs) | 81 | if (__n > __bd || __n > __bs) |
| 82 | __builtin_trap(); | 82 | __builtin_trap(); |
| @@ -94,7 +94,7 @@ __warning_if(__c != 0 && __n == 0, "'memset' will set `0` bytes; did you invert | |||
| 94 | #if __has_builtin(__builtin___memset_chk) && USE_NATIVE_CHK | 94 | #if __has_builtin(__builtin___memset_chk) && USE_NATIVE_CHK |
| 95 | return __builtin___memset_chk(__d, __c, __n, __bos(__d, 0)); | 95 | return __builtin___memset_chk(__d, __c, __n, __bos(__d, 0)); |
| 96 | #else | 96 | #else |
| 97 | size_t __b = __bos(__d, 0); | 97 | __fh_size_t __b = __bos(__d, 0); |
| 98 | 98 | ||
| 99 | if (__n > __b) | 99 | if (__n > __b) |
| 100 | __builtin_trap(); | 100 | __builtin_trap(); |
| @@ -111,7 +111,7 @@ _FORTIFY_FN(memchr) void *memchr(const void * _FORTIFY_POS0 __d, int __c, size_t | |||
| 111 | #if __has_builtin(__builtin___memchr_chk) && USE_NATIVE_CHK | 111 | #if __has_builtin(__builtin___memchr_chk) && USE_NATIVE_CHK |
| 112 | return __builtin___memchr_chk(__d, __c, __n, __bos(__d, 0)); | 112 | return __builtin___memchr_chk(__d, __c, __n, __bos(__d, 0)); |
| 113 | #else | 113 | #else |
| 114 | size_t __b = __bos(__d, 0); | 114 | __fh_size_t __b = __bos(__d, 0); |
| 115 | 115 | ||
| 116 | if (__n > __b) | 116 | if (__n > __b) |
| 117 | __builtin_trap(); | 117 | __builtin_trap(); |
| @@ -125,7 +125,7 @@ _FORTIFY_FN(strchr) char *strchr(const char * _FORTIFY_POS0 __s, int __c) | |||
| 125 | #if __has_builtin(__builtin___strchr_chk) && USE_NATIVE_CHK | 125 | #if __has_builtin(__builtin___strchr_chk) && USE_NATIVE_CHK |
| 126 | return __builtin___strchr_chk(__s, __c, __bos(__s, 0)); | 126 | return __builtin___strchr_chk(__s, __c, __bos(__s, 0)); |
| 127 | #else | 127 | #else |
| 128 | size_t __b = __bos(__s, 0); | 128 | __fh_size_t __b = __bos(__s, 0); |
| 129 | 129 | ||
| 130 | char* __r = __builtin_strchr(__s, __c); | 130 | char* __r = __builtin_strchr(__s, __c); |
| 131 | if (__r - __s > __b) | 131 | if (__r - __s > __b) |
| @@ -140,7 +140,7 @@ _FORTIFY_FN(strrchr) char *strrchr(const char * _FORTIFY_POS0 __s, int __c) | |||
| 140 | #if __has_builtin(__builtin___strrchr_chk) && USE_NATIVE_CHK | 140 | #if __has_builtin(__builtin___strrchr_chk) && USE_NATIVE_CHK |
| 141 | return __builtin___strrchr_chk(__s, __c, __bos(__s, 0)); | 141 | return __builtin___strrchr_chk(__s, __c, __bos(__s, 0)); |
| 142 | #else | 142 | #else |
| 143 | size_t __b = __bos(__s, 0); | 143 | __fh_size_t __b = __bos(__s, 0); |
| 144 | 144 | ||
| 145 | char* __r = __builtin_strrchr(__s, __c); | 145 | char* __r = __builtin_strrchr(__s, __c); |
| 146 | if (__r - __s > __b) | 146 | if (__r - __s > __b) |
| @@ -163,12 +163,12 @@ _FORTIFY_FN(stpcpy) char *stpcpy(char * _FORTIFY_POS0 __d, const char *__s) | |||
| 163 | #if __has_builtin(__builtin___stpcpy_chk) && USE_NATIVE_CHK | 163 | #if __has_builtin(__builtin___stpcpy_chk) && USE_NATIVE_CHK |
| 164 | return __builtin___stpcpy_chk(__d, __s, __bos(__d, 0)); | 164 | return __builtin___stpcpy_chk(__d, __s, __bos(__d, 0)); |
| 165 | #else | 165 | #else |
| 166 | size_t __n = strlen(__s) + 1; | 166 | __fh_size_t __n = strlen(__s) + 1; |
| 167 | 167 | ||
| 168 | if (__fh_overlap(__d, __s, __n)) | 168 | if (__fh_overlap(__d, __s, __n)) |
| 169 | __builtin_trap(); | 169 | __builtin_trap(); |
| 170 | 170 | ||
| 171 | size_t __b = __bos(__d, 0); | 171 | __fh_size_t __b = __bos(__d, 0); |
| 172 | if (__n > __b) | 172 | if (__n > __b) |
| 173 | __builtin_trap(); | 173 | __builtin_trap(); |
| 174 | return __orig_stpcpy(__d, __s); | 174 | return __orig_stpcpy(__d, __s); |
| @@ -190,7 +190,7 @@ _FORTIFY_FN(stpncpy) char *stpncpy(char * _FORTIFY_POS0 __d, const char *__s, | |||
| 190 | if (__fh_overlap(__d, __s, __n)) | 190 | if (__fh_overlap(__d, __s, __n)) |
| 191 | __builtin_trap(); | 191 | __builtin_trap(); |
| 192 | 192 | ||
| 193 | size_t __b = __bos(__d, 0); | 193 | __fh_size_t __b = __bos(__d, 0); |
| 194 | if (__n > __b && strlen(__s) + 1 > __b) | 194 | if (__n > __b && strlen(__s) + 1 > __b) |
| 195 | __builtin_trap(); | 195 | __builtin_trap(); |
| 196 | return __orig_stpncpy(__d, __s, __n); | 196 | return __orig_stpncpy(__d, __s, __n); |
| @@ -208,7 +208,7 @@ _FORTIFY_FN(strcat) char *strcat(char * _FORTIFY_POS0 __d, const char *__s) | |||
| 208 | #if __has_builtin(__builtin___strcat_chk) && USE_NATIVE_CHK | 208 | #if __has_builtin(__builtin___strcat_chk) && USE_NATIVE_CHK |
| 209 | return __builtin___strcat_chk(__d, __s, __bos(__d, 0)); | 209 | return __builtin___strcat_chk(__d, __s, __bos(__d, 0)); |
| 210 | #else | 210 | #else |
| 211 | size_t __b = __bos(__d, 0); | 211 | __fh_size_t __b = __bos(__d, 0); |
| 212 | 212 | ||
| 213 | if (strlen(__s) + strlen(__d) + 1 > __b) | 213 | if (strlen(__s) + strlen(__d) + 1 > __b) |
| 214 | __builtin_trap(); | 214 | __builtin_trap(); |
| @@ -226,12 +226,12 @@ _FORTIFY_FN(strcpy) char *strcpy(char * _FORTIFY_POS0 __d, const char *__s) | |||
| 226 | #if __has_builtin(__builtin___strcpy_chk) && USE_NATIVE_CHK | 226 | #if __has_builtin(__builtin___strcpy_chk) && USE_NATIVE_CHK |
| 227 | return __builtin___strcpy_chk(__d, __s, __bos(__d, 0)); | 227 | return __builtin___strcpy_chk(__d, __s, __bos(__d, 0)); |
| 228 | #else | 228 | #else |
| 229 | size_t __n = strlen(__s) + 1; | 229 | __fh_size_t __n = strlen(__s) + 1; |
| 230 | 230 | ||
| 231 | if (__fh_overlap(__d, __s, __n)) | 231 | if (__fh_overlap(__d, __s, __n)) |
| 232 | __builtin_trap(); | 232 | __builtin_trap(); |
| 233 | 233 | ||
| 234 | size_t __b = __bos(__d, 0); | 234 | __fh_size_t __b = __bos(__d, 0); |
| 235 | if (__n > __b) | 235 | if (__n > __b) |
| 236 | __builtin_trap(); | 236 | __builtin_trap(); |
| 237 | return __orig_strcpy(__d, __s); | 237 | return __orig_strcpy(__d, __s); |
| @@ -247,7 +247,7 @@ _FORTIFY_FN(strlen) size_t strlen(const char * _FORTIFY_POS0 __s) | |||
| 247 | #if __has_builtin(__builtin___strlen_chk) && USE_NATIVE_CHK | 247 | #if __has_builtin(__builtin___strlen_chk) && USE_NATIVE_CHK |
| 248 | return __builtin___strlen_chk(__s, __bos(__s, 0)); | 248 | return __builtin___strlen_chk(__s, __bos(__s, 0)); |
| 249 | #else | 249 | #else |
| 250 | size_t ret = __orig_strlen(__s); | 250 | __fh_size_t ret = __orig_strlen(__s); |
| 251 | if (ret > __bos(__s, 0) - 1) | 251 | if (ret > __bos(__s, 0) - 1) |
| 252 | __builtin_trap(); | 252 | __builtin_trap(); |
| 253 | return ret; | 253 | return ret; |
| @@ -265,11 +265,11 @@ _FORTIFY_FN(strncat) char *strncat(char * _FORTIFY_POS0 __d, const char *__s, | |||
| 265 | #if __has_builtin(__builtin___strncat_chk) && USE_NATIVE_CHK | 265 | #if __has_builtin(__builtin___strncat_chk) && USE_NATIVE_CHK |
| 266 | return __builtin___strncat_chk(__d, __s, __n, __bos(__d, 0)); | 266 | return __builtin___strncat_chk(__d, __s, __n, __bos(__d, 0)); |
| 267 | #else | 267 | #else |
| 268 | size_t __b = __bos(__d, 0); | 268 | __fh_size_t __b = __bos(__d, 0); |
| 269 | 269 | ||
| 270 | if (__n > __b) { | 270 | if (__n > __b) { |
| 271 | size_t __sl = strnlen(__s, __n); | 271 | __fh_size_t __sl = strnlen(__s, __n); |
| 272 | size_t __dl = strlen(__d); | 272 | __fh_size_t __dl = strlen(__d); |
| 273 | if (__sl + __dl + 1 > __b) | 273 | if (__sl + __dl + 1 > __b) |
| 274 | __builtin_trap(); | 274 | __builtin_trap(); |
| 275 | } | 275 | } |
| @@ -291,7 +291,7 @@ _FORTIFY_FN(strncpy) char *strncpy(char * _FORTIFY_POS0 __d, | |||
| 291 | if (__fh_overlap(__d, __s, __n)) | 291 | if (__fh_overlap(__d, __s, __n)) |
| 292 | __builtin_trap(); | 292 | __builtin_trap(); |
| 293 | 293 | ||
| 294 | size_t __b = __bos(__d, 0); | 294 | __fh_size_t __b = __bos(__d, 0); |
| 295 | if (__n > __b) | 295 | if (__n > __b) |
| 296 | __builtin_trap(); | 296 | __builtin_trap(); |
| 297 | return __orig_strncpy(__d, __s, __n); | 297 | return __orig_strncpy(__d, __s, __n); |
| @@ -311,8 +311,8 @@ _FORTIFY_FN(mempcpy) void *mempcpy(void * _FORTIFY_POS0 __d, | |||
| 311 | #if __has_builtin(__builtin___mempcpy_chk) && USE_NATIVE_CHK | 311 | #if __has_builtin(__builtin___mempcpy_chk) && USE_NATIVE_CHK |
| 312 | return __builtin___mempcpy_chk(__d, __s, __n, __bos(__d, 0)); | 312 | return __builtin___mempcpy_chk(__d, __s, __n, __bos(__d, 0)); |
| 313 | #else | 313 | #else |
| 314 | size_t __bd = __bos(__d, 0); | 314 | __fh_size_t __bd = __bos(__d, 0); |
| 315 | size_t __bs = __bos(__s, 0); | 315 | __fh_size_t __bs = __bos(__s, 0); |
| 316 | 316 | ||
| 317 | if (__n > __bd || __n > __bs) | 317 | if (__n > __bd || __n > __bs) |
| 318 | __builtin_trap(); | 318 | __builtin_trap(); |
| @@ -335,7 +335,7 @@ _FORTIFY_FN(strlcat) size_t strlcat(char * _FORTIFY_POS0 __d, | |||
| 335 | #if __has_builtin(__builtin___strlcat_chk) && USE_NATIVE_CHK | 335 | #if __has_builtin(__builtin___strlcat_chk) && USE_NATIVE_CHK |
| 336 | return __builtin___strlcat_chk(__d, __s, __n, __bos(__d, 0)); | 336 | return __builtin___strlcat_chk(__d, __s, __n, __bos(__d, 0)); |
| 337 | #else | 337 | #else |
| 338 | size_t __b = __bos(__d, 0); | 338 | __fh_size_t __b = __bos(__d, 0); |
| 339 | 339 | ||
| 340 | if (__n > __b) | 340 | if (__n > __b) |
| 341 | __builtin_trap(); | 341 | __builtin_trap(); |
| @@ -354,7 +354,7 @@ _FORTIFY_FN(strlcpy) size_t strlcpy(char * _FORTIFY_POS0 __d, | |||
| 354 | #if __has_builtin(__builtin___strlcpy_chk) && USE_NATIVE_CHK | 354 | #if __has_builtin(__builtin___strlcpy_chk) && USE_NATIVE_CHK |
| 355 | return __builtin___strlcpy_chk(__d, __s, __n, __bos(__d, 0)); | 355 | return __builtin___strlcpy_chk(__d, __s, __n, __bos(__d, 0)); |
| 356 | #else | 356 | #else |
| 357 | size_t __b = __bos(__d, 0); | 357 | __fh_size_t __b = __bos(__d, 0); |
| 358 | 358 | ||
| 359 | if (__n > __b) | 359 | if (__n > __b) |
| 360 | __builtin_trap(); | 360 | __builtin_trap(); |
