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/picosat-965/picosat.h
Examining data/picosat-965/picogcnf.c
Examining data/picosat-965/app.c
Examining data/picosat-965/version.c
Examining data/picosat-965/picomcs.c
Examining data/picosat-965/main.c
Examining data/picosat-965/picomus.c
Examining data/picosat-965/picosat.c

FINAL RESULTS:

data/picosat-965/app.c:15:8:  [4] (shell) popen:
  This causes a new program to execute and is difficult to use safely
  (CWE-78). try using a library call that implements the same functionality
  if available.
FILE * popen (const char *, const char*);
data/picosat-965/app.c:338:7:  [4] (format) sprintf:
  Potential format string problem (CWE-134). Make format string constant.
      sprintf (cmd, GZIP, name);
data/picosat-965/app.c:339:14:  [4] (shell) popen:
  This causes a new program to execute and is difficult to use safely
  (CWE-78). try using a library call that implements the same functionality
  if available.
      file = popen (cmd, "w");
data/picosat-965/app.c:897:4:  [4] (format) sprintf:
  Potential format string problem (CWE-134). Make format string constant.
	  sprintf (cmd, GUNZIP, argv[i]);
data/picosat-965/app.c:898:16:  [4] (shell) popen:
  This causes a new program to execute and is difficult to use safely
  (CWE-78). try using a library call that implements the same functionality
  if available.
	  if ((file = popen (cmd, "r")))
data/picosat-965/app.c:916:4:  [4] (format) sprintf:
  Potential format string problem (CWE-134). Make format string constant.
	  sprintf (cmd, BUNZIP2, argv[i]);
data/picosat-965/app.c:917:16:  [4] (shell) popen:
  This causes a new program to execute and is difficult to use safely
  (CWE-78). try using a library call that implements the same functionality
  if available.
	  if ((file = popen (cmd, "r")))
