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/rng-tools-debian-2.3/contrib/randstat.c
Examining data/rng-tools-debian-2.3/exits.h
Examining data/rng-tools-debian-2.3/fips.c
Examining data/rng-tools-debian-2.3/fips.h
Examining data/rng-tools-debian-2.3/rngd.c
Examining data/rng-tools-debian-2.3/rngd.h
Examining data/rng-tools-debian-2.3/rngd_entsource.c
Examining data/rng-tools-debian-2.3/rngd_entsource.h
Examining data/rng-tools-debian-2.3/rngd_linux.c
Examining data/rng-tools-debian-2.3/rngd_linux.h
Examining data/rng-tools-debian-2.3/rngd_signals.c
Examining data/rng-tools-debian-2.3/rngd_signals.h
Examining data/rng-tools-debian-2.3/rngd_threads.c
Examining data/rng-tools-debian-2.3/rngd_threads.h
Examining data/rng-tools-debian-2.3/rngtest.c
Examining data/rng-tools-debian-2.3/stats.c
Examining data/rng-tools-debian-2.3/stats.h
Examining data/rng-tools-debian-2.3/util.c
Examining data/rng-tools-debian-2.3/util.h
Examining data/rng-tools-debian-2.3/viapadlock-rng.c
Examining data/rng-tools-debian-2.3/viapadlock_engine.c
Examining data/rng-tools-debian-2.3/viapadlock_engine.h

FINAL RESULTS:

data/rng-tools-debian-2.3/viapadlock_engine.c:277:3:  [5] (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. Risk is high; the length parameter
  appears to be a constant, instead of computing the number of characters
  left.
		strncat(devpath, "/msr", sizeof(devpath)-1);
data/rng-tools-debian-2.3/viapadlock_engine.c:288:3:  [5] (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. Risk is high; the length parameter
  appears to be a constant, instead of computing the number of characters
  left.
		strncat(devpath, "/cpuid", sizeof(devpath)-1);
data/rng-tools-debian-2.3/rngd.c:514:3:  [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, fmt, ap);
data/rng-tools-debian-2.3/rngd.c:546:3:  [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, errfmt, ap);
data/rng-tools-debian-2.3/stats.c:104: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(buf, size-1, "%s%s: %" PRIu64 , stat_prefix, msg, value);
data/rng-tools-debian-2.3/viapadlock_engine.c:275:3:  [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(devpath, sizeof(devpath), cpudev_path, i);
data/rng-tools-debian-2.3/viapadlock_engine.c:286:3:  [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(devpath, sizeof(devpath), cpudev_path, i);
data/rng-tools-debian-2.3/contrib/randstat.c:15: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).
	random_fd = open("/dev/random", O_RDONLY);
data/rng-tools-debian-2.3/fips.c:37: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.
const char *fips_test_names[N_FIPS_TESTS] = {
data/rng-tools-debian-2.3/fips.h:52:14:  [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.
extern const char *fips_test_names[N_FIPS_TESTS];
data/rng-tools-debian-2.3/rngd.c:524: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 errbuf[STR_BUF_LEN];
data/rng-tools-debian-2.3/rngd.c:566:25:  [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 (((daemon_lockfd = open(pidfile_name, O_RDWR|O_CREAT, 0644)) == -1)
data/rng-tools-debian-2.3/rngd.c:622: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];
data/rng-tools-debian-2.3/rngd_entsource.c:177: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 tempbuf[4];
data/rng-tools-debian-2.3/rngd_entsource.c:184:13:  [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).
			rng_fd = open(arguments->rng_name, O_RDONLY);
data/rng-tools-debian-2.3/rngd_linux.c:81: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 procname[512];
data/rng-tools-debian-2.3/rngd_linux.c:88:14:  [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(procname, "r")) != NULL) &&
data/rng-tools-debian-2.3/rngd_linux.c:109: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 procname[512];
data/rng-tools-debian-2.3/rngd_linux.c:116:14:  [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(procname, "r+")) != NULL) &&
data/rng-tools-debian-2.3/rngd_linux.c:147: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).
	random_fd = open(arguments->random_name, O_RDWR);
data/rng-tools-debian-2.3/rngd_linux.c:189:12:  [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 data[size];
data/rng-tools-debian-2.3/rngd_linux.c:199: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(entropy.data, buf, size);
data/rng-tools-debian-2.3/rngd_linux.c:289:18:  [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.
			p = (unsigned char *)rng_buf[i];
data/rng-tools-debian-2.3/rngd_threads.h:36:18:  [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.
typedef unsigned char rng_buffer_t[FIPS_RNG_BUFFER_SIZE];
data/rng-tools-debian-2.3/rngtest.c:157: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.
unsigned char rng_buffer[FIPS_RNG_BUFFER_SIZE];
data/rng-tools-debian-2.3/rngtest.c:295: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];
data/rng-tools-debian-2.3/rngtest.c:334: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 tempbuf[4];
data/rng-tools-debian-2.3/stats.c:46: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 stat_prefix[20] = "";
data/rng-tools-debian-2.3/stats.c:133: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 unitscaled[20];
data/rng-tools-debian-2.3/viapadlock-rng.c:278: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];
data/rng-tools-debian-2.3/viapadlock-rng.c:317: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 tempbuf[4];
data/rng-tools-debian-2.3/viapadlock_engine.c:136: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 cpudev_path[PATH_MAX+1];
data/rng-tools-debian-2.3/viapadlock_engine.c:260: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 devpath[PATH_MAX+1];
data/rng-tools-debian-2.3/viapadlock_engine.c:278: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).
		msr_fd = open(devpath, O_RDWR);
data/rng-tools-debian-2.3/viapadlock_engine.c:289: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).
		cpuid_fd = open(devpath, O_RDONLY);
data/rng-tools-debian-2.3/viapadlock_engine.c:526: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((unsigned char *)buf + bytes_read, &xstore_buffer, s);
data/rng-tools-debian-2.3/rngd.c:534: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).
	s = strlen(fmt) + strlen(strerrbuf) + 3;
data/rng-tools-debian-2.3/rngd.c:534: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).
	s = strlen(fmt) + strlen(strerrbuf) + 3;
