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/eventstat-0.04.11/eventstat.c

FINAL RESULTS:

data/eventstat-0.04.11/eventstat.c:178:67:  [4] (format) printf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
static void es_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
data/eventstat-0.04.11/eventstat.c:370:62:  [4] (format) printf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
static void __attribute__ ((noreturn)) __attribute__((format(printf, 1, 2)))
data/eventstat-0.04.11/eventstat.c:377:8:  [4] (format) vfprintf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
	(void)vfprintf(stderr,fmt, ap);
data/eventstat-0.04.11/eventstat.c:495:13:  [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("/run/systemd/container", R_OK) == 0)
data/eventstat-0.04.11/eventstat.c:999:9:  [4] (format) fprintf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
		(void)fprintf(fp, ",%" PRIu64,
data/eventstat-0.04.11/eventstat.c:1303:9:  [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.
		(void)snprintf(ident, sizeof(ident), "%x%s%8.8s%" PRIx64,
data/eventstat-0.04.11/eventstat.c:1437:6:  [4] (format) vsnprintf:
  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.
	n = vsnprintf(buf, sizeof(buf), fmt, ap);
data/eventstat-0.04.11/eventstat.c:1446:34:  [4] (format) printf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
	(void)(g_curses_init ? printw : printf)("%s", buf);
data/eventstat-0.04.11/eventstat.c:1757:8:  [4] (buffer) sscanf:
  The scanf() family's %s operation, without a limit specification, permits
  buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a
  different input function.
			if (sscanf(tmpptr, "%s %*s %*s %*f: hrtimer_start: hrtimer=%" PRIx64 " function=%s", task, &info.timer, func) != 3)
data/eventstat-0.04.11/eventstat.c:1865:11:  [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.
		int c = getopt(argc, argv, "bcCdksSlhin:qr:t:Tuw");
data/eventstat-0.04.11/eventstat.c:268: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[32];
data/eventstat-0.04.11/eventstat.c:274: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).
	fd = open("/proc/sys/kernel/pid_max", O_RDONLY);
data/eventstat-0.04.11/eventstat.c:392: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).
	if ((fd = open(path, O_WRONLY, S_IRUSR | S_IWUSR)) < 0) {
data/eventstat-0.04.11/eventstat.c:421: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[64];
data/eventstat-0.04.11/eventstat.c:498: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).
	fp = fopen("/proc/1/environ", "r");
data/eventstat-0.04.11/eventstat.c:539: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 path[PATH_MAX];
data/eventstat-0.04.11/eventstat.c:582: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[4096], path[PATH_MAX], *ptr = buffer, *endptr, *tmp;
data/eventstat-0.04.11/eventstat.c:591: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).
	if ((fd = open(path, O_RDONLY)) < 0)
data/eventstat-0.04.11/eventstat.c:846: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[256];
data/eventstat-0.04.11/eventstat.c:852: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).
	if ((fd = open(buffer, O_RDONLY)) < 0)
data/eventstat-0.04.11/eventstat.c:888: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[4096];
data/eventstat-0.04.11/eventstat.c:895: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).
	if ((fd = open(buffer, O_RDONLY)) < 0)
data/eventstat-0.04.11/eventstat.c:960:12:  [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).
	if ((fp = fopen(filename, "w")) == NULL) {
data/eventstat-0.04.11/eventstat.c:1300: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 ident[128];
data/eventstat-0.04.11/eventstat.c:1434: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[256], *eol;
data/eventstat-0.04.11/eventstat.c:1655: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).
	if ((fd = open(g_sys_tracing_pipe, O_RDONLY)) < 0)
data/eventstat-0.04.11/eventstat.c:1662:10:  [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 buffer[EVENT_BUF_SIZE];
data/eventstat-0.04.11/eventstat.c:1707:9:  [2] (buffer) memcpy:
  Does not check for buffer overflows when copying to destination (CWE-120).
  Make sure destination can always hold the source data.
		(void)memcpy(g_get_events_buf + size, buffer, ret);
data/eventstat-0.04.11/eventstat.c:1735: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 func[64], task[64];
data/eventstat-0.04.11/eventstat.c:277:6:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	n = read(fd, buf, sizeof(buf) - 1);
data/eventstat-0.04.11/eventstat.c:390: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).
	const ssize_t len = (ssize_t)strlen(str);
data/eventstat-0.04.11/eventstat.c:503:12:  [1] (buffer) getc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
		int ch = getc(fp);
data/eventstat-0.04.11/eventstat.c:515:10:  [1] (buffer) getc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
				ch = getc(fp);
data/eventstat-0.04.11/eventstat.c:594:8:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	len = read(fd, buffer, sizeof(buffer) - 1);
data/eventstat-0.04.11/eventstat.c:855:8:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	ret = read(fd, buffer, sizeof(buffer));
data/eventstat-0.04.11/eventstat.c:869: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).
		size_t len = strlen(buffer) + 3;
data/eventstat-0.04.11/eventstat.c:898:8:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	ret = read(fd, buffer, sizeof(buffer));
data/eventstat-0.04.11/eventstat.c:1683:9:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
		ret = read(fd, buffer, sizeof(buffer));
data/eventstat-0.04.11/eventstat.c:1726:30:  [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).
	const size_t app_name_len = strlen(g_app_name);

ANALYSIS SUMMARY:

Hits = 39
Lines analyzed = 2077 in approximately 0.08 seconds (26787 lines/second)
Physical Source Lines of Code (SLOC) = 1513
Hits@level = [0]  39 [1]  10 [2]  19 [3]   1 [4]   9 [5]   0
Hits@level+ = [0+]  78 [1+]  39 [2+]  29 [3+]  10 [4+]   9 [5+]   0
Hits/KSLOC@level+ = [0+] 51.5532 [1+] 25.7766 [2+] 19.1672 [3+] 6.60939 [4+] 5.94845 [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.