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/bcache-tools-1.0.8/bcache-register.c Examining data/bcache-tools-1.0.8/bcache-super-show.c Examining data/bcache-tools-1.0.8/bcache-test.c Examining data/bcache-tools-1.0.8/bcache.h Examining data/bcache-tools-1.0.8/make-bcache.c Examining data/bcache-tools-1.0.8/probe-bcache.c Examining data/bcache-tools-1.0.8/bcache.c FINAL RESULTS: data/bcache-tools-1.0.8/bcache-super-show.c:107:2: [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. printf("sb.first_sector\t\t%" PRIu64, sb.offset); data/bcache-tools-1.0.8/bcache-super-show.c:116:2: [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. printf("sb.csum\t\t\t%" PRIX64, sb.csum); data/bcache-tools-1.0.8/bcache-super-show.c:128:2: [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. printf("sb.version\t\t%" PRIu64, sb.version); data/bcache-tools-1.0.8/bcache-super-show.c:68:14: [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 ((o = getopt(argc, argv, "f")) != EOF) data/bcache-tools-1.0.8/bcache-test.c:73:7: [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. x = random() / (double) (RAND_MAX / 2) - 1; data/bcache-tools-1.0.8/bcache-test.c:74:7: [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. y = random() / (double) (RAND_MAX / 2) - 1; data/bcache-tools-1.0.8/bcache-test.c:120:33: [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. sprintf(logbuf, "log.%i", abs(random()) % 1000); data/bcache-tools-1.0.8/bcache-test.c:170:14: [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 ((o = getopt(argc, argv, "dnwvscwlb:")) != EOF) data/bcache-tools-1.0.8/bcache-test.c:245:23: [3] (random) drand48: 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. nbytes = randsize ? drand48() * 16 + 1 : 1; data/bcache-tools-1.0.8/bcache-test.c:249:36: [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. offset += walk ? normal() * 20 : random(); data/bcache-tools-1.0.8/make-bcache.c:370: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, data/bcache-tools-1.0.8/probe-bcache.c:36:14: [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 ((o = getopt(argc, argv, "o:")) != EOF) data/bcache-tools-1.0.8/bcache-register.c:21:10: [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("/sys/fs/bcache/register", O_WRONLY); data/bcache-tools-1.0.8/bcache-super-show.c: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 uuid[40]; data/bcache-tools-1.0.8/bcache-super-show.c:87: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(argv[0], O_RDONLY); data/bcache-tools-1.0.8/bcache-super-show.c:150: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 label[SB_LABEL_SIZE + 1]; data/bcache-tools-1.0.8/bcache-test.c:35:10: [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 zero[4096]; data/bcache-tools-1.0.8/bcache-test.c:102: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 csum[16]; data/bcache-tools-1.0.8/bcache-test.c:103: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 oldcsum[16]; data/bcache-tools-1.0.8/bcache-test.c:110: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 logbuf[1 << 21]; data/bcache-tools-1.0.8/bcache-test.c:120:3: [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(logbuf, "log.%i", abs(random()) % 1000); data/bcache-tools-1.0.8/bcache-test.c:121: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(logbuf, O_WRONLY|O_CREAT|O_TRUNC, 0644); data/bcache-tools-1.0.8/bcache-test.c:163: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 c[16]; data/bcache-tools-1.0.8/bcache-test.c:197:16: [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). benchmark = atol(optarg); data/bcache-tools-1.0.8/bcache-test.c:219: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). fd1 = open(argv[0], (wtest ? O_RDWR : O_RDONLY)|direct); data/bcache-tools-1.0.8/bcache-test.c:221: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). fd2 = open(argv[1], (wtest ? O_RDWR : O_RDONLY)|direct); data/bcache-tools-1.0.8/bcache-test.c:284:6: [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(&p->oldcsum[0], &p->csum[0], 16); data/bcache-tools-1.0.8/bcache-test.c:285:6: [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(&p->csum[0], c, 16); data/bcache-tools-1.0.8/make-bcache.c:177: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 uuid_str[40], set_uuid_str[40], zeroes[SB_START] = {0}; data/bcache-tools-1.0.8/make-bcache.c:181:12: [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). if ((fd = open(dev, O_RDWR|O_EXCL)) == -1) { data/bcache-tools-1.0.8/make-bcache.c:216: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(sb.magic, bcache_magic, 16); data/bcache-tools-1.0.8/make-bcache.c:318:12: [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_RDONLY); data/bcache-tools-1.0.8/make-bcache.c:342: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 *cache_devices[argc]; data/bcache-tools-1.0.8/make-bcache.c:343: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 *backing_devices[argc]; data/bcache-tools-1.0.8/probe-bcache.c:33: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 uuid[40]; data/bcache-tools-1.0.8/probe-bcache.c:52:12: [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(argv[i], O_RDONLY); data/bcache-tools-1.0.8/bcache-super-show.c:151:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(label, (char*)sb.label, SB_LABEL_SIZE); data/bcache-tools-1.0.8/make-bcache.c:112: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). size = strlen(s); ANALYSIS SUMMARY: Hits = 38 Lines analyzed = 1417 in approximately 0.05 seconds (29164 lines/second) Physical Source Lines of Code (SLOC) = 1127 Hits@level = [0] 70 [1] 2 [2] 24 [3] 9 [4] 3 [5] 0 Hits@level+ = [0+] 108 [1+] 38 [2+] 36 [3+] 12 [4+] 3 [5+] 0 Hits/KSLOC@level+ = [0+] 95.8296 [1+] 33.7178 [2+] 31.9432 [3+] 10.6477 [4+] 2.66193 [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.