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/libpyzy-1.0.1/src/Bopomofo.h Examining data/libpyzy-1.0.1/src/BopomofoContext.cc Examining data/libpyzy-1.0.1/src/BopomofoContext.h Examining data/libpyzy-1.0.1/src/BopomofoKeyboard.h Examining data/libpyzy-1.0.1/src/Config.h Examining data/libpyzy-1.0.1/src/Const.h Examining data/libpyzy-1.0.1/src/Database.cc Examining data/libpyzy-1.0.1/src/Database.h Examining data/libpyzy-1.0.1/src/DoublePinyinContext.cc Examining data/libpyzy-1.0.1/src/DoublePinyinContext.h Examining data/libpyzy-1.0.1/src/DoublePinyinTable.h Examining data/libpyzy-1.0.1/src/DynamicSpecialPhrase.cc Examining data/libpyzy-1.0.1/src/DynamicSpecialPhrase.h Examining data/libpyzy-1.0.1/src/FullPinyinContext.cc Examining data/libpyzy-1.0.1/src/FullPinyinContext.h Examining data/libpyzy-1.0.1/src/InputContext.cc Examining data/libpyzy-1.0.1/src/InputContext.h Examining data/libpyzy-1.0.1/src/PhoneticContext.cc Examining data/libpyzy-1.0.1/src/PhoneticContext.h Examining data/libpyzy-1.0.1/src/Phrase.h Examining data/libpyzy-1.0.1/src/PhraseArray.h Examining data/libpyzy-1.0.1/src/PhraseEditor.cc Examining data/libpyzy-1.0.1/src/PhraseEditor.h Examining data/libpyzy-1.0.1/src/PinyinArray.h Examining data/libpyzy-1.0.1/src/PinyinContext.cc Examining data/libpyzy-1.0.1/src/PinyinContext.h Examining data/libpyzy-1.0.1/src/PinyinParser.cc Examining data/libpyzy-1.0.1/src/PinyinParser.h Examining data/libpyzy-1.0.1/src/PinyinParserTable.h Examining data/libpyzy-1.0.1/src/SimpTradConverter.cc Examining data/libpyzy-1.0.1/src/SimpTradConverter.h Examining data/libpyzy-1.0.1/src/SimpTradConverterTable.h Examining data/libpyzy-1.0.1/src/SpecialPhrase.cc Examining data/libpyzy-1.0.1/src/SpecialPhrase.h Examining data/libpyzy-1.0.1/src/SpecialPhraseTable.cc Examining data/libpyzy-1.0.1/src/SpecialPhraseTable.h Examining data/libpyzy-1.0.1/src/String.h Examining data/libpyzy-1.0.1/src/Util.h Examining data/libpyzy-1.0.1/src/Variant.cc Examining data/libpyzy-1.0.1/src/Variant.h Examining data/libpyzy-1.0.1/src/tests/basic.cc Examining data/libpyzy-1.0.1/src/Types.h FINAL RESULTS: data/libpyzy-1.0.1/src/PinyinParser.cc:259:10: [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). std::strcpy (buf, id_map[sheng]); data/libpyzy-1.0.1/src/PinyinParser.cc:276:14: [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). std::strcat (buf, id_map[yun]); data/libpyzy-1.0.1/src/String.h:40:14: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. String & printf (const char *fmt, ...) data/libpyzy-1.0.1/src/Util.h:110: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. str = std::getenv (name); data/libpyzy-1.0.1/src/tests/basic.cc:1040:37: [3] (buffer) g_get_tmp_dir: This function is synonymous with 'getenv("TMP")';it returns untrustable input if the environment can beset by an attacker. It 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. gchar *path = g_build_filename (g_get_tmp_dir(), kPyZyTestDirName, NULL); data/libpyzy-1.0.1/src/Database.cc:78: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. char str[64]; data/libpyzy-1.0.1/src/Database.cc:208:5: [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 (); data/libpyzy-1.0.1/src/Database.cc:241:11: [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). Database::open (void) data/libpyzy-1.0.1/src/Database.cc:402:19: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). g_unlink (tmpfile); data/libpyzy-1.0.1/src/Database.cc:405:30: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). if (sqlite3_open_v2 (tmpfile, &userdb, flags, NULL) != SQLITE_OK) data/libpyzy-1.0.1/src/Database.cc:417:19: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). g_rename (tmpfile, m_buffer); data/libpyzy-1.0.1/src/Database.cc:424:15: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). g_unlink (tmpfile); data/libpyzy-1.0.1/src/Database.h:89: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). bool open (void); data/libpyzy-1.0.1/src/DynamicSpecialPhrase.cc: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 string [32]; data/libpyzy-1.0.1/src/Phrase.h:35: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 phrase[PHRASE_LEN_IN_BYTE]; data/libpyzy-1.0.1/src/Phrase.h:61:14: [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 (pinyin_id + len, a.pinyin_id, a.len << 1); data/libpyzy-1.0.1/src/PinyinParser.cc:67: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 buf[8]; data/libpyzy-1.0.1/src/PinyinParser.cc:257: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 buf[16]; data/libpyzy-1.0.1/src/PinyinParser.cc:268:18: [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. std::strcat (buf, "ue"); data/libpyzy-1.0.1/src/PinyinParser.cc:271:18: [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. std::strcat (buf, "ve"); data/libpyzy-1.0.1/src/PinyinParser.cc:314:5: [2] (buffer) wchar_t: 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. wchar_t buf[MAX_BOPOMOFO_LEN + 1]; data/libpyzy-1.0.1/src/SimpTradConverter.cc:128: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. const char *pp[2]; data/libpyzy-1.0.1/src/String.h:71: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. char str[12]; data/libpyzy-1.0.1/src/Util.h: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 m_uuid[256]; data/libpyzy-1.0.1/src/PinyinParser.cc:77:14: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). std::strncpy (buf, p, len); data/libpyzy-1.0.1/src/PinyinParser.cc:88:10: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). std::strncpy (buf, p, len); data/libpyzy-1.0.1/src/SimpTradConverter.cc:138:22: [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). pend = in + std::strlen (in); ANALYSIS SUMMARY: Hits = 27 Lines analyzed = 23291 in approximately 0.63 seconds (37036 lines/second) Physical Source Lines of Code (SLOC) = 20929 Hits@level = [0] 1 [1] 3 [2] 19 [3] 2 [4] 3 [5] 0 Hits@level+ = [0+] 28 [1+] 27 [2+] 24 [3+] 5 [4+] 3 [5+] 0 Hits/KSLOC@level+ = [0+] 1.33786 [1+] 1.29008 [2+] 1.14673 [3+] 0.238903 [4+] 0.143342 [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.