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/petris-1.0.1/game.h Examining data/petris-1.0.1/highscore.h Examining data/petris-1.0.1/main.h Examining data/petris-1.0.1/config.h Examining data/petris-1.0.1/highscore.c Examining data/petris-1.0.1/game.c Examining data/petris-1.0.1/main.c Examining data/petris-1.0.1/petris.h FINAL RESULTS: data/petris-1.0.1/game.c:382:12: [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 cur = random() % BLOCK_TYPES; data/petris-1.0.1/game.c:383: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 next = random() % BLOCK_TYPES; data/petris-1.0.1/game.c:410:11: [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. next = random() % BLOCK_TYPES; data/petris-1.0.1/highscore.c:87:9: [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. name = getenv("USER"); data/petris-1.0.1/highscore.c:113:9: [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. name = getenv("USER"); data/petris-1.0.1/main.c:321:2: [3] (random) srandom: 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. srandom(time( (time_t *) 0 )); data/petris-1.0.1/game.c:184: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(tmp_well + (start + BLOCK_DOTS) * WELL_WIDTH, data/petris-1.0.1/game.c:194:4: [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(tmp_well + (start + y + lines) * WELL_WIDTH, data/petris-1.0.1/game.c:204: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(tmp_well + (lines * WELL_WIDTH), well_data, WELL_WIDTH * start); data/petris-1.0.1/game.c:206: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(well_data, tmp_well, WELL_HEIGHT * WELL_WIDTH); data/petris-1.0.1/highscore.c:15: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. char name[11]; data/petris-1.0.1/highscore.c:28: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). if ((file = fopen(HIGHSCORE_FILE, "r")) == NULL) { data/petris-1.0.1/highscore.c:55: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). if ((file = fopen(HIGHSCORE_FILE, "w")) == NULL) { data/petris-1.0.1/game.c:167:3: [1] (obsolete) usleep: This C routine is considered obsolete (as opposed to the shell command by the same name). The interaction of this function with SIGALRM and other timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead. usleep(500000 / 6); data/petris-1.0.1/highscore.c:72:10: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(hs_list[i].name, hs_list[i-1].name, sizeof(hs_list[i].name)-1); data/petris-1.0.1/highscore.c:78:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(hs_list[index].name, name, sizeof(hs_list[index].name)-1); ANALYSIS SUMMARY: Hits = 16 Lines analyzed = 1037 in approximately 0.05 seconds (22995 lines/second) Physical Source Lines of Code (SLOC) = 735 Hits@level = [0] 7 [1] 3 [2] 7 [3] 6 [4] 0 [5] 0 Hits@level+ = [0+] 23 [1+] 16 [2+] 13 [3+] 6 [4+] 0 [5+] 0 Hits/KSLOC@level+ = [0+] 31.2925 [1+] 21.7687 [2+] 17.6871 [3+] 8.16327 [4+] 0 [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.