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/libt3highlight-0.5.0/doc/main_doc.h
Examining data/libt3highlight-0.5.0/src.util/optionMacros.h
Examining data/libt3highlight-0.5.0/src.util/escapes.c
Examining data/libt3highlight-0.5.0/src.util/t3highlight.h
Examining data/libt3highlight-0.5.0/src.util/t3highlight.c
Examining data/libt3highlight-0.5.0/src/vector.c
Examining data/libt3highlight-0.5.0/src/pcre_compat.h
Examining data/libt3highlight-0.5.0/src/highlight_shared.c
Examining data/libt3highlight-0.5.0/src/utf8.c
Examining data/libt3highlight-0.5.0/src/highlight_errors.h
Examining data/libt3highlight-0.5.0/src/internal.h
Examining data/libt3highlight-0.5.0/src/pcre_compat.c
Examining data/libt3highlight-0.5.0/src/highlight_api.h
Examining data/libt3highlight-0.5.0/src/analyse.c
Examining data/libt3highlight-0.5.0/src/io.c
Examining data/libt3highlight-0.5.0/src/vector.h
Examining data/libt3highlight-0.5.0/src/match.c
Examining data/libt3highlight-0.5.0/src/highlight.h
Examining data/libt3highlight-0.5.0/src/highlight.c

FINAL RESULTS:

data/libt3highlight-0.5.0/src.util/t3highlight.c:89: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/libt3highlight-0.5.0/src.util/t3highlight.c:158: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(option_style, optArg);
data/libt3highlight-0.5.0/src.util/t3highlight.c:261: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(tmp, home_env);
data/libt3highlight-0.5.0/src.util/t3highlight.c:283: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(tmp, home_env);
data/libt3highlight-0.5.0/src/highlight.c:237:5:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
    sprintf(regex_with_define, "(?(DEFINE)(?<%s>))%s", pattern->extra->dynamic_name,
data/libt3highlight-0.5.0/src/match.c:109:5:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
    sprintf(pattern, "(?(DEFINE)(?<%s>\\Q", extra->dynamic_name);
data/libt3highlight-0.5.0/src/match.c:125: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(patptr, dynamic_pattern);
data/libt3highlight-0.5.0/src.util/t3highlight.c:255: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.
  char *home_env = getenv("HOME");
data/libt3highlight-0.5.0/src.util/t3highlight.c:278: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.
  home_env = getenv("HOME");
data/libt3highlight-0.5.0/src.util/t3highlight.c:102: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/libt3highlight-0.5.0/src.util/t3highlight.c:160:9:  [2] (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). Risk is low because the
  source is a constant string.
        strcat(option_style, ".style");
data/libt3highlight-0.5.0/src.util/t3highlight.c:262:5:  [2] (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). Risk is low because the
  source is a constant string.
    strcat(tmp, "/.libt3highlight");
data/libt3highlight-0.5.0/src.util/t3highlight.c:284:5:  [2] (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). Risk is low because the
  source is a constant string.
    strcat(tmp, "/.libt3highlight");
data/libt3highlight-0.5.0/src.util/t3highlight.c:545:23:  [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(option_input, "rb")) == NULL) {
data/libt3highlight-0.5.0/src/highlight.c:59:7:  [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(style_at_scope, style, style_len);
data/libt3highlight-0.5.0/src/highlight.c:60:7:  [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(style_at_scope + style_len, "@", 1);
data/libt3highlight-0.5.0/src/highlight.c:61:7:  [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(style_at_scope + style_len + 1, context->scope, scope_len);
data/libt3highlight-0.5.0/src/highlight.c:204: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 error_message[256];
data/libt3highlight-0.5.0/src/io.c:36: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/libt3highlight-0.5.0/src/io.c:53: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(name, "r")) == NULL) {
data/libt3highlight-0.5.0/src/io.c:127:5:  [2] (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). Risk is low because the
  source is a constant string.
    strcat(xdg_map, "/lang.map");
data/libt3highlight-0.5.0/src/io.c:192:11:  [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.
    free((char *)list[i].name);
data/libt3highlight-0.5.0/src/io.c:193:11:  [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.
    free((char *)list[i].lang_file);
data/libt3highlight-0.5.0/src/io.c:317: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 ((file = fopen(lang_file, "r")) == NULL) {
data/libt3highlight-0.5.0/src/io.c:476: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(matched_name, line + ovector[2], ovector[3] - ovector[2]);
data/libt3highlight-0.5.0/src/match.c:107:5:  [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(new_dynamic->extracted, dynamic_line, dynamic_length);
data/libt3highlight-0.5.0/src/match.c:124: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(patptr, "\\E))");
data/libt3highlight-0.5.0/src.util/escapes.c:76: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/libt3highlight-0.5.0/src.util/optionMacros.h:141: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).
          optlength = strlen(optcurrent);                 \
data/libt3highlight-0.5.0/src.util/optionMacros.h:238: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).
      (opttype == LONG && strlen(longName) == optlength - 2 &&   \
data/libt3highlight-0.5.0/src.util/optionMacros.h:247: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 (opttype == LONG && strlen(longName) == optlength - 2 &&  \
data/libt3highlight-0.5.0/src.util/t3highlight.c:97: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/libt3highlight-0.5.0/src.util/t3highlight.c:155: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).
      if ((option_style = malloc(strlen(optArg) + 7)) == NULL) {
data/libt3highlight-0.5.0/src.util/t3highlight.c:225: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).
  ptr->name_len = strlen(name);
data/libt3highlight-0.5.0/src.util/t3highlight.c:258: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).
    if ((tmp = malloc(strlen(home_env) + strlen("/.libt3highlight") + 1)) == NULL) {
data/libt3highlight-0.5.0/src.util/t3highlight.c:258: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).
    if ((tmp = malloc(strlen(home_env) + strlen("/.libt3highlight") + 1)) == NULL) {
data/libt3highlight-0.5.0/src.util/t3highlight.c:280: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).
    if ((tmp = malloc(strlen(home_env) + strlen("/.libt3highlight") + 1)) == NULL) {
data/libt3highlight-0.5.0/src.util/t3highlight.c:280: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).
    if ((tmp = malloc(strlen(home_env) + strlen("/.libt3highlight") + 1)) == NULL) {
data/libt3highlight-0.5.0/src.util/t3highlight.c:330: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).
      size_t name_len = strlen(name);
data/libt3highlight-0.5.0/src.util/t3highlight.c:385:36:  [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).
      translations[i].search_len = strlen(translations[i].search);
data/libt3highlight-0.5.0/src.util/t3highlight.c:386: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).
      translations[i].replace_len = strlen(translations[i].replace);
data/libt3highlight-0.5.0/src.util/t3highlight.c:484: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).
          write_data(tag_ptr->value, strlen(tag_ptr->value));
data/libt3highlight-0.5.0/src.util/t3highlight.c:504: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).
  fwrite(prev_ptr, 1, header + strlen(header) - prev_ptr, stdout);
data/libt3highlight-0.5.0/src.util/t3highlight.c:575: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).
    fwrite(footer, 1, strlen(footer), stdout);
data/libt3highlight-0.5.0/src/highlight.c:54: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).
    size_t style_len = strlen(style);
