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/mswatch-1.2.0/src/inotify-syscalls.h Examining data/mswatch-1.2.0/src/socketwatch/socketwatch.h Examining data/mswatch-1.2.0/src/socketwatch/socketwatch.cc Examining data/mswatch-1.2.0/src/socketwatch/libsocketwatch.cc Examining data/mswatch-1.2.0/src/inotify.h Examining data/mswatch-1.2.0/src/inputkill/inputkill.c Examining data/mswatch-1.2.0/src/watch_maildirs/dnotify/watcher_maildir.h Examining data/mswatch-1.2.0/src/watch_maildirs/dnotify/watch.cc Examining data/mswatch-1.2.0/src/watch_maildirs/dnotify/watcher_base.cc Examining data/mswatch-1.2.0/src/watch_maildirs/dnotify/watcher_maildir.cc Examining data/mswatch-1.2.0/src/watch_maildirs/dnotify/state.h Examining data/mswatch-1.2.0/src/watch_maildirs/dnotify/open_file.cc Examining data/mswatch-1.2.0/src/watch_maildirs/dnotify/watcher_partial.h Examining data/mswatch-1.2.0/src/watch_maildirs/dnotify/state.cc Examining data/mswatch-1.2.0/src/watch_maildirs/dnotify/watcher_base.h Examining data/mswatch-1.2.0/src/watch_maildirs/dnotify/watcher_partial.cc Examining data/mswatch-1.2.0/src/watch_maildirs/dnotify/open_file.h Examining data/mswatch-1.2.0/src/watch_maildirs/dnotify/watcher.h Examining data/mswatch-1.2.0/src/watch_maildirs/watch_maildirs.h Examining data/mswatch-1.2.0/src/watch_maildirs/watch_maildirs.cc Examining data/mswatch-1.2.0/src/watch_maildirs/inotify/watcher_maildir.h Examining data/mswatch-1.2.0/src/watch_maildirs/inotify/watch.cc Examining data/mswatch-1.2.0/src/watch_maildirs/inotify/watcher_base.cc Examining data/mswatch-1.2.0/src/watch_maildirs/inotify/watcher_maildir.cc Examining data/mswatch-1.2.0/src/watch_maildirs/inotify/state.h Examining data/mswatch-1.2.0/src/watch_maildirs/inotify/watcher_partial.h Examining data/mswatch-1.2.0/src/watch_maildirs/inotify/watcher_base.h Examining data/mswatch-1.2.0/src/watch_maildirs/inotify/watcher_partial.cc Examining data/mswatch-1.2.0/src/watch_maildirs/inotify/watcher.h Examining data/mswatch-1.2.0/src/watch_maildirs/inotify/state.cc Examining data/mswatch-1.2.0/src/compat.h Examining data/mswatch-1.2.0/src/lib/util.cc Examining data/mswatch-1.2.0/src/lib/util.h Examining data/mswatch-1.2.0/src/mswatch/timeout_calc.h Examining data/mswatch-1.2.0/src/mswatch/mswatch.cc Examining data/mswatch-1.2.0/src/mswatch/mailstore_watcher.h Examining data/mswatch-1.2.0/src/mswatch/timeout_calc.cc Examining data/mswatch-1.2.0/src/mswatch/rcparser/rcparser.h Examining data/mswatch-1.2.0/src/mswatch/rcparser/semantic_actions.c Examining data/mswatch-1.2.0/src/mswatch/rcparser/parser.c Examining data/mswatch-1.2.0/src/mswatch/rcparser/lexer.c Examining data/mswatch-1.2.0/src/mswatch/rcparser/parser_types.h Examining data/mswatch-1.2.0/src/mswatch/rcparser/rcparser.cc Examining data/mswatch-1.2.0/src/mswatch/rcparser/parser.h Examining data/mswatch-1.2.0/src/mswatch/rcparser/parser_types.c Examining data/mswatch-1.2.0/src/mswatch/rcparser/semantic_actions.h Examining data/mswatch-1.2.0/src/mswatch/mswatch_config.h Examining data/mswatch-1.2.0/src/mswatch/mailstore_watcher.cc FINAL RESULTS: data/mswatch-1.2.0/src/inputkill/inputkill.c:67:3: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. printf(PACKAGE " " VERSION "\n"); data/mswatch-1.2.0/src/inputkill/inputkill.c:100:3: [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(child_command[0], &child_command[0]); data/mswatch-1.2.0/src/lib/util.cc:48:2: [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, format, val); data/mswatch-1.2.0/src/lib/util.cc:64:2: [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, format, val); data/mswatch-1.2.0/src/mswatch/mailstore_watcher.cc:94:3: [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(config->watch_bin[0], config->watch_bin); data/mswatch-1.2.0/src/mswatch/mswatch.cc:183:4: [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(args[0], args); data/mswatch-1.2.0/src/mswatch/mswatch.cc:463:3: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. printf(PACKAGE " " VERSION "\n"); data/mswatch-1.2.0/src/mswatch/mswatch.cc:479: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(*configfilename, dirname); data/mswatch-1.2.0/src/mswatch/mswatch.cc:481: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(*configfilename + dirname_len + 1, DEFAULT_CONFIGFILENAME); data/mswatch-1.2.0/src/mswatch/rcparser/lexer.c:567:23: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. #define DPRINTF(x...) printf(x) data/mswatch-1.2.0/src/mswatch/rcparser/parser.c:708: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/mswatch-1.2.0/src/socketwatch/libsocketwatch.cc:27:24: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. # define Dprintf(x...) printf(x) data/mswatch-1.2.0/src/socketwatch/socketwatch.cc:99:5: [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. fprintf(stderr, BIN_NAME ": Not receiving heartbeats," data/mswatch-1.2.0/src/socketwatch/socketwatch.cc:178:3: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. printf(BIN_NAME "\n"); data/mswatch-1.2.0/src/socketwatch/socketwatch.cc:179:3: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. printf(PACKAGE " " VERSION "\n"); data/mswatch-1.2.0/src/socketwatch/socketwatch.cc:279:3: [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(child_command[0], &child_command[0]); data/mswatch-1.2.0/src/watch_maildirs/watch_maildirs.cc:136:3: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. printf(PACKAGE " " VERSION "\n"); data/mswatch-1.2.0/src/mswatch/mswatch.cc:315:2: [3] (random) srand: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. srand(time(NULL)); data/mswatch-1.2.0/src/mswatch/mswatch.cc:475:19: [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. char* dirname = getenv("HOME"); data/mswatch-1.2.0/src/socketwatch/libsocketwatch.cc:46:20: [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. shared_fd_cstr = getenv(SOCKETWATCH_SHARED_FD); data/mswatch-1.2.0/src/socketwatch/socketwatch.cc:253:26: [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. char *ldpreload_cstr = getenv("LD_PRELOAD"); data/mswatch-1.2.0/src/watch_maildirs/watch_maildirs.cc:142:7: [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 (getenv("MAILDIR")) data/mswatch-1.2.0/src/watch_maildirs/watch_maildirs.cc:143:22: [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. *maildir = strdup(getenv("MAILDIR")); data/mswatch-1.2.0/src/watch_maildirs/watch_maildirs.cc:145:33: [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. *maildir = strdup(mkfilename(getenv("HOME"), "Maildir").c_str()); data/mswatch-1.2.0/src/inotify.h:28: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 name[0]; /* stub for possible name */ data/mswatch-1.2.0/src/inputkill/inputkill.c:84: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 buf[1024]; data/mswatch-1.2.0/src/mswatch/mailstore_watcher.cc:114: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 time_str[100]; data/mswatch-1.2.0/src/mswatch/mailstore_watcher.cc:188: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 time_str[100]; data/mswatch-1.2.0/src/mswatch/mailstore_watcher.cc:221: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 buf[MAILBOXNAME_MAX]; data/mswatch-1.2.0/src/mswatch/mailstore_watcher.cc:229:3: [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(buf, mailboxes_buf, mailboxes_buf_len); data/mswatch-1.2.0/src/mswatch/mailstore_watcher.cc:243: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 time_str[100]; data/mswatch-1.2.0/src/mswatch/mailstore_watcher.cc:265: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(mailboxes_buf, buf + i, mailboxes_buf_len); data/mswatch-1.2.0/src/mswatch/mailstore_watcher.h:56: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 mailboxes_buf[MAILBOXNAME_MAX]; data/mswatch-1.2.0/src/mswatch/mswatch.cc:107:3: [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(name, mailbox.c_str(), mailbox.size()); data/mswatch-1.2.0/src/mswatch/mswatch.cc:115:3: [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(name, config.mailbox_prefix[0], prefix_len); data/mswatch-1.2.0/src/mswatch/mswatch.cc:116:3: [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(name + prefix_len, config.mailbox_prefix[1], sep_len); data/mswatch-1.2.0/src/mswatch/mswatch.cc:117:3: [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(name + prefix_len + sep_len, mailbox.c_str(), mailbox.size()); data/mswatch-1.2.0/src/mswatch/mswatch.cc:132: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 time_str[100]; data/mswatch-1.2.0/src/mswatch/mswatch.cc:388: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 time_str[100]; data/mswatch-1.2.0/src/mswatch/mswatch.cc:519:21: [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* configfile = fopen(configfilename, "r"); data/mswatch-1.2.0/src/mswatch/rcparser/lexer.c:938:29: [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.num = atoi(yytext); data/mswatch-1.2.0/src/mswatch/rcparser/parser.c:1008:7: [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/mswatch-1.2.0/src/mswatch/rcparser/parser.c:1025:7: [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 yyformat[sizeof yyunexpected data/mswatch-1.2.0/src/mswatch/rcparser/parser.c:1215: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/mswatch-1.2.0/src/socketwatch/libsocketwatch.cc:50:15: [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). shared_fd = atoi(shared_fd_cstr); data/mswatch-1.2.0/src/socketwatch/socketwatch.cc:205:14: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). shared_fd = mkstemp(shared_name); data/mswatch-1.2.0/src/watch_maildirs/dnotify/watcher_base.cc:116:11: [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(dir, O_RDONLY); data/mswatch-1.2.0/src/watch_maildirs/dnotify/watcher_maildir.cc:71:11: [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(dir, O_RDONLY); data/mswatch-1.2.0/src/watch_maildirs/dnotify/watcher_partial.cc:57:11: [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(dir, O_RDONLY); data/mswatch-1.2.0/src/watch_maildirs/inotify/watch.cc:71:4: [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 buf[100 * sizeof(struct inotify_event) + MAXNAMLEN]; data/mswatch-1.2.0/src/inputkill/inputkill.c:111:26: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). r = TEMP_FAILURE_RETRY(read(STDIN_FILENO, &buf, sizeof(buf))); data/mswatch-1.2.0/src/lib/util.cc:114:26: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). r = TEMP_FAILURE_RETRY(read(fd, &c, 1)); data/mswatch-1.2.0/src/mswatch/mailstore_watcher.cc:110:25: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). r = TEMP_FAILURE_RETRY(read(from_fd, &c, 1)); data/mswatch-1.2.0/src/mswatch/mailstore_watcher.cc:234:32: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). read_len = TEMP_FAILURE_RETRY(read(from_fd, buf + buf_index, MAILBOXNAME_MAX - buf_index - 1)); data/mswatch-1.2.0/src/mswatch/mswatch.cc:112:25: [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). unsigned prefix_len = strlen(config.mailbox_prefix[0]); data/mswatch-1.2.0/src/mswatch/mswatch.cc:113: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). unsigned sep_len = omit_sep ? 0 : strlen(config.mailbox_prefix[1]); data/mswatch-1.2.0/src/mswatch/mswatch.cc:294:26: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). r = TEMP_FAILURE_RETRY(read(sigchld_pipe[0], &c, 1)); data/mswatch-1.2.0/src/mswatch/mswatch.cc:476:26: [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). unsigned dirname_len = strlen(dirname); data/mswatch-1.2.0/src/mswatch/mswatch.cc:477:54: [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). *configfilename = (char*) malloc(dirname_len + 1 + strlen(DEFAULT_CONFIGFILENAME) + 1); data/mswatch-1.2.0/src/mswatch/rcparser/lexer.c:680: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/mswatch-1.2.0/src/mswatch/rcparser/lexer.c:1759: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/mswatch-1.2.0/src/mswatch/rcparser/parser.c:889: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/mswatch-1.2.0/src/socketwatch/libsocketwatch.cc:100:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ssize_t read(int fd, void *buf, size_t count) data/mswatch-1.2.0/src/watch_maildirs/inotify/watch.cc:72:33: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int len = TEMP_FAILURE_RETRY(read(pfds[pfd].fd, buf, sizeof(buf))); ANALYSIS SUMMARY: Hits = 64 Lines analyzed = 8220 in approximately 0.29 seconds (28505 lines/second) Physical Source Lines of Code (SLOC) = 5870 Hits@level = [0] 105 [1] 14 [2] 26 [3] 7 [4] 17 [5] 0 Hits@level+ = [0+] 169 [1+] 64 [2+] 50 [3+] 24 [4+] 17 [5+] 0 Hits/KSLOC@level+ = [0+] 28.7905 [1+] 10.9029 [2+] 8.51789 [3+] 4.08859 [4+] 2.89608 [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.