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/libocxl-1.1.0/samples/memcpy/memcpy.c
Examining data/libocxl-1.1.0/src/afu.c
Examining data/libocxl-1.1.0/src/include/libocxl.h
Examining data/libocxl-1.1.0/src/internal.c
Examining data/libocxl-1.1.0/src/irq.c
Examining data/libocxl-1.1.0/src/libocxl_internal.h
Examining data/libocxl-1.1.0/src/mmio.c
Examining data/libocxl-1.1.0/src/setup.c
Examining data/libocxl-1.1.0/unittests/unittests.c
Examining data/libocxl-1.1.0/unittests/virtocxl.c

FINAL RESULTS:

data/libocxl-1.1.0/samples/memcpy/memcpy.c:35:28:  [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.
#define LOG_ERR(fmt, x...) fprintf(stderr, fmt, ##x)
data/libocxl-1.1.0/samples/memcpy/memcpy.c:36:28:  [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.
#define LOG_INF(fmt, x...) printf(fmt, ##x)
data/libocxl-1.1.0/src/internal.c:98:25:  [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.
__attribute__ ((format (printf, 5, 6)))
data/libocxl-1.1.0/src/internal.c:108:2:  [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.
	vfprintf(stderr, format, ap);
data/libocxl-1.1.0/src/internal.c:124:25:  [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.
__attribute__ ((format (printf, 3, 4)))
data/libocxl-1.1.0/src/internal.c:134:4:  [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.
			vsnprintf(buf, sizeof(buf), format, ap);
data/libocxl-1.1.0/src/internal.c:144:4:  [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.
			vsnprintf(buf, sizeof(buf), format, ap);
data/libocxl-1.1.0/samples/memcpy/memcpy.c:582: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, "+hs:it:v"
data/libocxl-1.1.0/src/internal.c:67:8:  [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.
	val = getenv("LIBOCXL_INFO");
data/libocxl-1.1.0/src/internal.c:72:8:  [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.
	val = getenv("LIBOCXL_TRACE_ALL");
data/libocxl-1.1.0/src/internal.c:78:8:  [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.
	val = getenv("LIBOCXL_VERBOSE_ERRORS_ALL");
data/libocxl-1.1.0/samples/memcpy/memcpy.c:603:30:  [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).
			args.completion_timeout = atoi(optarg);
data/libocxl-1.1.0/src/afu.c:357: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((char *)afu->identifier.afu_name, dev_ent->d_name, afu_name_len);
data/libocxl-1.1.0/src/afu.c:415:11:  [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 fd = open(afu->device_path, O_RDWR | O_CLOEXEC | O_NONBLOCK);
data/libocxl-1.1.0/src/afu.c:564: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 pattern[PATH_MAX];
data/libocxl-1.1.0/src/include/libocxl.h:68: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.
	const char afu_name[AFU_NAME_MAX + 1];	/**< The name of the AFU */
data/libocxl-1.1.0/src/internal.c:132:4:  [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[MAX_MESSAGE_LENGTH];
data/libocxl-1.1.0/src/internal.c:142:4:  [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[MAX_MESSAGE_LENGTH];
data/libocxl-1.1.0/src/irq.c:323: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[event_size];
data/libocxl-1.1.0/src/mmio.c:98: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 + 1];
data/libocxl-1.1.0/src/mmio.c:106:11:  [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 fd = open(path, O_RDWR | O_CLOEXEC);
data/libocxl-1.1.0/unittests/unittests.c:53: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 suite[SUITE_NAME_LEN+1];
data/libocxl-1.1.0/unittests/unittests.c:54: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 name[TEST_NAME_LEN+1];
data/libocxl-1.1.0/unittests/unittests.c:452: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 expected_path[PATH_MAX];
data/libocxl-1.1.0/unittests/unittests.c:938:1:  [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 err_buf[MAX_MESSAGE_LENGTH];
data/libocxl-1.1.0/unittests/virtocxl.c:54: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[KERNEL_EVENT_SIZE];
data/libocxl-1.1.0/unittests/virtocxl.c:75: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(buf, &header, sizeof(header));
data/libocxl-1.1.0/unittests/virtocxl.c:76: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(buf + sizeof(header), &translation_fault, sizeof(translation_fault));
data/libocxl-1.1.0/unittests/virtocxl.c:132: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 device_name[DEVICE_NAME_MAX];
data/libocxl-1.1.0/unittests/virtocxl.c:143: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 dev_name[PATH_MAX+9] = "DEVNAME=";
data/libocxl-1.1.0/unittests/virtocxl.c:196: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 sysfs_base[PATH_MAX];
data/libocxl-1.1.0/unittests/virtocxl.c:197: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 tmp[PATH_MAX];
data/libocxl-1.1.0/unittests/virtocxl.c:198: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/libocxl-1.1.0/src/afu.c:360: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).
	size_t dev_path_len = strlen(DEVICE_PATH) + 1 + strlen(dev_ent->d_name) + 1;
data/libocxl-1.1.0/src/afu.c:360:50:  [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 dev_path_len = strlen(DEVICE_PATH) + 1 + strlen(dev_ent->d_name) + 1;
data/libocxl-1.1.0/src/afu.c:368:26:  [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 sysfs_path_len = strlen(SYS_PATH) + 1 + strlen(dev_ent->d_name) + 1;
data/libocxl-1.1.0/src/afu.c:368:49:  [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 sysfs_path_len = strlen(SYS_PATH) + 1 + strlen(dev_ent->d_name) + 1;
data/libocxl-1.1.0/src/irq.c:326:18:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	if ((buf_used = read(afu->fd, buf, event_size)) < 0) {
data/libocxl-1.1.0/src/irq.c:450:15:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
			buf_used = read(info->irq->event.eventfd, &count, sizeof(count));
data/libocxl-1.1.0/unittests/unittests.c:110:2:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
	strncpy(tests[current_test].suite, suite, sizeof(tests->suite));
data/libocxl-1.1.0/unittests/unittests.c:111:2:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
	strncpy(tests[current_test].name, name, sizeof(tests->name));
data/libocxl-1.1.0/unittests/unittests.c:144:13:  [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).
		int len = strlen(tests[test].suite);
data/libocxl-1.1.0/unittests/unittests.c:149: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(tests[test].name);
data/libocxl-1.1.0/unittests/virtocxl.c:145:2:  [1] (buffer) strncat:
  Easily used incorrectly (e.g., incorrectly computing the correct maximum
  size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf,
  or automatically resizing strings.
	strncat(dev_name, info->device_name, sizeof(dev_name) - 9);

ANALYSIS SUMMARY:

Hits = 44
Lines analyzed = 4965 in approximately 0.28 seconds (17796 lines/second)
Physical Source Lines of Code (SLOC) = 2820
Hits@level = [0]  40 [1]  11 [2]  22 [3]   4 [4]   7 [5]   0
Hits@level+ = [0+]  84 [1+]  44 [2+]  33 [3+]  11 [4+]   7 [5+]   0
Hits/KSLOC@level+ = [0+] 29.7872 [1+] 15.6028 [2+] 11.7021 [3+] 3.90071 [4+] 2.48227 [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.