Flawfinder version 2.0.10, (C) 2001-2019 David A. Wheeler. Number of rules (primarily dangerous function names) in C/C++ ruleset: 223 Examining data/benchmark-1.5.2/bindings/python/google_benchmark/benchmark.cc Examining data/benchmark-1.5.2/cmake/gnu_posix_regex.cpp Examining data/benchmark-1.5.2/cmake/posix_regex.cpp Examining data/benchmark-1.5.2/cmake/std_regex.cpp Examining data/benchmark-1.5.2/cmake/steady_clock.cpp Examining data/benchmark-1.5.2/cmake/thread_safety_attributes.cpp Examining data/benchmark-1.5.2/conan/test_package/test_package.cpp Examining data/benchmark-1.5.2/include/benchmark/benchmark.h Examining data/benchmark-1.5.2/src/arraysize.h Examining data/benchmark-1.5.2/src/benchmark.cc Examining data/benchmark-1.5.2/src/benchmark_api_internal.cc Examining data/benchmark-1.5.2/src/benchmark_api_internal.h Examining data/benchmark-1.5.2/src/benchmark_main.cc Examining data/benchmark-1.5.2/src/benchmark_name.cc Examining data/benchmark-1.5.2/src/benchmark_register.cc Examining data/benchmark-1.5.2/src/benchmark_register.h Examining data/benchmark-1.5.2/src/benchmark_runner.cc Examining data/benchmark-1.5.2/src/benchmark_runner.h Examining data/benchmark-1.5.2/src/check.h Examining data/benchmark-1.5.2/src/colorprint.cc Examining data/benchmark-1.5.2/src/colorprint.h Examining data/benchmark-1.5.2/src/commandlineflags.cc Examining data/benchmark-1.5.2/src/commandlineflags.h Examining data/benchmark-1.5.2/src/complexity.cc Examining data/benchmark-1.5.2/src/complexity.h Examining data/benchmark-1.5.2/src/console_reporter.cc Examining data/benchmark-1.5.2/src/counter.cc Examining data/benchmark-1.5.2/src/counter.h Examining data/benchmark-1.5.2/src/csv_reporter.cc Examining data/benchmark-1.5.2/src/internal_macros.h Examining data/benchmark-1.5.2/src/json_reporter.cc Examining data/benchmark-1.5.2/src/log.h Examining data/benchmark-1.5.2/src/mutex.h Examining data/benchmark-1.5.2/src/re.h Examining data/benchmark-1.5.2/src/reporter.cc Examining data/benchmark-1.5.2/src/sleep.cc Examining data/benchmark-1.5.2/src/sleep.h Examining data/benchmark-1.5.2/src/statistics.cc Examining data/benchmark-1.5.2/src/statistics.h Examining data/benchmark-1.5.2/src/string_util.cc Examining data/benchmark-1.5.2/src/string_util.h Examining data/benchmark-1.5.2/src/sysinfo.cc Examining data/benchmark-1.5.2/src/thread_manager.h Examining data/benchmark-1.5.2/src/thread_timer.h Examining data/benchmark-1.5.2/src/timers.cc Examining data/benchmark-1.5.2/src/timers.h Examining data/benchmark-1.5.2/src/cycleclock.h Examining data/benchmark-1.5.2/test/args_product_test.cc Examining data/benchmark-1.5.2/test/basic_test.cc Examining data/benchmark-1.5.2/test/benchmark_gtest.cc Examining data/benchmark-1.5.2/test/benchmark_name_gtest.cc Examining data/benchmark-1.5.2/test/benchmark_test.cc Examining data/benchmark-1.5.2/test/clobber_memory_assembly_test.cc Examining data/benchmark-1.5.2/test/commandlineflags_gtest.cc Examining data/benchmark-1.5.2/test/complexity_test.cc Examining data/benchmark-1.5.2/test/cxx03_test.cc Examining data/benchmark-1.5.2/test/diagnostics_test.cc Examining data/benchmark-1.5.2/test/display_aggregates_only_test.cc Examining data/benchmark-1.5.2/test/donotoptimize_assembly_test.cc Examining data/benchmark-1.5.2/test/donotoptimize_test.cc Examining data/benchmark-1.5.2/test/filter_test.cc Examining data/benchmark-1.5.2/test/fixture_test.cc Examining data/benchmark-1.5.2/test/internal_threading_test.cc Examining data/benchmark-1.5.2/test/link_main_test.cc Examining data/benchmark-1.5.2/test/map_test.cc Examining data/benchmark-1.5.2/test/memory_manager_test.cc Examining data/benchmark-1.5.2/test/multiple_ranges_test.cc Examining data/benchmark-1.5.2/test/options_test.cc Examining data/benchmark-1.5.2/test/output_test.h Examining data/benchmark-1.5.2/test/output_test_helper.cc Examining data/benchmark-1.5.2/test/register_benchmark_test.cc Examining data/benchmark-1.5.2/test/report_aggregates_only_test.cc Examining data/benchmark-1.5.2/test/reporter_output_test.cc Examining data/benchmark-1.5.2/test/skip_with_error_test.cc Examining data/benchmark-1.5.2/test/state_assembly_test.cc Examining data/benchmark-1.5.2/test/statistics_gtest.cc Examining data/benchmark-1.5.2/test/string_util_gtest.cc Examining data/benchmark-1.5.2/test/templated_fixture_test.cc Examining data/benchmark-1.5.2/test/user_counters_tabular_test.cc Examining data/benchmark-1.5.2/test/user_counters_test.cc Examining data/benchmark-1.5.2/test/user_counters_thousands_test.cc FINAL RESULTS: data/benchmark-1.5.2/src/colorprint.cc:92:14: [4] (format) vsnprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. auto ret = vsnprintf(local_buff, size, msg, args_cp); data/benchmark-1.5.2/src/colorprint.cc:107:11: [4] (format) vsnprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. ret = vsnprintf(buff.get(), size, msg, args); data/benchmark-1.5.2/src/colorprint.cc:146:3: [4] (format) vprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vprintf(fmt, args); data/benchmark-1.5.2/src/string_util.cc:139:14: [4] (format) vsnprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. auto ret = vsnprintf(local_buff.data(), size, msg, args_cp); data/benchmark-1.5.2/src/string_util.cc:154:9: [4] (format) vsnprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. ret = vsnprintf(buff_ptr.get(), size, msg, args); data/benchmark-1.5.2/src/string_util.h:18:23: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. __attribute__((format(printf, 1, 2))) data/benchmark-1.5.2/src/string_util.h:34:20: [4] (buffer) StrCat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). inline std::string StrCat(Args&&... args) { data/benchmark-1.5.2/src/sysinfo.cc:19:8: [4] (buffer) StrCat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). #undef StrCat // Don't let StrCat in string_util.h be renamed to lstrcatA data/benchmark-1.5.2/src/sysinfo.cc:226:9: [4] (buffer) StrCat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). StrCat("/sys/devices/system/cpu/cpu", cpu, "/cpufreq/scaling_governor"); data/benchmark-1.5.2/src/sysinfo.cc:260:25: [4] (buffer) StrCat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). std::string FPath = StrCat(dir, "index", Idx++, "/"); data/benchmark-1.5.2/src/sysinfo.cc:261:21: [4] (buffer) StrCat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). std::ifstream f(StrCat(FPath, "size").c_str()); data/benchmark-1.5.2/src/sysinfo.cc:277:23: [4] (buffer) StrCat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). if (!ReadFromFile(StrCat(FPath, "type"), &info.type)) data/benchmark-1.5.2/src/sysinfo.cc:279:23: [4] (buffer) StrCat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). if (!ReadFromFile(StrCat(FPath, "level"), &info.level)) data/benchmark-1.5.2/src/sysinfo.cc:282:23: [4] (buffer) StrCat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). if (!ReadFromFile(StrCat(FPath, "shared_cpu_map"), &map_str)) data/benchmark-1.5.2/src/timers.cc:20:8: [4] (buffer) StrCat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). #undef StrCat // Don't let StrCat in string_util.h be renamed to lstrcatA data/benchmark-1.5.2/src/timers.cc:177:51: [4] (shell) system: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. #error Per-thread timing is not available on your system. data/benchmark-1.5.2/src/colorprint.cc:174:28: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. const char* const term = getenv("TERM"); data/benchmark-1.5.2/src/commandlineflags.cc:98:33: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. const char* const value_str = getenv(env_var.c_str()); data/benchmark-1.5.2/src/commandlineflags.cc:104:33: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. const char* const value_str = getenv(env_var.c_str()); data/benchmark-1.5.2/src/commandlineflags.cc:116:33: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. const char* const value_str = getenv(env_var.c_str()); data/benchmark-1.5.2/src/commandlineflags.cc:128:29: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. const char* const value = getenv(env_var.c_str()); data/benchmark-1.5.2/test/commandlineflags_gtest.cc:14:23: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. char* env_value = getenv(name); data/benchmark-1.5.2/test/output_test_helper.cc:478:20: [3] (tmpfile) GetTempFileName: Temporary file race condition in certain cases (e.g., if run as SYSTEM in many versions of Windows) (CWE-377). static std::string GetTempFileName() { data/benchmark-1.5.2/test/output_test_helper.cc:496:31: [3] (tmpfile) GetTempFileName: Temporary file race condition in certain cases (e.g., if run as SYSTEM in many versions of Windows) (CWE-377). std::string tmp_file_name = GetTempFileName(); data/benchmark-1.5.2/src/benchmark.cc:378:17: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). output_file.open(fname); data/benchmark-1.5.2/src/colorprint.cc:91:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char local_buff[256]; data/benchmark-1.5.2/src/sysinfo.cc:95:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char bytes[8]; data/benchmark-1.5.2/src/sysinfo.cc:139:10: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. std::memcpy(Arr.data(), data(), ArrSize); data/benchmark-1.5.2/src/sysinfo.cc:421:3: [2] (buffer) TCHAR: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. TCHAR hostname[COUNT] = {'\0'}; data/benchmark-1.5.2/src/sysinfo.cc:450:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char hostname[HOST_NAME_MAX]; data/benchmark-1.5.2/src/timers.cc:193:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char tz_offset[128]; data/benchmark-1.5.2/src/timers.cc:194:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char storage[128]; data/benchmark-1.5.2/test/donotoptimize_test.cc:20:21: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. static unsigned char arr[2] = {}; data/benchmark-1.5.2/test/donotoptimize_test.cc:31:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buffer8[8] = ""; data/benchmark-1.5.2/test/donotoptimize_test.cc:34:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buffer20[20] = ""; data/benchmark-1.5.2/test/donotoptimize_test.cc:37:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buffer1024[1024] = ""; data/benchmark-1.5.2/src/console_reporter.cc:163:56: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). printer(Out, COLOR_DEFAULT, " %*s%s", cNameLen - strlen(unit), s.c_str(), data/benchmark-1.5.2/src/timers.cc:231:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(tz_offset, "-00:00", kTzOffsetLen + 1); data/benchmark-1.5.2/src/timers.cc:240:8: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. std::strncat(storage, tz_offset, sizeof(storage) - timestamp_len - 1); ANALYSIS SUMMARY: Hits = 39 Lines analyzed = 13057 in approximately 0.36 seconds (36576 lines/second) Physical Source Lines of Code (SLOC) = 9358 Hits@level = [0] 7 [1] 3 [2] 12 [3] 8 [4] 16 [5] 0 Hits@level+ = [0+] 46 [1+] 39 [2+] 36 [3+] 24 [4+] 16 [5+] 0 Hits/KSLOC@level+ = [0+] 4.91558 [1+] 4.16756 [2+] 3.84698 [3+] 2.56465 [4+] 1.70977 [5+] 0 Dot directories skipped = 2 (--followdotdir overrides) Minimum risk level = 1 Not every hit is necessarily a security vulnerability. There may be other security vulnerabilities; review your code! See 'Secure Programming HOWTO' (https://dwheeler.com/secure-programs) for more information.