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/libubootenv-0.3/src/fw_printenv.c
Examining data/libubootenv-0.3/src/fw_setenv.c
Examining data/libubootenv-0.3/src/libuboot.h
Examining data/libubootenv-0.3/src/uboot_env.c
Examining data/libubootenv-0.3/src/uboot_private.h

FINAL RESULTS:

data/libubootenv-0.3/src/uboot_env.c:187:2:  [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.
	snprintf(filename, sizeof(filename), SYS_UBI_VOLUME_COUNT, dev_id);
data/libubootenv-0.3/src/uboot_env.c:214:2:  [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.
	snprintf(filename, sizeof(filename), SYS_UBI_VOLUME_NAME, dev_id, dev_id, vol_id);
data/libubootenv-0.3/src/uboot_env.c:225:6:  [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(data, "%s", vol_name) != 1)
data/libubootenv-0.3/src/uboot_env.c:278:3:  [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.
		sscanf(sep + 1, "%s", &volume[0]);
data/libubootenv-0.3/src/uboot_env.c:288:3:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
		sprintf(dev->devname, "%s_%d", device, vol_id);
data/libubootenv-0.3/src/uboot_env.c:570: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(sysfs_path, W_OK) == -1) {
data/libubootenv-0.3/src/uboot_env.c:797:29:  [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 (entry->type || entry->access)
data/libubootenv-0.3/src/uboot_env.c:814:30:  [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 (entry->type || entry->access) {
data/libubootenv-0.3/src/uboot_env.c:819:30:  [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.
						access_tostring(entry->access));
data/libubootenv-0.3/src/uboot_env.c:1202:17:  [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.
	switch (entry->access) {
data/libubootenv-0.3/src/uboot_private.h:102:19:  [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.
	access_attribute access;
data/libubootenv-0.3/src/fw_printenv.c:84:14:  [3] (buffer) getopt_long:
  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.
	while ((c = getopt_long(argc, argv, options,
data/libubootenv-0.3/src/uboot_env.c:1161:16:  [3] (buffer) realpath:
  This function does not protect against buffer overflows, and some
  implementations can overflow internally (CWE-120/CWE-785!). Ensure that the
  destination buffer is at least of size MAXPATHLEN, andto protect against
  implementation problems, the input argument should also be checked to
  ensure it is no larger than MAXPATHLEN.
			if ((path = realpath(tmp, NULL)) == NULL) {
data/libubootenv-0.3/src/uboot_env.c:62: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).
	lockfd = open(lockname, O_WRONLY | O_CREAT | O_TRUNC, 0666);
data/libubootenv-0.3/src/uboot_env.c:179: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 filename[DEVNAME_MAX_LENGTH];
data/libubootenv-0.3/src/uboot_env.c:180: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 data[DEVNAME_MAX_LENGTH];
data/libubootenv-0.3/src/uboot_env.c:188: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(filename, O_RDONLY);
data/libubootenv-0.3/src/uboot_env.c:204:32:  [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 int ubi_get_volume_name(char *device, int vol_id, char vol_name[DEVNAME_MAX_LENGTH])
data/libubootenv-0.3/src/uboot_env.c:204:58:  [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 int ubi_get_volume_name(char *device, int vol_id, char vol_name[DEVNAME_MAX_LENGTH])
data/libubootenv-0.3/src/uboot_env.c:206: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 filename[80];
data/libubootenv-0.3/src/uboot_env.c:207: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 data[DEVNAME_MAX_LENGTH];
data/libubootenv-0.3/src/uboot_env.c:215: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(filename, O_RDONLY);
data/libubootenv-0.3/src/uboot_env.c:247: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 name[DEVNAME_MAX_LENGTH];
data/libubootenv-0.3/src/uboot_env.c:266: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[DEVNAME_MAX_LENGTH];
data/libubootenv-0.3/src/uboot_env.c:267: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 volume[DEVNAME_MAX_LENGTH];
data/libubootenv-0.3/src/uboot_env.c:275:3:  [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(device, dev->devname, sep - dev->devname);
data/libubootenv-0.3/src/uboot_env.c:315: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(dev->devname, O_RDONLY);
data/libubootenv-0.3/src/uboot_env.c:500: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).
	dev->fd = open(dev->devname, O_RDONLY);
data/libubootenv-0.3/src/uboot_env.c:574: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).
	fd_force_ro = open(sysfs_path, O_RDWR);
data/libubootenv-0.3/src/uboot_env.c:713: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).
	dev->fd = open(dev->devname, O_RDWR);
data/libubootenv-0.3/src/uboot_env.c:744: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).
	dev->fd = open(dev->devname, O_RDWR);
data/libubootenv-0.3/src/uboot_env.c:867:11:  [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.
	unsigned char flags[2];
data/libubootenv-0.3/src/uboot_env.c:1069:8:  [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(filename, "r");
data/libubootenv-0.3/src/uboot_env.c:1124: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(config, "r");
data/libubootenv-0.3/src/uboot_private.h:69: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 			devname[DEVNAME_MAX_LENGTH];
data/libubootenv-0.3/src/uboot_env.c:155: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).
	if (!strncmp(device, DEVICE_MTD_NAME, strlen(DEVICE_MTD_NAME)))
data/libubootenv-0.3/src/uboot_env.c:157:45:  [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).
	else if (!strncmp(device, DEVICE_UBI_NAME, strlen(DEVICE_UBI_NAME)))
data/libubootenv-0.3/src/uboot_env.c:159:11:  [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).
	else if (strlen(device) > 0)
data/libubootenv-0.3/src/uboot_env.c:192:6:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	n = read(fd, data, sizeof(data));
data/libubootenv-0.3/src/uboot_env.c:220:6:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	n = read(fd, data, DEVNAME_MAX_LENGTH);
data/libubootenv-0.3/src/uboot_env.c:410:8:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	ret = read(dev->fd, data, dev->envsize);
data/libubootenv-0.3/src/uboot_env.c:431:9:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
		ret = read(dev->fd, data, dev->envsize);
data/libubootenv-0.3/src/uboot_env.c:467:8:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
			if (read(dev->fd, data, blocksize) != blocksize) {
data/libubootenv-0.3/src/uboot_env.c:485:8:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	ret = read(dev->fd, data, dev->envsize);
data/libubootenv-0.3/src/uboot_env.c:794: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).
		if ((strlen(entry->name) + strlen(entry->value) + 2) > size) 
data/libubootenv-0.3/src/uboot_env.c:794: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).
		if ((strlen(entry->name) + strlen(entry->value) + 2) > size) 
data/libubootenv-0.3/src/uboot_env.c:993:39:  [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).
		while (*pvar && (pvar - flagsvar) < strlen(flagsvar)) {
data/libubootenv-0.3/src/uboot_env.c:1002: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).
				pnext = flagsvar + strlen(flagsvar);
data/libubootenv-0.3/src/uboot_env.c:1008:25:  [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).
				for (int i = 0; i < strlen(pval); i++) {
data/libubootenv-0.3/src/uboot_env.c:1080: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(buf);
data/libubootenv-0.3/src/uboot_env.c:1097: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).
		if (!strlen(value))
data/libubootenv-0.3/src/uboot_env.c:1168:4:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
			strncpy(dev->devname, path, sizeof(dev->devname) - 1);
data/libubootenv-0.3/src/uboot_env.c:1227: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).
		ok_type = strlen(value) > 2 && (value[0] == 0) &&
data/libubootenv-0.3/src/uboot_env.c:1239:45:  [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).
 			value[0] == 'N' || value[0] == 'F') && (strlen(value) != 1);
data/libubootenv-0.3/src/uboot_env.c:1346:4:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
			strncpy(dev->devname, envdevs->devname, sizeof(dev->devname) - 1);

ANALYSIS SUMMARY:

Hits = 55
Lines analyzed = 1897 in approximately 0.06 seconds (32246 lines/second)
Physical Source Lines of Code (SLOC) = 1396
Hits@level = [0]  22 [1]  20 [2]  22 [3]   2 [4]  11 [5]   0
Hits@level+ = [0+]  77 [1+]  55 [2+]  35 [3+]  13 [4+]  11 [5+]   0
Hits/KSLOC@level+ = [0+] 55.1576 [1+] 39.3983 [2+] 25.0716 [3+] 9.31232 [4+] 7.87966 [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.