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/snp-sites-2.5.1/src/alignment-file.c Examining data/snp-sites-2.5.1/src/alignment-file.h Examining data/snp-sites-2.5.1/src/fasta-of-snp-sites.c Examining data/snp-sites-2.5.1/src/fasta-of-snp-sites.h Examining data/snp-sites-2.5.1/src/kseq.h Examining data/snp-sites-2.5.1/src/main.c Examining data/snp-sites-2.5.1/src/phylib-of-snp-sites.c Examining data/snp-sites-2.5.1/src/phylib-of-snp-sites.h Examining data/snp-sites-2.5.1/src/snp-sites.c Examining data/snp-sites-2.5.1/src/snp-sites.h Examining data/snp-sites-2.5.1/src/vcf.c Examining data/snp-sites-2.5.1/src/vcf.h Examining data/snp-sites-2.5.1/tests/check-snp-sites.c Examining data/snp-sites-2.5.1/tests/check-snp-sites.h Examining data/snp-sites-2.5.1/tests/check-vcf.c Examining data/snp-sites-2.5.1/tests/check-vcf.h Examining data/snp-sites-2.5.1/tests/helper-methods.c Examining data/snp-sites-2.5.1/tests/helper-methods.h Examining data/snp-sites-2.5.1/tests/run-all-tests.c FINAL RESULTS: data/snp-sites-2.5.1/src/alignment-file.c:173:4: [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). strcpy(sequence_names[number_of_samples], seq->name.s); data/snp-sites-2.5.1/src/main.c:119: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. if( access( argv[optind], F_OK ) == -1 ) { data/snp-sites-2.5.1/src/vcf.c:36:2: [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). strcpy(base_filename, filename); data/snp-sites-2.5.1/src/main.c:78: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 ((c = getopt (argc, argv, "mvrbpcCo:V")) != -1) data/snp-sites-2.5.1/src/fasta-of-snp-sites.c:33:23: [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). fasta_file_pointer = fopen(filename, "w"); data/snp-sites-2.5.1/src/kseq.h:125: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(str->s + str->l, ks->buf + ks->begin, i - ks->begin); \ data/snp-sites-2.5.1/src/main.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 multi_fasta_filename[FILENAME_MAX] = {""}; data/snp-sites-2.5.1/src/main.c:66: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 output_filename[FILENAME_MAX] = {"/dev/stdout"}; data/snp-sites-2.5.1/src/phylib-of-snp-sites.c:34:24: [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). phylip_file_pointer = fopen(filename, "w"); data/snp-sites-2.5.1/src/snp-sites.c:52: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 output_filename_base[FILENAME_MAX]; data/snp-sites-2.5.1/src/snp-sites.c:53: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 filename_without_directory[FILENAME_MAX]; data/snp-sites-2.5.1/src/snp-sites.c:64: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 vcf_output_filename[FILENAME_MAX]; data/snp-sites-2.5.1/src/snp-sites.c:68:4: [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. strcat(vcf_output_filename, ".vcf"); data/snp-sites-2.5.1/src/snp-sites.c:77: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 phylip_output_filename[FILENAME_MAX]; data/snp-sites-2.5.1/src/snp-sites.c:81:4: [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. strcat(phylip_output_filename, ".phylip"); data/snp-sites-2.5.1/src/snp-sites.c:88: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 multi_fasta_output_filename[FILENAME_MAX]; data/snp-sites-2.5.1/src/snp-sites.c:92:4: [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. strcat(multi_fasta_output_filename, ".snp_sites.aln"); data/snp-sites-2.5.1/src/snp-sites.c:145: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 cwd[100]; data/snp-sites-2.5.1/src/snp-sites.c:150:28: [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). output_file = (FILE *) fopen(output_filename, "w"); data/snp-sites-2.5.1/src/vcf.c:38:19: [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). vcf_file_pointer=fopen(base_filename, "w"); data/snp-sites-2.5.1/src/vcf.c:176:5: [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(result, "%i", index); data/snp-sites-2.5.1/tests/check-snp-sites.c:131: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 output_filename[100] = {"some_custom_name"}; data/snp-sites-2.5.1/tests/check-snp-sites.c:255: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 output_filename[30]; data/snp-sites-2.5.1/tests/check-snp-sites.c:265: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 output_filename[30]; data/snp-sites-2.5.1/tests/helper-methods.c:42:24: [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). expected_output_fh = fopen(expected_output_filename, "r"); data/snp-sites-2.5.1/tests/helper-methods.c:43:22: [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). actual_output_fh = fopen(actual_output_filename, "r"); data/snp-sites-2.5.1/src/main.c:106:11: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(output_filename, optarg, FILENAME_MAX); data/snp-sites-2.5.1/src/main.c:125:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(multi_fasta_filename, argv[optind], FILENAME_MAX); data/snp-sites-2.5.1/src/snp-sites.c:55:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(output_filename_base, filename_without_directory, FILENAME_MAX); data/snp-sites-2.5.1/src/snp-sites.c:59:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(output_filename_base, output_filename, FILENAME_MAX); data/snp-sites-2.5.1/src/snp-sites.c:65:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(vcf_output_filename, output_filename_base, FILENAME_MAX); data/snp-sites-2.5.1/src/snp-sites.c:78:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(phylip_output_filename, output_filename_base, FILENAME_MAX); data/snp-sites-2.5.1/src/snp-sites.c:89:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(multi_fasta_output_filename, output_filename_base, FILENAME_MAX); data/snp-sites-2.5.1/src/vcf.c:155:28: [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 length_of_alt_bases = strlen(alt_bases); data/snp-sites-2.5.1/src/vcf.c:167:3: [1] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source is a constant character. sprintf(result, "0"); data/snp-sites-2.5.1/src/vcf.c:171:3: [1] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source is a constant character. sprintf(result, "."); data/snp-sites-2.5.1/src/vcf.c:186:28: [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 number_of_alt_bases = strlen(alt_bases); ANALYSIS SUMMARY: Hits = 37 Lines analyzed = 2000 in approximately 0.09 seconds (22607 lines/second) Physical Source Lines of Code (SLOC) = 1349 Hits@level = [0] 58 [1] 11 [2] 22 [3] 1 [4] 3 [5] 0 Hits@level+ = [0+] 95 [1+] 37 [2+] 26 [3+] 4 [4+] 3 [5+] 0 Hits/KSLOC@level+ = [0+] 70.4225 [1+] 27.4277 [2+] 19.2735 [3+] 2.96516 [4+] 2.22387 [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.