vitalybuka added inline comments.
================
Comment at: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc:230
+ uptr from_length = internal_strnlen(s, size); \
+ uptr copy_length = Min(size, from_length); \
+ char *new_mem = (char *)WRAP(malloc)(copy_length + 1); \
----------------
Min() is redundant here, as (internal_strnlen(s, size) <= size)
================
Comment at: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc:233
+ if (common_flags()->intercept_strndup) { \
+ COMMON_INTERCEPTOR_READ_RANGE(ctx, s, copy_length + 1); \
+ } \
----------------
must be "COMMON_INTERCEPTOR_READ_RANGE(ctx, s, Min(copy_length + 1, size)); "
(copy_length + 1) is a problem if "s" is not zero terminated
Repository:
rL LLVM
https://reviews.llvm.org/D31457