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/libt3key-0.2.10/doc/main_doc.h
Examining data/libt3key-0.2.10/src.util/optionMacros.h
Examining data/libt3key-0.2.10/src.util/t3keyc/mappings.c
Examining data/libt3key-0.2.10/src.util/t3keyc/t3keyc.c
Examining data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c
Examining data/libt3key-0.2.10/src.util/t3learnkeys/x11.c
Examining data/libt3key-0.2.10/src.util/t3learnkeys/x11.h
Examining data/libt3key-0.2.10/src/key_api.h
Examining data/libt3key-0.2.10/src/shareddefs.h
Examining data/libt3key-0.2.10/src/key.h
Examining data/libt3key-0.2.10/src/key_shared.c
Examining data/libt3key-0.2.10/src/key_errors.h
Examining data/libt3key-0.2.10/src/key.c

FINAL RESULTS:

data/libt3key-0.2.10/src.util/t3keyc/t3keyc.c:70: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/libt3key-0.2.10/src.util/t3keyc/t3keyc.c:84:52:  [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).
static char *safe_strdup(const char *str) { return strcpy(safe_malloc(strlen(str) + 1), str); }
data/libt3key-0.2.10/src.util/t3keyc/t3keyc.c:356:7:  [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(buffer + 1, name);
data/libt3key-0.2.10/src.util/t3keyc/t3keyc.c:492: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(linkname, dirname);
data/libt3key-0.2.10/src.util/t3keyc/t3keyc.c:493: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(linkname, t3_config_get_string(aka));
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:161: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/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:187: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(result, str);
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:813: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"), *display_env = getenv("DISPLAY");
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:813:53:  [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"), *display_env = getenv("DISPLAY");
data/libt3key-0.2.10/src/key.c:339:12:  [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.
    term = getenv("TERM");
data/libt3key-0.2.10/src.util/t3keyc/t3keyc.c:233: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 buffer[1024];
data/libt3key-0.2.10/src.util/t3keyc/t3keyc.c:251: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(dest, "\\%03o", *seq++);
data/libt3key-0.2.10/src.util/t3keyc/t3keyc.c:348: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[100];
data/libt3key-0.2.10/src.util/t3keyc/t3keyc.c:515:15:  [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(input, "r")) == NULL) {
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:109: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 seq[MAX_SEQUENCE * 4 + 1];
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:287: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 seq[MAX_SEQUENCE];
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:325:11:  [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(retval->seq + dest, "\\%03o", seq[i]);
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:347: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(retval->seq, "\\%03o", c);
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:465: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 buffer[1024];
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:483: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(dest, "\\%03o", *seq++);
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:493: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[1024];
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:826: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 buffer[1024], *start = NULL;
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:908: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 ((output = fopen(option_output, "w")) == NULL) {
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:925: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[1024];
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:964: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 buffer[1024];
data/libt3key-0.2.10/src/key.c:71: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(result, str, len);
data/libt3key-0.2.10/src/key.c:205:9:  [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.
  const char *path[3] = {NULL, DB_DIRECTORY, NULL};
data/libt3key-0.2.10/src/key.c:567: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 function_key[10];
data/libt3key-0.2.10/src/key.c:599: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(function_key, "kf%d", j);
data/libt3key-0.2.10/src.util/optionMacros.h:126: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).
					optlength = strlen(optcurrent); \
data/libt3key-0.2.10/src.util/optionMacros.h:214:121:  [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).
#define OPTION(shortName, longName, argReq) if ((opttype == SHORT && optcurrent[1] == shortName) || (opttype == LONG && strlen(longName) == optlength - 2 && strncmp(optcurrent + 2, longName, optlength - 2) == 0)) { CHECK_ARG(argReq) {
data/libt3key-0.2.10/src.util/optionMacros.h:221:62:  [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).
#define LONG_OPTION(longName, argReq) if (opttype == LONG && strlen(longName) == optlength - 2 && strncmp(optcurrent + 2, longName, optlength - 2) == 0) { CHECK_ARG(argReq) {
data/libt3key-0.2.10/src.util/t3keyc/t3keyc.c:84:71:  [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).
static char *safe_strdup(const char *str) { return strcpy(safe_malloc(strlen(str) + 1), str); }
data/libt3key-0.2.10/src.util/t3keyc/t3keyc.c:128:30:  [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 max_read_position = strlen(string);
data/libt3key-0.2.10/src.util/t3keyc/t3keyc.c:291:30:  [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).
  name_len = minus == NULL ? strlen(name) : (size_t)(minus - name);
data/libt3key-0.2.10/src.util/t3keyc/t3keyc.c:293:69:  [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 (strncmp(name, valid_names[i], name_len) == 0 && name_len == strlen(valid_names[i])) {
data/libt3key-0.2.10/src.util/t3keyc/t3keyc.c:361: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(tistr) != str_len || memcmp(tistr, str, str_len) != 0) {
data/libt3key-0.2.10/src.util/t3keyc/t3keyc.c:491:28:  [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).
    linkname = safe_malloc(strlen(dirname) + strlen(t3_config_get_string(aka)) + 1);
data/libt3key-0.2.10/src.util/t3keyc/t3keyc.c:491:46:  [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).
    linkname = safe_malloc(strlen(dirname) + strlen(t3_config_get_string(aka)) + 1);
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:184: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).
  if ((result = malloc(strlen(str) + 1)) == 0) {
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:228:22:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    ssize_t retval = read(STDIN_FILENO, &c, 1);
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:366:39:  [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 key_name_len, modifier_len = strlen(key_desc[1].name);
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:376: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).
  key_name_len = key_modifiers == NULL ? strlen(*key_name) : (size_t)(key_modifiers - *key_name);
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:377: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(key_desc[0].identifier) != key_name_len ||
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:628:5:  [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(100000);
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:835:9:  [1] (buffer) scanf:
  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.
        scanf("%1023s", buffer);
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:844:55:  [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 (!(start == (char *)-1 || start == NULL || strlen(start) == 0)) {
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:892: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).
    if (display_env != NULL && strlen(display_env) > 0) {
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:938:45:  [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 (rmkx == (char *)-1 || rmkx == NULL || strlen(rmkx) == 0) {
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:952:45:  [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 (smkx != NULL && smkx != (void *)-1 && strlen(smkx) > 0) {
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:966:5:  [1] (buffer) scanf:
  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.
    scanf("%1023s", buffer);
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:976:7:  [1] (buffer) scanf:
  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.
      scanf("%1023s", buffer);
data/libt3key-0.2.10/src.util/t3learnkeys/t3learnkeys.c:984:7:  [1] (buffer) scanf:
  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.
      scanf("%1023s", buffer);
data/libt3key-0.2.10/src/key.c:66: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).
  size_t len = strlen(str) + 1;
data/libt3key-0.2.10/src/key.c:93:30:  [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 max_read_position = strlen(string);
data/libt3key-0.2.10/src/key.c:319:34:  [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).
        (*next)->string_length = strlen((*next)->string);
data/libt3key-0.2.10/src/key.c:462:33:  [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).
  (*next_node)->string_length = strlen(tiresult);

ANALYSIS SUMMARY:

Hits = 57
Lines analyzed = 3520 in approximately 0.11 seconds (30622 lines/second)
Physical Source Lines of Code (SLOC) = 2543
Hits@level = [0]  68 [1]  28 [2]  19 [3]   3 [4]   7 [5]   0
Hits@level+ = [0+] 125 [1+]  57 [2+]  29 [3+]  10 [4+]   7 [5+]   0
Hits/KSLOC@level+ = [0+] 49.1545 [1+] 22.4145 [2+] 11.4039 [3+] 3.93236 [4+] 2.75265 [5+]   0
Symlinks skipped = 1 (--allowlink overrides but see doc for security issue)
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.