data/rng-tools-debian-2.3/rngd_entsource.c:120:9:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
				r = read(rng_fd, (unsigned char *)buf + off, size);
data/rng-tools-debian-2.3/rngtest.c:226:7:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
		r = read(0, (unsigned char *)buf + off, size);
data/rng-tools-debian-2.3/stats.c:51:3:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
		strncpy(stat_prefix, prefix, sizeof(stat_prefix)-1);
data/rng-tools-debian-2.3/stats.c:78:3:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
		strncpy(unit, baseunit, unitsize - 1);
data/rng-tools-debian-2.3/viapadlock-rng.c:209:7:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
		r = read(0, (unsigned char *)buf + off, size);
data/rng-tools-debian-2.3/viapadlock_engine.c:182:6:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	if (read(cpuid_fd, &cpuid_buf, SIZE) == -1) return errno; \
data/rng-tools-debian-2.3/viapadlock_engine.c:268:2:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
	strncpy(cpudev_path, devicepath, sizeof(cpudev_path));

ANALYSIS SUMMARY:

Hits = 45
Lines analyzed = 4328 in approximately 0.12 seconds (35702 lines/second)
Physical Source Lines of Code (SLOC) = 2687
Hits@level = [0]  53 [1]   9 [2]  29 [3]   0 [4]   5 [5]   2
Hits@level+ = [0+]  98 [1+]  45 [2+]  36 [3+]   7 [4+]   7 [5+]   2
Hits/KSLOC@level+ = [0+] 36.4719 [1+] 16.7473 [2+] 13.3978 [3+] 2.60514 [4+] 2.60514 [5+] 0.744325
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.