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/fortunes-bofh-excuses-1.2/src/l2f.cc Examining data/fortunes-bofh-excuses-1.2/src/strfile.h Examining data/fortunes-bofh-excuses-1.2/src/strfile.c FINAL RESULTS: data/fortunes-bofh-excuses-1.2/src/strfile.c:333:11: [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). (void) strcpy(Outfile, *argv); data/fortunes-bofh-excuses-1.2/src/strfile.c:340:10: [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). (void) strcpy(Outfile, Infile); data/fortunes-bofh-excuses-1.2/src/strfile.c:367:2: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. fprintf(stderr, fmt, file); data/fortunes-bofh-excuses-1.2/src/strfile.c:300:15: [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 ((ch = getopt(argc, argv, "c:iorsx")) != -1) data/fortunes-bofh-excuses-1.2/src/strfile.c:479: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((int)(time((time_t *) NULL) + getpid())); data/fortunes-bofh-excuses-1.2/src/strfile.c:489: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. i = random() % cnt; data/fortunes-bofh-excuses-1.2/src/l2f.cc:10: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 buf[257]; data/fortunes-bofh-excuses-1.2/src/l2f.cc:12:3: [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). r=fopen("excuses","r"); data/fortunes-bofh-excuses-1.2/src/l2f.cc:13:3: [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). w=fopen("bofh-excuses","w"); data/fortunes-bofh-excuses-1.2/src/strfile.c:76:18: [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[4]; data/fortunes-bofh-excuses-1.2/src/strfile.c:83: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. memcpy(&rv, c, sizeof rv); data/fortunes-bofh-excuses-1.2/src/strfile.c:188:9: [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 string[257]; data/fortunes-bofh-excuses-1.2/src/strfile.c:196:13: [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 ((inf = fopen(Infile, "r")) == NULL) data/fortunes-bofh-excuses-1.2/src/strfile.c:199: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 ((outf = fopen(Outfile, "w")) == NULL) data/fortunes-bofh-excuses-1.2/src/strfile.c:341:10: [2] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). Risk is low because the source is a constant string. (void) strcat(Outfile, ".dat"); data/fortunes-bofh-excuses-1.2/src/strfile.c:403:11: [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). Sort_1 = fopen(Infile, "r"); data/fortunes-bofh-excuses-1.2/src/strfile.c:404:11: [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). Sort_2 = fopen(Infile, "r"); data/fortunes-bofh-excuses-1.2/src/strfile.c:507: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[8]; data/fortunes-bofh-excuses-1.2/src/strfile.h:56: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 stuff[4]; /* long aligned space */ data/fortunes-bofh-excuses-1.2/src/strfile.c:219:36: [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). length = pos - last_off - (sp ? strlen(sp) : 0); data/fortunes-bofh-excuses-1.2/src/strfile.c:440:23: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while (!isalnum(c1 = getc(Sort_1)) && c1 != '\0') data/fortunes-bofh-excuses-1.2/src/strfile.c:442:23: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while (!isalnum(c2 = getc(Sort_2)) && c2 != '\0') data/fortunes-bofh-excuses-1.2/src/strfile.c:456:8: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). c1 = getc(Sort_1); data/fortunes-bofh-excuses-1.2/src/strfile.c:457:8: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). c2 = getc(Sort_2); ANALYSIS SUMMARY: Hits = 24 Lines analyzed = 593 in approximately 0.04 seconds (16488 lines/second) Physical Source Lines of Code (SLOC) = 387 Hits@level = [0] 10 [1] 5 [2] 13 [3] 3 [4] 3 [5] 0 Hits@level+ = [0+] 34 [1+] 24 [2+] 19 [3+] 6 [4+] 3 [5+] 0 Hits/KSLOC@level+ = [0+] 87.8553 [1+] 62.0155 [2+] 49.0956 [3+] 15.5039 [4+] 7.75194 [5+] 0 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.