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/shared-mime-info-2.0/src/test-subclassing.c
Examining data/shared-mime-info-2.0/src/test-tree-magic.c
Examining data/shared-mime-info-2.0/src/update-mime-database.c
Examining data/shared-mime-info-2.0/tests/mime-detection/cfile.c
Examining data/shared-mime-info-2.0/tests/mime-detection/cplusplusfile.C
Examining data/shared-mime-info-2.0/tests/mime-detection/test-gettext.c

FINAL RESULTS:

data/shared-mime-info-2.0/src/update-mime-database.c:3701: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(mime_dir, F_OK))
data/shared-mime-info-2.0/src/update-mime-database.c:3709: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(package_dir, F_OK))
data/shared-mime-info-2.0/src/update-mime-database.c:2175: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.
	env = getenv("XDG_DATA_DIRS");
data/shared-mime-info-2.0/src/update-mime-database.c:2182: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.
	env = getenv("XDG_DATA_HOME");
data/shared-mime-info-2.0/src/update-mime-database.c:2186:30:  [3] (buffer) g_get_home_dir:
  This function is synonymous with 'getenv("HOME")';it returns untrustable
  input if the environment can beset by an attacker. It 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.
		dirs[n] = g_build_filename(g_get_home_dir(), ".local",
data/shared-mime-info-2.0/src/update-mime-database.c:3652:16:  [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.
	while ((opt = getopt(argc, argv, "hvVn")) != -1)
data/shared-mime-info-2.0/src/test-tree-magic.c:92:20:  [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).
	match->priority = atoi (line + 1);
data/shared-mime-info-2.0/src/test-tree-magic.c:114:12:  [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).
		*depth = atoi (line);
data/shared-mime-info-2.0/src/update-mime-database.c:955:9:  [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).
	return atoi(env);
data/shared-mime-info-2.0/src/update-mime-database.c:968: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(pathname, O_RDWR);
data/shared-mime-info-2.0/src/update-mime-database.c:2239: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 (s, n, len);
data/shared-mime-info-2.0/src/update-mime-database.c:2341:20:  [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).
          weight = atoi (values[i]);
data/shared-mime-info-2.0/src/update-mime-database.c:3556:17:  [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).
	FILE *stream = fopen(filename, "wb");
data/shared-mime-info-2.0/src/test-tree-magic.c:83: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).
	len = strlen (line);
data/shared-mime-info-2.0/src/test-tree-magic.c:220: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).
			lines = g_strsplit (text + strlen ("MIME-TreeMagic") + 2, "\n", 0);
data/shared-mime-info-2.0/src/update-mime-database.c:480: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).
		match->data_length = strlen (NOMAGIC);
data/shared-mime-info-2.0/src/update-mime-database.c:810:7:  [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).
		l = strlen(ent->d_name);
data/shared-mime-info-2.0/src/update-mime-database.c:997: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).
	len = strlen(pathname);
data/shared-mime-info-2.0/src/update-mime-database.c:1986: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).
			l = strlen(ent->d_name);
data/shared-mime-info-2.0/src/update-mime-database.c:1992:14:  [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).
			type_name[strlen(type_name) - 4] = '\0';
data/shared-mime-info-2.0/src/update-mime-database.c:2041:19:  [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).
		fwrite(line, 1, strlen(line), stream);
data/shared-mime-info-2.0/src/update-mime-database.c:2059:19:  [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).
		fwrite(line, 1, strlen(line), stream);
data/shared-mime-info-2.0/src/update-mime-database.c:2100:19:  [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).
		fwrite(line, 1, strlen(line), stream);
data/shared-mime-info-2.0/src/update-mime-database.c:2131:19:  [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).
		fwrite(line, 1, strlen(line), stream);
data/shared-mime-info-2.0/src/update-mime-database.c:2148:18:  [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).
	fwrite(line, 1, strlen(line), stream);
data/shared-mime-info-2.0/src/update-mime-database.c:2252:32:  [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).
  return write_data (cache, n, strlen (n) + 1);
data/shared-mime-info-2.0/src/update-mime-database.c:3395:48:  [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).
  sdata->offset = ALIGN_VALUE (sdata->offset + strlen (str) + 1, 4);
data/shared-mime-info-2.0/src/update-mime-database.c:3691: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).
		int l = strlen(mime_dir);

ANALYSIS SUMMARY:

Hits = 28
Lines analyzed = 4730 in approximately 0.14 seconds (33130 lines/second)
Physical Source Lines of Code (SLOC) = 3791
Hits@level = [0]   4 [1]  15 [2]   7 [3]   4 [4]   2 [5]   0
Hits@level+ = [0+]  32 [1+]  28 [2+]  13 [3+]   6 [4+]   2 [5+]   0
Hits/KSLOC@level+ = [0+] 8.44104 [1+] 7.38591 [2+] 3.42917 [3+] 1.5827 [4+] 0.527565 [5+]   0
Dot directories skipped = 3 (--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.