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/libppd-0.10/acconfig.h
Examining data/libppd-0.10/src/emit.c
Examining data/libppd-0.10/src/options.c
Examining data/libppd-0.10/src/page.c
Examining data/libppd-0.10/src/mark.c
Examining data/libppd-0.10/src/init.c
Examining data/libppd-0.10/src/debug.h
Examining data/libppd-0.10/src/ppdfilt.h
Examining data/libppd-0.10/src/testmacros.c
Examining data/libppd-0.10/src/dumpppd.c
Examining data/libppd-0.10/src/ppd.h
Examining data/libppd-0.10/src/ppdenums.h
Examining data/libppd-0.10/src/ppdmacros.h
Examining data/libppd-0.10/src/ppd.c
Examining data/libppd-0.10/src/ppdfilt.c

FINAL RESULTS:

data/libppd-0.10/src/debug.h:47:29:  [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 DEBUG_printf(x) printf x
data/libppd-0.10/src/emit.c:167:7:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
      sprintf(buf, "%%%%BeginFeature: %s %s\n", o->keyword->str,
data/libppd-0.10/src/ppdfilt.c:1337:5:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
    sprintf(filename, "%s/XXXXXX", tmpdir);
data/libppd-0.10/src/ppdfilt.c:296:29:  [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.
  const char *ppdfilename = getenv("PPD");
data/libppd-0.10/src/ppdfilt.c:351:6:  [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.
	    getopt_long(argc, argv, "+?24c:d::D:n:o:p:VZ:", long_options,
data/libppd-0.10/src/ppdfilt.c:1326: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.
  if ((tmpdir = getenv("TMPDIR")) == NULL)
data/libppd-0.10/src/emit.c:149: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 buf[1024];		/* Output buffer for feature */
data/libppd-0.10/src/page.c:55: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 units[255];		/* Page size units... */
data/libppd-0.10/src/ppd.c:415: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 keyword[41],		// Keyword from file 
data/libppd-0.10/src/ppd.c:489:29:  [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).
      ppd->language_level = atoi(string);
data/libppd-0.10/src/ppd.c:559:27:  [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).
      ppd->model_number = atoi(string);
data/libppd-0.10/src/ppd.c:992: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.
      {char copt1[81],		// These temporarily hold 
data/libppd-0.10/src/ppd.c:1140:13:  [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 ((fp = fopen(filename, "r")) != NULL) {
data/libppd-0.10/src/ppd.c:1355:19:  [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 unsigned char lut[32] =	// Lookup table for characters 
data/libppd-0.10/src/ppdfilt.c:269: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 tempfile[255];		// Temporary file name 
data/libppd-0.10/src/ppdfilt.c:272: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[8192];		// Line buffer 
data/libppd-0.10/src/ppdfilt.c:307: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.
  if (!strcmp((char *)g_basename(argv[0]), "pstops")) {
data/libppd-0.10/src/ppdfilt.c:320: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).
      if ((fp = fopen(argv[6], "rb")) == NULL) {
data/libppd-0.10/src/ppdfilt.c:327: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).
    copies = atoi(argv[4]);
data/libppd-0.10/src/ppdfilt.c:356: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).
	copies = atoi(optarg);
data/libppd-0.10/src/ppdfilt.c:400: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).
	NUp = atoi(optarg);
data/libppd-0.10/src/ppdfilt.c:432: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).
      if ((fp = fopen(argv[optind], "rb")) == NULL) {
data/libppd-0.10/src/ppdfilt.c:489: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).
    NUp = atoi(val);
data/libppd-0.10/src/ppdfilt.c:492: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).
    copies = atoi(val);
data/libppd-0.10/src/ppdfilt.c:495: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).
    gamma = atoi(val) * 0.001f;
data/libppd-0.10/src/ppdfilt.c:498: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).
    brightness = atoi(val) * 0.01f;
data/libppd-0.10/src/ppdfilt.c:594: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).
	tbytes = atoi(strchr(line, ':') + 1);
data/libppd-0.10/src/ppdfilt.c:661: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).
	tbytes = atoi(strchr(line, ':') + 1);
data/libppd-0.10/src/ppdfilt.c:905: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[8192];		// Data buffer 
data/libppd-0.10/src/ppdfilt.c:1157: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).
    int or = atoi(val);