data/libt3highlight-0.5.0/src/highlight.c:55: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).
    size_t scope_len = strlen(context->scope);
data/libt3highlight-0.5.0/src/highlight.c:232: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).
    if ((regex_with_define = malloc(strlen(t3_config_get_string(regex)) +
data/libt3highlight-0.5.0/src/highlight.c:233: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).
                                    strlen(pattern->extra->dynamic_name) + 18)) == NULL) {
data/libt3highlight-0.5.0/src/io.c:31: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/libt3highlight-0.5.0/src/io.c:125:79:  [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).
  xdg_map = t3_config_xdg_get_path(T3_CONFIG_XDG_DATA_HOME, "libt3highlight", strlen("lang.map"));
data/libt3highlight-0.5.0/src/match.c:87: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 ((pattern = malloc(21 + dynamic_length + replace_count * 5 + strlen(extra->dynamic_name) +
data/libt3highlight-0.5.0/src/match.c:88: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).
                          strlen(dynamic_pattern))) == NULL) {
data/libt3highlight-0.5.0/src/match.c:110: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).
    patptr = pattern + strlen(pattern);
data/libt3highlight-0.5.0/src/pcre_compat.c:108:54:  [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).
                   length == PCRE2_ZERO_TERMINATED ? strlen((const char *)subject) : length,
data/libt3highlight-0.5.0/src/pcre_compat.c:115:16:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
    copy_end = strncpy((char *)buffer, last_error_message, bufflen);
data/libt3highlight-0.5.0/src/pcre_compat.c:117:16:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120). Risk is low because the source is a
  constant string.
    copy_end = strncpy((char *)buffer, "unknown error", bufflen);

ANALYSIS SUMMARY:

Hits = 56
Lines analyzed = 4610 in approximately 0.16 seconds (29514 lines/second)
Physical Source Lines of Code (SLOC) = 2806
Hits@level = [0]  15 [1]  29 [2]  18 [3]   2 [4]   7 [5]   0
Hits@level+ = [0+]  71 [1+]  56 [2+]  27 [3+]   9 [4+]   7 [5+]   0
Hits/KSLOC@level+ = [0+] 25.3029 [1+] 19.9572 [2+] 9.62224 [3+] 3.20741 [4+] 2.49465 [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.