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/duperemove-0.11.1/bswap.h
Examining data/duperemove-0.11.1/btrfs-ioctl.h
Examining data/duperemove-0.11.1/btrfs-util.c
Examining data/duperemove-0.11.1/btrfs-util.h
Examining data/duperemove-0.11.1/csum-murmur3.c
Examining data/duperemove-0.11.1/csum-sha256.c
Examining data/duperemove-0.11.1/csum-test.c
Examining data/duperemove-0.11.1/csum-xxhash.c
Examining data/duperemove-0.11.1/csum.c
Examining data/duperemove-0.11.1/csum.h
Examining data/duperemove-0.11.1/dbfile.c
Examining data/duperemove-0.11.1/dbfile.h
Examining data/duperemove-0.11.1/debug.c
Examining data/duperemove-0.11.1/debug.h
Examining data/duperemove-0.11.1/dedupe.c
Examining data/duperemove-0.11.1/dedupe.h
Examining data/duperemove-0.11.1/file_scan.c
Examining data/duperemove-0.11.1/file_scan.h
Examining data/duperemove-0.11.1/filerec.c
Examining data/duperemove-0.11.1/filerec.h
Examining data/duperemove-0.11.1/find_dupes.c
Examining data/duperemove-0.11.1/find_dupes.h
Examining data/duperemove-0.11.1/hash-tree.c
Examining data/duperemove-0.11.1/hash-tree.h
Examining data/duperemove-0.11.1/hashstats.c
Examining data/duperemove-0.11.1/interval_tree.c
Examining data/duperemove-0.11.1/interval_tree.h
Examining data/duperemove-0.11.1/interval_tree_generic.h
Examining data/duperemove-0.11.1/kernel.h
Examining data/duperemove-0.11.1/list.h
Examining data/duperemove-0.11.1/list_sort.c
Examining data/duperemove-0.11.1/list_sort.h
Examining data/duperemove-0.11.1/memstats.c
Examining data/duperemove-0.11.1/rbtree.c
Examining data/duperemove-0.11.1/rbtree.h
Examining data/duperemove-0.11.1/rbtree_augmented.h
Examining data/duperemove-0.11.1/results-tree.c
Examining data/duperemove-0.11.1/results-tree.h
Examining data/duperemove-0.11.1/run_dedupe.c
Examining data/duperemove-0.11.1/run_dedupe.h
Examining data/duperemove-0.11.1/stats.c
Examining data/duperemove-0.11.1/stats.h
Examining data/duperemove-0.11.1/util.c
Examining data/duperemove-0.11.1/util.h
Examining data/duperemove-0.11.1/xxhash.c
Examining data/duperemove-0.11.1/xxhash.h
Examining data/duperemove-0.11.1/btrfs-extent-same.c
Examining data/duperemove-0.11.1/duperemove.c
Examining data/duperemove-0.11.1/memstats.h

FINAL RESULTS:

data/duperemove-0.11.1/dbfile.c:146: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.
		ret = access(filename, R_OK|W_OK);
