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/mailcheck-1.91.2/netrc.h Examining data/mailcheck-1.91.2/socket.c Examining data/mailcheck-1.91.2/mailcheck.c Examining data/mailcheck-1.91.2/netrc.c FINAL RESULTS: data/mailcheck-1.91.2/mailcheck.c:122: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 (dup, path); data/mailcheck-1.91.2/mailcheck.c:135:5: [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 (srcptr, envname); data/mailcheck-1.91.2/mailcheck.c:136:3: [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 (srcptr, tmpptr + 1); data/mailcheck-1.91.2/mailcheck.c:204:1: [4] (buffer) getpw: This function is dangerous; it may overflow the provided buffer. It extracts data from a 'protected' area, but most systems have many commands to let users modify the protected area, and it's not always clear what their limits are. Best to avoid using this function altogether (CWE-676, CWE-120). Use getpwuid() instead. getpw (char *host, char *account) data/mailcheck-1.91.2/mailcheck.c:317:7: [4] (buffer) getpw: This function is dangerous; it may overflow the provided buffer. It extracts data from a 'protected' area, but most systems have many commands to let users modify the protected area, and it's not always clear what their limits are. Best to avoid using this function altogether (CWE-676, CWE-120). Use getpwuid() instead. p = getpw (hostname, user); data/mailcheck-1.91.2/mailcheck.c:133:13: [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. envname = getenv (envptr); data/mailcheck-1.91.2/mailcheck.c:296:11: [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. q = getenv ("USER"); data/mailcheck-1.91.2/mailcheck.c:824: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. while ((opt= getopt(argc, argv, "bchlsf:")) != -1) data/mailcheck-1.91.2/mailcheck.c:859:8: [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. ptr= getenv ("HOME"); data/mailcheck-1.91.2/mailcheck.c:74: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 namebuf[256]; data/mailcheck-1.91.2/mailcheck.c:79:18: [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 ((rcfile= fopen(Options.rcfile_path, "r")) == NULL) { data/mailcheck-1.91.2/mailcheck.c:88:18: [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 ((rcfile= fopen(namebuf, "r")) == NULL) { data/mailcheck-1.91.2/mailcheck.c:89: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). if ((rcfile= fopen("/etc/mailcheckrc", "r")) == NULL) { data/mailcheck-1.91.2/mailcheck.c:145: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 fname[BUF_SIZE]; data/mailcheck-1.91.2/mailcheck.c:206: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 file[256]; data/mailcheck-1.91.2/mailcheck.c:252: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 buf[BUF_SIZE]; data/mailcheck-1.91.2/mailcheck.c:280:2: [2] (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). Risk is low because the source is a constant string. strcpy (box, "INBOX"); data/mailcheck-1.91.2/mailcheck.c:283:5: [2] (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). Risk is low because the source is a constant string. strcpy (box, "INBOX"); data/mailcheck-1.91.2/mailcheck.c:309:12: [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). int n = atoi (p); data/mailcheck-1.91.2/mailcheck.c:328: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 linebuf[BUF_SIZE]; data/mailcheck-1.91.2/mailcheck.c:333: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 ((mbox= fopen(path, "r")) == NULL) { data/mailcheck-1.91.2/mailcheck.c:380: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 dir[BUF_SIZE]; data/mailcheck-1.91.2/mailcheck.c:397: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 dir[BUF_SIZE]; data/mailcheck-1.91.2/mailcheck.c:448: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 buf[BUF_SIZE]; data/mailcheck-1.91.2/mailcheck.c:449: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 hostname[BUF_SIZE]; data/mailcheck-1.91.2/mailcheck.c:450: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 box[BUF_SIZE]; /* not actually used for pop3 */ data/mailcheck-1.91.2/mailcheck.c:451: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 user[128]; data/mailcheck-1.91.2/mailcheck.c:452: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 pass[128]; data/mailcheck-1.91.2/mailcheck.c:536: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 buf[BUF_SIZE]; data/mailcheck-1.91.2/mailcheck.c:537: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 hostname[BUF_SIZE]; data/mailcheck-1.91.2/mailcheck.c:538: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 box[BUF_SIZE]; data/mailcheck-1.91.2/mailcheck.c:539: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 user[128]; data/mailcheck-1.91.2/mailcheck.c:540: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 pass[128]; data/mailcheck-1.91.2/mailcheck.c:855: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 buf[1024], *ptr; data/mailcheck-1.91.2/netrc.c:88: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 buf[BUFSIZE + 1], *p, *tok; data/mailcheck-1.91.2/netrc.c:102: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 (file, "r"); data/mailcheck-1.91.2/mailcheck.c:114: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 (path); data/mailcheck-1.91.2/mailcheck.c:256:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (buf, path, BUF_SIZE - 1); data/mailcheck-1.91.2/mailcheck.c:278:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (box, p, BUF_SIZE - 1); data/mailcheck-1.91.2/mailcheck.c:300:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (user, q, 127); data/mailcheck-1.91.2/mailcheck.c:314:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (hostname, h, 127); data/mailcheck-1.91.2/mailcheck.c:319:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (pass, p, 127); data/mailcheck-1.91.2/mailcheck.c:326:45: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). check_mbox(const char *path, int *new, int *read, int *unread) data/mailcheck-1.91.2/mailcheck.c:354:11: [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). linelen= strlen(linebuf); data/mailcheck-1.91.2/mailcheck.c:360:6: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). (*read)++; data/mailcheck-1.91.2/mailcheck.c:396:48: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). check_maildir(const char *path, int *new, int *read, int *unread) { data/mailcheck-1.91.2/mailcheck.c:432:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). (*read)++; data/mailcheck-1.91.2/mailcheck.c:629: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). strncmp(mailpath, Homedir, strlen(Homedir)) == 0) { data/mailcheck-1.91.2/mailcheck.c:630: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). brief_name_offset= strlen(Homedir) + 1; data/mailcheck-1.91.2/mailcheck.c:649:11: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int new, read, unread; data/mailcheck-1.91.2/mailcheck.c:650:34: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (check_mbox(mailpath, &new, &read, &unread) == -1) data/mailcheck-1.91.2/mailcheck.c:727:11: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int new, read, unread; data/mailcheck-1.91.2/mailcheck.c:729:37: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (check_maildir(mailpath, &new, &read, &unread) == -1) { data/mailcheck-1.91.2/mailcheck.c:888:11: [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 (buf) && (*buf != '#')) data/mailcheck-1.91.2/netrc.c:119: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). for (p = buf + strlen (buf) - 1; (p >= buf) && isspace (*p); p--) ANALYSIS SUMMARY: Hits = 55 Lines analyzed = 1446 in approximately 0.05 seconds (27379 lines/second) Physical Source Lines of Code (SLOC) = 1086 Hits@level = [0] 80 [1] 19 [2] 27 [3] 4 [4] 5 [5] 0 Hits@level+ = [0+] 135 [1+] 55 [2+] 36 [3+] 9 [4+] 5 [5+] 0 Hits/KSLOC@level+ = [0+] 124.309 [1+] 50.6446 [2+] 33.1492 [3+] 8.28729 [4+] 4.60405 [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.