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/moon-buggy-1.0.51/moon-buggy.h
Examining data/moon-buggy-1.0.51/main.c
Examining data/moon-buggy-1.0.51/mode.c
Examining data/moon-buggy-1.0.51/title.c
Examining data/moon-buggy-1.0.51/pager.c
Examining data/moon-buggy-1.0.51/copying.h
Examining data/moon-buggy-1.0.51/game.c
Examining data/moon-buggy-1.0.51/level.c
Examining data/moon-buggy-1.0.51/ground.c
Examining data/moon-buggy-1.0.51/buggy.c
Examining data/moon-buggy-1.0.51/buggy.h
Examining data/moon-buggy-1.0.51/laser.c
Examining data/moon-buggy-1.0.51/meteor.c
Examining data/moon-buggy-1.0.51/highscore.c
Examining data/moon-buggy-1.0.51/realname.c
Examining data/moon-buggy-1.0.51/queue.c
Examining data/moon-buggy-1.0.51/vclock.c
Examining data/moon-buggy-1.0.51/date.c
Examining data/moon-buggy-1.0.51/persona.c
Examining data/moon-buggy-1.0.51/signal.c
Examining data/moon-buggy-1.0.51/keyboard.c
Examining data/moon-buggy-1.0.51/terminal.c
Examining data/moon-buggy-1.0.51/cursor.c
Examining data/moon-buggy-1.0.51/random.c
Examining data/moon-buggy-1.0.51/error.c
Examining data/moon-buggy-1.0.51/xmalloc.c
Examining data/moon-buggy-1.0.51/xstrdup.c
Examining data/moon-buggy-1.0.51/darray.h
Examining data/moon-buggy-1.0.51/hpath.c

FINAL RESULTS:

