Index: compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc =================================================================== --- compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -9834,12 +9834,12 @@ #endif #if SANITIZER_INTERCEPT_GETRANDOM -INTERCEPTOR(SSIZE_T, getrandom, void *buf, SIZE_T buflen, unsigned int flags) { +INTERCEPTOR(SSIZE_T, getrandom, void *bytes, SIZE_T count, unsigned int flags) { void *ctx; - COMMON_INTERCEPTOR_ENTER(ctx, getrandom, buf, buflen, flags); - SSIZE_T n = REAL(getrandom)(buf, buflen, flags); + COMMON_INTERCEPTOR_ENTER(ctx, getrandom, bytes, count, flags); + SSIZE_T n = REAL(getrandom)(bytes, count, flags); if (n > 0) { - COMMON_INTERCEPTOR_WRITE_RANGE(ctx, buf, n); + COMMON_INTERCEPTOR_WRITE_RANGE(ctx, bytes, n); } return n; } Index: compiler-rt/test/sanitizer_common/TestCases/Darwin/ccrandomgeneratebytes.c =================================================================== --- compiler-rt/test/sanitizer_common/TestCases/Darwin/ccrandomgeneratebytes.c +++ compiler-rt/test/sanitizer_common/TestCases/Darwin/ccrandomgeneratebytes.c @@ -1,14 +1,21 @@ +// We try to ensure the api interceptor functions properly. +// // RUN: %clang -O2 %s -o %t && %run %t -#include -#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 101000 #include +#include +#include int main() { char buf[16]; - int n = 0; - if (CCRandomGenerateBytes(buf, sizeof(buf)) != kCCSuccess) - n = 1; - return n <= 0; + int n = !(CCRandomGenerateBytes(buf, sizeof(buf)) == kCCSuccess); + if (n == 0) { + printf("CCRandomGenerateBytes\n"); + for (int i = 0; i