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/detox-1.3.0/src/clean_string.c Examining data/detox-1.3.0/src/clean_string.h Examining data/detox-1.3.0/src/config_file.h Examining data/detox-1.3.0/src/config_file_dump.c Examining data/detox-1.3.0/src/config_file_dump.h Examining data/detox-1.3.0/src/config_file_lex.c Examining data/detox-1.3.0/src/config_file_spoof.c Examining data/detox-1.3.0/src/config_file_spoof.h Examining data/detox-1.3.0/src/config_file_yacc.c Examining data/detox-1.3.0/src/config_file_yacc.h Examining data/detox-1.3.0/src/detox.c Examining data/detox-1.3.0/src/detox.h Examining data/detox-1.3.0/src/file.c Examining data/detox-1.3.0/src/file.h Examining data/detox-1.3.0/src/iso8859_1.h Examining data/detox-1.3.0/src/parse_options.c Examining data/detox-1.3.0/src/parse_options.h Examining data/detox-1.3.0/src/parse_table.c Examining data/detox-1.3.0/src/parse_table.h Examining data/detox-1.3.0/src/table.c Examining data/detox-1.3.0/src/table.h Examining data/detox-1.3.0/src/unicode.h FINAL RESULTS: data/detox-1.3.0/src/file.c:321:9: [5] (race) readlink: This accepts filename arguments; if an attacker can move those files or change the link content, a race condition results. Also, it does not terminate with ASCII NUL. (CWE-362, CWE-20). Reconsider approach. err = readlink(new_file, work, 1023); data/detox-1.3.0/src/config_file_yacc.c:722:21: [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. # define YYFPRINTF fprintf data/detox-1.3.0/src/file.c:136: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(new_filename + len, work); data/detox-1.3.0/src/file.c:213: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(new_file, indir); data/detox-1.3.0/src/parse_table.c:130: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. ret = sscanf(work, " %s %n", parsed, &offset); data/detox-1.3.0/src/parse_table.c:150:6: [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. sscanf(work + offset, "%s", parsed); data/detox-1.3.0/src/parse_table.c:175:6: [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. sscanf(work + offset, "%s", parsed); data/detox-1.3.0/src/parse_table.c:203: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. ret = sscanf(work, " %s %n", parsed, &offset); data/detox-1.3.0/src/parse_table.c:223:4: [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. sscanf(work + offset, "%s", parsed); data/detox-1.3.0/src/detox.c:110:15: [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. file_work = getenv("HOME"); data/detox-1.3.0/src/parse_options.c:163:32: [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. main_options->sequence_name = getenv("DETOX_SEQUENCE"); data/detox-1.3.0/src/parse_options.c:188:20: [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 ((optcode = getopt_long(argc, argv, "hrvV?Ls:f:n", longopts, NULL)) != -1) { data/detox-1.3.0/src/parse_options.c:190:20: [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 ((optcode = getopt(argc, argv, "hrvV?Ls:f:n")) != -1) { data/detox-1.3.0/src/clean_string.c:328: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 conv[3]; data/detox-1.3.0/src/config_file_lex.c:970: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). yylval.nvalue = atoi(yytext); data/detox-1.3.0/src/config_file_yacc.c:968: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 const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; data/detox-1.3.0/src/config_file_yacc.c:1155: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 yymsgbuf[128]; data/detox-1.3.0/src/config_file_yacc.c:1786:9: [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). yyin = fopen(filename, "r"); data/detox-1.3.0/src/config_file_yacc.c:1790:10: [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). yyout = fopen("/dev/null", "w"); data/detox-1.3.0/src/file.c:47:8: [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 badfiles[3][30] = { data/detox-1.3.0/src/file.c:81: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(old_filename, filename, len); data/detox-1.3.0/src/file.c:384: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 (!(fp = fopen(filename, "r"))) { data/detox-1.3.0/src/iso8859_1.h:40: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 iso8859_1_trans[ISO8859_1_COUNT][ISO8859_1_MAXLEN] = { data/detox-1.3.0/src/parse_table.c:97:16: [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). ttable_file = fopen(filename, "r"); data/detox-1.3.0/src/unicode.h:38: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 unicode_trans[UNICODE_COUNT][UNICODE_MAXLEN] = { data/detox-1.3.0/src/clean_string.c:65:19: [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). output = malloc((strlen(s) * ISO8859_1_MAXLEN) + 1); data/detox-1.3.0/src/clean_string.c:116:19: [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). output = malloc((strlen(s) * table->max_data_length) + 1); data/detox-1.3.0/src/clean_string.c:184:19: [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). output = malloc((strlen(s) * 5) + 1); data/detox-1.3.0/src/clean_string.c:281:19: [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). output = malloc((strlen(s) * table->max_data_length) + 1); data/detox-1.3.0/src/clean_string.c:334:18: [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). output = malloc(strlen(s) + 1); data/detox-1.3.0/src/clean_string.c:393:18: [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). output = malloc(strlen(s) + 1); data/detox-1.3.0/src/clean_string.c:470:19: [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). output = malloc((strlen(s) * UNICODE_MAXLEN) + 1); data/detox-1.3.0/src/clean_string.c:592:19: [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). output = malloc((strlen(s) * table->max_data_length) + 1); data/detox-1.3.0/src/clean_string.c:727:13: [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). s_length = strlen(s); data/detox-1.3.0/src/clean_string.c:747:15: [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). ext_length = strlen(input_walk); data/detox-1.3.0/src/clean_string.c:773:18: [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). output = malloc(strlen(s) + 1); data/detox-1.3.0/src/config_file_lex.c:690:14: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ data/detox-1.3.0/src/config_file_lex.c:1738:29: [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). return yy_scan_bytes(yystr,strlen(yystr) ); data/detox-1.3.0/src/config_file_yacc.c:868:21: [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). # define yystrlen strlen data/detox-1.3.0/src/file.c:75:8: [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). len = strlen(filename) + 1; data/detox-1.3.0/src/file.c:127:30: [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). new_filename = malloc(len + strlen(work) + 1); data/detox-1.3.0/src/file.c:135:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(new_filename, old_filename, len); data/detox-1.3.0/src/file.c:202:20: [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). new_file_length = strlen(indir) + 1024; data/detox-1.3.0/src/parse_table.c:153:43: [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). if (strncasecmp(parsed, system_ctype, strlen(parsed)) == 0) { data/detox-1.3.0/src/parse_table.c:180: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). if (strlen(parsed) > max_data_length) { data/detox-1.3.0/src/parse_table.c:181:24: [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). max_data_length = strlen(parsed); data/detox-1.3.0/src/parse_table.c:228:7: [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). if (strlen(parsed) > max_data_length) { data/detox-1.3.0/src/parse_table.c:229:22: [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). max_data_length = strlen(parsed); ANALYSIS SUMMARY: Hits = 48 Lines analyzed = 7650 in approximately 0.21 seconds (36083 lines/second) Physical Source Lines of Code (SLOC) = 4803 Hits@level = [0] 101 [1] 23 [2] 12 [3] 4 [4] 8 [5] 1 Hits@level+ = [0+] 149 [1+] 48 [2+] 25 [3+] 13 [4+] 9 [5+] 1 Hits/KSLOC@level+ = [0+] 31.0223 [1+] 9.99375 [2+] 5.20508 [3+] 2.70664 [4+] 1.87383 [5+] 0.208203 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.