data/libppd-0.10/src/ppdfilt.c:1312:10:  [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 buf[1024] = "";	/* Buffer if you pass in NULL and 0 */
data/libppd-0.10/src/ppdfilt.c:1332:5:  [2] (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). Risk is low because the source is a constant string.
    strcpy(buf, "/var/tmp/XXXXXX");
data/libppd-0.10/src/ppdfilt.c:1333:13:  [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).
    return (mkstemp(buf));
data/libppd-0.10/src/ppdfilt.c:1338:13:  [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).
    return (mkstemp(filename));
data/libppd-0.10/src/ppdfilt.h:83: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[IPP_MAX_NAME],	/* Printer or class name */
data/libppd-0.10/src/ppdfilt.h:85:14:  [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.
    unsigned char info[IPP_MAX_NAME],	/* Printer or class info/description */
data/libppd-0.10/src/ppdfilt.h:88:14:  [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.
    unsigned char message[IPP_MAX_NAME];	/* State text */
data/libppd-0.10/src/emit.c:115: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).
	if (choice->code[strlen(choice->code) - 1] != '\n')
data/libppd-0.10/src/emit.c:170:26:  [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 (write(fd, buf, strlen(buf)) < 1) {
data/libppd-0.10/src/emit.c:175: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).
      if (write(fd, choice->code, strlen(choice->code)) < 1) {
data/libppd-0.10/src/emit.c:185: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).
    else if (write(fd, choice->code, strlen(choice->code)) < 1) {
data/libppd-0.10/src/page.c:93:11:  [1] (buffer) sscanf:
  It's unclear if the %s limit in the format string is small enough
  (CWE-120). Check that the limit is sufficiently small, or use a different
  input function.
      if (sscanf(name + 7, "%fx%f%254s", &w, &l, units) < 2)
data/libppd-0.10/src/ppd.c:95: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).
  for (i = strlen(str) - 1; i >= 0; i--)
data/libppd-0.10/src/ppd.c:480: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).
      if (strlen(string) > 40)
data/libppd-0.10/src/ppd.c:739:26:  [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).
	memmove(name, name + 1, strlen(name));
data/libppd-0.10/src/ppd.c:806:26:  [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).
	memmove(name, name + 1, strlen(name));
data/libppd-0.10/src/ppd.c:832: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).
	memmove(string, h+1, strlen(h));
data/libppd-0.10/src/ppd.c:855:11:  [1] (buffer) sscanf:
  It's unclear if the %s limit in the format string is small enough
  (CWE-120). Check that the limit is sufficiently small, or use a different
  input function.
      if (sscanf(string, "%f%40s%40s", &order, name, keyword) != 3)
data/libppd-0.10/src/ppd.c:858: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).
	memmove(keyword, keyword + 1, strlen(keyword));
data/libppd-0.10/src/ppd.c:997:11:  [1] (buffer) sscanf:
  It's unclear if the %s limit in the format string is small enough
  (CWE-120). Check that the limit is sufficiently small, or use a different
  input function.
      m = sscanf(string, "%80s%80s%80s%80s", copt1, cchoice1, copt2, cchoice2);
data/libppd-0.10/src/ppd.c:1184:18:  [1] (buffer) getc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    while ((ch = getc(fp)) != EOF
data/libppd-0.10/src/ppd.c:1193:14:  [1] (buffer) getc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	  if ((ch = getc(fp)) == EOF)
data/libppd-0.10/src/ppd.c:1284:26:  [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).
      *string = g_malloc(strlen(lineptr) + 1);
data/libppd-0.10/src/ppdfilt.c:380: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).
	    } else sp=cur+strlen(cur)-1;
data/libppd-0.10/src/ppdfilt.c:970:15:  [1] (buffer) getc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    if ((ch = getc(fp)) == EOF)
data/libppd-0.10/src/ppdfilt.c:978:12:  [1] (buffer) getc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
      ch = getc(fp);
data/libppd-0.10/src/ppdfilt.c:1329: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).
  if ((int)(strlen(tmpdir) + 8) > len) {

ANALYSIS SUMMARY:

Hits = 57
Lines analyzed = 5080 in approximately 0.29 seconds (17618 lines/second)
Physical Source Lines of Code (SLOC) = 3277
Hits@level = [0]  82 [1]  20 [2]  31 [3]   3 [4]   3 [5]   0
Hits@level+ = [0+] 139 [1+]  57 [2+]  37 [3+]   6 [4+]   3 [5+]   0
Hits/KSLOC@level+ = [0+] 42.4168 [1+] 17.394 [2+] 11.2908 [3+] 1.83094 [4+] 0.915471 [5+]   0
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.