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/xdg-user-dirs-0.17/xdg-user-dir-lookup.c
Examining data/xdg-user-dirs-0.17/xdg-user-dirs-update.c
Examining data/xdg-user-dirs-0.17/translate.c

FINAL RESULTS:

data/xdg-user-dirs-0.17/xdg-user-dir-lookup.c:71:7:  [4] (buffer) strcpy:
  Does not check for buffer overflows when copying to destination [MS-banned]
  (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy
  easily misused).
      strcpy (config_file, home_dir);
data/xdg-user-dirs-0.17/xdg-user-dir-lookup.c:80:7:  [4] (buffer) strcpy:
  Does not check for buffer overflows when copying to destination [MS-banned]
  (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy
  easily misused).
      strcpy (config_file, config_home);
data/xdg-user-dirs-0.17/xdg-user-dir-lookup.c:140:4:  [4] (buffer) strcpy:
  Does not check for buffer overflows when copying to destination [MS-banned]
  (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy
  easily misused).
	  strcpy (user_dir, home_dir);
data/xdg-user-dirs-0.17/xdg-user-dir-lookup.c:211:7:  [4] (buffer) strcpy:
  Does not check for buffer overflows when copying to destination [MS-banned]
  (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy
  easily misused).
      strcpy (user_dir, home_dir);
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:60:7:  [4] (buffer) strcat:
  Does not check for buffer overflows when concatenating to destination
  [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or
  snprintf (warning: strncat is easily misused).
      strcat (res, next);
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:775:3:  [4] (buffer) strcpy:
  Does not check for buffer overflows when copying to destination [MS-banned]
  (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy
  easily misused).
  strcpy (tmp_file, user_config_file);
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:864:7:  [4] (buffer) strcat:
  Does not check for buffer overflows when concatenating to destination
  [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or
  snprintf (warning: strncat is easily misused).
      strcat (res, translated);
data/xdg-user-dirs-0.17/xdg-user-dir-lookup.c:59:14:  [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.
  home_dir = getenv ("HOME");
data/xdg-user-dirs-0.17/xdg-user-dir-lookup.c:64:17:  [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.
  config_home = getenv ("XDG_CONFIG_HOME");
data/xdg-user-dirs-0.17/xdg-user-dir-lookup.c:199:14:  [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.
  home_dir = getenv ("HOME");
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:285:14:  [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.
  home_env = getenv ("HOME");
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:310:17:  [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.
  config_home = getenv ("XDG_CONFIG_HOME");
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:404:17:  [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.
  config_dirs = getenv ("XDG_CONFIG_DIRS");
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:1021:25:  [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.
      char *data_dirs = getenv ("XDG_DATA_DIRS");
data/xdg-user-dirs-0.17/xdg-user-dir-lookup.c:53: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 buffer[512];
data/xdg-user-dirs-0.17/xdg-user-dir-lookup.c:72:7:  [2] (buffer) strcat:
  Does not check for buffer overflows when concatenating to destination
  [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or
  snprintf (warning: strncat is easily misused). Risk is low because the
  source is a constant string.
      strcat (config_file, "/.config/user-dirs.dirs");
data/xdg-user-dirs-0.17/xdg-user-dir-lookup.c:81:7:  [2] (buffer) strcat:
  Does not check for buffer overflows when concatenating to destination
  [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or
  snprintf (warning: strncat is easily misused). Risk is low because the
  source is a constant string.
      strcat (config_file, "/user-dirs.dirs");
data/xdg-user-dirs-0.17/xdg-user-dir-lookup.c:84:10:  [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 = fopen (config_file, "r");
data/xdg-user-dirs-0.17/xdg-user-dir-lookup.c:212:7:  [2] (buffer) strcat:
  Does not check for buffer overflows when concatenating to destination
  [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or
  snprintf (warning: strncat is easily misused). Risk is low because the
  source is a constant string.
      strcat (user_dir, "/Desktop");
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:74: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 (res, start, end - start);
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:469: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 buffer[512];
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:473:10:  [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 = fopen (path, "r");
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:546: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 buffer[512];
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:560:10:  [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 = fopen (paths[0], "r");
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:615: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 buffer[512];
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:624:10:  [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 = fopen (user_config_file, "r");
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:717:10:  [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 = fopen (user_locale_file, "w");
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:776:3:  [2] (buffer) strcat:
  Does not check for buffer overflows when concatenating to destination
  [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or
  snprintf (warning: strncat is easily misused). Risk is low because the
  source is a constant string.
  strcat (tmp_file, "XXXXXX");
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:778:12:  [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).
  tmp_fd = mkstemp (tmp_file);
data/xdg-user-dirs-0.17/xdg-user-dir-lookup.c:67:37:  [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).
      config_file = (char*) malloc (strlen (home_dir) + strlen ("/.config/user-dirs.dirs") + 1);
data/xdg-user-dirs-0.17/xdg-user-dir-lookup.c:67:57:  [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).
      config_file = (char*) malloc (strlen (home_dir) + strlen ("/.config/user-dirs.dirs") + 1);
data/xdg-user-dirs-0.17/xdg-user-dir-lookup.c:76:37:  [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).
      config_file = (char*) malloc (strlen (config_home) + strlen ("/user-dirs.dirs") + 1);
data/xdg-user-dirs-0.17/xdg-user-dir-lookup.c:76:60:  [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).
      config_file = (char*) malloc (strlen (config_home) + strlen ("/user-dirs.dirs") + 1);
data/xdg-user-dirs-0.17/xdg-user-dir-lookup.c:93: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).
      len = strlen (buffer);
data/xdg-user-dirs-0.17/xdg-user-dir-lookup.c:104:29:  [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 (p, type, strlen (type)) != 0)
data/xdg-user-dirs-0.17/xdg-user-dir-lookup.c:106:12:  [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).
      p += strlen (type);
data/xdg-user-dirs-0.17/xdg-user-dir-lookup.c:136: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).
	  user_dir = (char*) malloc (strlen (home_dir) + 1 + strlen (p) + 1);
data/xdg-user-dirs-0.17/xdg-user-dir-lookup.c:136:55:  [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).
	  user_dir = (char*) malloc (strlen (home_dir) + 1 + strlen (p) + 1);
data/xdg-user-dirs-0.17/xdg-user-dir-lookup.c:141:4:  [1] (buffer) strcat:
  Does not check for buffer overflows when concatenating to destination
  [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or
  snprintf (warning: strncat is easily misused). Risk is low because the
  source is a constant character.
	  strcat (user_dir, "/");
data/xdg-user-dirs-0.17/xdg-user-dir-lookup.c:145: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).
	  user_dir = (char*) malloc (strlen (p) + 1);
data/xdg-user-dirs-0.17/xdg-user-dir-lookup.c:152:22:  [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).
      d = user_dir + strlen (user_dir);
data/xdg-user-dirs-0.17/xdg-user-dir-lookup.c:207:34:  [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).
      user_dir = (char*) malloc (strlen (home_dir) + strlen ("/Desktop") + 1);
data/xdg-user-dirs-0.17/xdg-user-dir-lookup.c:207:54:  [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).
      user_dir = (char*) malloc (strlen (home_dir) + strlen ("/Desktop") + 1);
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:54: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 (res) + 1;
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:59:33:  [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).
      res = realloc (res, len + strlen (next) + 1);
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:82: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 strncmp (str, prefix, strlen (prefix)) == 0;
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:114: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 (s);
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:191:23:  [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).
  unescaped = malloc (strlen (escaped) + 1);
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:211:21:  [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).
  escaped = malloc (strlen (unescaped) * 2 + 1);
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:239: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 (utf8_path);
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:366:10:  [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 (p);
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:480: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).
      len = strlen (buffer);
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:496: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).
	  p += strlen ("enabled=");
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:501: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).
	  p += strlen ("filename_encoding=");
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:570: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).
      len = strlen (buffer);
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:633: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).
      len = strlen (buffer);
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:774:22:  [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).
  tmp_file = malloc (strlen (user_config_file) + 6 + 1);
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:861:27:  [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).
      res = realloc (res, strlen (res) + 1 + strlen (translated) + 1);
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:861:46:  [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).
      res = realloc (res, strlen (res) + 1 + strlen (translated) + 1);
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:863:2:  [1] (buffer) strcat:
  Does not check for buffer overflows when concatenating to destination
  [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or
  snprintf (warning: strncat is easily misused). Risk is low because the
  source is a constant character.
	strcat (res, "/");
data/xdg-user-dirs-0.17/xdg-user-dirs-update.c:1104:12:  [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).
	  path += strlen (home);

ANALYSIS SUMMARY:

Hits = 61
Lines analyzed = 1400 in approximately 0.06 seconds (24890 lines/second)
Physical Source Lines of Code (SLOC) = 1092
Hits@level = [0]  25 [1]  32 [2]  15 [3]   7 [4]   7 [5]   0
Hits@level+ = [0+]  86 [1+]  61 [2+]  29 [3+]  14 [4+]   7 [5+]   0
Hits/KSLOC@level+ = [0+] 78.7546 [1+] 55.8608 [2+] 26.5568 [3+] 12.8205 [4+] 6.41026 [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.