You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* trap if pointers are overlapping but not if dst == src.
* gcc seems to like to generate code that relies on dst == src */
if ((__d<__s&&__d+__n>__s) ||
(__s<__d&&__s+__n>__d))
__builtin_trap();
size_t__b=__bos(__d, 0);
if (__n>__b)
__builtin_trap();
return__orig_strcpy(__d, __s);
By the time, __orig_strcpy is called, the length has already been computed and has been established to be in bound. There's no need to pay for the nul-byte search again inside of __orig_strcpy when the faster memcpy can be called instead.
Some of the other str* functions suffer from the same issue.
The text was updated successfully, but these errors were encountered:
N-R-K
changed the title
Avoid unnecessarily calling slow functions
Avoid unnecessarily calling slower functions
Jul 31, 2023
For example, in
strcpy
(ignoring the UB overlapping check):fortify-headers/include/string.h
Lines 139 to 150 in 9aa4490
By the time,
__orig_strcpy
is called, the length has already been computed and has been established to be in bound. There's no need to pay for the nul-byte search again inside of__orig_strcpy
when the fastermemcpy
can be called instead.Some of the other
str*
functions suffer from the same issue.The text was updated successfully, but these errors were encountered: