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/ninja-build-1.10.1/src/browse.cc Examining data/ninja-build-1.10.1/src/browse.h Examining data/ninja-build-1.10.1/src/build.cc Examining data/ninja-build-1.10.1/src/build.h Examining data/ninja-build-1.10.1/src/build_log.cc Examining data/ninja-build-1.10.1/src/build_log.h Examining data/ninja-build-1.10.1/src/build_log_perftest.cc Examining data/ninja-build-1.10.1/src/build_log_test.cc Examining data/ninja-build-1.10.1/src/build_test.cc Examining data/ninja-build-1.10.1/src/canon_perftest.cc Examining data/ninja-build-1.10.1/src/clean.cc Examining data/ninja-build-1.10.1/src/clean.h Examining data/ninja-build-1.10.1/src/clean_test.cc Examining data/ninja-build-1.10.1/src/clparser.cc Examining data/ninja-build-1.10.1/src/clparser.h Examining data/ninja-build-1.10.1/src/clparser_perftest.cc Examining data/ninja-build-1.10.1/src/clparser_test.cc Examining data/ninja-build-1.10.1/src/debug_flags.cc Examining data/ninja-build-1.10.1/src/debug_flags.h Examining data/ninja-build-1.10.1/src/depfile_parser.cc Examining data/ninja-build-1.10.1/src/depfile_parser.h Examining data/ninja-build-1.10.1/src/depfile_parser.in.cc Examining data/ninja-build-1.10.1/src/depfile_parser_perftest.cc Examining data/ninja-build-1.10.1/src/depfile_parser_test.cc Examining data/ninja-build-1.10.1/src/deps_log.cc Examining data/ninja-build-1.10.1/src/deps_log.h Examining data/ninja-build-1.10.1/src/deps_log_test.cc Examining data/ninja-build-1.10.1/src/disk_interface.cc Examining data/ninja-build-1.10.1/src/disk_interface.h Examining data/ninja-build-1.10.1/src/disk_interface_test.cc Examining data/ninja-build-1.10.1/src/dyndep.cc Examining data/ninja-build-1.10.1/src/dyndep.h Examining data/ninja-build-1.10.1/src/dyndep_parser.cc Examining data/ninja-build-1.10.1/src/dyndep_parser.h Examining data/ninja-build-1.10.1/src/dyndep_parser_test.cc Examining data/ninja-build-1.10.1/src/edit_distance.cc Examining data/ninja-build-1.10.1/src/edit_distance.h Examining data/ninja-build-1.10.1/src/edit_distance_test.cc Examining data/ninja-build-1.10.1/src/eval_env.cc Examining data/ninja-build-1.10.1/src/eval_env.h Examining data/ninja-build-1.10.1/src/exit_status.h Examining data/ninja-build-1.10.1/src/getopt.c Examining data/ninja-build-1.10.1/src/getopt.h Examining data/ninja-build-1.10.1/src/graph.cc Examining data/ninja-build-1.10.1/src/graph.h Examining data/ninja-build-1.10.1/src/graph_test.cc Examining data/ninja-build-1.10.1/src/graphviz.cc Examining data/ninja-build-1.10.1/src/graphviz.h Examining data/ninja-build-1.10.1/src/hash_collision_bench.cc Examining data/ninja-build-1.10.1/src/hash_map.h Examining data/ninja-build-1.10.1/src/includes_normalize-win32.cc Examining data/ninja-build-1.10.1/src/includes_normalize.h Examining data/ninja-build-1.10.1/src/includes_normalize_test.cc Examining data/ninja-build-1.10.1/src/lexer.cc Examining data/ninja-build-1.10.1/src/lexer.h Examining data/ninja-build-1.10.1/src/lexer.in.cc Examining data/ninja-build-1.10.1/src/lexer_test.cc Examining data/ninja-build-1.10.1/src/line_printer.cc Examining data/ninja-build-1.10.1/src/line_printer.h Examining data/ninja-build-1.10.1/src/load_status.h Examining data/ninja-build-1.10.1/src/manifest_parser.cc Examining data/ninja-build-1.10.1/src/manifest_parser.h Examining data/ninja-build-1.10.1/src/manifest_parser_perftest.cc Examining data/ninja-build-1.10.1/src/manifest_parser_test.cc Examining data/ninja-build-1.10.1/src/metrics.cc Examining data/ninja-build-1.10.1/src/metrics.h Examining data/ninja-build-1.10.1/src/minidump-win32.cc Examining data/ninja-build-1.10.1/src/msvc_helper-win32.cc Examining data/ninja-build-1.10.1/src/msvc_helper.h Examining data/ninja-build-1.10.1/src/msvc_helper_main-win32.cc Examining data/ninja-build-1.10.1/src/msvc_helper_test.cc Examining data/ninja-build-1.10.1/src/ninja.cc Examining data/ninja-build-1.10.1/src/ninja_test.cc Examining data/ninja-build-1.10.1/src/parser.cc Examining data/ninja-build-1.10.1/src/parser.h Examining data/ninja-build-1.10.1/src/state.cc Examining data/ninja-build-1.10.1/src/state.h Examining data/ninja-build-1.10.1/src/state_test.cc Examining data/ninja-build-1.10.1/src/string_piece.h Examining data/ninja-build-1.10.1/src/string_piece_util.cc Examining data/ninja-build-1.10.1/src/string_piece_util.h Examining data/ninja-build-1.10.1/src/string_piece_util_test.cc Examining data/ninja-build-1.10.1/src/subprocess-posix.cc Examining data/ninja-build-1.10.1/src/subprocess-win32.cc Examining data/ninja-build-1.10.1/src/subprocess.h Examining data/ninja-build-1.10.1/src/subprocess_test.cc Examining data/ninja-build-1.10.1/src/test.cc Examining data/ninja-build-1.10.1/src/test.h Examining data/ninja-build-1.10.1/src/timestamp.h Examining data/ninja-build-1.10.1/src/util.cc Examining data/ninja-build-1.10.1/src/util.h Examining data/ninja-build-1.10.1/src/util_test.cc Examining data/ninja-build-1.10.1/src/version.cc Examining data/ninja-build-1.10.1/src/version.h Examining data/ninja-build-1.10.1/src/win32port.h FINAL RESULTS: data/ninja-build-1.10.1/src/browse.cc:60:7: [4] (shell) execvp: 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. execvp(command[0], (char**)&command[0]); data/ninja-build-1.10.1/src/build.h:288:7: [4] (format) snprintf: 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. snprintf(buf, S, format, rate); data/ninja-build-1.10.1/src/build_log.cc:199:9: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. if (fprintf(log_file_, kFileSignature, kCurrentVersion) < 0) { data/ninja-build-1.10.1/src/build_log.cc:277:7: [4] (buffer) sscanf: The scanf() family's %s operation, without a limit specification, permits buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a different input function. If the scanf format is influenceable by an attacker, it's exploitable. sscanf(line_start, kFileSignature, &log_version); data/ninja-build-1.10.1/src/build_log.cc:399:7: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. if (fprintf(f, kFileSignature, kCurrentVersion) < 0) { data/ninja-build-1.10.1/src/build_log.cc:450:7: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. if (fprintf(f, kFileSignature, kCurrentVersion) < 0) { data/ninja-build-1.10.1/src/canon_perftest.cc:31:3: [4] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). strcpy(buf, kPath); data/ninja-build-1.10.1/src/manifest_parser_perftest.cc:48:19: [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. int exit_code = system(command.c_str()); data/ninja-build-1.10.1/src/minidump-win32.cc:37:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(temp_file, "%s\\ninja_crash_dump_%lu.dmp", data/ninja-build-1.10.1/src/ninja_test.cc:57:3: [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. vsnprintf(buf, N, format, ap); data/ninja-build-1.10.1/src/test.cc:206:3: [4] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). strcpy(name_template, name.c_str()); data/ninja-build-1.10.1/src/test.cc:231:7: [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. if (system(command.c_str()) < 0) data/ninja-build-1.10.1/src/util.cc:61:3: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(stderr, msg, ap); data/ninja-build-1.10.1/src/util.cc:79:3: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(stderr, msg, ap); data/ninja-build-1.10.1/src/util.cc:88:3: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(stderr, msg, ap); data/ninja-build-1.10.1/src/util.h:108:9: [4] (format) snprintf: 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. #define snprintf _snprintf data/ninja-build-1.10.1/src/util.h:108:18: [4] (format) _snprintf: 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. #define snprintf _snprintf data/ninja-build-1.10.1/src/build.cc:90: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. progress_status_format_ = getenv("NINJA_STATUS"); data/ninja-build-1.10.1/src/getopt.c:182:17: [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. ordering = (getenv ("POSIXLY_CORRECT") != NULL) ? REQUIRE_ORDER : PERMUTE; data/ninja-build-1.10.1/src/getopt.c:390:1: [3] (buffer) getopt: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. getopt (int argc, char **argv, char *optstring) data/ninja-build-1.10.1/src/getopt.c:397:1: [3] (buffer) getopt_long: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. getopt_long (int argc, char **argv, const char *shortopts, data/ninja-build-1.10.1/src/getopt.h:43:7: [3] (buffer) getopt: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. int getopt (int argc, char **argv, char *optstring); data/ninja-build-1.10.1/src/getopt.h:45:7: [3] (buffer) getopt_long: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. int getopt_long (int argc, char **argv, const char *shortopts, data/ninja-build-1.10.1/src/hash_collision_bench.cc:23:5: [3] (random) random: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. int random(int low, int high) { data/ninja-build-1.10.1/src/hash_collision_bench.cc:28:13: [3] (random) random: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. int len = random(5, 100); data/ninja-build-1.10.1/src/hash_collision_bench.cc:31:21: [3] (random) random: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. (*s)[i] = (char)random(32, 127); data/ninja-build-1.10.1/src/hash_collision_bench.cc:41:3: [3] (random) srand: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. srand((int)time(NULL)); data/ninja-build-1.10.1/src/line_printer.cc:34:22: [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* term = getenv("TERM"); data/ninja-build-1.10.1/src/line_printer.cc:53:34: [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* clicolor_force = getenv("CLICOLOR_FORCE"); data/ninja-build-1.10.1/src/manifest_parser_perftest.cc:77:17: [3] (buffer) getopt: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. while ((opt = getopt(argc, argv, const_cast<char*>("fh"))) != -1) { data/ninja-build-1.10.1/src/msvc_helper_main-win32.cc:90:17: [3] (buffer) getopt_long: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. while ((opt = getopt_long(argc, argv, "e:o:p:h", kLongOptions, NULL)) != -1) { data/ninja-build-1.10.1/src/ninja.cc:576:17: [3] (buffer) getopt: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. while ((opt = getopt(argc, argv, const_cast<char*>("hd"))) != -1) { data/ninja-build-1.10.1/src/ninja.cc:640:17: [3] (buffer) getopt: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. while ((opt = getopt(argc, argv, const_cast<char*>("hs"))) != -1) { data/ninja-build-1.10.1/src/ninja.cc:683:17: [3] (buffer) getopt: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. while ((opt = getopt(argc, argv, const_cast<char*>("hgr"))) != -1) { data/ninja-build-1.10.1/src/ninja.cc:788:17: [3] (buffer) getopt: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. while ((opt = getopt(argc, argv, const_cast<char*>("hx"))) != -1) { data/ninja-build-1.10.1/src/ninja.cc:869:17: [3] (buffer) getopt: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. while ((opt = getopt(argc, argv, const_cast<char*>("h"))) != -1) { data/ninja-build-1.10.1/src/ninja.cc:1271:17: [3] (buffer) getopt_long: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. (opt = getopt_long(*argc, *argv, "d:f:j:k:l:nt:vw:C:h", kLongOptions, data/ninja-build-1.10.1/src/ninja_test.cc:100:17: [3] (buffer) getopt_long: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. while ((opt = getopt_long(*argc, *argv, "h", kLongOptions, NULL)) != -1) { data/ninja-build-1.10.1/src/test.cc:74:25: [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* tempdir = getenv("TMPDIR"); data/ninja-build-1.10.1/src/build.cc:208: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 buf[32]; data/ninja-build-1.10.1/src/build_log.cc:72:5: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(&k, data, sizeof k); data/ninja-build-1.10.1/src/build_log.cc:187:15: [2] (misc) fopen: 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). log_file_ = fopen(log_file_path_.c_str(), "ab"); data/ninja-build-1.10.1/src/build_log.cc:250: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 buf_[256 << 10]; data/ninja-build-1.10.1/src/build_log.cc:260:16: [2] (misc) fopen: 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). FILE* file = fopen(path.c_str(), "r"); data/ninja-build-1.10.1/src/build_log.cc:305:18: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). start_time = atoi(start); data/ninja-build-1.10.1/src/build_log.cc:312:16: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). end_time = atoi(start); data/ninja-build-1.10.1/src/build_log.cc:393:13: [2] (misc) fopen: 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). FILE* f = fopen(temp_path.c_str(), "wb"); data/ninja-build-1.10.1/src/build_log.cc:444:13: [2] (misc) fopen: 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). FILE* f = fopen(temp_path.c_str(), "wb"); data/ninja-build-1.10.1/src/build_log_perftest.cc:67: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 buf[80]; data/ninja-build-1.10.1/src/build_log_perftest.cc:68:5: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(buf, "-I../../and/arbitrary/but/fairly/long/path/suffixed/%d ", i); data/ninja-build-1.10.1/src/build_log_perftest.cc:83: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 buf[80]; data/ninja-build-1.10.1/src/build_log_perftest.cc:84:5: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(buf, "build input%d.o: cxx input%d.cc\n", i, i); data/ninja-build-1.10.1/src/build_log_test.cc:104:13: [2] (misc) fopen: 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). FILE* f = fopen(kTestFilename, "wb"); data/ninja-build-1.10.1/src/build_log_test.cc:159:13: [2] (misc) fopen: 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). FILE* f = fopen(kTestFilename, "wb"); data/ninja-build-1.10.1/src/build_log_test.cc:171:13: [2] (misc) fopen: 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). FILE* f = fopen(kTestFilename, "wb"); data/ninja-build-1.10.1/src/build_log_test.cc:193:13: [2] (misc) fopen: 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). FILE* f = fopen(kTestFilename, "wb"); data/ninja-build-1.10.1/src/build_log_test.cc:243:13: [2] (misc) fopen: 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). FILE* f = fopen(kTestFilename, "wb"); data/ninja-build-1.10.1/src/build_log_test.cc:271:13: [2] (misc) fopen: 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). FILE* f = fopen(kTestFilename, "wb"); data/ninja-build-1.10.1/src/canon_perftest.cc:29: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 buf[200]; data/ninja-build-1.10.1/src/deps_log.cc:152: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 buf[kMaxRecordSize + 1]; data/ninja-build-1.10.1/src/deps_log.cc:153:13: [2] (misc) fopen: 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). FILE* f = fopen(path.c_str(), "rb"); data/ninja-build-1.10.1/src/deps_log.cc:408:11: [2] (misc) fopen: 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). file_ = fopen(file_path_.c_str(), "ab"); data/ninja-build-1.10.1/src/deps_log_test.cc:102:7: [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 buf[32]; data/ninja-build-1.10.1/src/deps_log_test.cc:103:7: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(buf, "file%d.h", i); data/ninja-build-1.10.1/src/deps_log_test.cc:336:22: [2] (misc) fopen: 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). FILE* deps_log = fopen(kTestFilename, "wb"); data/ninja-build-1.10.1/src/disk_interface.cc:221:14: [2] (misc) fopen: 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). FILE* fp = fopen(path.c_str(), "w"); data/ninja-build-1.10.1/src/disk_interface_test.cc:39:15: [2] (misc) fopen: 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). FILE *f = fopen(path, "w"); data/ninja-build-1.10.1/src/disk_interface_test.cc:179:13: [2] (misc) fopen: 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). FILE* f = fopen(kTestFile, "wb"); data/ninja-build-1.10.1/src/disk_interface_test.cc:194:13: [2] (misc) fopen: 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). FILE* f = fopen((path + "a_file").c_str(), "w"); data/ninja-build-1.10.1/src/disk_interface_test.cc:200:14: [2] (misc) fopen: 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). FILE* f2 = fopen((path2 + "a_file").c_str(), "w"); data/ninja-build-1.10.1/src/hash_map.h:33:5: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(&k, data, sizeof k); data/ninja-build-1.10.1/src/includes_normalize-win32.cc:77: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 a_absolute[_MAX_PATH]; data/ninja-build-1.10.1/src/includes_normalize-win32.cc:78: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 b_absolute[_MAX_PATH]; data/ninja-build-1.10.1/src/includes_normalize-win32.cc:85: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 a_drive[_MAX_DIR]; data/ninja-build-1.10.1/src/includes_normalize-win32.cc:86: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 b_drive[_MAX_DIR]; data/ninja-build-1.10.1/src/includes_normalize-win32.cc:147: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 result[_MAX_PATH]; data/ninja-build-1.10.1/src/includes_normalize-win32.cc:184: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 copy[_MAX_PATH + 1]; data/ninja-build-1.10.1/src/includes_normalize_test.cc:28: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 buf[_MAX_PATH]; data/ninja-build-1.10.1/src/includes_normalize_test.cc:117: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 kExactlyMaxPath[_MAX_PATH + 1]; data/ninja-build-1.10.1/src/includes_normalize_test.cc:154: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 kExactlyMaxPath[_MAX_PATH + 1]; data/ninja-build-1.10.1/src/lexer.cc:35: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 buf[1024]; data/ninja-build-1.10.1/src/lexer.in.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 buf[1024]; data/ninja-build-1.10.1/src/manifest_parser.cc:115:15: [2] (integer) atol: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). depth = atol(depth_string.c_str()); data/ninja-build-1.10.1/src/minidump-win32.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 temp_path[MAX_PATH]; data/ninja-build-1.10.1/src/minidump-win32.cc:36: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 temp_file[MAX_PATH]; data/ninja-build-1.10.1/src/msvc_helper-win32.cc:83: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 buf[64 << 10]; data/ninja-build-1.10.1/src/msvc_helper_main-win32.cc:53:19: [2] (misc) fopen: 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). FILE* depfile = fopen(depfile_path.c_str(), "w"); data/ninja-build-1.10.1/src/ninja.cc:538:17: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). depth = atoi(argv[1]); data/ninja-build-1.10.1/src/ninja_test.cc:53: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 buf[N]; data/ninja-build-1.10.1/src/subprocess-posix.cc:136: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 buf[4 << 10]; data/ninja-build-1.10.1/src/subprocess-win32.cc:40: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 pipe_name[100]; data/ninja-build-1.10.1/src/subprocess.h:69: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 overlapped_buf_[4 << 10]; data/ninja-build-1.10.1/src/test.cc:69: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 buf[1024]; data/ninja-build-1.10.1/src/test.cc:205: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 name_template[1024]; data/ninja-build-1.10.1/src/test.cc:207:3: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. strcat(name_template, "-XXXXXX"); data/ninja-build-1.10.1/src/util.cc:330: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 buf[64 << 10]; data/ninja-build-1.10.1/src/util.cc:343:13: [2] (misc) fopen: 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). FILE* f = fopen(path.c_str(), "rb"); data/ninja-build-1.10.1/src/util.cc:359: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 buf[64 << 10]; data/ninja-build-1.10.1/src/version.cc:25:12: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). *major = atoi(version.substr(0, end).c_str()); data/ninja-build-1.10.1/src/version.cc:30:14: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). *minor = atoi(version.substr(start, end).c_str()); data/ninja-build-1.10.1/src/build_log.cc:238:37: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). buf_end_ = buf_ + size_rest + read; data/ninja-build-1.10.1/src/build_log_test.cc:75:30: [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). const size_t kVersionPos = strlen(kExpectedVersion) - 2; // Points at 'X'. data/ninja-build-1.10.1/src/build_log_test.cc:274:40: [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). for (size_t i = 0; i < (512 << 10) / strlen(" more_command"); ++i) data/ninja-build-1.10.1/src/canon_perftest.cc:30:16: [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). size_t len = strlen(kPath); data/ninja-build-1.10.1/src/deps_log_test.cc:339:9: [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). strlen(kInvalidHeaders[i]), data/ninja-build-1.10.1/src/deps_log_test.cc:340:39: [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). fwrite(kInvalidHeaders[i], 1, strlen(kInvalidHeaders[i]), deps_log)); data/ninja-build-1.10.1/src/getopt.c:242:25: [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). match_chars = strlen (argv[optind]); data/ninja-build-1.10.1/src/getopt.c:254:34: [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). if (match_chars == strlen (longopts[optindex].name)) data/ninja-build-1.10.1/src/includes_normalize-win32.cc:190:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(copy, input.c_str(), input.size() + 1); data/ninja-build-1.10.1/src/includes_normalize_test.cc:120:17: [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). int cwd_len = strlen(kExactlyMaxPath); data/ninja-build-1.10.1/src/includes_normalize_test.cc:136:13: [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). EXPECT_EQ(strlen(kExactlyMaxPath), _MAX_PATH); data/ninja-build-1.10.1/src/includes_normalize_test.cc:162:13: [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). EXPECT_EQ(strlen(kExactlyMaxPath), _MAX_PATH); data/ninja-build-1.10.1/src/msvc_helper_main-win32.cc:46:24: [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). as_str = &as_str[strlen(as_str) + 1]; data/ninja-build-1.10.1/src/string_piece.h:34:50: [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). StringPiece(const char* str) : str_(str), len_(strlen(str)) {} data/ninja-build-1.10.1/src/subprocess-posix.cc:137:17: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ssize_t len = read(fd_, buf, sizeof(buf)); data/ninja-build-1.10.1/src/test.cc:51:38: [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). int err = _mktemp_s(name_template, strlen(name_template) + 1); data/ninja-build-1.10.1/src/util_test.cc:359:9: [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). len = strlen("foo/."); // Canonicalize only the part before the space. data/ninja-build-1.10.1/src/util_test.cc:361:13: [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). EXPECT_EQ(strlen("foo"), len); data/ninja-build-1.10.1/src/util_test.cc:365:9: [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). len = strlen("foo/../file"); data/ninja-build-1.10.1/src/util_test.cc:367:13: [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). EXPECT_EQ(strlen("file"), len); ANALYSIS SUMMARY: Hits = 120 Lines analyzed = 23935 in approximately 0.56 seconds (42594 lines/second) Physical Source Lines of Code (SLOC) = 17477 Hits@level = [0] 158 [1] 20 [2] 61 [3] 22 [4] 17 [5] 0 Hits@level+ = [0+] 278 [1+] 120 [2+] 100 [3+] 39 [4+] 17 [5+] 0 Hits/KSLOC@level+ = [0+] 15.9066 [1+] 6.86617 [2+] 5.72181 [3+] 2.2315 [4+] 0.972707 [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.