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/git-crypt-0.6.0/commands.cpp
Examining data/git-crypt-0.6.0/commands.hpp
Examining data/git-crypt-0.6.0/coprocess-unix.cpp
Examining data/git-crypt-0.6.0/coprocess-unix.hpp
Examining data/git-crypt-0.6.0/coprocess-win32.cpp
Examining data/git-crypt-0.6.0/coprocess-win32.hpp
Examining data/git-crypt-0.6.0/coprocess.cpp
Examining data/git-crypt-0.6.0/coprocess.hpp
Examining data/git-crypt-0.6.0/crypto-openssl-10.cpp
Examining data/git-crypt-0.6.0/crypto-openssl-11.cpp
Examining data/git-crypt-0.6.0/crypto.cpp
Examining data/git-crypt-0.6.0/crypto.hpp
Examining data/git-crypt-0.6.0/fhstream.cpp
Examining data/git-crypt-0.6.0/fhstream.hpp
Examining data/git-crypt-0.6.0/git-crypt.cpp
Examining data/git-crypt-0.6.0/git-crypt.hpp
Examining data/git-crypt-0.6.0/gpg.cpp
Examining data/git-crypt-0.6.0/gpg.hpp
Examining data/git-crypt-0.6.0/key.cpp
Examining data/git-crypt-0.6.0/key.hpp
Examining data/git-crypt-0.6.0/parse_options.cpp
Examining data/git-crypt-0.6.0/parse_options.hpp
Examining data/git-crypt-0.6.0/util-unix.cpp
Examining data/git-crypt-0.6.0/util-win32.cpp
Examining data/git-crypt-0.6.0/util.cpp
Examining data/git-crypt-0.6.0/util.hpp

FINAL RESULTS:

