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/conmon-2.0.20/src/cgroup.c
Examining data/conmon-2.0.20/src/cgroup.h
Examining data/conmon-2.0.20/src/cli.c
Examining data/conmon-2.0.20/src/cli.h
Examining data/conmon-2.0.20/src/cmsg.c
Examining data/conmon-2.0.20/src/cmsg.h
Examining data/conmon-2.0.20/src/config.h
Examining data/conmon-2.0.20/src/conmon.c
Examining data/conmon-2.0.20/src/conn_sock.c
Examining data/conmon-2.0.20/src/conn_sock.h
Examining data/conmon-2.0.20/src/ctr_exit.c
Examining data/conmon-2.0.20/src/ctr_exit.h
Examining data/conmon-2.0.20/src/ctr_logging.c
Examining data/conmon-2.0.20/src/ctr_logging.h
Examining data/conmon-2.0.20/src/ctr_stdio.c
Examining data/conmon-2.0.20/src/ctr_stdio.h
Examining data/conmon-2.0.20/src/ctrl.c
Examining data/conmon-2.0.20/src/ctrl.h
Examining data/conmon-2.0.20/src/globals.c
Examining data/conmon-2.0.20/src/globals.h
Examining data/conmon-2.0.20/src/oom.c
Examining data/conmon-2.0.20/src/oom.h
Examining data/conmon-2.0.20/src/parent_pipe_fd.c
Examining data/conmon-2.0.20/src/parent_pipe_fd.h
Examining data/conmon-2.0.20/src/runtime_args.c
Examining data/conmon-2.0.20/src/runtime_args.h
Examining data/conmon-2.0.20/src/utils.c
Examining data/conmon-2.0.20/src/utils.h

FINAL RESULTS:

data/conmon-2.0.20/src/cgroup.c:206:6:  [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(cgroup_event_control_path, F_OK) < 0) {
data/conmon-2.0.20/src/cli.c:145:6:  [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(opt_runtime_path, X_OK) < 0)
data/conmon-2.0.20/src/conmon.c:268: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(g_ptr_array_index(runtime_argv, 0), (char **)runtime_argv->pdata);
data/conmon-2.0.20/src/ctr_exit.c:190:2:  [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(opt_exit_command, args);
data/conmon-2.0.20/src/conmon.c:237: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.
		char *listenpid = getenv("LISTEN_PID");
data/conmon-2.0.20/src/conn_sock.c:27:38:  [3] (buffer) g_get_tmp_dir:
  This function is synonymous with 'getenv("TMP")';it returns untrustable
  input if the environment can beset by an attacker. It 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.
	_cleanup_free_ const char *tmpdir = g_get_tmp_dir();
data/conmon-2.0.20/src/parent_pipe_fd.c:15: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.
	char *pipe_str = getenv(envname);
data/conmon-2.0.20/src/cgroup.c:52:30:  [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).
	_cleanup_fclose_ FILE *fp = fopen(cgroups_file_path, "re");
data/conmon-2.0.20/src/cgroup.c:142:28:  [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).
	_cleanup_close_ int cfd = open(memory_cgroup_file_path, O_WRONLY | O_CLOEXEC);
data/conmon-2.0.20/src/cgroup.c:150:12:  [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).
	int ofd = open(memory_cgroup_file_oom_path, O_RDONLY | O_CLOEXEC); /* Not closed */
data/conmon-2.0.20/src/cgroup.c:167: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 events[events_size];
data/conmon-2.0.20/src/cgroup.c:263:30:  [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).
	_cleanup_fclose_ FILE *fp = fopen(memory_events_file_path, "re");
data/conmon-2.0.20/src/cgroup.c:302:36:  [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).
		_cleanup_close_ int ctr_oom_fd = open(ctr_oom_file_path, O_CREAT, 0666);
data/conmon-2.0.20/src/cgroup.c:307:31:  [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).
	_cleanup_close_ int oom_fd = open("oom", O_CREAT, 0666);
data/conmon-2.0.20/src/cli.c:149: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 cwd[PATH_MAX];
data/conmon-2.0.20/src/cmsg.c:63: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[CMSG_SPACE(sizeof(file.fd))];
data/conmon-2.0.20/src/cmsg.c:89: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(fdptr, &file.fd, sizeof(int));
data/conmon-2.0.20/src/cmsg.c:111: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[CMSG_SPACE(sizeof(file.fd))];
data/conmon-2.0.20/src/conmon.c:28: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[BUF_SIZE];
data/conmon-2.0.20/src/conmon.c:61:15:  [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).
	dev_null_r = open("/dev/null", O_RDONLY | O_CLOEXEC);
data/conmon-2.0.20/src/conmon.c:65:15:  [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).
	dev_null_w = open("/dev/null", O_WRONLY | O_CLOEXEC);
data/conmon-2.0.20/src/conmon.c:78: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 content[12];
data/conmon-2.0.20/src/conmon.c:79:5:  [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(content, "%i", main_pid);
data/conmon-2.0.20/src/conmon.c:365: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).
	container_pid = atoi(contents);
data/conmon-2.0.20/src/conn_sock.h:15: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[CONN_SOCK_BUF_SIZE];
data/conmon-2.0.20/src/ctr_logging.c:47: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 short_cuuid[TRUNC_ID_LEN + 1];
data/conmon-2.0.20/src/ctr_logging.c:90:16:  [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).
		k8s_log_fd = open(k8s_log_path, O_WRONLY | O_APPEND | O_CREAT | O_CLOEXEC, 0600);
data/conmon-2.0.20/src/ctr_logging.c:211:33:  [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).
	_cleanup_close_ int dev_null = open("/dev/null", O_WRONLY | O_CLOEXEC);
data/conmon-2.0.20/src/ctr_logging.c:293: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 tsbuf[TSBUFLEN];
data/conmon-2.0.20/src/ctr_logging.c:525:15:  [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).
	k8s_log_fd = open(k8s_log_path_tmp, O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, 0600);
data/conmon-2.0.20/src/ctr_stdio.c:107: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 real_buf[STDIO_BUF_SIZE + 2];
data/conmon-2.0.20/src/ctrl.c:162: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 ctlbuf[CTLBUFSZ];
data/conmon-2.0.20/src/ctrl.c:256:17:  [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).
	if ((*fifo_r = open(fifo_path, O_RDONLY | O_NONBLOCK | O_CLOEXEC)) == -1)
data/conmon-2.0.20/src/ctrl.c:259:17:  [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).
	if ((*fifo_w = open(fifo_path, O_WRONLY | O_CLOEXEC)) == -1)
data/conmon-2.0.20/src/oom.c:12:21:  [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).
	int oom_score_fd = open("/proc/self/oom_score_adj", O_WRONLY);
data/conmon-2.0.20/src/cgroup.c:59:10:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	ssize_t read;
data/conmon-2.0.20/src/cgroup.c:79: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).
			subsystem_path[strlen(subsystem_path) - 1] = '\0';
data/conmon-2.0.20/src/cgroup.c:93: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).
				subsystem_path[strlen(subsystem_path) - 1] = '\0';
