diff options
| author | jvoisin | 2023-12-27 16:17:55 +0100 |
|---|---|---|
| committer | jvoisin | 2023-12-27 16:17:55 +0100 |
| commit | 8513fddefca4c6e3982718732afeec71bad4e688 (patch) | |
| tree | 46f1132082012f57628d0fad296c64fa22209c90 /include/string.h | |
| parent | 80a83a56b52e833e6d3afec4d0723d7625d52cee (diff) | |
Improve __fh_overlap implementation
Diffstat (limited to 'include/string.h')
| -rw-r--r-- | include/string.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/include/string.h b/include/string.h index 925e572..9cb0598 100644 --- a/include/string.h +++ b/include/string.h | |||
| @@ -56,7 +56,7 @@ __error_if((__fh_bos(__od, 0) < __n), "'memcpy' called with `n` bigger than the | |||
| 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 | ||
| 59 | if __fh_overlap(__d, __s, __n) | 59 | if __fh_overlap(__d, __bd, __s, __n) |
| 60 | __builtin_trap(); | 60 | __builtin_trap(); |
| 61 | if (__n > __bd || __n > __bs) | 61 | if (__n > __bd || __n > __bs) |
| 62 | __builtin_trap(); | 62 | __builtin_trap(); |
| @@ -166,11 +166,11 @@ _FORTIFY_FN(stpcpy) char *stpcpy(char * _FORTIFY_POS0 __d, const char *__s) | |||
| 166 | return __builtin___stpcpy_chk(__d, __s, __fh_bos(__d, 0)); | 166 | return __builtin___stpcpy_chk(__d, __s, __fh_bos(__d, 0)); |
| 167 | #else | 167 | #else |
| 168 | __fh_size_t __n = strlen(__s) + 1; | 168 | __fh_size_t __n = strlen(__s) + 1; |
| 169 | __fh_size_t __b = __fh_bos(__d, 0); | ||
| 169 | 170 | ||
| 170 | if (__fh_overlap(__d, __s, __n)) | 171 | if (__fh_overlap(__d, __b, __s, __n)) |
| 171 | __builtin_trap(); | 172 | __builtin_trap(); |
| 172 | 173 | ||
| 173 | __fh_size_t __b = __fh_bos(__d, 0); | ||
| 174 | if (__n > __b) | 174 | if (__n > __b) |
| 175 | __builtin_trap(); | 175 | __builtin_trap(); |
| 176 | return __orig_stpcpy(__d, __s); | 176 | return __orig_stpcpy(__d, __s); |
| @@ -236,11 +236,11 @@ _FORTIFY_FN(strcpy) char *strcpy(char * _FORTIFY_POS0 __d, const char *__s) | |||
| 236 | return __builtin___strcpy_chk(__d, __s, __fh_bos(__d, 0)); | 236 | return __builtin___strcpy_chk(__d, __s, __fh_bos(__d, 0)); |
| 237 | #else | 237 | #else |
| 238 | __fh_size_t __n = strlen(__s) + 1; | 238 | __fh_size_t __n = strlen(__s) + 1; |
| 239 | __fh_size_t __b = __fh_bos(__d, 0); | ||
| 239 | 240 | ||
| 240 | if (__fh_overlap(__d, __s, __n)) | 241 | if (__fh_overlap(__d, __b, __s, __n)) |
| 241 | __builtin_trap(); | 242 | __builtin_trap(); |
| 242 | 243 | ||
| 243 | __fh_size_t __b = __fh_bos(__d, 0); | ||
| 244 | if (__n > __b) | 244 | if (__n > __b) |
| 245 | __builtin_trap(); | 245 | __builtin_trap(); |
| 246 | return __orig_strcpy(__d, __s); | 246 | return __orig_strcpy(__d, __s); |