data/picosat-965/picogcnf.c:34:27:  [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.
#define LOG(ARGS...) do { printf (##ARGS); } while (0)
data/picosat-965/picogcnf.c:45: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/picosat-965/picogcnf.c:55:3:  [4] (format) vprintf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
  vprintf (fmt, ap);
data/picosat-965/picomcs.c:107:3:  [4] (format) vprintf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
  vprintf (fmt, ap);
data/picosat-965/picomus.c:61: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 (stdout, fmt, ap);
data/picosat-965/picomus.c:72: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 (stdout, fmt, ap);
data/picosat-965/picomus.c:141: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 (stdout, fmt, ap);
data/picosat-965/picomus.c:239:7:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
      sprintf (cmd, "gunzip -c %s 2>/dev/null", input_name);
data/picosat-965/picomus.c:240:20:  [4] (shell) popen:
  This causes a new program to execute and is difficult to use safely
  (CWE-78). try using a library call that implements the same functionality
  if available.
      input_file = popen (cmd, "r");
data/picosat-965/picosat.c:376:9:  [4] (format) fprintf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
#define fprintf(...) do { } while (0)
data/picosat-965/picosat.c:377:9:  [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.
#define vfprintf(...) do { } while (0)
data/picosat-965/picosat.c:1171: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 (ps->prefix, str);
data/picosat-965/picosat.c:1259:19:  [4] (shell) popen:
  This causes a new program to execute and is difficult to use safely
  (CWE-78). try using a library call that implements the same functionality
  if available.
  ps->fviscores = popen (
data/picosat-965/picosat.c:1268:3:  [4] (shell) system:
  This causes a new program to execute and is difficult to use safely
  (CWE-78). try using a library call that implements the same functionality
  if available.
  system ("rm -rf /tmp/picosat-viscores");
data/picosat-965/picosat.c:1269:3:  [4] (shell) system:
  This causes a new program to execute and is difficult to use safely
  (CWE-78). try using a library call that implements the same functionality
  if available.
  system ("mkdir /tmp/picosat-viscores");
data/picosat-965/picosat.c:1270:3:  [4] (shell) system:
  This causes a new program to execute and is difficult to use safely
  (CWE-78). try using a library call that implements the same functionality
  if available.
  system ("mkdir /tmp/picosat-viscores/data");
data/picosat-965/picosat.c:1272:3:  [4] (shell) system:
  This causes a new program to execute and is difficult to use safely
  (CWE-78). try using a library call that implements the same functionality
  if available.
  system ("mkdir /tmp/picosat-viscores/gif");
data/picosat-965/picosat.c:3267:2:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
	sprintf (ps->rline[1], "%6s", "");
data/picosat-965/picosat.c:3279:7:  [4] (format) sprintf:
  Potential format string problem (CWE-134). Make format string constant.
      sprintf (ps->rline[x] + y, fmt, name, "");
data/picosat-965/picosat.c:4398:3:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
  sprintf (cmd, "sort -n|nl>%s", name);
data/picosat-965/picosat.c:4400:10:  [4] (shell) popen:
  This causes a new program to execute and is difficult to use safely
  (CWE-78). try using a library call that implements the same functionality
  if available.
  data = popen (cmd, "w");
data/picosat-965/picosat.c:4414:7:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
      sprintf (cmd, "awk '$3%%8==%d' %s>%s.%d", i, name, name, i);
data/picosat-965/picosat.c:4415:7:  [4] (shell) system:
  This causes a new program to execute and is difficult to use safely
  (CWE-78). try using a library call that implements the same functionality
  if available.
      system (cmd);
data/picosat-965/picosat.c:8287: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 (ps->out, fmt, ap);
data/picosat-965/picosat.c:1535:11:  [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.
  assert (getenv ("LEAK") || !ps->current_bytes);	/* found leak if failing */
data/picosat-965/app.c:27: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 buffer[100];
data/picosat-965/app.c:192: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.
  l = sprintf (bhead, " %d", i);
data/picosat-965/app.c:310:11:  [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).
    lit = atoi (sargv[i]);
data/picosat-965/app.c:345: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).
      file = fopen (name, "w");
data/picosat-965/app.c:622:23:  [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).
	    decision_limit = atoi (argv[i]);
data/picosat-965/app.c:633:32:  [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).
	      time_limit_in_seconds = atoi (argv[i]);
data/picosat-965/app.c:675:14:  [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).
	  else if (!atoi (argv[i]))
data/picosat-965/app.c:699:13:  [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).
	    seed = atoi (argv[i]);
data/picosat-965/app.c:716:22:  [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).
	  else if (!(file = fopen (argv[i], "w")))
data/picosat-965/app.c:807:22:  [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).
	  else if (!(file = fopen (argv[i], "w")))
data/picosat-965/app.c:932:25:  [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).
      else if (!(file = fopen (argv[i], "r")))	/* TODO .gz ? */
data/picosat-965/app.c:1039:18:  [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).
		  assumption = atoi (argv[i]);
data/picosat-965/picogcnf.c:79:16:  [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 (!(file = fopen (argv[1], "r"))) die ("can not read '%s'", argv[1]);
data/picosat-965/picomcs.c:73: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 (clause->lits, stk, bytes);
data/picosat-965/picomcs.c:89: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 (mcs->clauses, stk, bytes);
data/picosat-965/picomcs.c:305:26:  [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).
    } else if (!(input = fopen ((input_name = argv[i]), "r"))) {
data/picosat-965/picomus.c:243:25:  [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).
    } else input_file = fopen (input_name, "r"), fclose_input = 1;
data/picosat-965/picomus.c:379:19:  [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).
    output_file = fopen (output_name, "w");
data/picosat-965/picosat.c:499: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 data[BLK_FILL_BYTES];
data/picosat-965/picosat.c:601: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 *rline[2];
data/picosat-965/picosat.c:2176: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->znt, ps->buffer, count);
data/picosat-965/picosat.c:2266: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 line[80];
data/picosat-965/picosat.c:2269: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 (line, "%%RUPD32 %u %u", ps->rupvariables, ps->rupclauses);
data/picosat-965/picosat.c:3520: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).
  unsigned open, minlevel, siglevels, l, old, i, orig;
data/picosat-965/picosat.c:3616: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).
     if ((!open && ps->LEVEL) || !c)
