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/postgresql-plsh-1.20200522/plsh.c FINAL RESULTS: data/postgresql-plsh-1.20200522/plsh.c:631:3: [4] (shell) execv: 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. execv(arguments[0], arguments); data/postgresql-plsh-1.20200522/plsh.c:239: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. if ((tmpdir_envvar = getenv("TMPDIR"))) data/postgresql-plsh-1.20200522/plsh.c:385:6: [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("PATH")) data/postgresql-plsh-1.20200522/plsh.c:392:47: [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(p, sizeof(buf) - (p - buf), ":%s", getenv("PATH")); data/postgresql-plsh-1.20200522/plsh.c:203: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[512]; data/postgresql-plsh-1.20200522/plsh.c:235: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. static char tempfile[MAXPGPATH]; data/postgresql-plsh-1.20200522/plsh.c:242:3: [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(tempfile, "/tmp/plsh-XXXXXX"); data/postgresql-plsh-1.20200522/plsh.c:244:7: [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(tempfile); data/postgresql-plsh-1.20200522/plsh.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 buf[16]; data/postgresql-plsh-1.20200522/plsh.c:381:3: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(buf, "%u", PostPortNumber); data/postgresql-plsh-1.20200522/plsh.c:387: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[MAXPGPATH]; data/postgresql-plsh-1.20200522/plsh.c:435: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 * arguments[FUNC_MAX_ARGS + 2]; data/postgresql-plsh-1.20200522/plsh.c:773: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 * arguments[FUNC_MAX_ARGS + 2]; data/postgresql-plsh-1.20200522/plsh.c:166:6: [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(sourcecode) < 3 data/postgresql-plsh-1.20200522/plsh.c:177:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(s, rest, len); data/postgresql-plsh-1.20200522/plsh.c:211:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(buffer + len, buf, l); data/postgresql-plsh-1.20200522/plsh.c:668: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(stdout_buffer); data/postgresql-plsh-1.20200522/plsh.c:699: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(stderr_buffer); ANALYSIS SUMMARY: Hits = 18 Lines analyzed = 784 in approximately 0.03 seconds (28612 lines/second) Physical Source Lines of Code (SLOC) = 568 Hits@level = [0] 4 [1] 5 [2] 9 [3] 3 [4] 1 [5] 0 Hits@level+ = [0+] 22 [1+] 18 [2+] 13 [3+] 4 [4+] 1 [5+] 0 Hits/KSLOC@level+ = [0+] 38.7324 [1+] 31.6901 [2+] 22.8873 [3+] 7.04225 [4+] 1.76056 [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.