data/moon-buggy-1.0.51/highscore.c:210:5:  [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 (highscore[i].name, name, MAX_NAME_CHARS);
data/moon-buggy-1.0.51/highscore.c:244:5:  [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 (highscore[i].name, name, MAX_NAME_CHARS);
data/moon-buggy-1.0.51/error.c:33: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, format, ap);
data/moon-buggy-1.0.51/highscore.c:67:5:  [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 (res, dir);
data/moon-buggy-1.0.51/highscore.c:69:5:  [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, name);
data/moon-buggy-1.0.51/highscore.c:141: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 (highscore[n].name, names[uniform_rnd(13)]);
data/moon-buggy-1.0.51/keyboard.c:417:2:  [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 (buffer, keys[i].data[k].name);
data/moon-buggy-1.0.51/keyboard.c:422: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 (buffer, b[i].desc);
data/moon-buggy-1.0.51/moon-buggy.h:203:53:  [4] (format) printf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
	__attribute__ ((noreturn)) __attribute__ ((format (printf, 1, 2)));
data/moon-buggy-1.0.51/xstrdup.c:21: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, str);
data/moon-buggy-1.0.51/main.c:164:9:  [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.
    c = getopt_long (argc, argv, MB_SHORT_OPTIONS, long_options, &ind);
data/moon-buggy-1.0.51/main.c:166:9:  [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.
    c = getopt (argc, argv, MB_SHORT_OPTIONS);
data/moon-buggy-1.0.51/random.c:23:3:  [3] (random) srand:
  This function is not sufficiently random for security-related functions
  such as key and nonce creation (CWE-327). Use a more secure technique for
  acquiring random values.
  srand (time (0));
data/moon-buggy-1.0.51/date.c:58:3:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
  sprintf (buffer, "%d-%d-%d %d:%d:%d",
data/moon-buggy-1.0.51/date.c:72:3:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
  sprintf (buffer, "%4d-%02d-%02d",
data/moon-buggy-1.0.51/date.c:86:5:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
    sprintf (buffer, "soon");
data/moon-buggy-1.0.51/date.c:88:5:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
    sprintf (buffer, " -- ");
data/moon-buggy-1.0.51/date.c:90:5:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
    sprintf (buffer, "%3dd", (int)(dt/day+0.5));
data/moon-buggy-1.0.51/date.c:92:5:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
    sprintf (buffer, "%3dh", (int)(dt/hour+0.5));
data/moon-buggy-1.0.51/date.c:94:5:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
    sprintf (buffer, "%3dm", (int)(dt/60+0.5));
data/moon-buggy-1.0.51/highscore.c:52: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 [MAX_NAME_CHARS];
data/moon-buggy-1.0.51/highscore.c:122:5:  [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 (last, entry, sizeof (struct score_entry));
data/moon-buggy-1.0.51/highscore.c:133:16:  [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 const char *names [13] = {
data/moon-buggy-1.0.51/highscore.c:197:5:  [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 [MAX_NAME_CHARS+1];
data/moon-buggy-1.0.51/highscore.c:229:5:  [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  date [MAX_DATE_CHARS];
data/moon-buggy-1.0.51/highscore.c:230:5:  [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 [MAX_NAME_CHARS+1];
data/moon-buggy-1.0.51/highscore.c:280: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.
      char buffer [80];
data/moon-buggy-1.0.51/highscore.c:281:7:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
      sprintf (buffer, "Invalid score file version %d", version);
data/moon-buggy-1.0.51/highscore.c:306:5:  [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  date [MAX_DATE_CHARS];
data/moon-buggy-1.0.51/highscore.c:365:10:  [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 (name, flags, mode);
data/moon-buggy-1.0.51/highscore.c:514:5:  [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  date [16];
data/moon-buggy-1.0.51/highscore.c:515:5:  [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  expire [16];
data/moon-buggy-1.0.51/highscore.c:574:5:  [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  date [16];
data/moon-buggy-1.0.51/highscore.c:575:5:  [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  expire [16];
data/moon-buggy-1.0.51/keyboard.c:168: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.
  static  char  buffer [8];
data/moon-buggy-1.0.51/keyboard.c:228:7:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
      sprintf (buffer, "F%d", i);
data/moon-buggy-1.0.51/keyboard.c:238:5:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
    sprintf (buffer, "%c", key);
data/moon-buggy-1.0.51/keyboard.c:242:5:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
    sprintf (buffer, "C-%c", key+'a'-1);
data/moon-buggy-1.0.51/keyboard.c:250: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 [8];
data/moon-buggy-1.0.51/keyboard.c:410:8:  [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 (buffer, "  ");
data/moon-buggy-1.0.51/queue.c:167: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 [16];
data/moon-buggy-1.0.51/realname.c:58:5:  [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  tmpl [100];
data/moon-buggy-1.0.51/realname.c:65:7:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
      sprintf (tmpl, "please enter your name (default: \"%%.%ds\"): ", size);
data/moon-buggy-1.0.51/realname.c:70:7:  [2] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf. Risk is low because the source has a constant maximum length.
      sprintf (tmpl, "please enter your name (default: \"%%.%ds..\"): ",
data/moon-buggy-1.0.51/highscore.c:66: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).
    res = xmalloc (strlen(dir) + 1 + strlen(name) + 1);
data/moon-buggy-1.0.51/highscore.c:66:38:  [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 = xmalloc (strlen(dir) + 1 + strlen(name) + 1);
data/moon-buggy-1.0.51/highscore.c:68:5:  [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/moon-buggy-1.0.51/highscore.c:363:10:  [1] (access) umask:
  Ensure that umask is given most restrictive possible setting (e.g., 066 or
  077) (CWE-732).
  mask = umask (0);
data/moon-buggy-1.0.51/highscore.c:370:3:  [1] (access) umask:
  Ensure that umask is given most restrictive possible setting (e.g., 066 or
  077) (CWE-732).
  umask (mask);
data/moon-buggy-1.0.51/keyboard.c:274: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).
  if (strlen (aa->name) < strlen (bb->name))  return -1;
data/moon-buggy-1.0.51/keyboard.c:274: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).
  if (strlen (aa->name) < strlen (bb->name))  return -1;
data/moon-buggy-1.0.51/keyboard.c:275: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).
  if (strlen (aa->name) > strlen (bb->name))  return +1;
data/moon-buggy-1.0.51/keyboard.c:275: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).
  if (strlen (aa->name) > strlen (bb->name))  return +1;
data/moon-buggy-1.0.51/keyboard.c:299: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).
    x += 2 + strlen(b[i].desc);	/* "x:desc" */
data/moon-buggy-1.0.51/keyboard.c:314:16:  [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 -= 1 + strlen(b[i].desc); /* ":desc" */
data/moon-buggy-1.0.51/keyboard.c:324: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).
	x += strlen (keys[i].data[k].name);
data/moon-buggy-1.0.51/keyboard.c:370:6:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
	    strncpy (keys[i].data[k].name, name, 7);
data/moon-buggy-1.0.51/keyboard.c:405: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 (buffer, ",");
data/moon-buggy-1.0.51/keyboard.c:412:8:  [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 (buffer, " ");
data/moon-buggy-1.0.51/keyboard.c:421:7:  [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 (buffer, ":");
data/moon-buggy-1.0.51/main.c:53:16:  [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 (str);
data/moon-buggy-1.0.51/queue.c:175:10:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  while (read (0, buffer, 16) == 16)
data/moon-buggy-1.0.51/realname.c:44:7:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
      strncpy (buffer, my_passwd->pw_gecos, size);
data/moon-buggy-1.0.51/realname.c:63:5:  [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).
		- strlen("please enter your name (default: \"\"): "));
data/moon-buggy-1.0.51/realname.c:87:5:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
    strncpy (buffer, tmp+start, size-start);
data/moon-buggy-1.0.51/xstrdup.c:20: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).
  char *tmp = xmalloc (strlen(str) + 1);
data/moon-buggy-1.0.51/xstrdup.c:41:3:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
  strncpy (tmp, str, n);

ANALYSIS SUMMARY:

Hits = 67
Lines analyzed = 5154 in approximately 0.14 seconds (36626 lines/second)
Physical Source Lines of Code (SLOC) = 4076
Hits@level = [0]  10 [1]  23 [2]  31 [3]   3 [4]   8 [5]   2
Hits@level+ = [0+]  77 [1+]  67 [2+]  44 [3+]  13 [4+]  10 [5+]   2
Hits/KSLOC@level+ = [0+] 18.8911 [1+] 16.4377 [2+] 10.7949 [3+] 3.1894 [4+] 2.45339 [5+] 0.490677
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.