data/picosat-965/picosat.c:4383: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[100], cmd[200];
data/picosat-965/picosat.c:4397: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 (name, "/tmp/picosat-viscores/data/%08u", ps->conflicts);
data/picosat-965/app.c:39:13:  [1] (buffer) getc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  int res = getc (input);
data/picosat-965/app.c:257: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).
  return str + strlen (str) - strlen (suffix) == tmp;
data/picosat-965/app.c:257: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).
  return str + strlen (str) - strlen (suffix) == tmp;
data/picosat-965/app.c:337: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).
      cmd = malloc (strlen (GZIP) + strlen (name));
data/picosat-965/app.c:337: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).
      cmd = malloc (strlen (GZIP) + strlen (name));
data/picosat-965/app.c:896: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 *cmd = malloc (strlen (GUNZIP) + strlen (argv[i]));
data/picosat-965/app.c:896:42:  [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 *cmd = malloc (strlen (GUNZIP) + strlen (argv[i]));
data/picosat-965/app.c:915: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 *cmd = malloc (strlen (BUNZIP2) + strlen (argv[i]));
data/picosat-965/app.c:915:43:  [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 *cmd = malloc (strlen (BUNZIP2) + strlen (argv[i]));
data/picosat-965/picogcnf.c:82:8:  [1] (buffer) getc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  ch = getc (file);
data/picosat-965/picogcnf.c:84:18:  [1] (buffer) getc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    while ((ch = getc (file)) != '\n')
data/picosat-965/picogcnf.c:89:7:  [1] (buffer) getc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
      getc (file) != ' ' ||
data/picosat-965/picogcnf.c:96:8:  [1] (buffer) getc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  ch = getc (file);
data/picosat-965/picogcnf.c:106:12:  [1] (buffer) getc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
      ch = getc (file);
data/picosat-965/picogcnf.c:109:26:  [1] (buffer) getc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    while (isdigit (ch = getc (file)))
data/picosat-965/picogcnf.c:125:10:  [1] (buffer) getc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    ch = getc (file);
data/picosat-965/picogcnf.c:129:26:  [1] (buffer) getc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    while (isdigit (ch = getc (file)))
data/picosat-965/picogcnf.c:133:12:  [1] (buffer) getc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
      ch = getc (file);
data/picosat-965/picomcs.c:97:13:  [1] (buffer) getc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  int res = getc (input);
data/picosat-965/picomus.c:51:13:  [1] (buffer) fgetc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  int res = fgetc (input_file);
data/picosat-965/picomus.c:236: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).
    len = strlen (input_name);
data/picosat-965/picosat.c:1161: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).
  delete (ps, ps->prefix, strlen (ps->prefix) + 1);
data/picosat-965/picosat.c:1170:25:  [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).
  ps->prefix = new (ps, strlen (str) + 1);
data/picosat-965/picosat.c:2272: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).
  for (i = 255 - strlen (line); i >= 0; i--)
data/picosat-965/picosat.c:3236: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).
	  p = ps->rline[x] + strlen (ps->rline[x]);
data/picosat-965/picosat.c:3269: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 (name);
data/picosat-965/picosat.c:4429:3:  [1] (obsolete) usleep:
  This C routine is considered obsolete (as opposed to the shell command by
  the same name). The interaction of this function with SIGALRM and other
  timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is
  unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead.
  usleep (50000);		/* refresh rate of 20 Hz */

ANALYSIS SUMMARY:

Hits = 86
Lines analyzed = 11279 in approximately 0.26 seconds (43115 lines/second)
Physical Source Lines of Code (SLOC) = 8906
Hits@level = [0] 237 [1]  27 [2]  27 [3]   1 [4]  31 [5]   0
Hits@level+ = [0+] 323 [1+]  86 [2+]  59 [3+]  32 [4+]  31 [5+]   0
Hits/KSLOC@level+ = [0+] 36.2677 [1+] 9.65641 [2+] 6.62475 [3+] 3.59308 [4+] 3.4808 [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.