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/golang-github-containers-storage-1.23.9+dfsg1/pkg/unshare/unshare.c

FINAL RESULTS:

data/golang-github-containers-storage-1.23.9+dfsg1/pkg/unshare/unshare.c:187:6:  [5] (race) readlink:
  This accepts filename arguments; if an attacker can move those files or
  change the link content, a race condition results. Also, it does not
  terminate with ASCII NUL. (CWE-362, CWE-20). Reconsider approach.
	if (readlink("/proc/self/exe", src, sizeof (src) - 1) < 0)
data/golang-github-containers-storage-1.23.9+dfsg1/pkg/unshare/unshare.c:62:6:  [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.
	p = getenv(envname);
data/golang-github-containers-storage-1.23.9+dfsg1/pkg/unshare/unshare.c:79: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/golang-github-containers-storage-1.23.9+dfsg1/pkg/unshare/unshare.c:83: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(path, "r");
data/golang-github-containers-storage-1.23.9+dfsg1/pkg/unshare/unshare.c:91:8:  [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).
			r = atoi(buf);
data/golang-github-containers-storage-1.23.9+dfsg1/pkg/unshare/unshare.c:107: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(list, O_RDONLY);
data/golang-github-containers-storage-1.23.9+dfsg1/pkg/unshare/unshare.c:171: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 src[PATH_MAX] = {0};
data/golang-github-containers-storage-1.23.9+dfsg1/pkg/unshare/unshare.c:172: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 template[64] = {0};
data/golang-github-containers-storage-1.23.9+dfsg1/pkg/unshare/unshare.c:180:7:  [2] (tmpfile) mkstemp:
  Potential for temporary file vulnerability in some circumstances. Some
  older Unix-like systems create temp files with permission to write by all
  by default, so be sure to set the umask to override this. Also, some older
  Unix systems might fail to use O_EXCL when opening the file, so make sure
  that O_EXCL is used by the library (CWE-377).
	fd = mkstemp(template);
data/golang-github-containers-storage-1.23.9+dfsg1/pkg/unshare/unshare.c:196:8:  [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).
	ret = open(template, O_PATH | O_CLOEXEC);
data/golang-github-containers-storage-1.23.9+dfsg1/pkg/unshare/unshare.c:223: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[2048];
data/golang-github-containers-storage-1.23.9+dfsg1/pkg/unshare/unshare.c:225: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/self/exe", O_RDONLY | O_CLOEXEC);
data/golang-github-containers-storage-1.23.9+dfsg1/pkg/unshare/unshare.c:302: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[2048];
data/golang-github-containers-storage-1.23.9+dfsg1/pkg/unshare/unshare.c:125:7:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
		n = read(fd, buf + used, size - used - 1);
data/golang-github-containers-storage-1.23.9+dfsg1/pkg/unshare/unshare.c:174:2:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120). Risk is low because the source is a
  constant string.
	strncpy(template, "/tmp/containers.XXXXXX", sizeof(template) - 1);
data/golang-github-containers-storage-1.23.9+dfsg1/pkg/unshare/unshare.c:242:12:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
		n_read = read(fd, buf, sizeof(buf));
data/golang-github-containers-storage-1.23.9+dfsg1/pkg/unshare/unshare.c:319:35:  [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 size = write(pidfd, buf, strlen(buf));
data/golang-github-containers-storage-1.23.9+dfsg1/pkg/unshare/unshare.c:320: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).
		if (size != strlen(buf)) {
data/golang-github-containers-storage-1.23.9+dfsg1/pkg/unshare/unshare.c:328:7:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
		n = read(continuefd, buf, sizeof(buf));

ANALYSIS SUMMARY:

Hits = 19
Lines analyzed = 378 in approximately 0.11 seconds (3371 lines/second)
Physical Source Lines of Code (SLOC) = 319
Hits@level = [0]  26 [1]   6 [2]  11 [3]   1 [4]   0 [5]   1
Hits@level+ = [0+]  45 [1+]  19 [2+]  13 [3+]   2 [4+]   1 [5+]   1
Hits/KSLOC@level+ = [0+] 141.066 [1+] 59.5611 [2+] 40.7524 [3+] 6.26959 [4+] 3.1348 [5+] 3.1348
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.