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/libtermkey-0.22/termkey.c
Examining data/libtermkey-0.22/driver-ti.c
Examining data/libtermkey-0.22/demo-glib.c
Examining data/libtermkey-0.22/termkey-internal.h
Examining data/libtermkey-0.22/demo-async.c
Examining data/libtermkey-0.22/driver-csi.c
Examining data/libtermkey-0.22/termkey.h
Examining data/libtermkey-0.22/demo.c
Examining data/libtermkey-0.22/t/02getkey.c
Examining data/libtermkey-0.22/t/taplib.c
Examining data/libtermkey-0.22/t/06buffer.c
Examining data/libtermkey-0.22/t/30mouse.c
Examining data/libtermkey-0.22/t/11strfkey.c
Examining data/libtermkey-0.22/t/31position.c
Examining data/libtermkey-0.22/t/13cmpkey.c
Examining data/libtermkey-0.22/t/05read.c
Examining data/libtermkey-0.22/t/12strpkey.c
Examining data/libtermkey-0.22/t/40ti-override.c
Examining data/libtermkey-0.22/t/39dcs.c
Examining data/libtermkey-0.22/t/38csi.c
Examining data/libtermkey-0.22/t/taplib.h
Examining data/libtermkey-0.22/t/32modereport.c
Examining data/libtermkey-0.22/t/10keyname.c
Examining data/libtermkey-0.22/t/04flags.c
Examining data/libtermkey-0.22/t/01base.c
Examining data/libtermkey-0.22/t/03utf8.c
Examining data/libtermkey-0.22/t/20canon.c

FINAL RESULTS:

data/libtermkey-0.22/driver-ti.c:301:5:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
    sprintf(name, "key_%s", funcs[i].funcname);
data/libtermkey-0.22/driver-ti.c:311:5:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
    sprintf(name, "key_s%s", funcs[i].funcname);
data/libtermkey-0.22/t/taplib.c:40: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, args);
data/libtermkey-0.22/termkey.c:1329:11:  [4] (format) snprintf:
  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.
      l = snprintf(buffer + pos, len - pos, wrapbracket ? "<^%c>" : "^%c", (char)codepoint - 0x20);
data/libtermkey-0.22/termkey.c:1336:11:  [4] (format) snprintf:
  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.
      l = snprintf(buffer + pos, len - pos, wrapbracket ? "<^%c>" : "^%c", (char)codepoint);
data/libtermkey-0.22/demo.c:22:16:  [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((opt = getopt(argc, argv, "m::p:")) != -1) {
data/libtermkey-0.22/termkey.c:412: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.
    if(((e = getenv("LANG")) || (e = getenv("LC_MESSAGES")) || (e = getenv("LC_ALL"))) &&
data/libtermkey-0.22/termkey.c:412:38:  [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(((e = getenv("LANG")) || (e = getenv("LC_MESSAGES")) || (e = getenv("LC_ALL"))) &&
data/libtermkey-0.22/termkey.c:412:69:  [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(((e = getenv("LANG")) || (e = getenv("LC_MESSAGES")) || (e = getenv("LC_ALL"))) &&
data/libtermkey-0.22/termkey.c:422:22:  [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 *term = getenv("TERM");
data/libtermkey-0.22/demo-async.c:11: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[50];
data/libtermkey-0.22/demo-glib.c:11: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[50];
data/libtermkey-0.22/demo.c:18: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[50];
data/libtermkey-0.22/demo.c:26:17:  [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).
        mouse = atoi(optarg);
data/libtermkey-0.22/demo.c:33:21:  [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).
      mouse_proto = atoi(optarg);
data/libtermkey-0.22/driver-csi.c:10: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 ss3_kpalts[64];
data/libtermkey-0.22/driver-ti.c:299: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_FUNCNAME + 5 + 1];
data/libtermkey-0.22/driver-ti.c:323: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[9];
data/libtermkey-0.22/driver-ti.c:324: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(name, "key_f%d", i);
data/libtermkey-0.22/t/11strfkey.c:8: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/libtermkey-0.22/t/30mouse.c:10: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[32];
data/libtermkey-0.22/termkey.c:192: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 errorbuffer[256];
data/libtermkey-0.22/termkey.c:897:11:  [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(tk->buffer, tk->buffer + halfsize, halfsize);
data/libtermkey-0.22/termkey.c:1184: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(tk->buffer + tk->buffcount, bytes, len);
data/libtermkey-0.22/termkey.c:1485: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 event_name[32];
data/libtermkey-0.22/termkey.h:135: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       mouse[4];  /* TERMKEY_TYPE_MOUSE */
data/libtermkey-0.22/termkey.h:143: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 utf8[7];
data/libtermkey-0.22/driver-csi.c:686:3:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
  strncpy(csi->saved_string, (char *)tk->buffer + tk->buffstart + introlen, len);
data/libtermkey-0.22/driver-ti.c:449: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(start_string);
data/libtermkey-0.22/driver-ti.c:484: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(stop_string);
data/libtermkey-0.22/termkey.c:1147:9:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  len = read(tk->fd, tk->buffer + tk->buffcount, tk->buffsize - tk->buffcount);
data/libtermkey-0.22/termkey.c:1234: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).
    size_t len = strlen(thiskey);
data/libtermkey-0.22/termkey.c:1468: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(n == strlen(mods->alt) && strncmp(mods->alt, str, n) == 0)
data/libtermkey-0.22/termkey.c:1470: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).
    else if(n == strlen(mods->ctrl) && strncmp(mods->ctrl, str, n) == 0)
data/libtermkey-0.22/termkey.c:1472: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).
    else if(n == strlen(mods->shift) && strncmp(mods->shift, str, n) == 0)
data/libtermkey-0.22/termkey.c:1532:50:  [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(parse_utf8((unsigned const char *)str, strlen(str), &key->code.codepoint, &nbytes) == TERMKEY_RES_KEY) {

ANALYSIS SUMMARY:

Hits = 36
Lines analyzed = 4944 in approximately 0.16 seconds (30620 lines/second)
Physical Source Lines of Code (SLOC) = 3708
Hits@level = [0]  78 [1]   9 [2]  17 [3]   5 [4]   5 [5]   0
Hits@level+ = [0+] 114 [1+]  36 [2+]  27 [3+]  10 [4+]   5 [5+]   0
Hits/KSLOC@level+ = [0+] 30.7443 [1+] 9.70874 [2+] 7.28155 [3+] 2.69687 [4+] 1.34844 [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.