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/simple-tpm-pk11-0.06/src/common.h
Examining data/simple-tpm-pk11-0.06/src/common_test.cc
Examining data/simple-tpm-pk11-0.06/src/exfiltrate.cc
Examining data/simple-tpm-pk11-0.06/src/fake_tspi.cc
Examining data/simple-tpm-pk11-0.06/src/internal.h
Examining data/simple-tpm-pk11-0.06/src/keygen.cc
Examining data/simple-tpm-pk11-0.06/src/keygen_test.cc
Examining data/simple-tpm-pk11-0.06/src/libgtest.cc
Examining data/simple-tpm-pk11-0.06/src/pk11_test.cc
Examining data/simple-tpm-pk11-0.06/src/sign.cc
Examining data/simple-tpm-pk11-0.06/src/sign_test.cc
Examining data/simple-tpm-pk11-0.06/src/test_util.h
Examining data/simple-tpm-pk11-0.06/src/tspiwrap.cc
Examining data/simple-tpm-pk11-0.06/src/tspiwrap.h
Examining data/simple-tpm-pk11-0.06/src/verify.cc
Examining data/simple-tpm-pk11-0.06/src/verify_test.cc
Examining data/simple-tpm-pk11-0.06/src/wrap_main.cc
Examining data/simple-tpm-pk11-0.06/src/common.cc
Examining data/simple-tpm-pk11-0.06/src/pk11.cc
Examining data/simple-tpm-pk11-0.06/src/session.h
Examining data/simple-tpm-pk11-0.06/src/session.cc

FINAL RESULTS:

data/simple-tpm-pk11-0.06/src/common.cc:324:14:  [4] (format) vsnprintf:
  If format strings can be influenced by an attacker, they can be exploited,
  and note that sprintf variations do not always \0-terminate (CWE-134). Use
  a constant for the format specification.
  size_t s = vsnprintf(NULL, 0, fmt, args) + 1;
data/simple-tpm-pk11-0.06/src/common.cc:328:3:  [4] (format) vsnprintf:
  If format strings can be influenced by an attacker, they can be exploited,
  and note that sprintf variations do not always \0-terminate (CWE-134). Use
  a constant for the format specification.
  vsnprintf(&buf[0], s, fmt, va2);
data/simple-tpm-pk11-0.06/src/pk11.cc:34:10:  [4] (format) syslog:
  If syslog's format strings can be influenced by an attacker, they can be
  exploited (CWE-134). Use a constant format string for syslog.
#include<syslog.h>
data/simple-tpm-pk11-0.06/src/session.cc:173:14:  [4] (format) vsnprintf:
  If format strings can be influenced by an attacker, they can be exploited,
  and note that sprintf variations do not always \0-terminate (CWE-134). Use
  a constant for the format specification.
  size_t s = vsnprintf(NULL, 0, fmt, args) + 1;
data/simple-tpm-pk11-0.06/src/session.cc:177:3:  [4] (format) vsnprintf:
  If format strings can be influenced by an attacker, they can be exploited,
  and note that sprintf variations do not always \0-terminate (CWE-134). Use
  a constant for the format specification.
  vsnprintf(&buf[0], s, fmt, va2);
