Index: lib/sanitizer_common/sanitizer_common_interceptors.inc =================================================================== --- lib/sanitizer_common/sanitizer_common_interceptors.inc +++ lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -7664,6 +7664,19 @@ #define INIT_SYSCTLGETMIBINFO #endif +#if SANITIZER_INTERCEPT_NL_LANGINFO +INTERCEPTOR(char *, nl_langinfo, long item) { + void *ctx; + COMMON_INTERCEPTOR_ENTER(ctx, nl_langinfo, item); + char *ret = REAL(nl_langinfo)(item); + if (ret) + COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ret, REAL(strlen)(ret) + 1); + return ret; +} +#define INIT_NL_LANGINFO COMMON_INTERCEPT_FUNCTION(nl_langinfo) +#else +#define INIT_NL_LANGINFO +#endif static void InitializeCommonInterceptors() { static u64 metadata_mem[sizeof(MetadataHashMap) / sizeof(u64) + 1]; @@ -7927,6 +7940,7 @@ INIT_SYSCTL; INIT_ASYSCTL; INIT_SYSCTLGETMIBINFO; + INIT_NL_LANGINFO; 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 @@ -520,6 +520,7 @@ SI_LINUX || SI_MAC) #define SANITIZER_INTERCEPT_GETMNTINFO SI_NETBSD #define SANITIZER_INTERCEPT_MI_VECTOR_HASH SI_NETBSD +#define SANITIZER_INTERCEPT_NL_LANGINFO SI_NETBSD #define SANITIZER_INTERCEPT_GETVFSSTAT SI_NETBSD #define SANITIZER_INTERCEPT_REGEX SI_NETBSD #define SANITIZER_INTERCEPT_FTS SI_NETBSD Index: test/sanitizer_common/TestCases/NetBSD/nl_langinfo.cc =================================================================== --- test/sanitizer_common/TestCases/NetBSD/nl_langinfo.cc +++ test/sanitizer_common/TestCases/NetBSD/nl_langinfo.cc @@ -0,0 +1,18 @@ +// RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s + +#include + +#include + +int main(void) { + printf("nl_langinfo\n"); + + char *info = nl_langinfo(DAY_1); + + printf("DAY_1='%s'\n", info); + + // CHECK: nl_langinfo + // CHECK: DAY_1='{{.*}}' + + return 0; +}