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/away-0.9.5+ds/away.c Examining data/away-0.9.5+ds/away.h FINAL RESULTS: data/away-0.9.5+ds/away.c:182:18: [4] (format) snprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. int nchars = snprintf (buffer, size, format, dirs, filename); data/away-0.9.5+ds/away.c:288:11: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. if (access(mb->path, F_OK) == -1) data/away-0.9.5+ds/away.c:290:16: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. else if (access(mb->path, R_OK) == -1) data/away-0.9.5+ds/away.c:375: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(tmp->path, path); data/away-0.9.5+ds/away.c:376: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(tmp->desc, desc); data/away-0.9.5+ds/away.c:441:7: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. if (access(filename, F_OK) == -1) { data/away-0.9.5+ds/away.c:450:7: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. if (access(filename, R_OK) == -1) { data/away-0.9.5+ds/away.c:522:20: [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). cp = strcat(cp=strdup("/"), save); data/away-0.9.5+ds/away.c:524:23: [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). else cp = strcat(homedir, cp); data/away-0.9.5+ds/away.c:658: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(original, newargv); data/away-0.9.5+ds/away.c:39:15: [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 ((c = getopt_long(argc, argv, "cCf:FhmpPt:Tv", long_options, &option_index)) && c != -1) { data/away-0.9.5+ds/away.c:663: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(AWAY_RCFILE)) { data/away-0.9.5+ds/away.c:664:14: [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. rcfile = getenv(AWAY_RCFILE); data/away-0.9.5+ds/away.c:669: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(AWAY_NOTIME)) { data/away-0.9.5+ds/away.c:672:14: [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. } else if (getenv(AWAY_TIME)) { data/away-0.9.5+ds/away.c:673:14: [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 (atoi(getenv(AWAY_TIME)) >= MIN_TIME) { data/away-0.9.5+ds/away.c:674: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. TIME = atoi(getenv(AWAY_TIME)); data/away-0.9.5+ds/away.c:680: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(AWAY_PERSIST)) { data/away-0.9.5+ds/away.c:681: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. PERSIST = atoi(getenv(AWAY_PERSIST)); data/away-0.9.5+ds/away.c:686: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(AWAY_MAIL)) { data/away-0.9.5+ds/away.c:687:23: [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. CHECK_MAIL = atoi(getenv(AWAY_MAIL)); data/away-0.9.5+ds/away.c:74:13: [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). if (atoi(optarg) >= MIN_TIME) data/away-0.9.5+ds/away.c:390: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 tmpPath[FILE_NAME_LEN], tmpDesc[FILE_NAME_LEN]; data/away-0.9.5+ds/away.c:430: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 line[1024], filename[256]; data/away-0.9.5+ds/away.c:457:7: [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(filename, "r"); data/away-0.9.5+ds/away.c:490:49: [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). else if (strcasecmp(cp,"yes") == 0 || atoi(cp) == 1) data/away-0.9.5+ds/away.c:492:48: [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). else if (strcasecmp(cp,"no") == 0 || atoi(cp) == 0) data/away-0.9.5+ds/away.c:580:49: [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). else if (strcasecmp(cp,"yes") == 0 || atoi(cp) == 1) data/away-0.9.5+ds/away.c:582:48: [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). else if (strcasecmp(cp,"no") == 0 || atoi(cp) == 0) data/away-0.9.5+ds/away.c:609:20: [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). else if (atoi(cp) >= MIN_TIME) TIME = atoi(cp); data/away-0.9.5+ds/away.c:609:49: [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). else if (atoi(cp) >= MIN_TIME) TIME = atoi(cp); data/away-0.9.5+ds/away.c:642: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 *newargv[argc]; data/away-0.9.5+ds/away.c:673:9: [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). if (atoi(getenv(AWAY_TIME)) >= MIN_TIME) { data/away-0.9.5+ds/away.c:674:14: [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). TIME = atoi(getenv(AWAY_TIME)); data/away-0.9.5+ds/away.c:681: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). PERSIST = atoi(getenv(AWAY_PERSIST)); data/away-0.9.5+ds/away.c:687:18: [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). CHECK_MAIL = atoi(getenv(AWAY_MAIL)); data/away-0.9.5+ds/away.c:177: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). if (last != 0 && strlen(last) == 1) format = "%s%s"; data/away-0.9.5+ds/away.c:249:3: [1] (buffer) getchar: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). getchar(); data/away-0.9.5+ds/away.c:373:40: [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->path = (char *) my_malloc(5 + strlen(path)); data/away-0.9.5+ds/away.c:374:40: [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->desc = (char *) my_malloc(5 + strlen(desc)); data/away-0.9.5+ds/away.c:550: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). } else if (strlen(desc) == strspn(desc, WHITESPACE)) { ANALYSIS SUMMARY: Hits = 41 Lines analyzed = 864 in approximately 0.04 seconds (21048 lines/second) Physical Source Lines of Code (SLOC) = 654 Hits@level = [0] 63 [1] 5 [2] 15 [3] 11 [4] 10 [5] 0 Hits@level+ = [0+] 104 [1+] 41 [2+] 36 [3+] 21 [4+] 10 [5+] 0 Hits/KSLOC@level+ = [0+] 159.021 [1+] 62.6911 [2+] 55.0459 [3+] 32.1101 [4+] 15.2905 [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.