data/simple-tpm-pk11-0.06/src/common.cc:337:20:  [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 *doit{getenv(env_log_stderr)};
data/simple-tpm-pk11-0.06/src/exfiltrate.cc:56:22:  [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 (EOF != (c = getopt(argc, argv, "hk:Ops"))) {
data/simple-tpm-pk11-0.06/src/keygen.cc:59:22:  [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 (EOF != (c = getopt(argc, argv, "b:ho:sSp"))) {
data/simple-tpm-pk11-0.06/src/pk11.cc:74:19:  [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 *dbg{getenv(env_debug)};
data/simple-tpm-pk11-0.06/src/pk11.cc:96:20:  [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* home{getenv("HOME")};
data/simple-tpm-pk11-0.06/src/pk11.cc:103:24:  [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* conf_env{getenv(env_config)};
data/simple-tpm-pk11-0.06/src/sign.cc:60:22:  [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 (EOF != (c = getopt(argc, argv, "rhk:f:s"))) {
data/simple-tpm-pk11-0.06/src/verify.cc:60:22:  [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 (EOF != (c = getopt(argc, argv, "hk:f:s:q"))) {
data/simple-tpm-pk11-0.06/src/common.cc:268:5:  [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).
  f.open(random_device, std::ios::binary);
data/simple-tpm-pk11-0.06/src/common.cc:308: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[128] = {0};
data/simple-tpm-pk11-0.06/src/common.cc:563: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(&buf[0], fullpath.data(), s);
data/simple-tpm-pk11-0.06/src/common.cc:594: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 t[2] = {(unsigned char)c, 0};
data/simple-tpm-pk11-0.06/src/pk11.cc:141:7:  [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((char*)pInfo->manufacturerID, "simple-tpm-pk11 manufacturer");
data/simple-tpm-pk11-0.06/src/pk11.cc:142:7:  [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((char*)pInfo->libraryDescription, "simple-tpm-pk11 library");
data/simple-tpm-pk11-0.06/src/pk11.cc:213:7:  [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((char*)pInfo->slotDescription, "Simple-TPM-PK11 slot");
data/simple-tpm-pk11-0.06/src/pk11.cc:214:7:  [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((char*)pInfo->manufacturerID, "manuf id");
data/simple-tpm-pk11-0.06/src/pk11.cc:228:7:  [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((char*)pInfo->label, "Simple-TPM-PK11 token");
data/simple-tpm-pk11-0.06/src/pk11.cc:229:7:  [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((char*)pInfo->manufacturerID, "manuf id");
data/simple-tpm-pk11-0.06/src/pk11.cc:230:7:  [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((char*)pInfo->model, "model");
data/simple-tpm-pk11-0.06/src/pk11.cc:231:7:  [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((char*)pInfo->serialNumber, "serial");
data/simple-tpm-pk11-0.06/src/pk11.cc:262:7:  [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((char*)pInfo->utcTime, "bleh");  // TODO.
data/simple-tpm-pk11-0.06/src/session.cc:42: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(&buf[0], relative.data(), s);
data/simple-tpm-pk11-0.06/src/session.cc:64:15:  [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).
    logfile_->open(logfilename_, std::ofstream::app);
data/simple-tpm-pk11-0.06/src/session.cc:223:9:  [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(pTemplate[i].pValue, key.modulus.data(), key.modulus.size());
data/simple-tpm-pk11-0.06/src/session.cc:232:9:  [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(pTemplate[i].pValue, key.exponent.data(), key.exponent.size());
data/simple-tpm-pk11-0.06/src/session.cc:294: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(pSignature, signature.data(), signature.size());
data/simple-tpm-pk11-0.06/src/common.cc:272:5:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  f.read(&buf[0], buf.size());
data/simple-tpm-pk11-0.06/src/common.cc:310: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).
  while (strlen(buf) && buf[strlen(buf)-1] == '\n') {
data/simple-tpm-pk11-0.06/src/common.cc:310: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).
  while (strlen(buf) && buf[strlen(buf)-1] == '\n') {
data/simple-tpm-pk11-0.06/src/common.cc:311: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).
    buf[strlen(buf)-1] = 0;

ANALYSIS SUMMARY:

Hits = 35
Lines analyzed = 3526 in approximately 0.10 seconds (35675 lines/second)
Physical Source Lines of Code (SLOC) = 2623
Hits@level = [0]   1 [1]   4 [2]  18 [3]   8 [4]   5 [5]   0
Hits@level+ = [0+]  36 [1+]  35 [2+]  31 [3+]  13 [4+]   5 [5+]   0
Hits/KSLOC@level+ = [0+] 13.7247 [1+] 13.3435 [2+] 11.8185 [3+] 4.95616 [4+] 1.90621 [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.