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/wl-clipboard-2.0.0/src/includes/selection-protocols.h Examining data/wl-clipboard-2.0.0/src/includes/shell-protocols.h Examining data/wl-clipboard-2.0.0/src/types/copy-action.c Examining data/wl-clipboard-2.0.0/src/types/copy-action.h Examining data/wl-clipboard-2.0.0/src/types/device-manager.c Examining data/wl-clipboard-2.0.0/src/types/device-manager.h Examining data/wl-clipboard-2.0.0/src/types/device.c Examining data/wl-clipboard-2.0.0/src/types/device.h Examining data/wl-clipboard-2.0.0/src/types/keyboard.c Examining data/wl-clipboard-2.0.0/src/types/keyboard.h Examining data/wl-clipboard-2.0.0/src/types/offer.c Examining data/wl-clipboard-2.0.0/src/types/offer.h Examining data/wl-clipboard-2.0.0/src/types/popup-surface.c Examining data/wl-clipboard-2.0.0/src/types/popup-surface.h Examining data/wl-clipboard-2.0.0/src/types/registry.c Examining data/wl-clipboard-2.0.0/src/types/registry.h Examining data/wl-clipboard-2.0.0/src/types/seat.c Examining data/wl-clipboard-2.0.0/src/types/seat.h Examining data/wl-clipboard-2.0.0/src/types/shell-surface.c Examining data/wl-clipboard-2.0.0/src/types/shell-surface.h Examining data/wl-clipboard-2.0.0/src/types/shell.c Examining data/wl-clipboard-2.0.0/src/types/shell.h Examining data/wl-clipboard-2.0.0/src/types/source.c Examining data/wl-clipboard-2.0.0/src/types/source.h Examining data/wl-clipboard-2.0.0/src/util/files.c Examining data/wl-clipboard-2.0.0/src/util/files.h Examining data/wl-clipboard-2.0.0/src/util/misc.c Examining data/wl-clipboard-2.0.0/src/util/misc.h Examining data/wl-clipboard-2.0.0/src/util/string.c Examining data/wl-clipboard-2.0.0/src/util/string.h Examining data/wl-clipboard-2.0.0/src/wl-copy.c Examining data/wl-clipboard-2.0.0/src/wl-paste.c FINAL RESULTS: data/wl-clipboard-2.0.0/src/types/copy-action.c:81:13: [4] (shell) execlp: 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. execlp("cat", "cat", self->file_to_copy, NULL); data/wl-clipboard-2.0.0/src/types/offer.c:50: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(ptr, mime_type); \ data/wl-clipboard-2.0.0/src/util/files.c:128:9: [4] (shell) execlp: 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. execlp("xdg-mime", "xdg-mime", "query", "filetype", file_path, NULL); data/wl-clipboard-2.0.0/src/util/files.c:219: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(res_path + sizeof(dirpath), name); data/wl-clipboard-2.0.0/src/util/files.c:235:9: [4] (shell) execlp: 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. execlp("cat", "cat", NULL); data/wl-clipboard-2.0.0/src/util/misc.h:25:28: [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 bail(message) do { fprintf(stderr, message "\n"); exit(1); } while (0) data/wl-clipboard-2.0.0/src/wl-copy.c:75:9: [4] (shell) execlp: 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. execlp("rm", "rm", "-r", dirname(temp_file), NULL); data/wl-clipboard-2.0.0/src/wl-paste.c:256:13: [4] (shell) execvp: 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. execvp(options.watch_command[0], options.watch_command); data/wl-clipboard-2.0.0/src/wl-paste.c:264:13: [4] (shell) execlp: 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. execlp("cat", "cat", NULL); data/wl-clipboard-2.0.0/src/util/files.c:102:12: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. return realpath(fdpath, NULL); data/wl-clipboard-2.0.0/src/wl-copy.c:140:17: [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. int c = getopt_long(argc, argv, opts, long_options, &option_index); data/wl-clipboard-2.0.0/src/wl-paste.c:332:17: [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. int c = getopt_long(argc, argv, opts, long_options, &option_index); data/wl-clipboard-2.0.0/src/util/files.c:60:19: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). return fileno(tmpfile()); data/wl-clipboard-2.0.0/src/util/files.c:64:14: [2] (misc) open: 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). int fd = open(file_path, O_RDWR); data/wl-clipboard-2.0.0/src/util/files.c:100: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 fdpath[64]; data/wl-clipboard-2.0.0/src/util/files.c:125:23: [2] (misc) open: 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). int devnull = open("/dev/null", O_RDONLY); data/wl-clipboard-2.0.0/src/util/files.c:164: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). FILE *f = fopen("/etc/mime.types", "r"); data/wl-clipboard-2.0.0/src/util/files.c:166: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). f = fopen("/usr/local/etc/mime.types", "r"); data/wl-clipboard-2.0.0/src/util/files.c:172: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. for (char line[200]; fgets(line, sizeof(line), f) != NULL;) { data/wl-clipboard-2.0.0/src/util/files.c:179: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. char mime_type[200]; data/wl-clipboard-2.0.0/src/util/files.c:186:14: [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. for (char ext[200]; sscanf(lineptr, "%199s%n", ext, &consumed) == 1;) { data/wl-clipboard-2.0.0/src/util/files.c:217:5: [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(res_path, dirpath, sizeof(dirpath)); data/wl-clipboard-2.0.0/src/types/copy-action.c:116:34: [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). fwrite(*word, 1, strlen(*word), f); data/wl-clipboard-2.0.0/src/types/offer.c:48: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). strlen(mime_type) + 1 \ data/wl-clipboard-2.0.0/src/types/offer.h:42: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). mime_type += strlen(mime_type) + 1 \ data/wl-clipboard-2.0.0/src/util/files.c:82:20: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int read_res = read(fd, &last_char, 1); data/wl-clipboard-2.0.0/src/util/files.c:144:18: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). size_t len = read(pipefd[0], res, 256); data/wl-clipboard-2.0.0/src/util/files.c:181:13: [1] (buffer) sscanf: It's unclear if the %s limit in the format string is small enough (CWE-120). Check that the limit is sufficiently small, or use a different input function. if (sscanf(line, "%199s%n", mime_type, &consumed) != 1) { data/wl-clipboard-2.0.0/src/util/files.c:186:29: [1] (buffer) sscanf: It's unclear if the %s limit in the format string is small enough (CWE-120). Check that the limit is sufficiently small, or use a different input function. for (char ext[200]; sscanf(lineptr, "%199s%n", ext, &consumed) == 1;) { data/wl-clipboard-2.0.0/src/util/files.c:216: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). char *res_path = malloc(strlen(dirpath) + 1 + strlen(name) + 1); data/wl-clipboard-2.0.0/src/util/files.c:216: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). char *res_path = malloc(strlen(dirpath) + 1 + strlen(name) + 1); data/wl-clipboard-2.0.0/src/util/string.c:57: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). size_t prefix_length = strlen(prefix); data/wl-clipboard-2.0.0/src/util/string.c:62: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). size_t string_length = strlen(string); data/wl-clipboard-2.0.0/src/util/string.c:63: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). size_t suffix_length = strlen(suffix); ANALYSIS SUMMARY: Hits = 34 Lines analyzed = 3452 in approximately 0.11 seconds (32710 lines/second) Physical Source Lines of Code (SLOC) = 2133 Hits@level = [0] 8 [1] 12 [2] 10 [3] 3 [4] 9 [5] 0 Hits@level+ = [0+] 42 [1+] 34 [2+] 22 [3+] 12 [4+] 9 [5+] 0 Hits/KSLOC@level+ = [0+] 19.6906 [1+] 15.94 [2+] 10.3141 [3+] 5.62588 [4+] 4.21941 [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.