COMMON_INTERCEPTOR_COPY_STRING only had an implementation in msan, but it would make sense to implement it for asan as well.
This was added due to false negative in ASan on buggy strlcpy usage. Added a regression test for strlcpy as well.
rdar://83965778
Given that this macro is supposed to model a copy operation we probably need to model the read operation too with something like.
However, this isn't really enough because it's undefined what happens when to and from overlap for strlcpy.
ASan already has support for this kind of thing in its CHECK_RANGES_OVERLAP macro. So maybe we could introduce a COMMON_INTERCEPTOR_CHECK_RANGES_OVERLAP() macro
// In `asan_interceptors.cpp` #define COMMON_INTERCEPTOR_CHECK_RANGES_OVERLAP(ctx, name, buffer1, length1, buffer2, length2 ) { \ CHECK_RANGES_OVERLAP(name, buffer1, length1, buffer2, length2) \ }// In `sanitizer_common_interceptors.inc` // FIXME: Figure this out. Maybe we should implement a barebones implementation here? #ifndef COMMON_INTERCEPTOR_CHECK_RANGES_OVERLAP #define COMMON_INTERCEPTOR_CHECK_RANGES_OVERLAP(ctx, name, buffer1, length1, buffer2, length2 ) { } #endif #ifndef COMMON_INTERCEPTOR_COPY_STRING #define COMMON_INTERCEPTOR_COPY_STRING(ctx, name, to, from, size) { \ COMMON_INTERCEPTOR_CHECK_RANGES_OVERLAP(ctx, name, from, size, to, size) \ COMMON_INTERCEPTOR_READ_RANGE(ctx, from, size); \ COMMON_INTERCEPTOR_WRITE_RANGE(ctx, to, size); \ } #endifNote I changed COMMON_INTERCEPTOR_CHECK_RANGES_OVERLAP's signature to pass name which is the name of the function being intercepted because the CHECK_RANGES_OVERLAP macro needs it.