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/runawk-1.6.0/runawk/common.h Examining data/runawk-1.6.0/runawk/dynarray.c Examining data/runawk-1.6.0/runawk/dynarray.h Examining data/runawk-1.6.0/runawk/file_hier.c Examining data/runawk-1.6.0/runawk/file_hier.h Examining data/runawk-1.6.0/runawk/runawk.c FINAL RESULTS: data/runawk-1.6.0/runawk/runawk.c:219: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 (buf, R_OK)){ data/runawk-1.6.0/runawk/runawk.c:228:9: [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 (buf, R_OK)){ data/runawk-1.6.0/runawk/runawk.c:764:5: [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 (interp, (char *const *) new_argv.array); data/runawk-1.6.0/runawk/runawk.c:138: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. const char *keep = getenv ("RUNAWK_KEEPTMP"); data/runawk-1.6.0/runawk/runawk.c:162: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. const char *dir = getenv ("RUNAWK_TMPDIR"); data/runawk-1.6.0/runawk/runawk.c:164:9: [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. dir = getenv ("TMPDIR"); data/runawk-1.6.0/runawk/runawk.c:168:13: [3] (tmpfile) tempnam: Temporary file race condition (CWE-377). temp_dir = tempnam (dir, "awk."); data/runawk-1.6.0/runawk/runawk.c:290:46: [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. snprintf (buffer, sizeof (buffer), "%s%s", getenv ("HOME"), name+1); data/runawk-1.6.0/runawk/runawk.c:605:27: [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. const char *env_interp = getenv ("RUNAWK_AWKPROG"); data/runawk-1.6.0/runawk/runawk.c:629:16: [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. awkpath_env = getenv ("AWKPATH"); data/runawk-1.6.0/runawk/runawk.c:651:13: [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 (c = getopt (argc, argv, "+de:f:F:htTVv:"), c != EOF){ data/runawk-1.6.0/runawk/runawk.c:723:16: [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. interp_var = getenv (interp_var); data/runawk-1.6.0/runawk/file_hier.c:40: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 buffer [PATH_MAX]; data/runawk-1.6.0/runawk/runawk.c:102:8: [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 temp_fn [PATH_MAX] = "/tmp/runawk.XXXXXX"; data/runawk-1.6.0/runawk/runawk.c:110:8: [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 cwd [PATH_MAX]; data/runawk-1.6.0/runawk/runawk.c:214: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 [PATH_MAX]; data/runawk-1.6.0/runawk/runawk.c:278: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 ((void *) ret, (const void *) p, len); data/runawk-1.6.0/runawk/runawk.c:286: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 buffer [4000]; data/runawk-1.6.0/runawk/runawk.c:312: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 buffer [2000]; data/runawk-1.6.0/runawk/runawk.c:345:7: [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 (buffer, start, len); data/runawk-1.6.0/runawk/runawk.c:414: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 dir [PATH_MAX]; data/runawk-1.6.0/runawk/runawk.c:442: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). fd = fopen (name, "r"); data/runawk-1.6.0/runawk/runawk.c:479:8: [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). fd = mkstemp (temp_fn); data/runawk-1.6.0/runawk/runawk.c:585: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 [30 + PATH_MAX]; data/runawk-1.6.0/runawk/runawk.c:602: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 buffer [4000]; data/runawk-1.6.0/runawk/file_hier.c:41:19: [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 dir_len = strlen (dir)+1; data/runawk-1.6.0/runawk/runawk.c:423: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). len = strlen (name); data/runawk-1.6.0/runawk/runawk.c:424:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (dir, name, sizeof (dir)); data/runawk-1.6.0/runawk/runawk.c:522: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 (name); data/runawk-1.6.0/runawk/runawk.c:547:46: [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 (p && (p == inc || (p [-1] == '/' && p [strlen (p)] == 0))){ data/runawk-1.6.0/runawk/runawk.c:633:16: [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). awkpath_len = strlen (awkpath_env) + 1 + strlen (sys_awkdir); data/runawk-1.6.0/runawk/runawk.c:633:43: [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). awkpath_len = strlen (awkpath_env) + 1 + strlen (sys_awkdir); data/runawk-1.6.0/runawk/runawk.c:703:31: [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). add_buffer (prog_specified, strlen (prog_specified)); ANALYSIS SUMMARY: Hits = 33 Lines analyzed = 1055 in approximately 0.07 seconds (14312 lines/second) Physical Source Lines of Code (SLOC) = 723 Hits@level = [0] 20 [1] 8 [2] 13 [3] 9 [4] 3 [5] 0 Hits@level+ = [0+] 53 [1+] 33 [2+] 25 [3+] 12 [4+] 3 [5+] 0 Hits/KSLOC@level+ = [0+] 73.3057 [1+] 45.6432 [2+] 34.5781 [3+] 16.5975 [4+] 4.14938 [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.