data/conmon-2.0.20/src/cgroup.c:158:27:  [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 (write_all(cfd, data, strlen(data)) < 0)
data/conmon-2.0.20/src/cgroup.c:170:6:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	if (read(fd, &events, events_size) < 0) {
data/conmon-2.0.20/src/cgroup.c:217:21:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	ssize_t num_read = read(fd, &event_count, sizeof(uint64_t));
data/conmon-2.0.20/src/cgroup.c:271:10:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	ssize_t read;
data/conmon-2.0.20/src/cgroup.c:275:7:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
		if (read < 6 || memcmp(line, "oom ", 4))
data/conmon-2.0.20/src/cmsg.c:74: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).
	iov[0].iov_len = strlen(file.name) + 1;
data/conmon-2.0.20/src/conmon.c:51:14:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
		num_read = read(start_pipe_fd, buf, BUF_SIZE);
data/conmon-2.0.20/src/conmon.c:81:60:  [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 (!g_file_set_contents(opt_conmon_pid_file, content, strlen(content), &err)) {
data/conmon-2.0.20/src/conmon.c:259:16:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
				num_read = read(start_pipe_fd, buf, BUF_SIZE);
data/conmon-2.0.20/src/conmon.c:341:15:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
			num_read = read(mainfd_stderr, buf, BUF_SIZE - 1);
data/conmon-2.0.20/src/conn_sock.c:40:2:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
	strncpy(addr.sun_path, csname, sizeof(addr.sun_path) - 1);
data/conmon-2.0.20/src/conn_sock.c:81: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(attach_symlink_dir_path) == (sizeof(attach_addr.sun_path) - 1))
data/conmon-2.0.20/src/conn_sock.c:90:2:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
	strncpy(attach_addr.sun_path, attach_sock_path, sizeof(attach_addr.sun_path) - 1);
data/conmon-2.0.20/src/conn_sock.c:168:13:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	num_read = read(sock->fd, sock->buf, CONN_SOCK_BUF_SIZE);
data/conmon-2.0.20/src/ctr_logging.c:105:15:  [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).
		cuuid_len = strlen(cuuid_);
data/conmon-2.0.20/src/ctr_logging.c:110:3:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
		strncpy(short_cuuid, cuuid, TRUNC_ID_LEN);
data/conmon-2.0.20/src/ctr_logging.c:119: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).
			container_tag_len = strlen(container_tag);
data/conmon-2.0.20/src/ctr_logging.c:127:15:  [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).
			name_len = strlen(name);
data/conmon-2.0.20/src/ctr_stdio.c:115:13:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	num_read = read(fd, buf, STDIO_BUF_SIZE);
data/conmon-2.0.20/src/ctrl.c:137:33:  [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 (write(winsz_fd_w, hw_str, strlen(hw_str)) < 0) {
data/conmon-2.0.20/src/ctrl.c:165:21:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	ssize_t num_read = read(fd, readptr, readsz);
data/conmon-2.0.20/src/oom.c:17:37:  [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 (write(oom_score_fd, OOM_SCORE, strlen(OOM_SCORE)) < 0) {
data/conmon-2.0.20/src/parent_pipe_fd.c:52: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(json);
data/conmon-2.0.20/src/parent_pipe_fd.c:61: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).
	GString *escaped = g_string_sized_new(strlen(str));

ANALYSIS SUMMARY:

Hits = 62
Lines analyzed = 3335 in approximately 0.12 seconds (27590 lines/second)
Physical Source Lines of Code (SLOC) = 2353
Hits@level = [0]  37 [1]  27 [2]  28 [3]   3 [4]   4 [5]   0
Hits@level+ = [0+]  99 [1+]  62 [2+]  35 [3+]   7 [4+]   4 [5+]   0
Hits/KSLOC@level+ = [0+] 42.0739 [1+] 26.3493 [2+] 14.8746 [3+] 2.97493 [4+] 1.69996 [5+]   0
Dot directories skipped = 2 (--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.