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/pgagent-4.0.0/connection.cpp Examining data/pgagent-4.0.0/include/connection.h Examining data/pgagent-4.0.0/include/job.h Examining data/pgagent-4.0.0/include/misc.h Examining data/pgagent-4.0.0/include/pgAgent.h Examining data/pgagent-4.0.0/job.cpp Examining data/pgagent-4.0.0/misc.cpp Examining data/pgagent-4.0.0/pgAgent.cpp Examining data/pgagent-4.0.0/pgaevent/pgaevent.c Examining data/pgagent-4.0.0/pgaevent/pgamsgevent.h Examining data/pgagent-4.0.0/precomp.cpp Examining data/pgagent-4.0.0/unix.cpp Examining data/pgagent-4.0.0/win32.cpp FINAL RESULTS: data/pgagent-4.0.0/job.cpp:221:16: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. int ret = chmod((const char *)sfilename.c_str(), S_IRWXU); data/pgagent-4.0.0/job.cpp:275:17: [4] (shell) popen: 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. fp_script = popen((const char *)sfilename.c_str(), "r"); data/pgagent-4.0.0/misc.cpp:172:5: [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/pgagent-4.0.0/misc.cpp:210: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 *s = getenv("TMPDIR"); data/pgagent-4.0.0/misc.cpp:216: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. const char *s1 = getenv("TMP"); data/pgagent-4.0.0/misc.cpp:220:30: [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 *s2 = getenv("TEMP"); data/pgagent-4.0.0/misc.cpp:224:34: [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 *s3 = getenv("TEMPDIR"); data/pgagent-4.0.0/include/connection.h:151:10: [2] (integer) atol: 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). return atol(PQcmdTuples(m_result)); data/pgagent-4.0.0/job.cpp:206:14: [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). out_file.open((const char *)sfilename.c_str(), std::ios::out); data/pgagent-4.0.0/job.cpp:238: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 chBuf[4098]; data/pgagent-4.0.0/job.cpp:273: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 buf[4098]; data/pgagent-4.0.0/job.cpp:310: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). FILE* fpErr = fopen((const char *)serrorFile.c_str(), "r"); data/pgagent-4.0.0/job.cpp:313: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 buffer[4098]; data/pgagent-4.0.0/misc.cpp:64:16: [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 val = atoi((const char*)getArg(argc, argv).c_str()); data/pgagent-4.0.0/misc.cpp:71:16: [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 val = atoi((const char*)getArg(argc, argv).c_str()); data/pgagent-4.0.0/misc.cpp:78:16: [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 val = atoi((const char*)getArg(argc, argv).c_str()); data/pgagent-4.0.0/misc.cpp:204:5: [2] (buffer) wchar_t: 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. wchar_t wcharPath[MAX_PATH]; data/pgagent-4.0.0/unix.cpp:55:7: [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). out.open((const char *)log_file.c_str(), ios::out | ios::app); data/pgagent-4.0.0/win32.cpp:300:37: [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. serviceName = CharToWString((const char *)argv[0]); data/pgagent-4.0.0/misc.cpp:157:20: [1] (buffer) wcslen: 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). int wstr_length = wcslen(wchar_str); ANALYSIS SUMMARY: Hits = 20 Lines analyzed = 2653 in approximately 0.07 seconds (36966 lines/second) Physical Source Lines of Code (SLOC) = 1969 Hits@level = [0] 29 [1] 1 [2] 12 [3] 5 [4] 1 [5] 1 Hits@level+ = [0+] 49 [1+] 20 [2+] 19 [3+] 7 [4+] 2 [5+] 1 Hits/KSLOC@level+ = [0+] 24.8857 [1+] 10.1574 [2+] 9.64957 [3+] 3.5551 [4+] 1.01574 [5+] 0.507872 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.