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/libcangjie-1.3/src/bench.c
Examining data/libcangjie-1.3/src/cangjiecharlist.h
Examining data/libcangjie-1.3/src/cangjieerrors.h
Examining data/libcangjie-1.3/src/cangjie.c
Examining data/libcangjie-1.3/src/cli.c
Examining data/libcangjie-1.3/src/dbbuilder.c
Examining data/libcangjie-1.3/src/cangjiechar.c
Examining data/libcangjie-1.3/src/cangjiecharlist.c
Examining data/libcangjie-1.3/src/cangjiecommon.h
Examining data/libcangjie-1.3/src/cangjie.h
Examining data/libcangjie-1.3/src/cangjiechar.h
Examining data/libcangjie-1.3/tests/test_cangjie.c
Examining data/libcangjie-1.3/tests/test_cangjiecharlist.c
Examining data/libcangjie-1.3/tests/test_cangjiechar.c

FINAL RESULTS:

data/libcangjie-1.3/src/bench.c:27:9:  [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.
#define snprintf sprintf_s
data/libcangjie-1.3/src/cangjie.c:168: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(tmp->cj_query, BASE_QUERY);
data/libcangjie-1.3/src/cangjie.c:176: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(tmp->cj_query, filter_query);
data/libcangjie-1.3/src/cangjie.c:187: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(tmp->shortcode_query, BASE_QUERY);
data/libcangjie-1.3/src/cangjie.c:237: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(cj_query, cj->cj_query);
data/libcangjie-1.3/src/cli.c:140:21:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
                    sprintf(errmsg, "Invalid filter option '%s'", optarg);
data/libcangjie-1.3/src/cli.c:153:21:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
                    sprintf(errmsg, "Invalid query mode '%s'", optarg);
data/libcangjie-1.3/src/cli.c:164:21:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
                    sprintf(errmsg, "Invalid Cangjie version '%s'", optarg);
data/libcangjie-1.3/tests/test_cangjie.c:28: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(buf, name);
data/libcangjie-1.3/tests/test_cangjie.c:30: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(buf, value);
data/libcangjie-1.3/src/cangjie.c:191:21:  [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.
    database_path = getenv("CANGJIE_DB");
data/libcangjie-1.3/src/cli.c:103:15:  [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.
        opt = getopt_long(argc, argv, "f:m:C:h", long_options, &option_index);
data/libcangjie-1.3/src/cangjie.c:71: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(query, "OR ");
data/libcangjie-1.3/src/cangjie.c:94: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(*query, " AND ( ");
data/libcangjie-1.3/src/cangjie.c:97: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(*query, "big5 = 1 ");
data/libcangjie-1.3/src/cangjie.c:103: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(*query, "hkscs = 1 ");
data/libcangjie-1.3/src/cangjie.c:108: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(*query, "punct = 1 ");
data/libcangjie-1.3/src/cangjie.c:113: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(*query, "zh = 1 ");
data/libcangjie-1.3/src/cangjie.c:118: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(*query, "zhuyin = 1 ");
data/libcangjie-1.3/src/cangjie.c:123: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(*query, "kanji = 1 ");
data/libcangjie-1.3/src/cangjie.c:128: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(*query, "katakana = 1 ");
data/libcangjie-1.3/src/cangjie.c:133: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(*query, "hiragana = 1 ");
data/libcangjie-1.3/src/cangjie.c:138: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(*query, "symbol = 1 ");
data/libcangjie-1.3/src/cangjie.c:141: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(*query, ") ");
data/libcangjie-1.3/src/cangjie.c:188: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->shortcode_query, "AND code = '%q';");
data/libcangjie-1.3/src/cangjie.c:249: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(cj_query, "AND code = '%q';");
data/libcangjie-1.3/src/cangjie.c:251: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(cj_query, "AND code GLOB '%q';");
data/libcangjie-1.3/src/cangjie.c:382:21:  [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.
        *radical = (char *)cangjie_radicals[key - 'a'];
data/libcangjie-1.3/src/cangjiechar.h:29: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     chchar[5];
data/libcangjie-1.3/src/cangjiechar.h:30: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     code[6];
data/libcangjie-1.3/src/cli.c:82: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 errmsg[255];
data/libcangjie-1.3/src/dbbuilder.c:81:19:  [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).
    uint32_t zh = atoi(strtok_r(NULL, " ", &saveptr));
data/libcangjie-1.3/src/dbbuilder.c:82: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).
    uint32_t big5 = atoi(strtok_r(NULL, " ", &saveptr));
data/libcangjie-1.3/src/dbbuilder.c:83:22:  [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).
    uint32_t hkscs = atoi(strtok_r(NULL, " ", &saveptr));
data/libcangjie-1.3/src/dbbuilder.c:84:23:  [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).
    uint32_t zhuyin = atoi(strtok_r(NULL, " ", &saveptr));
data/libcangjie-1.3/src/dbbuilder.c:85:22:  [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).
    uint32_t kanji = atoi(strtok_r(NULL, " ", &saveptr));
data/libcangjie-1.3/src/dbbuilder.c:86:25:  [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).
    uint32_t hiragana = atoi(strtok_r(NULL, " ", &saveptr));
data/libcangjie-1.3/src/dbbuilder.c:87:25:  [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).
    uint32_t katakana = atoi(strtok_r(NULL, " ", &saveptr));
data/libcangjie-1.3/src/dbbuilder.c:88:22:  [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).
    uint32_t punct = atoi(strtok_r(NULL, " ", &saveptr));
data/libcangjie-1.3/src/dbbuilder.c:89:23:  [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).
    uint32_t symbol = atoi(strtok_r(NULL, " ", &saveptr));
data/libcangjie-1.3/src/dbbuilder.c:93:26:  [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).
    uint32_t frequency = atoi(strtok_r(NULL, "\0", &saveptr));
data/libcangjie-1.3/src/dbbuilder.c:173: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 line[128];
data/libcangjie-1.3/src/dbbuilder.c:197: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).
    table = fopen(tablefile, "r");
data/libcangjie-1.3/src/cangjie.c:161: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).
    tmp->cj_query = calloc(strlen(BASE_QUERY) + MAX_LEN_FILTER_QUERY + 1,
data/libcangjie-1.3/src/cangjie.c:180: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).
    tmp->shortcode_query = calloc(strlen(BASE_QUERY) + MAX_LEN_CODE_QUERY + 1,
data/libcangjie-1.3/src/cangjie.c:222:31:  [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 (input_code == NULL || strlen(input_code) == 0 || strlen(input_code) > 5) {
data/libcangjie-1.3/src/cangjie.c:222:58:  [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 (input_code == NULL || strlen(input_code) == 0 || strlen(input_code) > 5) {
data/libcangjie-1.3/src/cangjie.c:226:44:  [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 (input_code[0] == '*' || input_code[strlen(input_code) - 1] == '*') {
data/libcangjie-1.3/src/cangjie.c:231: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).
    cj_query = calloc(strlen(cj->cj_query) + MAX_LEN_CODE_QUERY + 1,
data/libcangjie-1.3/src/cangjie.c:244:5:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
    strncpy(query_code, input_code, 5);
data/libcangjie-1.3/src/cangjie.c:317:31:  [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 (input_code == NULL || strlen(input_code) != 1) {
data/libcangjie-1.3/src/cangjiechar.c:37:5:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
    strncpy(tmp->chchar, chchar, 4);
data/libcangjie-1.3/src/cangjiechar.c:40:5:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
    strncpy(tmp->code, code, 5);
data/libcangjie-1.3/src/dbbuilder.c:96:9:  [1] (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 character.
        strcpy(short_code, " ");
data/libcangjie-1.3/src/dbbuilder.c:204:15:  [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(line);
data/libcangjie-1.3/tests/test_cangjie.c:27: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).
    char *buf = (char *)calloc(strlen(name) + strlen(value) + 2, 1);
data/libcangjie-1.3/tests/test_cangjie.c:27:47:  [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).
    char *buf = (char *)calloc(strlen(name) + strlen(value) + 2, 1);
data/libcangjie-1.3/tests/test_cangjie.c:29:5:  [1] (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 character.
    strcat(buf, "=");

ANALYSIS SUMMARY:

Hits = 58
Lines analyzed = 1701 in approximately 0.10 seconds (16646 lines/second)
Physical Source Lines of Code (SLOC) = 1094
Hits@level = [0]  44 [1]  15 [2]  31 [3]   2 [4]  10 [5]   0
Hits@level+ = [0+] 102 [1+]  58 [2+]  43 [3+]  12 [4+]  10 [5+]   0
Hits/KSLOC@level+ = [0+] 93.2358 [1+] 53.0165 [2+] 39.3053 [3+] 10.9689 [4+] 9.14077 [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.