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/allelecount-4.2.1/c/src/alleleCounter.c Examining data/allelecount-4.2.1/c/src/bam_access.c Examining data/allelecount-4.2.1/c/src/bam_access.h Examining data/allelecount-4.2.1/c/src/dbg.h Examining data/allelecount-4.2.1/c/src/khash.h Examining data/allelecount-4.2.1/c/tests/bam_access_tests.c Examining data/allelecount-4.2.1/c/tests/minunit.h FINAL RESULTS: data/allelecount-4.2.1/c/src/alleleCounter.c:276:10: [4] (buffer) sscanf: The scanf() family's %s operation, without a limit specification, permits buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a different input function. chk = sscanf(line,"%s%*[ \t]%d%*[ \t]%*s%*[ \t]%*s%*[ \t]%c%*[ \t]%c",stats->chr,&(stats->pos),&(stats->allele_A),&(stats->allele_B)); data/allelecount-4.2.1/c/src/alleleCounter.c:287:10: [4] (buffer) sscanf: The scanf() family's %s operation, without a limit specification, permits buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a different input function. chk = sscanf(line,"%s%*[ \t]%d",stats->chr,&(stats->pos)); data/allelecount-4.2.1/c/src/bam_access.c:330:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(region,"%s:%d-%d",this_chr,start,stop); data/allelecount-4.2.1/c/src/bam_access.c:421:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(region,"%s:%d-%d",chr,posn,posn); data/allelecount-4.2.1/c/src/alleleCounter.c:111:18: [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((iarg = getopt_long(argc, argv, "f:F:l:b:m:o:q:r:c:hdsvx", long_opts, &index)) != -1){ data/allelecount-4.2.1/c/src/alleleCounter.c:45: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). if((fp = fopen(fname,"r"))){ data/allelecount-4.2.1/c/src/alleleCounter.c:126:22: [2] (integer) atoi: 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). min_base_q = atoi(optarg); data/allelecount-4.2.1/c/src/alleleCounter.c:134:21: [2] (integer) atoi: 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). min_map_q = atoi(optarg); data/allelecount-4.2.1/c/src/alleleCounter.c:162:22: [2] (integer) atoi: 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). inc_flag = atoi(optarg); data/allelecount-4.2.1/c/src/alleleCounter.c:166:22: [2] (integer) atoi: 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). exc_flag = atoi(optarg); data/allelecount-4.2.1/c/src/alleleCounter.c:272:14: [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. int try = sprintf(stats->chr,"%d",chr_d); data/allelecount-4.2.1/c/src/alleleCounter.c:283:14: [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. int try = sprintf(stats->chr,"%d",chr_d); data/allelecount-4.2.1/c/src/alleleCounter.c:298: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). FILE *f = fopen(file_path,"r"); data/allelecount-4.2.1/c/src/alleleCounter.c:301: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 rd[ 5000 ]; data/allelecount-4.2.1/c/src/alleleCounter.c:348: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). loci_in = fopen(loci_file,"r"); data/allelecount-4.2.1/c/src/alleleCounter.c:351: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 line[2048]; data/allelecount-4.2.1/c/src/alleleCounter.c:397:17: [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). FILE *output = fopen(out_file,"w"); data/allelecount-4.2.1/c/tests/bam_access_tests.c:89: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). FILE *output = fopen("../testData/test10X.cnts","w"); data/allelecount-4.2.1/c/tests/bam_access_tests.c:104:17: [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). FILE *gold = fopen(test_10X_cnts,"r"); data/allelecount-4.2.1/c/tests/bam_access_tests.c:105:20: [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). FILE *cnts10X = fopen("../testData/test10X.cnts","r"); data/allelecount-4.2.1/c/src/bam_access.c:328:38: [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). region = malloc((sizeof(char *) * (strlen(this_chr)+1))+sizeof(":")+sizeof("-")+(sizeof(char)*((no_of_digits(start)+no_of_digits(stop))+1))); data/allelecount-4.2.1/c/src/bam_access.c:419:37: [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). region = malloc((sizeof(char *) * (strlen(chr)+1))+sizeof(":")+sizeof("-")+(sizeof(char)*((no_of_digits(posn)*2)+1))); data/allelecount-4.2.1/c/tests/bam_access_tests.c:111:12: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ch1 = getc(gold); data/allelecount-4.2.1/c/tests/bam_access_tests.c:112:12: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ch2 = getc(cnts10X); ANALYSIS SUMMARY: Hits = 24 Lines analyzed = 1889 in approximately 0.07 seconds (26121 lines/second) Physical Source Lines of Code (SLOC) = 1243 Hits@level = [0] 49 [1] 4 [2] 15 [3] 1 [4] 4 [5] 0 Hits@level+ = [0+] 73 [1+] 24 [2+] 20 [3+] 5 [4+] 4 [5+] 0 Hits/KSLOC@level+ = [0+] 58.7289 [1+] 19.3081 [2+] 16.0901 [3+] 4.02253 [4+] 3.21802 [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.