data/duperemove-0.11.1/debug.h:30:37:  [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.
#define dprintf(args...)	if (debug) printf(args)
data/duperemove-0.11.1/debug.h:31:9:  [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.
#define vprintf(args...)	if (verbose) printf(args)
data/duperemove-0.11.1/debug.h:31:39:  [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.
#define vprintf(args...)	if (verbose) printf(args)
data/duperemove-0.11.1/debug.h:32:38:  [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.
#define qprintf(args...)	if (!quiet) printf(args)
data/duperemove-0.11.1/file_scan.c:214:8:  [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.
	ret = access(name, R_OK);
data/duperemove-0.11.1/file_scan.c:305:9:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
		ret = sprintf(pathp, "%s", name);
data/duperemove-0.11.1/file_scan.c:307:9:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
		ret = sprintf(pathp, "/%s", name);
data/duperemove-0.11.1/util.c:103:10:  [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.
		return snprintf(str, str_bytes, "%"PRIu64, size);
data/duperemove-0.11.1/csum-test.c:68:14:  [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 ((c = getopt_long(argc, argv, "b:", long_ops, NULL))
data/duperemove-0.11.1/duperemove.c:394:14:  [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 ((c = getopt_long(argc, argv, "Ab:vdDrh?xLR:q", long_ops, NULL))
data/duperemove-0.11.1/file_scan.c:319:6:  [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.
	if (realpath(path, abspath) == NULL) {
data/duperemove-0.11.1/hashstats.c:298:14:  [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 ((c = getopt_long(argc, argv, "labn:?", long_ops, NULL))
data/duperemove-0.11.1/btrfs-extent-same.c:94: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).
	ret = open(srcf, O_RDONLY);
data/duperemove-0.11.1/btrfs-extent-same.c:109:9:  [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).
		ret = open(destf, geteuid() ? O_WRONLY : O_RDONLY);
data/duperemove-0.11.1/btrfs-util.c:113:7:  [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).
	fd = open(name, O_RDONLY);
data/duperemove-0.11.1/btrfs-util.c:177: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).
		fd = open(filename, O_RDONLY);
data/duperemove-0.11.1/csum-murmur3.c:91: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 rem_buffer[REM_BUFFER_LEN]; /* Holds partial block between calls */
data/duperemove-0.11.1/csum-murmur3.c:117: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 block[16];
data/duperemove-0.11.1/csum-murmur3.c:128:3:  [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(block, c->rem_buffer, c->rem_len);
data/duperemove-0.11.1/csum-murmur3.c:172:2:  [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(&c->rem_buffer[c->rem_len], data, len);
data/duperemove-0.11.1/csum-test.c:51:17:  [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 digest[DIGEST_LEN_MAX] = { 0, };
data/duperemove-0.11.1/csum-test.c:72: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).
			buf_len = atoi(optarg);
data/duperemove-0.11.1/csum-test.c:110:7:  [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).
	fd = open(fname, O_RDONLY);
data/duperemove-0.11.1/csum.c:27:1:  [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		hash_type[8];
data/duperemove-0.11.1/csum.h:25:8:  [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.
extern char hash_type[8];
data/duperemove-0.11.1/dbfile.c:884: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			buf[0];
data/duperemove-0.11.1/duperemove.c:595: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 db_hash_type[8];
data/duperemove-0.11.1/file_scan.c:54:8:  [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 char path[PATH_MAX] = { 0, };
data/duperemove-0.11.1/file_scan.c:222:7:  [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).
	fd = open(name, O_RDONLY);
data/duperemove-0.11.1/file_scan.c:295: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 abspath[PATH_MAX];
data/duperemove-0.11.1/file_scan.c:581: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[DIGEST_LEN_MAX];
data/duperemove-0.11.1/file_scan.c:738:3:  [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(hashes[nb_hash].digest, curr_block.digest,
data/duperemove-0.11.1/file_scan.h:40: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[DIGEST_LEN_MAX];
data/duperemove-0.11.1/filerec.c:418: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).
		fd = open(file->filename, flags);
data/duperemove-0.11.1/filerec.c:495: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			buf[FIEMAP_BUF_SIZE];
data/duperemove-0.11.1/filerec.c:657: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 buf[16384];
data/duperemove-0.11.1/filerec.c:775:8:  [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 char flagstr[FLAG_STR_LEN];
data/duperemove-0.11.1/find_dupes.c:218: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 match_id[DIGEST_LEN_MAX] = {0, };
data/duperemove-0.11.1/hash-tree.c:299:3:  [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(d->dl_hash, digest, digest_len);
data/duperemove-0.11.1/hash-tree.h:37: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		dl_hash[DIGEST_LEN_MAX];
data/duperemove-0.11.1/hashstats.c:311:19:  [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).
			num_to_print = atoi(optarg);
data/duperemove-0.11.1/results-tree.c:217:2:  [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(dext->de_hash, digest, digest_len);
data/duperemove-0.11.1/results-tree.c:290:54:  [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.
int insert_result(struct results_tree *res, unsigned char *digest,
data/duperemove-0.11.1/results-tree.h:34: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		de_hash[DIGEST_LEN_MAX];
data/duperemove-0.11.1/results-tree.h:87:54:  [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.
int insert_result(struct results_tree *res, unsigned char *digest,
data/duperemove-0.11.1/run_dedupe.c:508: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		bd_hash[DIGEST_LEN_MAX];
data/duperemove-0.11.1/run_dedupe.c:713:3:  [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(&bdl->bd_hash, &dups->dl_hash, DIGEST_LEN_MAX);
data/duperemove-0.11.1/util.c:187: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 line[LINE_MAX + 1];
data/duperemove-0.11.1/util.c:191:7:  [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).
	fp = fopen("/proc/cpuinfo", "r");
data/duperemove-0.11.1/util.h:37:19:  [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 __thread char _str[32];				\
data/duperemove-0.11.1/xxhash.c:75:12:  [2] (buffer) memcpy:
  Does not check for buffer overflows when copying to destination (CWE-120).
  Make sure destination can always hold the source data.
    return memcpy(dest,src,size);
data/duperemove-0.11.1/xxhash.c:459: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 memory[16];
data/duperemove-0.11.1/xxhash.c:471: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 memory[32];
data/duperemove-0.11.1/csum-test.c:127:9:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
		len = read(fd, buf, buf_len);
data/duperemove-0.11.1/csum-test.c:139:10:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
			len = read(fd, buf, buf_len);
data/duperemove-0.11.1/csum.c:53:2:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
	strncpy(hash_type, csum_mod->hash_type, 8);
data/duperemove-0.11.1/dbfile.c:541:3:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
		strncpy((char *)val, (char *)local, len);
data/duperemove-0.11.1/dbfile.c:891:12:  [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 len = strlen(filename);
data/duperemove-0.11.1/dbfile.c:896:3:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
		strncpy(o->filename, filename, len);
data/duperemove-0.11.1/duperemove.c:177:7:  [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 (strlen(rm->filename) == 1 && rm->filename[0] == '-') {
data/duperemove-0.11.1/duperemove.c:261: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).
			token += strlen("no");
data/duperemove-0.11.1/file_scan.c:290: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 ret, len = strlen(name);
data/duperemove-0.11.1/file_scan.c:597:15:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	bytes_read = read(data->file->fd, data->buf + stored_bytes,
data/duperemove-0.11.1/util.c:218:12:  [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).
		c = &val[strlen(val) - 1];

ANALYSIS SUMMARY:

Hits = 65
Lines analyzed = 13083 in approximately 0.35 seconds (37007 lines/second)
Physical Source Lines of Code (SLOC) = 8973
Hits@level = [0] 242 [1]  11 [2]  41 [3]   4 [4]   9 [5]   0
Hits@level+ = [0+] 307 [1+]  65 [2+]  54 [3+]  13 [4+]   9 [5+]   0
Hits/KSLOC@level+ = [0+] 34.2138 [1+] 7.24395 [2+] 6.01805 [3+] 1.44879 [4+] 1.00301 [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.