[PATCH] D42061: Add new interceptors: strlcpy(3) and strlcat(3)
Kamil Rytarowski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 1 11:39:38 PST 2018
krytarowski added a comment.
Should be done.
================
Comment at: lib/sanitizer_common/sanitizer_common_interceptors.inc:6618
+ SIZE_T len = REAL(strnlen)(src, size);
+ COMMON_INTERCEPTOR_READ_RANGE(ctx, src, len >= size ? size : len + 1);
+ }
----------------
vitalybuka wrote:
> from doc
> > Also note that strlcpy() and strlcat() only operate on true ``C'' strings.
> so we need COMMON_INTERCEPTOR_READ_STRING to enable strict_string_checks
>
> len can't be len > size, so
>
> ```
> if len < size
> we need to read len + 1
> if len == size
> we need to read len or size
> ```
>
> this probably should be
> COMMON_INTERCEPTOR_READ_STRING(ctx, src, MIN(REAL(strnlen)(src, size), size - 1) + 1)
"len can't be len > size, so" I don't see this enforced in the specification of the function.
Repository:
rL LLVM
https://reviews.llvm.org/D42061
More information about the llvm-commits
mailing list