Index: lib/sanitizer_common/sanitizer_common_interceptors.inc =================================================================== --- lib/sanitizer_common/sanitizer_common_interceptors.inc +++ lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -7252,6 +7252,19 @@ #define INIT_NETENT #endif +#if SANITIZER_INTERCEPT_ATOF +INTERCEPTOR(double, atof, char *nptr) { + void *ctx; + COMMON_INTERCEPTOR_ENTER(ctx, atof, nptr); + if (nptr) + COMMON_INTERCEPTOR_READ_RANGE(ctx, nptr, REAL(strlen)(nptr) + 1); + return REAL(atof)(nptr); +} +#define INIT_ATOF COMMON_INTERCEPT_FUNCTION(atof) +#else +#define INIT_ATOF +#endif + static void InitializeCommonInterceptors() { static u64 metadata_mem[sizeof(MetadataHashMap) / sizeof(u64) + 1]; interceptor_metadata_map = new((void *)&metadata_mem) MetadataHashMap(); @@ -7503,6 +7516,7 @@ INIT_TTYENT; INIT_PROTOENT; INIT_NETENT; + INIT_ATOF; INIT___PRINTF_CHK; } Index: lib/sanitizer_common/sanitizer_platform_interceptors.h =================================================================== --- lib/sanitizer_common/sanitizer_platform_interceptors.h +++ lib/sanitizer_common/sanitizer_platform_interceptors.h @@ -514,5 +514,6 @@ #define SANITIZER_INTERCEPT_TTYENT SI_NETBSD #define SANITIZER_INTERCEPT_PROTOENT SI_NETBSD #define SANITIZER_INTERCEPT_NETENT SI_NETBSD +#define SANITIZER_INTERCEPT_ATOF SI_NETBSD #endif // #ifndef SANITIZER_PLATFORM_INTERCEPTORS_H Index: test/sanitizer_common/TestCases/NetBSD/atof.cc =================================================================== --- /dev/null +++ test/sanitizer_common/TestCases/NetBSD/atof.cc @@ -0,0 +1,15 @@ +// RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s + +#include +#include + +int main(void) { + double d; + + d = atof("3.14"); + printf("atof() = %.2f\n", d); + + // CHECK: atof() = 3.14 + + return 0; +}