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/fdupes-2.1.1/commandidentifier.c Examining data/fdupes-2.1.1/commandidentifier.h Examining data/fdupes-2.1.1/dir.c Examining data/fdupes-2.1.1/dir.h Examining data/fdupes-2.1.1/errormsg.c Examining data/fdupes-2.1.1/errormsg.h Examining data/fdupes-2.1.1/fdupes.c Examining data/fdupes-2.1.1/fdupes.h Examining data/fdupes-2.1.1/filegroup.h Examining data/fdupes-2.1.1/flags.c Examining data/fdupes-2.1.1/flags.h Examining data/fdupes-2.1.1/fmatch.c Examining data/fdupes-2.1.1/fmatch.h Examining data/fdupes-2.1.1/log.c Examining data/fdupes-2.1.1/log.h Examining data/fdupes-2.1.1/mbstowcs_escape_invalid.c Examining data/fdupes-2.1.1/mbstowcs_escape_invalid.h Examining data/fdupes-2.1.1/md5/md5.c Examining data/fdupes-2.1.1/md5/md5.h Examining data/fdupes-2.1.1/ncurses-commands.c Examining data/fdupes-2.1.1/ncurses-commands.h Examining data/fdupes-2.1.1/ncurses-getcommand.c Examining data/fdupes-2.1.1/ncurses-getcommand.h Examining data/fdupes-2.1.1/ncurses-interface.c Examining data/fdupes-2.1.1/ncurses-interface.h Examining data/fdupes-2.1.1/ncurses-print.c Examining data/fdupes-2.1.1/ncurses-print.h Examining data/fdupes-2.1.1/ncurses-prompt.c Examining data/fdupes-2.1.1/ncurses-prompt.h Examining data/fdupes-2.1.1/ncurses-status.c Examining data/fdupes-2.1.1/ncurses-status.h Examining data/fdupes-2.1.1/positive_wcwidth.c Examining data/fdupes-2.1.1/positive_wcwidth.h Examining data/fdupes-2.1.1/sigint.c Examining data/fdupes-2.1.1/sigint.h Examining data/fdupes-2.1.1/wcs.c Examining data/fdupes-2.1.1/wcs.h FINAL RESULTS: data/fdupes-2.1.1/errormsg.c:33:3: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(stderr, message, ap); data/fdupes-2.1.1/fdupes.c:125:5: [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(*filename_ptr, tmp); data/fdupes-2.1.1/fdupes.c:172:5: [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(args[x], argv[x]); data/fdupes-2.1.1/fdupes.c:269:7: [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(newfile->d_name, dir); data/fdupes-2.1.1/fdupes.c:273:7: [4] (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). strcat(newfile->d_name, dirinfo->d_name); data/fdupes-2.1.1/fdupes.c:512:3: [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(filename_a, file_a->d_name); data/fdupes-2.1.1/fdupes.c:513:3: [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(filename_b, file_b->d_name); data/fdupes-2.1.1/mbstowcs_escape_invalid.c:32:5: [4] (format) swprintf: Potential format string problem (CWE-134). Make format string constant. swprintf(dest, 5, L"\\%03o", (unsigned char) c); data/fdupes-2.1.1/ncurses-interface.c:325:3: [4] (buffer) wcscpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using a function version that stops copying at the end of the buffer. wcscpy(commandbuffer, commandbuffer_in); data/fdupes-2.1.1/ncurses-interface.c:876:19: [4] (shell) system: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. if (system(HELP_COMMAND_STRING) == -1) data/fdupes-2.1.1/ncurses-print.c:137:10: [4] (format) vfwprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. size = vfwprintf(fp, format, args); data/fdupes-2.1.1/ncurses-prompt.c:83:3: [4] (format) vswprintf: Potential format string problem (CWE-134). Make format string constant. vswprintf(prompt->text, prompt->allocated, format, ap); data/fdupes-2.1.1/ncurses-status.c:104:3: [4] (format) vswprintf: Potential format string problem (CWE-134). Make format string constant. vswprintf(status->left, status->width + 1, format, ap); data/fdupes-2.1.1/ncurses-status.c:123:3: [4] (format) vswprintf: Potential format string problem (CWE-134). Make format string constant. vswprintf(status->right, status->width + 1, format, ap); data/fdupes-2.1.1/fdupes.c:1277:16: [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. #define GETOPT getopt_long data/fdupes-2.1.1/fdupes.c:1279:16: [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. #define GETOPT getopt data/fdupes-2.1.1/fdupes.c:1514:21: [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. if (newterm(getenv("TERM"), stdout, stdin) != 0) data/fdupes-2.1.1/fdupes.c:146: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. static char buf[64]; data/fdupes-2.1.1/fdupes.c:354: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). file = fopen(filename, "rb"); data/fdupes-2.1.1/fdupes.c:690:12: [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 c1[CHUNK_SIZE]; data/fdupes-2.1.1/fdupes.c:691:12: [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 c2[CHUNK_SIZE]; data/fdupes-2.1.1/fdupes.c:714:11: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). file_t *tmpfile; data/fdupes-2.1.1/fdupes.c:723:14: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). while (tmpfile != NULL) data/fdupes-2.1.1/fdupes.c:750:11: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). file_t *tmpfile; data/fdupes-2.1.1/fdupes.c:763:14: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). while (tmpfile != NULL) { data/fdupes-2.1.1/fdupes.c:840:11: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). file_t *tmpfile; data/fdupes-2.1.1/fdupes.c:863:14: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). while (tmpfile) { data/fdupes-2.1.1/fdupes.c:907:14: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). while (tmpfile) { data/fdupes-2.1.1/fdupes.c:908:24: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). dupelist[++counter] = tmpfile; data/fdupes-2.1.1/fdupes.c:1462:15: [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). file1 = fopen(curfile->d_name, "rb"); data/fdupes-2.1.1/fdupes.c:1468:15: [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). file2 = fopen((*match)->d_name, "rb"); data/fdupes-2.1.1/log.c:45: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). info->file = fopen(filename, "a+"); data/fdupes-2.1.1/md5/md5.c:71: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. static const char *const test[7] = { data/fdupes-2.1.1/md5/md5.c:222: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(xbuf, data, 64); data/fdupes-2.1.1/md5/md5.c:373: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(pms->buf + offset, p, copy); data/fdupes-2.1.1/md5/md5.c:387: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(pms->buf, p, left); data/fdupes-2.1.1/ncurses-print.c:133:8: [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). fp = fopen("/dev/null", "w"); data/fdupes-2.1.1/fdupes.c:106: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). tmp = (char*) malloc(strlen(filename) * 2 + 1); data/fdupes-2.1.1/fdupes.c:112:27: [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). for (x = 0, tx = 0; x < strlen(filename); x++) { data/fdupes-2.1.1/fdupes.c:120:44: [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). *filename_ptr = realloc(*filename_ptr, strlen(tmp) + 1); data/fdupes-2.1.1/fdupes.c:165: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). args[x] = (char*) malloc(strlen(argv[x]) + 1); data/fdupes-2.1.1/fdupes.c:260:39: [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). newfile->d_name = (char*)malloc(strlen(dir)+strlen(dirinfo->d_name)+2); data/fdupes-2.1.1/fdupes.c:260:51: [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). newfile->d_name = (char*)malloc(strlen(dir)+strlen(dirinfo->d_name)+2); data/fdupes-2.1.1/fdupes.c:270: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). lastchar = strlen(dir) - 1; data/fdupes-2.1.1/fdupes.c:272:2: [1] (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 character. strcat(newfile->d_name, "/"); data/fdupes-2.1.1/fdupes.c:498:35: [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). memmove(filename_a, basename_a, strlen(basename_a) + 1); data/fdupes-2.1.1/fdupes.c:501:35: [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). memmove(filename_b, basename_b, strlen(basename_b) + 1); data/fdupes-2.1.1/fdupes.c:957:6: [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). i = strlen(preservestr) - 1; data/fdupes-2.1.1/fdupes.c:961:27: [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). realloc(preservestr, strlen(preservestr) + 1 + INPUT_SIZE); data/fdupes-2.1.1/fdupes.c:974: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). i = strlen(preservestr)-1; data/fdupes-2.1.1/fmatch.c:33: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). len = strlen(matchstring); data/fdupes-2.1.1/fmatch.c:36:9: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). c = fgetc(file); data/fdupes-2.1.1/log.c:34:10: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). size_t read; data/fdupes-2.1.1/log.c:55:46: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). fmatch(info->file, LOG_HEADER, &is_match, &read); data/fdupes-2.1.1/log.c:56:20: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (!is_match && read > 0) data/fdupes-2.1.1/log.c:65:18: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). info->append = read > 0; data/fdupes-2.1.1/md5/md5.c:89:50: [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). md5_append(&state, (const md5_byte_t *)test[i], strlen(test[i])); data/fdupes-2.1.1/ncurses-getcommand.c:37:7: [1] (buffer) wcslen: 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). l = wcslen(input); data/fdupes-2.1.1/ncurses-getcommand.c:82:47: [1] (buffer) wcslen: 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). prompt->cursor = wcswidth(*commandbuffer, wcslen(*commandbuffer)); data/fdupes-2.1.1/ncurses-getcommand.c:84:25: [1] (buffer) wcslen: 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). wmove(promptwin, 0, wcslen(prompt->text) + prompt->cursor - prompt->offset); data/fdupes-2.1.1/ncurses-getcommand.c:136:20: [1] (buffer) wcslen: 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 = wcslen(*commandbuffer); data/fdupes-2.1.1/ncurses-getcommand.c:170:20: [1] (buffer) wcslen: 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 = wcslen(*commandbuffer); data/fdupes-2.1.1/ncurses-getcommand.c:191:20: [1] (buffer) wcslen: 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 = wcslen(*commandbuffer); data/fdupes-2.1.1/ncurses-getcommand.c:200:20: [1] (buffer) wcslen: 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 = wcslen(*commandbuffer); data/fdupes-2.1.1/ncurses-getcommand.c:209:20: [1] (buffer) wcslen: 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 = wcslen(*commandbuffer); data/fdupes-2.1.1/ncurses-getcommand.c:237:25: [1] (buffer) wcslen: 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). wmove(promptwin, 0, wcslen(prompt->text) + prompt->cursor - prompt->offset); data/fdupes-2.1.1/ncurses-interface.c:76:10: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). size_t read; data/fdupes-2.1.1/ncurses-interface.c:321:45: [1] (buffer) wcslen: 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). commandbuffer = malloc(sizeof(wchar_t) * (wcslen(commandbuffer_in)+1)); data/fdupes-2.1.1/ncurses-prompt.c:85:10: [1] (buffer) wcslen: 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). size = wcslen(prompt->text); data/fdupes-2.1.1/ncurses-prompt.c:104:30: [1] (buffer) wcslen: 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). const size_t cursor_stop = wcslen(prompt->text); data/fdupes-2.1.1/ncurses-prompt.c:110:41: [1] (buffer) wcslen: 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 (prompt->cursor + cursor_delta > wcslen(commandbuffer)) data/fdupes-2.1.1/ncurses-prompt.c:111:21: [1] (buffer) wcslen: 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). cursor_delta = wcslen(commandbuffer) - prompt->cursor; data/fdupes-2.1.1/ncurses-prompt.c:131:18: [1] (buffer) wcslen: 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). prompt->text[wcslen(prompt->text) - 2] = '='; data/fdupes-2.1.1/ncurses-prompt.c:133:18: [1] (buffer) wcslen: 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). prompt->text[wcslen(prompt->text) - 2] = ':'; data/fdupes-2.1.1/ncurses-prompt.c:137:25: [1] (buffer) wcslen: 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 (prompt->offset <= wcslen(prompt->text)) data/fdupes-2.1.1/ncurses-prompt.c:145:29: [1] (buffer) wcslen: 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). else if (prompt->offset < wcslen(prompt->text) + wcslen(commandbuffer)) data/fdupes-2.1.1/ncurses-prompt.c:145:52: [1] (buffer) wcslen: 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). else if (prompt->offset < wcslen(prompt->text) + wcslen(commandbuffer)) data/fdupes-2.1.1/ncurses-prompt.c:147:58: [1] (buffer) wcslen: 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). waddwstr(promptwin, commandbuffer + prompt->offset - wcslen(prompt->text)); data/fdupes-2.1.1/ncurses-status.c:140:7: [1] (buffer) wcslen: 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). l = wcslen(status->left); data/fdupes-2.1.1/ncurses-status.c:146:7: [1] (buffer) wcslen: 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). l = wcslen(status->right); data/fdupes-2.1.1/ncurses-status.c:152:38: [1] (buffer) wcslen: 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). mvwaddnwstr(statuswin, 0, 0, text, wcslen(text)); data/fdupes-2.1.1/wcs.c:85:34: [1] (buffer) wcslen: 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 (wcsncmp(haystackw, needle, wcslen(needle)) == 0) ANALYSIS SUMMARY: Hits = 82 Lines analyzed = 6575 in approximately 0.22 seconds (29883 lines/second) Physical Source Lines of Code (SLOC) = 4520 Hits@level = [0] 97 [1] 45 [2] 20 [3] 3 [4] 14 [5] 0 Hits@level+ = [0+] 179 [1+] 82 [2+] 37 [3+] 17 [4+] 14 [5+] 0 Hits/KSLOC@level+ = [0+] 39.6018 [1+] 18.1416 [2+] 8.18584 [3+] 3.76106 [4+] 3.09735 [5+] 0 Symlinks skipped = 1 (--allowlink overrides but see doc for security issue) 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.