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/highlight-3.41/src/gui-qt/mainwindow.h Examining data/highlight-3.41/src/gui-qt/showtextfile.h Examining data/highlight-3.41/src/gui-qt/io_report.cpp Examining data/highlight-3.41/src/gui-qt/precomp.h Examining data/highlight-3.41/src/gui-qt/io_report.h Examining data/highlight-3.41/src/gui-qt/mainwindow.cpp Examining data/highlight-3.41/src/gui-qt/syntax_chooser.cpp Examining data/highlight-3.41/src/gui-qt/showtextfile.cpp Examining data/highlight-3.41/src/gui-qt/main.cpp Examining data/highlight-3.41/src/gui-qt/syntax_chooser.h Examining data/highlight-3.41/src/cli/help.cpp Examining data/highlight-3.41/src/cli/arg_parser.h Examining data/highlight-3.41/src/cli/cmdlineoptions.h Examining data/highlight-3.41/src/cli/arg_parser.cc Examining data/highlight-3.41/src/cli/cmdlineoptions.cpp Examining data/highlight-3.41/src/cli/help.h Examining data/highlight-3.41/src/cli/main.h Examining data/highlight-3.41/src/cli/main.cpp Examining data/highlight-3.41/src/include/enums.h Examining data/highlight-3.41/src/include/syntaxreader.h Examining data/highlight-3.41/src/include/codegenerator.h Examining data/highlight-3.41/src/include/bbcodegenerator.h Examining data/highlight-3.41/src/include/stylecolour.h Examining data/highlight-3.41/src/include/ansigenerator.h Examining data/highlight-3.41/src/include/odtgenerator.h Examining data/highlight-3.41/src/include/charcodes.h Examining data/highlight-3.41/src/include/xterm256generator.h Examining data/highlight-3.41/src/include/platform_fs.h Examining data/highlight-3.41/src/include/rtfgenerator.h Examining data/highlight-3.41/src/include/version.h Examining data/highlight-3.41/src/include/pangogenerator.h Examining data/highlight-3.41/src/include/Diluculum/LuaUserData.hpp Examining data/highlight-3.41/src/include/Diluculum/LuaState.hpp Examining data/highlight-3.41/src/include/Diluculum/LuaWrappers.hpp Examining data/highlight-3.41/src/include/Diluculum/LuaExceptions.hpp Examining data/highlight-3.41/src/include/Diluculum/LuaVariable.hpp Examining data/highlight-3.41/src/include/Diluculum/Types.hpp Examining data/highlight-3.41/src/include/Diluculum/LuaFunction.hpp Examining data/highlight-3.41/src/include/Diluculum/LuaUtils.hpp Examining data/highlight-3.41/src/include/Diluculum/LuaValue.hpp Examining data/highlight-3.41/src/include/Diluculum/CppObject.hpp Examining data/highlight-3.41/src/include/htmlgenerator.h Examining data/highlight-3.41/src/include/elementstyle.h Examining data/highlight-3.41/src/include/stringtools.h Examining data/highlight-3.41/src/include/xhtmlgenerator.h Examining data/highlight-3.41/src/include/preformatter.h Examining data/highlight-3.41/src/include/astyle/ASStreamIterator.h Examining data/highlight-3.41/src/include/astyle/astyle.h Examining data/highlight-3.41/src/include/texgenerator.h Examining data/highlight-3.41/src/include/svggenerator.h Examining data/highlight-3.41/src/include/latexgenerator.h Examining data/highlight-3.41/src/include/themereader.h Examining data/highlight-3.41/src/include/datadir.h Examining data/highlight-3.41/src/core/bbcodegenerator.cpp Examining data/highlight-3.41/src/core/codegenerator.cpp Examining data/highlight-3.41/src/core/odtgenerator.cpp Examining data/highlight-3.41/src/core/pangogenerator.cpp Examining data/highlight-3.41/src/core/platform_fs.cpp Examining data/highlight-3.41/src/core/ansigenerator.cpp Examining data/highlight-3.41/src/core/latexgenerator.cpp Examining data/highlight-3.41/src/core/stringtools.cpp Examining data/highlight-3.41/src/core/htmlgenerator.cpp Examining data/highlight-3.41/src/core/datadir.cpp Examining data/highlight-3.41/src/core/themereader.cpp Examining data/highlight-3.41/src/core/preformatter.cpp Examining data/highlight-3.41/src/core/Diluculum/InternalUtils.cpp Examining data/highlight-3.41/src/core/Diluculum/LuaFunction.cpp Examining data/highlight-3.41/src/core/Diluculum/LuaUtils.cpp Examining data/highlight-3.41/src/core/Diluculum/LuaUserData.cpp Examining data/highlight-3.41/src/core/Diluculum/LuaVariable.cpp Examining data/highlight-3.41/src/core/Diluculum/LuaExceptions.cpp Examining data/highlight-3.41/src/core/Diluculum/LuaState.cpp Examining data/highlight-3.41/src/core/Diluculum/InternalUtils.hpp Examining data/highlight-3.41/src/core/Diluculum/LuaWrappers.cpp Examining data/highlight-3.41/src/core/Diluculum/LuaValue.cpp Examining data/highlight-3.41/src/core/elementstyle.cpp Examining data/highlight-3.41/src/core/svggenerator.cpp Examining data/highlight-3.41/src/core/stylecolour.cpp Examining data/highlight-3.41/src/core/astyle/ASStreamIterator.cpp Examining data/highlight-3.41/src/core/astyle/ASResource.cpp Examining data/highlight-3.41/src/core/astyle/ASFormatter.cpp Examining data/highlight-3.41/src/core/astyle/ASEnhancer.cpp Examining data/highlight-3.41/src/core/astyle/ASBeautifier.cpp Examining data/highlight-3.41/src/core/syntaxreader.cpp Examining data/highlight-3.41/src/core/rtfgenerator.cpp Examining data/highlight-3.41/src/core/xhtmlgenerator.cpp Examining data/highlight-3.41/src/core/xterm256generator.cpp Examining data/highlight-3.41/src/core/texgenerator.cpp Examining data/highlight-3.41/extras/tcl/tclhighlight.c FINAL RESULTS: data/highlight-3.41/src/gui-qt/main.cpp:48:90: [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. translator.load(QString("%1/gui_files/l10n/highlight_%2").arg(DATA_DIR).arg(QLocale::system().name())); data/highlight-3.41/src/gui-qt/main.cpp:50:101: [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. translator.load(QString("%1/gui_files/l10n/highlight_%2").arg(QDir::currentPath()).arg(QLocale::system().name())); data/highlight-3.41/src/cli/cmdlineoptions.cpp:191:24: [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* hlEnvOptions=getenv("HIGHLIGHT_OPTIONS"); data/highlight-3.41/src/core/datadir.cpp:50: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. char* hlEnvPath=getenv("HIGHLIGHT_DATADIR"); data/highlight-3.41/src/core/Diluculum/InternalUtils.cpp:116: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. memcpy (buff.get(), f->getData(), f->getSize()); data/highlight-3.41/src/core/Diluculum/InternalUtils.cpp:117: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. memcpy (buff.get() + f->getSize(), data, size); data/highlight-3.41/src/core/Diluculum/LuaFunction.cpp:38: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(data_.typeLuaFunction, luaChunk.c_str(), size_); data/highlight-3.41/src/core/Diluculum/LuaFunction.cpp:45: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(data_.typeLuaFunction, data, size); data/highlight-3.41/src/core/Diluculum/LuaFunction.cpp:62:13: [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 (getData(), other.getData(), getSize()); data/highlight-3.41/src/core/Diluculum/LuaFunction.cpp:67:13: [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_, &other.data_, sizeof(PossibleTypes)); data/highlight-3.41/src/core/Diluculum/LuaFunction.cpp:94: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(data_.typeLuaFunction, data, size); data/highlight-3.41/src/core/Diluculum/LuaFunction.cpp:111:13: [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 (getData(), rhs.getData(), getSize()); data/highlight-3.41/src/core/Diluculum/LuaFunction.cpp:116:13: [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_, &rhs.data_, sizeof(PossibleTypes)); data/highlight-3.41/src/core/Diluculum/LuaUserData.cpp:42: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 (data_.get(), other.getData(), getSize()); data/highlight-3.41/src/core/Diluculum/LuaUserData.cpp:52: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 (getData(), rhs.getData(), getSize()); data/highlight-3.41/src/core/Diluculum/LuaUtils.cpp:67:13: [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 (ud.getData(), addr, size); data/highlight-3.41/src/core/Diluculum/LuaUtils.cpp:155:13: [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 (addr, value.asUserData().getData(), size); data/highlight-3.41/src/core/Diluculum/LuaValue.cpp:195:13: [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_, &other.data_, sizeof(PossibleTypes)); data/highlight-3.41/src/core/Diluculum/LuaValue.cpp:229:13: [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_, &rhs.data_, sizeof(PossibleTypes)); data/highlight-3.41/src/core/astyle/ASStreamIterator.cpp:106:4: [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(outputEOL, "\r\n"); // Windows (CR+LF) data/highlight-3.41/src/core/codegenerator.cpp:471:75: [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). make_pair ( matchBegin + 1 + offset, ReGroup ( regexElem->open, cur->length(groupID), regexElem->kwClass, regexElem->langName ) ) ); data/highlight-3.41/src/core/codegenerator.cpp:812:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buffer [10]= {0}; data/highlight-3.41/src/core/platform_fs.cpp:57: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 pathAndName[MAX_PATH], path[MAX_PATH], drive[3]; data/highlight-3.41/src/core/rtfgenerator.cpp:191: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 styleName[20]; data/highlight-3.41/src/core/rtfgenerator.cpp:193:13: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf ( styleName, "HL Keyword %c", 'A'+i ); //maybe better simple numbering data/highlight-3.41/src/core/syntaxreader.cpp:431: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 className[5]= {0}; data/highlight-3.41/src/core/themereader.cpp:114: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 kwName[5]; data/highlight-3.41/src/core/xterm256generator.cpp:93:14: [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 rgb[3]; data/highlight-3.41/src/core/xterm256generator.cpp:155:14: [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 c, rgb[3]; data/highlight-3.41/src/gui-qt/mainwindow.cpp:58:19: [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). if (filterDef.open(QIODevice::ReadOnly | QIODevice::Text)) { data/highlight-3.41/src/gui-qt/showtextfile.cpp:67:15: [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). if ( file.open( QIODevice::ReadOnly) ) { data/highlight-3.41/src/include/astyle/ASStreamIterator.h:66: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 outputEOL[4]; // output end of line char data/highlight-3.41/src/include/syntaxreader.h:395: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). :open ( STANDARD ), end ( STANDARD ), kwClass ( 0 ),capturingGroup ( -1 ), langName(), instanceId(instanceCnt++) data/highlight-3.41/src/include/syntaxreader.h:401:9: [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 ( oState ), end ( eState ), kwClass ( cID ), capturingGroup ( group ), langName(name),instanceId(instanceCnt++) data/highlight-3.41/src/include/syntaxreader.h:411: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). State open, ///< opening state data/highlight-3.41/src/include/xterm256generator.h:106: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. static unsigned char colortable[254][3]; data/highlight-3.41/src/include/xterm256generator.h:112:27: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. static const unsigned char basic16[16][3]; data/highlight-3.41/src/cli/arg_parser.cc:38: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). if( std::strlen( options[i].name ) == len ) // Exact match found data/highlight-3.41/src/core/astyle/ASStreamIterator.cpp:108:4: [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(outputEOL, "\r"); // MacOld (CR) data/highlight-3.41/src/core/astyle/ASStreamIterator.cpp:111:3: [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(outputEOL, "\n"); // Linux (LF) data/highlight-3.41/src/core/astyle/ASStreamIterator.cpp:113:3: [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(outputEOL, "\r"); // MacOld (CR) data/highlight-3.41/src/core/codegenerator.cpp:813:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). in->read ( buffer,8 ); //only read the first 8 bytes of input stream data/highlight-3.41/src/core/codegenerator.cpp:817:59: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). if ( !strncmp ( buffer, magic_table[magic_index], strlen ( magic_table[magic_index] ) ) ) { data/highlight-3.41/src/core/stringtools.cpp:128:17: [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. return std::equal(ending.rbegin(), ending.rend(), value.rbegin()); data/highlight-3.41/src/include/astyle/astyle.h:1039:40: [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 currentLine.compare(charNum, strlen(sequence), sequence) == 0; } ANALYSIS SUMMARY: Hits = 45 Lines analyzed = 32834 in approximately 0.81 seconds (40417 lines/second) Physical Source Lines of Code (SLOC) = 22344 Hits@level = [0] 2 [1] 8 [2] 33 [3] 2 [4] 2 [5] 0 Hits@level+ = [0+] 47 [1+] 45 [2+] 37 [3+] 4 [4+] 2 [5+] 0 Hits/KSLOC@level+ = [0+] 2.10347 [1+] 2.01396 [2+] 1.65593 [3+] 0.179019 [4+] 0.0895095 [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.