diff --git a/compiler-rt/include/fuzzer/FuzzedDataProvider.h b/compiler-rt/include/fuzzer/FuzzedDataProvider.h index 428db9a04e38..fd895b767d9e 100644 --- a/compiler-rt/include/fuzzer/FuzzedDataProvider.h +++ b/compiler-rt/include/fuzzer/FuzzedDataProvider.h @@ -284,9 +284,9 @@ class FuzzedDataProvider { // Avoid using implementation-defined unsigned to signer conversions. // To learn more, see https://stackoverflow.com/questions/13150449. - if (value <= std::numeric_limits::max()) + if (value <= std::numeric_limits::max()) { return static_cast(value); - else { + } else { constexpr auto TS_min = std::numeric_limits::min(); return TS_min + static_cast(value - TS_min); } diff --git a/compiler-rt/lib/asan/asan_malloc_win.cpp b/compiler-rt/lib/asan/asan_malloc_win.cpp index 9d107bee84fb..13c6f652119b 100644 --- a/compiler-rt/lib/asan/asan_malloc_win.cpp +++ b/compiler-rt/lib/asan/asan_malloc_win.cpp @@ -528,10 +528,11 @@ void ReplaceSystemMalloc() { (uptr)WRAP(RtlAllocateHeap), (uptr *)&REAL(RtlAllocateHeap)); } else { -#define INTERCEPT_UCRT_FUNCTION(func) \ - if (!INTERCEPT_FUNCTION_DLLIMPORT("ucrtbase.dll", \ - "api-ms-win-core-heap-l1-1-0.dll", func)) \ - VPrintf(2, "Failed to intercept ucrtbase.dll import %s\n", #func); +#define INTERCEPT_UCRT_FUNCTION(func) \ + if (!INTERCEPT_FUNCTION_DLLIMPORT( \ + "ucrtbase.dll", "api-ms-win-core-heap-l1-1-0.dll", func)) { \ + VPrintf(2, "Failed to intercept ucrtbase.dll import %s\n", #func); \ + } INTERCEPT_UCRT_FUNCTION(HeapAlloc); INTERCEPT_UCRT_FUNCTION(HeapFree); INTERCEPT_UCRT_FUNCTION(HeapReAlloc); diff --git a/compiler-rt/lib/asan/asan_report.cpp b/compiler-rt/lib/asan/asan_report.cpp index 5c16cb3e43f8..2e6ce436d030 100644 --- a/compiler-rt/lib/asan/asan_report.cpp +++ b/compiler-rt/lib/asan/asan_report.cpp @@ -410,8 +410,12 @@ static bool IsInvalidPointerPair(uptr a1, uptr a2) { static INLINE void CheckForInvalidPointerPair(void *p1, void *p2) { switch (flags()->detect_invalid_pointer_pairs) { - case 0 : return; - case 1 : if (p1 == nullptr || p2 == nullptr) return; break; + case 0: + return; + case 1: + if (p1 == nullptr || p2 == nullptr) + return; + break; } uptr a1 = reinterpret_cast(p1); diff --git a/compiler-rt/lib/asan/asan_rtems.cpp b/compiler-rt/lib/asan/asan_rtems.cpp index 360d5780a3f2..ecd568c5981b 100644 --- a/compiler-rt/lib/asan/asan_rtems.cpp +++ b/compiler-rt/lib/asan/asan_rtems.cpp @@ -181,11 +181,11 @@ static void ThreadStartHook(void *hook, uptr os_id) { asanThreadRegistry().GetThreadLocked(thread->tid())->status; DCHECK(status == ThreadStatusCreated || status == ThreadStatusRunning); // Determine whether we are starting or restarting the thread. - if (status == ThreadStatusCreated) + if (status == ThreadStatusCreated) { // In lieu of AsanThread::ThreadStart. asanThreadRegistry().StartThread(thread->tid(), os_id, ThreadType::Regular, nullptr); - else { + } else { // In a thread restart, a thread may resume execution at an // arbitrary function entry point, with its stack and TLS state // reset. We unpoison the stack in that case. diff --git a/compiler-rt/lib/asan/asan_scariness_score.h b/compiler-rt/lib/asan/asan_scariness_score.h index 9e7ba47d82dc..3932973c225e 100644 --- a/compiler-rt/lib/asan/asan_scariness_score.h +++ b/compiler-rt/lib/asan/asan_scariness_score.h @@ -43,7 +43,7 @@ struct ScarinessScoreBase { internal_strlcat(descr, "-", sizeof(descr)); internal_strlcat(descr, reason, sizeof(descr)); score += add_to_score; - }; + } int GetScore() const { return score; } const char *GetDescription() const { return descr; } void Print() const { diff --git a/compiler-rt/lib/asan/asan_thread.cpp b/compiler-rt/lib/asan/asan_thread.cpp index c75cdc2bbd0d..6734d9a1668c 100644 --- a/compiler-rt/lib/asan/asan_thread.cpp +++ b/compiler-rt/lib/asan/asan_thread.cpp @@ -367,8 +367,9 @@ uptr AsanThread::GetStackVariableShadowStart(uptr addr) { } else if (has_fake_stack()) { bottom = fake_stack()->AddrIsInFakeStack(addr); CHECK(bottom); - } else + } else { return 0; + } uptr aligned_addr = RoundDownTo(addr, SANITIZER_WORDSIZE / 8); // align addr. u8 *shadow_ptr = (u8*)MemToShadow(aligned_addr); diff --git a/compiler-rt/lib/dfsan/dfsan.h b/compiler-rt/lib/dfsan/dfsan.h index df6847cdbe9b..d662391216e4 100644 --- a/compiler-rt/lib/dfsan/dfsan.h +++ b/compiler-rt/lib/dfsan/dfsan.h @@ -38,7 +38,7 @@ dfsan_label dfsan_union(dfsan_label l1, dfsan_label l2); } // extern "C" template -void dfsan_set_label(dfsan_label label, T &data) { +void dfsan_set_label(dfsan_label label, T &data) { // NOLINT dfsan_set_label(label, (void *)&data, sizeof(T)); } diff --git a/compiler-rt/lib/dfsan/dfsan_custom.cpp b/compiler-rt/lib/dfsan/dfsan_custom.cpp index 78d12d7d652a..84f0271b15e0 100644 --- a/compiler-rt/lib/dfsan/dfsan_custom.cpp +++ b/compiler-rt/lib/dfsan/dfsan_custom.cpp @@ -505,7 +505,7 @@ int __dfsw_getrusage(int who, struct rusage *usage, dfsan_label who_label, SANITIZER_INTERFACE_ATTRIBUTE char *__dfsw_strcpy(char *dest, const char *src, dfsan_label dst_label, dfsan_label src_label, dfsan_label *ret_label) { - char *ret = strcpy(dest, src); + char *ret = strcpy(dest, src); // NOLINT if (ret) { internal_memcpy(shadow_for(dest), shadow_for(src), sizeof(dfsan_label) * (strlen(src) + 1)); diff --git a/compiler-rt/lib/interception/interception_win.cpp b/compiler-rt/lib/interception/interception_win.cpp index b94e214fdff8..1a1c327e6124 100644 --- a/compiler-rt/lib/interception/interception_win.cpp +++ b/compiler-rt/lib/interception/interception_win.cpp @@ -883,8 +883,8 @@ uptr InternalGetProcAddress(void *module, const char *func_name) { // Check that the module header is full and present. RVAPtr dos_stub(module, 0); RVAPtr headers(module, dos_stub->e_lfanew); - if (!module || dos_stub->e_magic != IMAGE_DOS_SIGNATURE || // "MZ" - headers->Signature != IMAGE_NT_SIGNATURE || // "PE\0\0" + if (!module || dos_stub->e_magic != IMAGE_DOS_SIGNATURE || // "MZ" + headers->Signature != IMAGE_NT_SIGNATURE || // "PE\0\0" headers->FileHeader.SizeOfOptionalHeader < sizeof(IMAGE_OPTIONAL_HEADER)) { return 0; @@ -963,8 +963,8 @@ bool OverrideImportedFunction(const char *module_to_patch, // Check that the module header is full and present. RVAPtr dos_stub(module, 0); RVAPtr headers(module, dos_stub->e_lfanew); - if (!module || dos_stub->e_magic != IMAGE_DOS_SIGNATURE || // "MZ" - headers->Signature != IMAGE_NT_SIGNATURE || // "PE\0\0" + if (!module || dos_stub->e_magic != IMAGE_DOS_SIGNATURE || // "MZ" + headers->Signature != IMAGE_NT_SIGNATURE || // "PE\0\0" headers->FileHeader.SizeOfOptionalHeader < sizeof(IMAGE_OPTIONAL_HEADER)) { return false; diff --git a/compiler-rt/lib/lsan/lsan_common.cpp b/compiler-rt/lib/lsan/lsan_common.cpp index 529daee43688..86bd120e776a 100644 --- a/compiler-rt/lib/lsan/lsan_common.cpp +++ b/compiler-rt/lib/lsan/lsan_common.cpp @@ -535,7 +535,7 @@ static void ReportIfNotSuspended(ThreadContextBase *tctx, void *arg) { if (i >= suspended_threads.size() || suspended_threads[i] != tctx->os_id) Report("Running thread %d was not suspended. False leaks are possible.\n", tctx->os_id); - }; + } } static void ReportUnsuspendedThreads( diff --git a/compiler-rt/lib/msan/msan.h b/compiler-rt/lib/msan/msan.h index b2bc14f36662..12aeaa43519a 100644 --- a/compiler-rt/lib/msan/msan.h +++ b/compiler-rt/lib/msan/msan.h @@ -346,10 +346,11 @@ const int STACK_TRACE_TAG_POISON = StackTrace::TAG_CUSTOM + 1; #define GET_STORE_STACK_TRACE \ GET_STORE_STACK_TRACE_PC_BP(StackTrace::GetCurrentPc(), GET_CURRENT_FRAME()) -#define GET_FATAL_STACK_TRACE_PC_BP(pc, bp) \ - BufferedStackTrace stack; \ - if (msan_inited) \ - stack.Unwind(pc, bp, nullptr, common_flags()->fast_unwind_on_fatal) +#define GET_FATAL_STACK_TRACE_PC_BP(pc, bp) \ + BufferedStackTrace stack; \ + if (msan_inited) { \ + stack.Unwind(pc, bp, nullptr, common_flags()->fast_unwind_on_fatal); \ + } #define GET_FATAL_STACK_TRACE_HERE \ GET_FATAL_STACK_TRACE_PC_BP(StackTrace::GetCurrentPc(), GET_CURRENT_FRAME()) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc index fe992bf2900c..7ea896ef2d44 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -3070,13 +3070,14 @@ INTERCEPTOR(int, sendmmsg, int fd, struct __sanitizer_mmsghdr *msgvec, COMMON_INTERCEPTOR_FD_RELEASE(ctx, fd); } int res = REAL(sendmmsg)(fd, msgvec, vlen, flags); - if (res >= 0 && msgvec) + if (res >= 0 && msgvec) { for (int i = 0; i < res; ++i) { COMMON_INTERCEPTOR_WRITE_RANGE(ctx, &msgvec[i].msg_len, sizeof(msgvec[i].msg_len)); if (common_flags()->intercept_send) read_msghdr(ctx, &msgvec[i].msg_hdr, msgvec[i].msg_len); } + } return res; } #define INIT_SENDMMSG COMMON_INTERCEPT_FUNCTION(sendmmsg); @@ -3207,20 +3208,21 @@ INTERCEPTOR(uptr, ptrace, int request, int pid, void *addr, void *data) { __sanitizer_iovec local_iovec; if (data) { - if (request == ptrace_setregs) + if (request == ptrace_setregs) { COMMON_INTERCEPTOR_READ_RANGE(ctx, data, struct_user_regs_struct_sz); - else if (request == ptrace_setfpregs) + } else if (request == ptrace_setfpregs) { COMMON_INTERCEPTOR_READ_RANGE(ctx, data, struct_user_fpregs_struct_sz); - else if (request == ptrace_setfpxregs) + } else if (request == ptrace_setfpxregs) { COMMON_INTERCEPTOR_READ_RANGE(ctx, data, struct_user_fpxregs_struct_sz); - else if (request == ptrace_setvfpregs) + } else if (request == ptrace_setvfpregs) { COMMON_INTERCEPTOR_READ_RANGE(ctx, data, struct_user_vfpregs_struct_sz); - else if (request == ptrace_setsiginfo) + } else if (request == ptrace_setsiginfo) { COMMON_INTERCEPTOR_READ_RANGE(ctx, data, siginfo_t_sz); + // Some kernel might zero the iovec::iov_base in case of invalid // write access. In this case copy the invalid address for further // inspection. - else if (request == ptrace_setregset || request == ptrace_getregset) { + } else if (request == ptrace_setregset || request == ptrace_getregset) { __sanitizer_iovec *iovec = (__sanitizer_iovec*)data; COMMON_INTERCEPTOR_READ_RANGE(ctx, iovec, sizeof(*iovec)); local_iovec = *iovec; @@ -3237,19 +3239,19 @@ INTERCEPTOR(uptr, ptrace, int request, int pid, void *addr, void *data) { if (!res && data) { // Note that PEEK* requests assign different meaning to the return value. // This function does not handle them (nor does it need to). - if (request == ptrace_getregs) + if (request == ptrace_getregs) { COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data, struct_user_regs_struct_sz); - else if (request == ptrace_getfpregs) + } else if (request == ptrace_getfpregs) { COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data, struct_user_fpregs_struct_sz); - else if (request == ptrace_getfpxregs) + } else if (request == ptrace_getfpxregs) { COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data, struct_user_fpxregs_struct_sz); - else if (request == ptrace_getvfpregs) + } else if (request == ptrace_getvfpregs) { COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data, struct_user_vfpregs_struct_sz); - else if (request == ptrace_getsiginfo) + } else if (request == ptrace_getsiginfo) { COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data, siginfo_t_sz); - else if (request == ptrace_geteventmsg) + } else if (request == ptrace_geteventmsg) { COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data, sizeof(unsigned long)); - else if (request == ptrace_getregset) { + } else if (request == ptrace_getregset) { __sanitizer_iovec *iovec = (__sanitizer_iovec*)data; COMMON_INTERCEPTOR_WRITE_RANGE(ctx, iovec, sizeof(*iovec)); COMMON_INTERCEPTOR_WRITE_RANGE(ctx, local_iovec.iov_base, @@ -7842,10 +7844,11 @@ INTERCEPTOR(int, modctl, int operation, void *argp) { if (iov) COMMON_INTERCEPTOR_WRITE_RANGE( ctx, iov->iov_base, Min(iov_len, iov->iov_len)); - } else if (operation == modctl_exists) + } else if (operation == modctl_exists) { ret = REAL(modctl)(operation, argp); - else + } else { ret = REAL(modctl)(operation, argp); + } return ret; } diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp index 4831814b6dfb..1e2bc6652617 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp @@ -83,8 +83,9 @@ void FlagParser::parse_flag(const char *env_option_name) { Printf("%s: ERROR: expected '=' in %s\n", SanitizerToolName, env_option_name); Die(); - } else + } else { fatal_error("expected '='"); + } } char *name = ll_strndup(buf_ + name_start, pos_ - name_start); diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.h b/compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.h index b68e29cd929b..c24ad25626ba 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.h @@ -24,7 +24,7 @@ class FlagHandlerBase { virtual bool Parse(const char *value) { return false; } protected: - ~FlagHandlerBase() {}; + ~FlagHandlerBase() {} }; template diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc b/compiler-rt/lib/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc index 1ec73827b8b1..03ef7c1788cd 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_interceptors_ioctl_netbsd.inc @@ -1404,7 +1404,7 @@ static void ioctl_table_fill() { _(SNDCTL_DSP_SKIP, NONE, 0); _(SNDCTL_DSP_SILENCE, NONE, 0); #undef _ -} +} // NOLINT static bool ioctl_initialized = false; diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_libc.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_libc.cpp index 5c9d3a80c133..4bc04b486870 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_libc.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_libc.cpp @@ -63,10 +63,11 @@ void *internal_memmove(void *dest, const void *src, uptr n) { for (i = 0; i < signed_n; ++i) d[i] = s[i]; } else { - if (d > s && signed_n > 0) - for (i = signed_n - 1; i >= 0 ; --i) { + if (d > s && signed_n > 0) { + for (i = signed_n - 1; i >= 0; --i) { d[i] = s[i]; } + } } return dest; } @@ -270,9 +271,9 @@ bool mem_is_zero(const char *beg, uptr size) { for (; aligned_beg < aligned_end; aligned_beg++) all |= *aligned_beg; // Epilogue. - if ((char*)aligned_end >= beg) - for (const char *mem = (char*)aligned_end; mem < end; mem++) - all |= *mem; + if ((char *)aligned_end >= beg) { + for (const char *mem = (char *)aligned_end; mem < end; mem++) all |= *mem; + } return all == 0; } diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp index b520dc8daca6..651d5056dd9d 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp @@ -223,10 +223,11 @@ bool ThreadSuspender::SuspendAllThreads() { case ThreadLister::Ok: break; } - for (tid_t tid : threads) + for (tid_t tid : threads) { if (SuspendThread(tid)) retry = true; - }; + } + } return suspended_threads_list_.ThreadCount(); } diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_report.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_report.cpp index a8b449b030e7..d6699f3ed6f6 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_report.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_report.cpp @@ -106,8 +106,9 @@ void ReportMmapWriteExec(int prot) { if (StackTrace::WillUseFastUnwind(fast)) { GetThreadStackTopAndBottom(false, &top, &bottom); stack->Unwind(kStackTraceMax, pc, bp, nullptr, top, bottom, true); - } else + } else { stack->Unwind(kStackTraceMax, pc, 0, nullptr, 0, 0, false); + } Printf("%s", d.Warning()); Report("WARNING: %s: writable-executable page usage\n", SanitizerToolName); diff --git a/compiler-rt/lib/sanitizer_common/scripts/check_lint.sh b/compiler-rt/lib/sanitizer_common/scripts/check_lint.sh index ecd61c07e352..8c8fc33ee949 100755 --- a/compiler-rt/lib/sanitizer_common/scripts/check_lint.sh +++ b/compiler-rt/lib/sanitizer_common/scripts/check_lint.sh @@ -17,15 +17,15 @@ fi # Filters # TODO: remove some of these filters COMMON_LINT_FILTER=-build/include,-build/header_guard,-legal/copyright,-whitespace/comments,-readability/casting,\ --build/namespaces,-readability/braces,-build/c++11,-runtime/int +-build/namespaces,-build/c++11,-runtime/int COMMON_LIT_TEST_LINT_FILTER=-whitespace/indent,-whitespace/line_length,-runtime/arrays ASAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER} -ASAN_TEST_LINT_FILTER=${COMMON_LINT_FILTER},-runtime/sizeof,-runtime/printf,-runtime/threadsafe_fn +ASAN_TEST_LINT_FILTER=${COMMON_LINT_FILTER},-runtime/printf,-runtime/threadsafe_fn ASAN_LIT_TEST_LINT_FILTER=${ASAN_TEST_LINT_FILTER},${COMMON_LIT_TEST_LINT_FILTER} -TSAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER} +TSAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER},-readability/braces TSAN_TEST_LINT_FILTER=${TSAN_RTL_LINT_FILTER},-runtime/threadsafe_fn TSAN_LIT_TEST_LINT_FILTER=${TSAN_TEST_LINT_FILTER},${COMMON_LIT_TEST_LINT_FILTER} @@ -34,10 +34,10 @@ MSAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER} LSAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER} LSAN_LIT_TEST_LINT_FILTER=${LSAN_RTL_LINT_FILTER},${COMMON_LIT_TEST_LINT_FILTER} -DFSAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER},-runtime/printf,-runtime/references,-readability/function +DFSAN_RTL_LINT_FILTER=${COMMON_LINT_FILTER} SCUDO_RTL_LINT_FILTER=${COMMON_LINT_FILTER} -COMMON_RTL_INC_LINT_FILTER=${COMMON_LINT_FILTER},-runtime/sizeof,-runtime/printf,-readability/fn_size +COMMON_RTL_INC_LINT_FILTER=${COMMON_LINT_FILTER} SANITIZER_INCLUDES_LINT_FILTER=${COMMON_LINT_FILTER} diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_printf_test.cpp b/compiler-rt/lib/sanitizer_common/tests/sanitizer_printf_test.cpp index d213d107c019..956ed6545019 100644 --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_printf_test.cpp +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_printf_test.cpp @@ -33,7 +33,7 @@ TEST(Printf, Basic) { TEST(Printf, OverflowStr) { char buf[] = "123456789"; - uptr len = internal_snprintf(buf, 4, "%s", "abcdef"); + uptr len = internal_snprintf(buf, 4, "%s", "abcdef"); // NOLINT EXPECT_EQ(len, (uptr)6); EXPECT_STREQ("abc", buf); EXPECT_EQ(buf[3], 0); @@ -47,7 +47,7 @@ TEST(Printf, OverflowStr) { TEST(Printf, OverflowInt) { char buf[] = "123456789"; - internal_snprintf(buf, 4, "%d", -123456789); + internal_snprintf(buf, 4, "%d", -123456789); // NOLINT EXPECT_STREQ("-12", buf); EXPECT_EQ(buf[3], 0); EXPECT_EQ(buf[4], '5'); @@ -66,7 +66,7 @@ TEST(Printf, OverflowUint) { } else { val = (uptr)0x123456789ULL; } - internal_snprintf(buf, 4, "a%zx", val); + internal_snprintf(buf, 4, "a%zx", val); // NOLINT EXPECT_STREQ("a12", buf); EXPECT_EQ(buf[3], 0); EXPECT_EQ(buf[4], '5'); @@ -85,7 +85,7 @@ TEST(Printf, OverflowPtr) { } else { p = (void*)0x123456789ULL; } - internal_snprintf(buf, 4, "%p", p); + internal_snprintf(buf, 4, "%p", p); // NOLINT EXPECT_STREQ("0x0", buf); EXPECT_EQ(buf[3], 0); EXPECT_EQ(buf[4], '5'); @@ -149,7 +149,7 @@ TEST(Printf, Precision) { EXPECT_STREQ("12345 ", buf); // Check that width does not overflow the smaller buffer, although // 10 chars is requested, it stops at the buffer size, 8. - len = internal_snprintf(buf, 8, "%-10s", "12345"); + len = internal_snprintf(buf, 8, "%-10s", "12345"); // NOLINT EXPECT_EQ(10U, len); // The required size reported. EXPECT_STREQ("12345 ", buf); } diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_suppressions_test.cpp b/compiler-rt/lib/sanitizer_common/tests/sanitizer_suppressions_test.cpp index 6fce03a573b4..50a6ce92f9be 100644 --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_suppressions_test.cpp +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_suppressions_test.cpp @@ -18,7 +18,7 @@ namespace __sanitizer { static bool MyMatch(const char *templ, const char *func) { char tmp[1024]; - strcpy(tmp, templ); + snprintf(tmp, sizeof(tmp), "%s", templ); return TemplateMatch(tmp, func); } diff --git a/compiler-rt/test/asan/TestCases/scariness_score_test.cpp b/compiler-rt/test/asan/TestCases/scariness_score_test.cpp index fb174eb52b2b..b60122541cc3 100644 --- a/compiler-rt/test/asan/TestCases/scariness_score_test.cpp +++ b/compiler-rt/test/asan/TestCases/scariness_score_test.cpp @@ -155,9 +155,9 @@ int main(int argc, char **argv) { case 10: StackBufferOverflow(0, Write); break; case 11: StackBufferOverflow(0, Read); break; case 12: - if (scale <= 3) + if (scale <= 3) { StackBufferOverflow(16, Write); - else { + } else { // At large shadow granularity, there is not enough redzone // between stack elements to detect far-from-bounds. Pretend // that this test passes.