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/libime-1.0.1/src/libime/core/constants.h Examining data/libime-1.0.1/src/libime/core/datrie.cpp Examining data/libime-1.0.1/src/libime/core/datrie.h Examining data/libime-1.0.1/src/libime/core/decoder.cpp Examining data/libime-1.0.1/src/libime/core/decoder.h Examining data/libime-1.0.1/src/libime/core/dictionary.cpp Examining data/libime-1.0.1/src/libime/core/dictionary.h Examining data/libime-1.0.1/src/libime/core/historybigram.cpp Examining data/libime-1.0.1/src/libime/core/historybigram.h Examining data/libime-1.0.1/src/libime/core/inputbuffer.cpp Examining data/libime-1.0.1/src/libime/core/inputbuffer.h Examining data/libime-1.0.1/src/libime/core/languagemodel.cpp Examining data/libime-1.0.1/src/libime/core/languagemodel.h Examining data/libime-1.0.1/src/libime/core/lattice.cpp Examining data/libime-1.0.1/src/libime/core/lattice.h Examining data/libime-1.0.1/src/libime/core/lattice_p.h Examining data/libime-1.0.1/src/libime/core/lrucache.h Examining data/libime-1.0.1/src/libime/core/naivevector.h Examining data/libime-1.0.1/src/libime/core/prediction.cpp Examining data/libime-1.0.1/src/libime/core/prediction.h Examining data/libime-1.0.1/src/libime/core/segmentgraph.cpp Examining data/libime-1.0.1/src/libime/core/segmentgraph.h Examining data/libime-1.0.1/src/libime/core/triedictionary.cpp Examining data/libime-1.0.1/src/libime/core/triedictionary.h Examining data/libime-1.0.1/src/libime/core/userlanguagemodel.cpp Examining data/libime-1.0.1/src/libime/core/userlanguagemodel.h Examining data/libime-1.0.1/src/libime/core/utils.cpp Examining data/libime-1.0.1/src/libime/core/utils.h Examining data/libime-1.0.1/src/libime/core/utils_p.h Examining data/libime-1.0.1/src/libime/pinyin/constants.h Examining data/libime-1.0.1/src/libime/pinyin/pinyincontext.cpp Examining data/libime-1.0.1/src/libime/pinyin/pinyincontext.h Examining data/libime-1.0.1/src/libime/pinyin/pinyindata.cpp Examining data/libime-1.0.1/src/libime/pinyin/pinyindata.h Examining data/libime-1.0.1/src/libime/pinyin/pinyindecoder.cpp Examining data/libime-1.0.1/src/libime/pinyin/pinyindecoder.h Examining data/libime-1.0.1/src/libime/pinyin/pinyindecoder_p.h Examining data/libime-1.0.1/src/libime/pinyin/pinyindictionary.cpp Examining data/libime-1.0.1/src/libime/pinyin/pinyindictionary.h Examining data/libime-1.0.1/src/libime/pinyin/pinyinencoder.cpp Examining data/libime-1.0.1/src/libime/pinyin/pinyinencoder.h Examining data/libime-1.0.1/src/libime/pinyin/pinyinime.cpp Examining data/libime-1.0.1/src/libime/pinyin/pinyinime.h Examining data/libime-1.0.1/src/libime/pinyin/pinyinmatchstate.cpp Examining data/libime-1.0.1/src/libime/pinyin/pinyinmatchstate.h Examining data/libime-1.0.1/src/libime/pinyin/pinyinmatchstate_p.h Examining data/libime-1.0.1/src/libime/pinyin/shuangpindata.h Examining data/libime-1.0.1/src/libime/pinyin/shuangpinprofile.cpp Examining data/libime-1.0.1/src/libime/pinyin/shuangpinprofile.h Examining data/libime-1.0.1/src/libime/table/autophrasedict.cpp Examining data/libime-1.0.1/src/libime/table/autophrasedict.h Examining data/libime-1.0.1/src/libime/table/constants.h Examining data/libime-1.0.1/src/libime/table/log.cpp Examining data/libime-1.0.1/src/libime/table/log.h Examining data/libime-1.0.1/src/libime/table/tablebaseddictionary.cpp Examining data/libime-1.0.1/src/libime/table/tablebaseddictionary.h Examining data/libime-1.0.1/src/libime/table/tablecontext.cpp Examining data/libime-1.0.1/src/libime/table/tablecontext.h Examining data/libime-1.0.1/src/libime/table/tabledecoder.cpp Examining data/libime-1.0.1/src/libime/table/tabledecoder.h Examining data/libime-1.0.1/src/libime/table/tabledecoder_p.h Examining data/libime-1.0.1/src/libime/table/tableoptions.cpp Examining data/libime-1.0.1/src/libime/table/tableoptions.h Examining data/libime-1.0.1/src/libime/table/tablerule.h Examining data/libime-1.0.1/test/testautophrasedict.cpp Examining data/libime-1.0.1/test/testdecoder.cpp Examining data/libime-1.0.1/test/testhistorybigram.cpp Examining data/libime-1.0.1/test/testinputbuffer.cpp Examining data/libime-1.0.1/test/testmodel.cpp Examining data/libime-1.0.1/test/testpinyincontext.cpp Examining data/libime-1.0.1/test/testpinyindata.cpp Examining data/libime-1.0.1/test/testpinyindictionary.cpp Examining data/libime-1.0.1/test/testpinyinencoder.cpp Examining data/libime-1.0.1/test/testpinyinime.cpp Examining data/libime-1.0.1/test/testprediction.cpp Examining data/libime-1.0.1/test/testshuangpinprofile.cpp Examining data/libime-1.0.1/test/testtable.cpp Examining data/libime-1.0.1/test/testtableime.cpp Examining data/libime-1.0.1/test/testtableime_unit.cpp Examining data/libime-1.0.1/test/testtrie.cpp Examining data/libime-1.0.1/test/testutils.h Examining data/libime-1.0.1/test/triebench.cpp Examining data/libime-1.0.1/tools/libime_history.cpp Examining data/libime-1.0.1/tools/libime_migrate_fcitx4_pinyin.cpp Examining data/libime-1.0.1/tools/libime_migrate_fcitx4_table.cpp Examining data/libime-1.0.1/tools/libime_pinyindict.cpp Examining data/libime-1.0.1/tools/libime_prediction.cpp Examining data/libime-1.0.1/tools/libime_tabledict.cpp Examining data/libime-1.0.1/kenlm/lm/bhiksha.cc Examining data/libime-1.0.1/kenlm/lm/binary_format.cc Examining data/libime-1.0.1/kenlm/lm/build_binary_main.cc Examining data/libime-1.0.1/kenlm/lm/config.cc Examining data/libime-1.0.1/kenlm/lm/fragment_main.cc Examining data/libime-1.0.1/kenlm/lm/kenlm_benchmark_main.cc Examining data/libime-1.0.1/kenlm/lm/left_test.cc Examining data/libime-1.0.1/kenlm/lm/lm_exception.cc Examining data/libime-1.0.1/kenlm/lm/model.cc Examining data/libime-1.0.1/kenlm/lm/model_test.cc Examining data/libime-1.0.1/kenlm/lm/partial_test.cc Examining data/libime-1.0.1/kenlm/lm/quantize.cc Examining data/libime-1.0.1/kenlm/lm/read_arpa.cc Examining data/libime-1.0.1/kenlm/lm/search_hashed.cc Examining data/libime-1.0.1/kenlm/lm/search_trie.cc Examining data/libime-1.0.1/kenlm/lm/sizes.cc Examining data/libime-1.0.1/kenlm/lm/trie.cc Examining data/libime-1.0.1/kenlm/lm/trie_sort.cc Examining data/libime-1.0.1/kenlm/lm/value_build.cc Examining data/libime-1.0.1/kenlm/lm/virtual_interface.cc Examining data/libime-1.0.1/kenlm/lm/vocab.cc Examining data/libime-1.0.1/kenlm/lm/query_main.cc Examining data/libime-1.0.1/kenlm/util/bit_packing.cc Examining data/libime-1.0.1/kenlm/util/bit_packing_test.cc Examining data/libime-1.0.1/kenlm/util/cat_compressed_main.cc Examining data/libime-1.0.1/kenlm/util/ersatz_progress.cc Examining data/libime-1.0.1/kenlm/util/exception.cc Examining data/libime-1.0.1/kenlm/util/file.cc Examining data/libime-1.0.1/kenlm/util/file_piece_test.cc Examining data/libime-1.0.1/kenlm/util/integer_to_string.cc Examining data/libime-1.0.1/kenlm/util/integer_to_string_test.cc Examining data/libime-1.0.1/kenlm/util/joint_sort_test.cc Examining data/libime-1.0.1/kenlm/util/mmap.cc Examining data/libime-1.0.1/kenlm/util/multi_intersection_test.cc Examining data/libime-1.0.1/kenlm/util/murmur_hash.cc Examining data/libime-1.0.1/kenlm/util/parallel_read.cc Examining data/libime-1.0.1/kenlm/util/pcqueue_test.cc Examining data/libime-1.0.1/kenlm/util/pool.cc Examining data/libime-1.0.1/kenlm/util/probing_hash_table_benchmark_main.cc Examining data/libime-1.0.1/kenlm/util/probing_hash_table_test.cc Examining data/libime-1.0.1/kenlm/util/read_compressed.cc Examining data/libime-1.0.1/kenlm/util/read_compressed_test.cc Examining data/libime-1.0.1/kenlm/util/scoped.cc Examining data/libime-1.0.1/kenlm/util/sized_iterator_test.cc Examining data/libime-1.0.1/kenlm/util/sorted_uniform_test.cc Examining data/libime-1.0.1/kenlm/util/spaces.cc Examining data/libime-1.0.1/kenlm/util/string_piece.cc Examining data/libime-1.0.1/kenlm/util/string_stream_test.cc Examining data/libime-1.0.1/kenlm/util/tokenize_piece_test.cc Examining data/libime-1.0.1/kenlm/util/usage.cc Examining data/libime-1.0.1/kenlm/util/file_piece.cc Examining data/libime-1.0.1/kenlm/util/float_to_string.cc FINAL RESULTS: data/libime-1.0.1/kenlm/util/file.cc:588:19: [5] (race) readlink: This accepts filename arguments; if an attacker can move those files or change the link content, a race condition results. Also, it does not terminate with ASCII NUL. (CWE-362, CWE-20). Reconsider approach. ssize_t ret = readlink(name.c_str(), &out[0], out.size()); data/libime-1.0.1/kenlm/util/file_piece_test.cc:86:18: [4] (shell) popen: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. FILE *catter = popen(popen_args.c_str(), "r"); data/libime-1.0.1/kenlm/util/file_piece_test.cc:113:26: [4] (shell) system: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. BOOST_REQUIRE_EQUAL(0, system(command.c_str())); data/libime-1.0.1/kenlm/util/file_piece_test.cc:136:19: [4] (shell) popen: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. FILE * catter = popen(command.c_str(), "r"); data/libime-1.0.1/kenlm/util/read_compressed_test.cc:22:22: [4] (tmpfile) mktemp: Temporary file race condition (CWE-377). char *filename = mktemp(stemplate); data/libime-1.0.1/kenlm/util/read_compressed_test.cc:84:26: [4] (shell) system: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. BOOST_REQUIRE_EQUAL(0, system(command.c_str())); data/libime-1.0.1/kenlm/lm/build_binary_main.cc:115:19: [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, "q:b:a:u:p:t:T:m:S:w:sir:vh")) != -1) { data/libime-1.0.1/kenlm/lm/query_main.cc:40:17: [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, "bnv:l:")) != -1) { data/libime-1.0.1/kenlm/util/file.cc:547:7: [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. getenv data/libime-1.0.1/kenlm/util/file.cc:550:7: [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. getenv data/libime-1.0.1/tools/libime_history.cpp:20:17: [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 ((c = getopt(argc, argv, "h")) != -1) { data/libime-1.0.1/tools/libime_migrate_fcitx4_pinyin.cpp:195:17: [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 ((c = getopt(argc, argv, "Oo:Pp:UXh")) != -1) { data/libime-1.0.1/tools/libime_migrate_fcitx4_table.cpp:670:17: [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 ((c = getopt(argc, argv, "Bb:Oo:Pp:UXh")) != -1) { data/libime-1.0.1/tools/libime_pinyindict.cpp:23:17: [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 ((c = getopt(argc, argv, "dh")) != -1) { data/libime-1.0.1/tools/libime_prediction.cpp:162:17: [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 ((c = getopt(argc, argv, "df:s:h")) != -1) { data/libime-1.0.1/tools/libime_tabledict.cpp:25:17: [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 ((c = getopt(argc, argv, "dhu")) != -1) { data/libime-1.0.1/kenlm/lm/binary_format.cc:18: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. const char *kModelNames[6] = {"probing hash tables", "probing hash tables with rest costs", "trie", "trie with quantization", "trie with array-compressed pointers", "trie with quantization and array-compressed pointers"}; data/libime-1.0.1/kenlm/lm/binary_format.cc:30: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 magic[sizeof(kMagicBytes)]; data/libime-1.0.1/kenlm/lm/binary_format.cc:48: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 magic[ALIGN8(sizeof(kMagicBytes))]; data/libime-1.0.1/kenlm/lm/binary_format.cc:55:10: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. std::memcpy(magic, kMagicBytes, sizeof(kMagicBytes)); data/libime-1.0.1/kenlm/lm/binary_format.cc:71:8: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. std::memcpy(to, &header, sizeof(Sanity)); data/libime-1.0.1/kenlm/lm/quantize.cc:42:12: [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 buffer[3]; data/libime-1.0.1/kenlm/lm/search_trie.cc:72: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(current_, to, entry_size_ - sizeof(ProbPointer)); data/libime-1.0.1/kenlm/lm/trie_sort.cc:43: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(inner_.Data(), from.inner_.Data(), attention_size_); data/libime-1.0.1/kenlm/lm/trie_sort.cc:48: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(inner_.Data(), from.Data(), attention_size_); data/libime-1.0.1/kenlm/lm/vocab.cc:38: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 check_unk[6]; data/libime-1.0.1/kenlm/lm/vocab.cc:119: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(copied, str.data(), str.size()); data/libime-1.0.1/kenlm/util/bit_packing.cc:27: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 mem[57+8]; data/libime-1.0.1/kenlm/util/bit_packing_test.cc:15: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 mem[16]; data/libime-1.0.1/kenlm/util/bit_packing_test.cc:22: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 mem[16]; data/libime-1.0.1/kenlm/util/bit_packing_test.cc:31: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 mem[57+8]; data/libime-1.0.1/kenlm/util/bit_packing_test.cc:43: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 mem[25+8]; data/libime-1.0.1/kenlm/util/exception.cc:73: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[200]; data/libime-1.0.1/kenlm/util/exception.cc:94: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 error_msg[256] = ""; data/libime-1.0.1/kenlm/util/file.cc:76:30: [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). UTIL_THROW_IF(-1 == (ret = open(name, O_RDONLY)), ErrnoException, "while opening " << name); data/libime-1.0.1/kenlm/util/file.cc:86:30: [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). UTIL_THROW_IF(-1 == (ret = open(name, O_CREAT | O_TRUNC | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)), ErrnoException, "while creating " << name); data/libime-1.0.1/kenlm/util/file.cc:491:13: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). int ret = mkstemp(tmpl); data/libime-1.0.1/kenlm/util/file.cc:532: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 dir_buffer[1000]; data/libime-1.0.1/kenlm/util/integer_to_string.cc:54: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. const char gDigitsLut[200] = { data/libime-1.0.1/kenlm/util/integer_to_string.cc:104:24: [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. ALIGN_PRE static const char kAsciiZero[16] ALIGN_SUF = { '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0' }; data/libime-1.0.1/kenlm/util/integer_to_string_test.cc:15: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[ToStringBuf<T>::kBytes]; data/libime-1.0.1/kenlm/util/joint_sort_test.cc:9: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 keys[2]; data/libime-1.0.1/kenlm/util/joint_sort_test.cc:21: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 keys[3]; data/libime-1.0.1/kenlm/util/joint_sort_test.cc:33: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 keys[4]; data/libime-1.0.1/kenlm/util/joint_sort_test.cc:51: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 keys[2] = {0, 1}; data/libime-1.0.1/kenlm/util/mmap.cc:236: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(replacement.get(), mem.get(), mem.size()); data/libime-1.0.1/kenlm/util/mmap.cc:261: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(replacement.get(), mem.get(), std::min(to, mem.size())); data/libime-1.0.1/kenlm/util/murmur_hash.cc:46: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(&k, data, ksize); data/libime-1.0.1/kenlm/util/murmur_hash.cc:103: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(&k1, data, ksize); data/libime-1.0.1/kenlm/util/murmur_hash.cc:105: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(&k2, data, ksize); data/libime-1.0.1/kenlm/util/murmur_hash.cc:124: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(&k1, data, ksize); data/libime-1.0.1/kenlm/util/read_compressed.cc:83: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(buf_.get(), already_data, already_size); data/libime-1.0.1/kenlm/util/read_compressed.cc:92: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(to, remain_, sending); data/libime-1.0.1/kenlm/util/read_compressed.cc:115:15: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. back_(memcpy(in_buffer_.get(), already_data, already_size), already_size) {} data/libime-1.0.1/kenlm/util/read_compressed_test.cc:18:14: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). #if !defined mkstemp data/libime-1.0.1/kenlm/util/read_compressed_test.cc:20:5: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). int mkstemp(char * stemplate) data/libime-1.0.1/kenlm/util/read_compressed_test.cc:25:12: [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). return open(filename, O_RDWR | O_CREAT, 0600); data/libime-1.0.1/kenlm/util/read_compressed_test.cc:48:22: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). scoped_fd original(mkstemp(name)); data/libime-1.0.1/kenlm/util/read_compressed_test.cc:73:21: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). scoped_fd gzipped(mkstemp(gzname)); data/libime-1.0.1/kenlm/util/sized_iterator_test.cc:15: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 items[3] = {1, 2, 0}; data/libime-1.0.1/kenlm/util/string_stream_test.cc:65: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 non_const[3]; data/libime-1.0.1/src/libime/core/datrie.cpp:183:10: [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). void open(std::istream &fin) { data/libime-1.0.1/src/libime/core/datrie.cpp:941:8: [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). d->open(fin); data/libime-1.0.1/src/libime/core/datrie.cpp:946:8: [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). d->open(fin); data/libime-1.0.1/src/libime/core/datrie.cpp:975:8: [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). d->open(in); data/libime-1.0.1/src/libime/core/languagemodel.cpp:43:17: [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). fin.open(d->file_ + ".predict", std::ios::in | std::ios::binary); data/libime-1.0.1/src/libime/core/utils_p.h:27: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(data, &v, sizeof(v)); data/libime-1.0.1/src/libime/core/utils_p.h:53: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(data, &c, sizeof(c)); data/libime-1.0.1/src/libime/pinyin/shuangpindata.h:12: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 strQP[5]; data/libime-1.0.1/src/libime/pinyin/shuangpindata.h:17: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 strQP[3]; data/libime-1.0.1/src/libime/table/tablebaseddictionary.cpp:53: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. const char *strConst[2][STR_LAST] = { data/libime-1.0.1/tools/libime_history.cpp:46:14: [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). fout.open(argv[optind + 1], std::ios::out | std::ios::binary); data/libime-1.0.1/tools/libime_migrate_fcitx4_pinyin.cpp:223:32: [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). sourceFd = UnixFD::own(open(argv[optind], O_RDONLY)); data/libime-1.0.1/tools/libime_migrate_fcitx4_pinyin.cpp:255:34: [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). dictFD = UnixFD::own(open(dictFile, O_RDONLY)); data/libime-1.0.1/tools/libime_migrate_fcitx4_pinyin.cpp:283:37: [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). historyFD = UnixFD::own(open(historyFile, O_RDONLY)); data/libime-1.0.1/tools/libime_migrate_fcitx4_table.cpp:51:26: [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). .open(StandardPath::Type::Config, data/libime-1.0.1/tools/libime_migrate_fcitx4_table.cpp:57:36: [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). sourceFd = UnixFD::own(open(sourceFile.data(), O_RDONLY)); data/libime-1.0.1/tools/libime_migrate_fcitx4_table.cpp:71:30: [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). fd = UnixFD::own(open(path.data(), O_RDONLY)); data/libime-1.0.1/tools/libime_migrate_fcitx4_table.cpp:325:34: [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). baseFd = UnixFD::own(open( data/libime-1.0.1/tools/libime_migrate_fcitx4_table.cpp:331:26: [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). .open(fcitx::StandardPath::Type::PkgData, data/libime-1.0.1/tools/libime_migrate_fcitx4_table.cpp:341:30: [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). baseFd = UnixFD::own(open(option.baseFile.data(), O_RDONLY)); data/libime-1.0.1/tools/libime_pinyindict.cpp:52:14: [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). fout.open(argv[optind + 1], std::ios::out | std::ios::binary); data/libime-1.0.1/tools/libime_prediction.cpp:47:13: [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). fin.open(arpa, std::ios::in | std::ios::binary); data/libime-1.0.1/tools/libime_prediction.cpp:119:14: [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). fout.open(output, std::ios::out | std::ios::binary); data/libime-1.0.1/tools/libime_prediction.cpp:132:13: [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). fin.open(input, std::ios::in | std::ios::binary); data/libime-1.0.1/tools/libime_prediction.cpp:144:14: [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). fout.open(output, std::ios::out | std::ios::binary); data/libime-1.0.1/tools/libime_tabledict.cpp:54:13: [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). fin.open(argv[optind], std::ios::in | std::ios::binary); data/libime-1.0.1/tools/libime_tabledict.cpp:69:14: [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). fout.open(argv[optind + 1], std::ios::out | std::ios::binary); data/libime-1.0.1/kenlm/lm/binary_format.cc:98:52: [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 (!std::memcmp(memory.get(), kMagicIncomplete, strlen(kMagicIncomplete))) { data/libime-1.0.1/kenlm/lm/binary_format.cc:101: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 (!std::memcmp(memory.get(), kMagicBeforeVersion, strlen(kMagicBeforeVersion))) { data/libime-1.0.1/kenlm/lm/binary_format.cc:103:74: [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). const char *begin_version = static_cast<const char*>(memory.get()) + strlen(kMagicBeforeVersion); data/libime-1.0.1/kenlm/lm/binary_format.cc:192:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(reinterpret_cast<char*>(vocab_base), kMagicIncomplete, header_size_); data/libime-1.0.1/kenlm/lm/read_arpa.cc:61: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 (static_cast<size_t>(line.size()) >= strlen(kBinaryMagic) && StringPiece(line.data(), strlen(kBinaryMagic)) == kBinaryMagic) data/libime-1.0.1/kenlm/lm/read_arpa.cc:61:94: [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 (static_cast<size_t>(line.size()) >= strlen(kBinaryMagic) && StringPiece(line.data(), strlen(kBinaryMagic)) == kBinaryMagic) data/libime-1.0.1/kenlm/lm/vocab.cc:157: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). StringPiece str(entry.str, strlen(entry.str)); data/libime-1.0.1/kenlm/util/file.cc:181:11: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ret = read(fd, to, GuardLarge(amount)); data/libime-1.0.1/kenlm/util/file.cc:424: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 (tmpl); data/libime-1.0.1/kenlm/util/read_compressed.cc:326:20: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (!stream_.read(static_cast<char*>(to), amount)) { data/libime-1.0.1/src/libime/core/datrie.cpp:200:30: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). throw_if_io_fail(fin.read(reinterpret_cast<char *>(m_tail.data()), data/libime-1.0.1/src/libime/core/datrie.cpp:288: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). size_t len_tail = std::strlen(&m_tail[-m_array[to].base]); data/libime-1.0.1/src/libime/core/datrie.cpp:306: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). return traverse(key, from, pos, std::strlen(key)); data/libime-1.0.1/src/libime/core/datrie.cpp:318: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). update(key, std::strlen(key), data/libime-1.0.1/src/libime/core/datrie.cpp:462:57: [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). int erase(const char *key) { return erase(key, std::strlen(key)); } data/libime-1.0.1/src/libime/core/datrie.cpp:563: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). const size_t len_ = std::strlen(&m_tail[-base]); data/libime-1.0.1/src/libime/core/inputbuffer.h:30:14: [1] (buffer) equal: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. bool equal(iterator const &other) const { data/libime-1.0.1/src/libime/core/utils.h:64:12: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (in.read(reinterpret_cast<char *>(&c.i), sizeof(c.i))) { data/libime-1.0.1/src/libime/core/utils.h:74:15: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). return in.read(reinterpret_cast<char *>(&data), sizeof(data)); data/libime-1.0.1/src/libime/core/utils.h:86:12: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (in.read(reinterpret_cast<char *>(&c.i), sizeof(c.i))) { data/libime-1.0.1/src/libime/core/utils.h:101:17: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (!in.read(buffer.data(), sizeof(char) * length)) { data/libime-1.0.1/src/libime/core/utils_p.h:57:8: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). in.read(reinterpret_cast<char *>(&data), sizeof(data)); data/libime-1.0.1/src/libime/core/utils_p.h:64:8: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). in.read(reinterpret_cast<char *>(data.data()), sizeof(char) * data.size()); data/libime-1.0.1/src/libime/pinyin/shuangpinprofile.cpp:137:51: [1] (buffer) equal: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. std::string pinyin{lineView.substr(0, equal)}; data/libime-1.0.1/src/libime/pinyin/shuangpinprofile.cpp:147:51: [1] (buffer) equal: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. std::string pinyin{lineView.substr(0, equal)}; data/libime-1.0.1/src/libime/table/tablebaseddictionary.cpp:431: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). if (buf.compare(0, std::strlen(strConst[0][index]), data/libime-1.0.1/src/libime/table/tablebaseddictionary.cpp:435: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). if (buf.compare(0, std::strlen(strConst[1][index]), data/libime-1.0.1/src/libime/table/tablebaseddictionary.cpp:466: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). buf.substr(strlen(strConst[match][STR_KEYCODE])); data/libime-1.0.1/src/libime/table/tablebaseddictionary.cpp:471: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). std::stoi(buf.substr(strlen(strConst[match][STR_CODELEN]))); data/libime-1.0.1/src/libime/table/tablebaseddictionary.cpp:476: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). buf.substr(strlen(strConst[match][STR_IGNORECHAR])); data/libime-1.0.1/src/libime/table/tablebaseddictionary.cpp:481: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). d->pinyinKey_ = buf[strlen(strConst[match][STR_PINYIN])]; data/libime-1.0.1/src/libime/table/tablebaseddictionary.cpp:483: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). d->promptKey_ = buf[strlen(strConst[match][STR_PROMPT])]; data/libime-1.0.1/src/libime/table/tablebaseddictionary.cpp:486: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). buf[strlen(strConst[match][STR_CONSTRUCTPHRASE])]; ANALYSIS SUMMARY: Hits = 121 Lines analyzed = 25419 in approximately 0.99 seconds (25674 lines/second) Physical Source Lines of Code (SLOC) = 20813 Hits@level = [0] 1 [1] 33 [2] 72 [3] 10 [4] 5 [5] 1 Hits@level+ = [0+] 122 [1+] 121 [2+] 88 [3+] 16 [4+] 6 [5+] 1 Hits/KSLOC@level+ = [0+] 5.86172 [1+] 5.81367 [2+] 4.22813 [3+] 0.76875 [4+] 0.288281 [5+] 0.0480469 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.