data/git-crypt-0.6.0/commands.cpp:599:7:  [4] (race) access:
  This usually indicates a security flaw. If an attacker can change anything
  along the path between the call to access() and the file's actual use
  (e.g., by moving files), the attacker can exploit the race condition
  (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid())
  and try to open the file directly.
		if (access(path.c_str(), F_OK) == 0) {
data/git-crypt-0.6.0/commands.cpp:634:6:  [4] (race) access:
  This usually indicates a security flaw. If an attacker can change anything
  along the path between the call to access() and the file's actual use
  (e.g., by moving files), the attacker can exploit the race condition
  (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid())
  and try to open the file directly.
	if (access(keys_path.c_str(), F_OK) == 0) {
data/git-crypt-0.6.0/commands.cpp:673:7:  [4] (race) access:
  This usually indicates a security flaw. If an attacker can change anything
  along the path between the call to access() and the file's actual use
  (e.g., by moving files), the attacker can exploit the race condition
  (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid())
  and try to open the file directly.
		if (access(path.c_str(), F_OK) == 0) {
data/git-crypt-0.6.0/commands.cpp:961:6:  [4] (race) access:
  This usually indicates a security flaw. If an attacker can change anything
  along the path between the call to access() and the file's actual use
  (e.g., by moving files), the attacker can exploit the race condition
  (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid())
  and try to open the file directly.
	if (access(internal_key_path.c_str(), F_OK) == 0) {
data/git-crypt-0.6.0/commands.cpp:1153:7:  [4] (race) access:
  This usually indicates a security flaw. If an attacker can change anything
  along the path between the call to access() and the file's actual use
  (e.g., by moving files), the attacker can exploit the race condition
  (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid())
  and try to open the file directly.
		if (access(internal_key_path.c_str(), F_OK) == -1 && errno == ENOENT) {
data/git-crypt-0.6.0/commands.cpp:1244:6:  [4] (race) access:
  This usually indicates a security flaw. If an attacker can change anything
  along the path between the call to access() and the file's actual use
  (e.g., by moving files), the attacker can exploit the race condition
  (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid())
  and try to open the file directly.
	if (access(state_gitattributes_path.c_str(), F_OK) != 0) {
data/git-crypt-0.6.0/commands.cpp:1399:46:  [4] (race) access:
  This usually indicates a security flaw. If an attacker can change anything
  along the path between the call to access() and the file's actual use
  (e.g., by moving files), the attacker can exploit the race condition
  (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid())
  and try to open the file directly.
	if (std::strcmp(key_file_name, "-") != 0 && access(key_file_name, F_OK) == 0) {
data/git-crypt-0.6.0/commands.cpp:1613:9:  [4] (race) access:
  This usually indicates a security flaw. If an attacker can change anything
  along the path between the call to access() and the file's actual use
  (e.g., by moving files), the attacker can exploit the race condition
  (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid())
  and try to open the file directly.
				if (access(filename.c_str(), F_OK) != 0) {
data/git-crypt-0.6.0/coprocess-unix.cpp:37:12:  [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.
static int execvp (const std::string& file, const std::vector<std::string>& args)
data/git-crypt-0.6.0/coprocess-unix.cpp:45:9:  [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.
	return execvp(file.c_str(), const_cast<char**>(&args_c_str[0]));
data/git-crypt-0.6.0/coprocess-unix.cpp:143:3:  [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(args[0], args);
data/git-crypt-0.6.0/util-unix.cpp:76:7:  [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).
	std::strcpy(path, tmpdir);
data/git-crypt-0.6.0/util-unix.cpp:67:24:  [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*		tmpdir = getenv("TMPDIR");
data/git-crypt-0.6.0/util-unix.cpp:135:28:  [3] (buffer) realpath:
  This function does not protect against buffer overflows, and some
  implementations can overflow internally (CWE-120/CWE-785!). Ensure that the
  destination buffer is at least of size MAXPATHLEN, andto protect against
  implementation problems, the input argument should also be checked to
  ensure it is no larger than MAXPATHLEN.
		char*		resolved_path_p = realpath(argv0, nullptr);
data/git-crypt-0.6.0/util-win32.cpp:75:6:  [3] (tmpfile) GetTempFileName:
  Temporary file race condition in certain cases (e.g., if run as SYSTEM in
  many versions of Windows) (CWE-377).
	if (GetTempFileName(tmpdir, TEXT("git-crypt"), 0, tmpfilename) == 0) {
data/git-crypt-0.6.0/commands.cpp:88:26:  [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).
		version.push_back(std::atoi(component.c_str()));
data/git-crypt-0.6.0/commands.cpp:458:2:  [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				header[10];
data/git-crypt-0.6.0/commands.cpp:725:2:  [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			buffer[1024];
data/git-crypt-0.6.0/commands.cpp:739:15:  [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).
				temp_file.open(std::fstream::in | std::fstream::out | std::fstream::binary | std::fstream::app);
data/git-crypt-0.6.0/commands.cpp:774:11:  [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.
	unsigned char		digest[Hmac_sha1_state::LEN];
data/git-crypt-0.6.0/commands.cpp:827:12:  [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.
		unsigned char	buffer[1024];
data/git-crypt-0.6.0/commands.cpp:834:11:  [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.
	unsigned char		digest[Hmac_sha1_state::LEN];
data/git-crypt-0.6.0/commands.cpp:866:11:  [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.
	unsigned char		header[10 + Aes_ctr_decryptor::NONCE_LEN];
data/git-crypt-0.6.0/commands.cpp:913:11:  [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.
	unsigned char		header[10 + Aes_ctr_decryptor::NONCE_LEN];
data/git-crypt-0.6.0/crypto-openssl-10.cpp:112:4:  [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		error_string[120];
data/git-crypt-0.6.0/crypto-openssl-11.cpp:111:4:  [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		error_string[120];
data/git-crypt-0.6.0/crypto.cpp:40:7:  [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(ctr_value, nonce, NONCE_LEN);
data/git-crypt-0.6.0/crypto.cpp:74:11:  [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.
	unsigned char		buffer[1024];
data/git-crypt-0.6.0/crypto.hpp:79:11:  [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.
	unsigned char		ctr_value[BLOCK_LEN];	// Current CTR value (used as input to AES to derive pad)
data/git-crypt-0.6.0/crypto.hpp:80:11:  [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.
	unsigned char		pad[BLOCK_LEN];		// Current encryption pad (output of AES)
data/git-crypt-0.6.0/fhstream.cpp:188:7:  [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(s, gptr(), bytes_available);
data/git-crypt-0.6.0/fhstream.cpp:209:7:  [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(buffer + (putback_size - nputback), s - nputback, nputback);
data/git-crypt-0.6.0/key.cpp:181:11:  [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.
	unsigned char	preamble[16];
data/git-crypt-0.6.0/key.hpp:49:12:  [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.
		unsigned char		aes_key[AES_KEY_LEN];
data/git-crypt-0.6.0/key.hpp:50:12:  [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.
		unsigned char		hmac_key[HMAC_KEY_LEN];
data/git-crypt-0.6.0/util-unix.cpp:63:20:  [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).
void	temp_fstream::open (std::ios_base::openmode mode)
data/git-crypt-0.6.0/util-unix.cpp:77:7:  [2] (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). Risk is low because the source is a constant string.
	std::strcpy(path + tmpdir_len, "/git-crypt.XXXXXX");
data/git-crypt-0.6.0/util-unix.cpp:79:13:  [2] (tmpfile) mkstemp:
  Potential for temporary file vulnerability in some circumstances. Some
  older Unix-like systems create temp files with permission to write by all
  by default, so be sure to set the umask to override this. Also, some older
  Unix systems might fail to use O_EXCL when opening the file, so make sure
  that O_EXCL is used by the library (CWE-377).
	int			fd = mkstemp(path);
data/git-crypt-0.6.0/util-unix.cpp:86:16:  [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).
	std::fstream::open(path, mode);
data/git-crypt-0.6.0/util-unix.cpp:170:11:  [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).
	int	fd = open(path, O_WRONLY | O_CREAT, 0600);
data/git-crypt-0.6.0/util-win32.cpp:61:20:  [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).
void	temp_fstream::open (std::ios_base::openmode mode)
data/git-crypt-0.6.0/util-win32.cpp:65:2:  [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			tmpdir[MAX_PATH + 1];
data/git-crypt-0.6.0/util-win32.cpp:74:2:  [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			tmpfilename[MAX_PATH + 1];
data/git-crypt-0.6.0/util-win32.cpp:81:16:  [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).
	std::fstream::open(filename.c_str(), mode);
data/git-crypt-0.6.0/util.cpp:95:11:  [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.
	unsigned char buffer[4];
data/git-crypt-0.6.0/util.cpp:106:11:  [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.
	unsigned char buffer[4];
data/git-crypt-0.6.0/util.hpp:57:8:  [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).
	void		open (std::ios_base::openmode);
data/git-crypt-0.6.0/commands.cpp:459:9:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	output.read(header, sizeof(header));
data/git-crypt-0.6.0/commands.cpp:728:12:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
		std::cin.read(buffer, sizeof(buffer));
data/git-crypt-0.6.0/commands.cpp:799:14:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
			temp_file.read(buffer, sizeof(buffer));
data/git-crypt-0.6.0/commands.cpp:828:6:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
		in.read(reinterpret_cast<char*>(buffer), sizeof(buffer));
data/git-crypt-0.6.0/commands.cpp:867:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	std::cin.read(reinterpret_cast<char*>(header), sizeof(header));
data/git-crypt-0.6.0/commands.cpp:914:5:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	in.read(reinterpret_cast<char*>(header), sizeof(header));
data/git-crypt-0.6.0/commands.cpp:1224:78:  [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 bool is_full_fingerprint(std::strncmp(argv[i], "0x", 2) == 0 && std::strlen(argv[i]) == 42);
data/git-crypt-0.6.0/coprocess-unix.cpp:181:16:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	while ((ret = read(fd, buf, count)) == -1 && errno == EINTR); // restart if interrupted
data/git-crypt-0.6.0/crypto.cpp:76:6:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
		in.read(reinterpret_cast<char*>(buffer), sizeof(buffer));
data/git-crypt-0.6.0/key.cpp:78:7:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
			in.read(reinterpret_cast<char*>(aes_key), AES_KEY_LEN);
data/git-crypt-0.6.0/key.cpp:86:7:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
			in.read(reinterpret_cast<char*>(hmac_key), HMAC_KEY_LEN);
data/git-crypt-0.6.0/key.cpp:110:5:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	in.read(reinterpret_cast<char*>(aes_key), AES_KEY_LEN);
data/git-crypt-0.6.0/key.cpp:116:5:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	in.read(reinterpret_cast<char*>(hmac_key), HMAC_KEY_LEN);
data/git-crypt-0.6.0/key.cpp:182:5:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	in.read(reinterpret_cast<char*>(preamble), 16);
data/git-crypt-0.6.0/key.cpp:225:8:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
				in.read(&bytes[0], field_len);
data/git-crypt-0.6.0/util-unix.cpp:68: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).
	size_t			tmpdir_len = tmpdir ? std::strlen(tmpdir) : 0;
data/git-crypt-0.6.0/util-unix.cpp:78:23:  [1] (access) umask:
  Ensure that umask is given most restrictive possible setting (e.g., 066 or
  077) (CWE-732).
	mode_t			old_umask = umask(0077);
data/git-crypt-0.6.0/util-unix.cpp:82:3:  [1] (access) umask:
  Ensure that umask is given most restrictive possible setting (e.g., 066 or
  077) (CWE-732).
		umask(old_umask);
data/git-crypt-0.6.0/util-unix.cpp:85:2:  [1] (access) umask:
  Ensure that umask is given most restrictive possible setting (e.g., 066 or
  077) (CWE-732).
	umask(old_umask);
data/git-crypt-0.6.0/util.cpp:96:5:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	in.read(reinterpret_cast<char*>(buffer), 4);

ANALYSIS SUMMARY:

Hits = 67
Lines analyzed = 5002 in approximately 0.24 seconds (20553 lines/second)
Physical Source Lines of Code (SLOC) = 3387
Hits@level = [0]   0 [1]  20 [2]  32 [3]   3 [4]  12 [5]   0
Hits@level+ = [0+]  67 [1+]  67 [2+]  47 [3+]  15 [4+]  12 [5+]   0
Hits/KSLOC@level+ = [0+] 19.7815 [1+] 19.7815 [2+] 13.8766 [3+] 4.4287 [4+] 3.54296 [5+]   0
Dot directories skipped = 1 (--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.