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/fsverity-utils-1.2/common/common_defs.h Examining data/fsverity-utils-1.2/common/fsverity_uapi.h Examining data/fsverity-utils-1.2/common/libfsverity.h Examining data/fsverity-utils-1.2/lib/compute_digest.c Examining data/fsverity-utils-1.2/lib/hash_algs.c Examining data/fsverity-utils-1.2/lib/lib_private.h Examining data/fsverity-utils-1.2/lib/sign_digest.c Examining data/fsverity-utils-1.2/lib/utils.c Examining data/fsverity-utils-1.2/programs/cmd_enable.c Examining data/fsverity-utils-1.2/programs/cmd_measure.c Examining data/fsverity-utils-1.2/programs/cmd_sign.c Examining data/fsverity-utils-1.2/programs/fsverity.c Examining data/fsverity-utils-1.2/programs/fsverity.h Examining data/fsverity-utils-1.2/programs/test_compute_digest.c Examining data/fsverity-utils-1.2/programs/test_hash_algs.c Examining data/fsverity-utils-1.2/programs/test_sign_digest.c Examining data/fsverity-utils-1.2/programs/utils.c Examining data/fsverity-utils-1.2/programs/utils.h FINAL RESULTS: data/fsverity-utils-1.2/common/common_defs.h:33:24: [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, fmt_idx, vargs_idx))) data/fsverity-utils-1.2/programs/utils.c:52:2: [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, format, va); data/fsverity-utils-1.2/programs/cmd_enable.c:78: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, "", longopts, NULL)) != -1) { data/fsverity-utils-1.2/programs/cmd_sign.c:69: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, "", longopts, NULL)) != -1) { data/fsverity-utils-1.2/lib/compute_digest.c:95: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(padded_salt, salt, salt_size); data/fsverity-utils-1.2/lib/compute_digest.c:227: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(desc.salt, params->salt, params->salt_size); data/fsverity-utils-1.2/lib/sign_digest.c:29: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 magic[8]; /* must be "FSVerity" */ data/fsverity-utils-1.2/lib/sign_digest.c:391: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(d->magic, "FSVerity", 8); data/fsverity-utils-1.2/lib/sign_digest.c:394: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(d->digest, digest->digest, digest->digest_size); data/fsverity-utils-1.2/lib/utils.c:45:9: [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(p, mem, size); data/fsverity-utils-1.2/lib/utils.c: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 errbuf[64]; data/fsverity-utils-1.2/programs/cmd_measure.c:23: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 digest_hex[FS_VERITY_MAX_DIGEST_SIZE * 2 + 1]; data/fsverity-utils-1.2/programs/cmd_measure.c:24: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 _hash_alg_name[32]; data/fsverity-utils-1.2/programs/cmd_measure.c:51:4: [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(_hash_alg_name, "ALG_%u", d->digest_algorithm); data/fsverity-utils-1.2/programs/cmd_sign.c:63: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 digest_hex[FS_VERITY_MAX_DIGEST_SIZE * 2 + 1]; data/fsverity-utils-1.2/programs/test_compute_digest.c:28: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(buf, &f->data[f->offset], count); data/fsverity-utils-1.2/programs/test_compute_digest.c:148: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 alg_name[32] = {}; data/fsverity-utils-1.2/programs/test_sign_digest.c:36: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(d->digest, data/fsverity-utils-1.2/programs/utils.c:39:9: [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(xmalloc(size), mem, size); data/fsverity-utils-1.2/programs/utils.c:105:13: [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). file->fd = open(filename, flags, mode); data/fsverity-utils-1.2/programs/fsverity.c:177:19: [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). *salt_size_ptr = strlen(arg) / 2; data/fsverity-utils-1.2/programs/test_compute_digest.c:151:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(alg_name, libfsverity_get_hash_name(t->hash_algorithm), data/fsverity-utils-1.2/programs/test_compute_digest.c:277:23: [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). params.salt_size = strlen(test_cases[i].salt); data/fsverity-utils-1.2/programs/utils.c:44:20: [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). return xmemdup(s, strlen(s) + 1); data/fsverity-utils-1.2/programs/utils.c:132:11: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int n = read(file->fd, buf, min(count, INT_MAX)); data/fsverity-utils-1.2/programs/utils.c:195:6: [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(hex) != 2 * bin_len) ANALYSIS SUMMARY: Hits = 26 Lines analyzed = 2691 in approximately 0.12 seconds (22121 lines/second) Physical Source Lines of Code (SLOC) = 1958 Hits@level = [0] 22 [1] 6 [2] 16 [3] 2 [4] 2 [5] 0 Hits@level+ = [0+] 48 [1+] 26 [2+] 20 [3+] 4 [4+] 2 [5+] 0 Hits/KSLOC@level+ = [0+] 24.5148 [1+] 13.2789 [2+] 10.2145 [3+] 2.0429 [4+] 1.02145 [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.