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/ctemplate-2.4/src/base/arena-inl.h Examining data/ctemplate-2.4/src/base/arena.cc Examining data/ctemplate-2.4/src/base/arena.h Examining data/ctemplate-2.4/src/base/fileutil.h Examining data/ctemplate-2.4/src/base/macros.h Examining data/ctemplate-2.4/src/base/manual_constructor.h Examining data/ctemplate-2.4/src/base/mutex.h Examining data/ctemplate-2.4/src/base/small_map.h Examining data/ctemplate-2.4/src/base/thread_annotations.h Examining data/ctemplate-2.4/src/base/util.h Examining data/ctemplate-2.4/src/diff_tpl_auto_escape.cc Examining data/ctemplate-2.4/src/htmlparser/htmlparser.cc Examining data/ctemplate-2.4/src/htmlparser/htmlparser.h Examining data/ctemplate-2.4/src/htmlparser/htmlparser_cpp.h Examining data/ctemplate-2.4/src/htmlparser/jsparser.cc Examining data/ctemplate-2.4/src/htmlparser/jsparser.h Examining data/ctemplate-2.4/src/htmlparser/statemachine.cc Examining data/ctemplate-2.4/src/htmlparser/statemachine.h Examining data/ctemplate-2.4/src/indented_writer.h Examining data/ctemplate-2.4/src/make_tpl_varnames_h.cc Examining data/ctemplate-2.4/src/per_expand_data.cc Examining data/ctemplate-2.4/src/template.cc Examining data/ctemplate-2.4/src/template_annotator.cc Examining data/ctemplate-2.4/src/template_cache.cc Examining data/ctemplate-2.4/src/template_dictionary.cc Examining data/ctemplate-2.4/src/template_modifiers.cc Examining data/ctemplate-2.4/src/template_modifiers_internal.h Examining data/ctemplate-2.4/src/template_namelist.cc Examining data/ctemplate-2.4/src/template_pathops.cc Examining data/ctemplate-2.4/src/template_string.cc Examining data/ctemplate-2.4/src/tests/compile_test.cc Examining data/ctemplate-2.4/src/tests/config_for_unittests.h Examining data/ctemplate-2.4/src/tests/generate_fsm_c_test.c Examining data/ctemplate-2.4/src/tests/htmlparser_cpp_test.cc Examining data/ctemplate-2.4/src/tests/htmlparser_testdata/sample_fsm.c Examining data/ctemplate-2.4/src/tests/statemachine_test.c Examining data/ctemplate-2.4/src/tests/template_cache_test.cc Examining data/ctemplate-2.4/src/tests/template_dictionary_unittest.cc Examining data/ctemplate-2.4/src/tests/template_modifiers_unittest.cc Examining data/ctemplate-2.4/src/tests/template_regtest.cc Examining data/ctemplate-2.4/src/tests/template_setglobals_unittest.cc Examining data/ctemplate-2.4/src/tests/template_test_util.cc Examining data/ctemplate-2.4/src/tests/template_test_util.h Examining data/ctemplate-2.4/src/tests/template_test_util_test.cc Examining data/ctemplate-2.4/src/tests/template_unittest.cc Examining data/ctemplate-2.4/src/windows/config.h Examining data/ctemplate-2.4/src/windows/ctemplate/find_ptr.h Examining data/ctemplate-2.4/src/windows/ctemplate/per_expand_data.h Examining data/ctemplate-2.4/src/windows/ctemplate/str_ref.h Examining data/ctemplate-2.4/src/windows/ctemplate/template.h Examining data/ctemplate-2.4/src/windows/ctemplate/template_annotator.h Examining data/ctemplate-2.4/src/windows/ctemplate/template_cache.h Examining data/ctemplate-2.4/src/windows/ctemplate/template_dictionary.h Examining data/ctemplate-2.4/src/windows/ctemplate/template_dictionary_interface.h Examining data/ctemplate-2.4/src/windows/ctemplate/template_emitter.h Examining data/ctemplate-2.4/src/windows/ctemplate/template_enums.h Examining data/ctemplate-2.4/src/windows/ctemplate/template_modifiers.h Examining data/ctemplate-2.4/src/windows/ctemplate/template_namelist.h Examining data/ctemplate-2.4/src/windows/ctemplate/template_pathops.h Examining data/ctemplate-2.4/src/windows/ctemplate/template_string.h Examining data/ctemplate-2.4/src/windows/port.cc Examining data/ctemplate-2.4/src/windows/port.h FINAL RESULTS: data/ctemplate-2.4/src/base/fileutil.h:71:12: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. return access(filename, R_OK) == 0; data/ctemplate-2.4/src/diff_tpl_auto_escape.cc:118:3: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(severity == LOG_INFO || severity == LOG_VERBOSE ? stdout: stderr, data/ctemplate-2.4/src/htmlparser/htmlparser.cc:816:3: [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(dst->tag, src->tag); data/ctemplate-2.4/src/htmlparser/htmlparser.cc:817:3: [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(dst->attr, src->attr); data/ctemplate-2.4/src/htmlparser/htmlparser.cc:818:3: [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(dst->value, src->value); data/ctemplate-2.4/src/make_tpl_varnames_h.cc:102:3: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(stderr, pat, ap); data/ctemplate-2.4/src/template_dictionary.cc:379:16: [4] (format) vsnprintf: 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. int result = vsnprintf(space, kBufsize, format, backup_ap); data/ctemplate-2.4/src/template_dictionary.cc:401:14: [4] (format) vsnprintf: 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. result = vsnprintf(buf, length, format, backup_ap); data/ctemplate-2.4/src/template_dictionary.cc:557:3: [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. snprintf(index_str, sizeof(index_str), "%" PRIuS, index); data/ctemplate-2.4/src/template_dictionary.cc:854:5: [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. snprintf(buf, sizeof(buf), "%" PRIuS " of %" PRIuS, index, size); data/ctemplate-2.4/src/tests/template_dictionary_unittest.cc:150:5: [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. snprintf(expected, sizeof(expected), data/ctemplate-2.4/src/tests/template_test_util.cc:115:3: [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(g_tmpdir, dirname.c_str()); data/ctemplate-2.4/src/tests/template_test_util.cc:176:3: [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, outstring.c_str()); data/ctemplate-2.4/src/tests/template_test_util.cc:190:3: [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, outstring.c_str()); data/ctemplate-2.4/src/windows/port.cc:53:5: [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. int snprintf(char *str, size_t size, const char *format, ...) { data/ctemplate-2.4/src/windows/port.cc:57:7: [4] (format) vsnprintf: 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. r = vsnprintf(str, size, format, ap); data/ctemplate-2.4/src/windows/port.h:73:9: [4] (race) access: This usually indicates a security flaw. If an attacker can change anything along the path between the call to access() and the file's actual use (e.g., by moving files), the attacker can exploit the race condition (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid()) and try to open the file directly. #define access _access data/ctemplate-2.4/src/windows/port.h:80:9: [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. #define popen _popen data/ctemplate-2.4/src/windows/port.h:104:31: [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. extern CTEMPLATE_DLL_DECL int snprintf(char *str, size_t size, data/ctemplate-2.4/src/windows/port.h:108:9: [4] (format) vsnprintf: 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 vsnprintf(str, size, format, ap) safe_vsnprintf(str, size, format, ap) data/ctemplate-2.4/src/base/mutex.h:254:3: [3] (misc) InitializeCriticalSection: Exceptions can be thrown in low-memory situations. Use InitializeCriticalSectionAndSpinCount instead. InitializeCriticalSection(&mutex_); data/ctemplate-2.4/src/base/mutex.h:258:3: [3] (misc) InitializeCriticalSection: Exceptions can be thrown in low-memory situations. Use InitializeCriticalSectionAndSpinCount instead. InitializeCriticalSection(&mutex_); data/ctemplate-2.4/src/base/mutex.h:262:44: [3] (misc) EnterCriticalSection: On some versions of Windows, exceptions can be thrown in low-memory situations. Use InitializeCriticalSectionAndSpinCount instead. void Mutex::Lock() { if (is_safe_) EnterCriticalSection(&mutex_); } data/ctemplate-2.4/src/diff_tpl_auto_escape.cc:284:30: [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. # define GETOPT(argc, argv) getopt_long(argc, argv, "t:s:hvV", \ data/ctemplate-2.4/src/diff_tpl_auto_escape.cc:287:30: [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. # define GETOPT(argc, argv) getopt(argc, argv, "t:s:hvV") data/ctemplate-2.4/src/make_tpl_varnames_h.cc:326:30: [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. # define GETOPT(argc, argv) getopt_long(argc, argv, "t:o:s:f:ndqhV", \ data/ctemplate-2.4/src/make_tpl_varnames_h.cc:329:30: [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. # define GETOPT(argc, argv) getopt(argc, argv, "t:o:s:f:ndqhV") data/ctemplate-2.4/src/tests/htmlparser_cpp_test.cc:537:34: [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. const char* template_rootdir = getenv("TEMPLATE_ROOTDIR"); data/ctemplate-2.4/src/tests/template_regtest.cc:480:34: [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. const char* template_rootdir = getenv("TEMPLATE_ROOTDIR"); data/ctemplate-2.4/src/base/arena.cc:486: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(newstr, s, min(oldsize, newsize)); data/ctemplate-2.4/src/base/arena.cc:500: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(newstr, s, min(oldsize, newsize)); data/ctemplate-2.4/src/base/arena.h:511: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(newstr, s, bytes); data/ctemplate-2.4/src/base/arena.h:516: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(newstr, s, bytes); data/ctemplate-2.4/src/base/arena.h:523: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(newstr, s, bytes); data/ctemplate-2.4/src/base/arena.h:633: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(newstr, s, bytes); data/ctemplate-2.4/src/base/arena.h:638: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(newstr, s, bytes); data/ctemplate-2.4/src/base/arena.h:645: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(newstr, s, bytes); data/ctemplate-2.4/src/base/fileutil.h:75: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 binary_mode[3]; data/ctemplate-2.4/src/base/fileutil.h:85:16: [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). FILE* fp = fopen(filename, mode_to_use); data/ctemplate-2.4/src/base/manual_constructor.h:67:56: [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. template<int size> struct AlignType<0, size> { typedef char result[size]; }; data/ctemplate-2.4/src/base/manual_constructor.h:81:41: [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. typedef UTIL_GTL_ALIGN_ATTRIBUTE(X) char result[size]; \ data/ctemplate-2.4/src/base/manual_constructor.h:116:28: [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. struct AlignType { typedef char result[Size]; }; data/ctemplate-2.4/src/base/util.h:180:10: [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). return atoi(s); data/ctemplate-2.4/src/htmlparser/htmlparser.cc:338: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(dst, src, sizeof(entityfilter_ctx)); data/ctemplate-2.4/src/htmlparser/htmlparser.h:123: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[HTMLPARSER_MAX_ENTITY_SIZE]; data/ctemplate-2.4/src/htmlparser/htmlparser.h:128: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 output[HTMLPARSER_MAX_ENTITY_SIZE]; data/ctemplate-2.4/src/htmlparser/htmlparser.h:194: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 tag[HTMLPARSER_MAX_STRING]; data/ctemplate-2.4/src/htmlparser/htmlparser.h:197: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 attr[HTMLPARSER_MAX_STRING]; data/ctemplate-2.4/src/htmlparser/htmlparser.h:200: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 value[HTMLPARSER_MAX_STRING]; data/ctemplate-2.4/src/htmlparser/jsparser.cc:448: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 buffer[JSPARSER_RING_BUFFER_SIZE]; data/ctemplate-2.4/src/htmlparser/jsparser.cc:620: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(dst->buffer, src->buffer, sizeof(src->buffer)); data/ctemplate-2.4/src/htmlparser/jsparser.h:83: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 buffer[JSPARSER_RING_BUFFER_SIZE]; data/ctemplate-2.4/src/htmlparser/statemachine.cc:286: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(dst, src, sizeof(statemachine_ctx)); data/ctemplate-2.4/src/htmlparser/statemachine.cc:361: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 encoded_char[10]; data/ctemplate-2.4/src/htmlparser/statemachine.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 record_buffer[STATEMACHINE_RECORD_BUFFER_SIZE]; data/ctemplate-2.4/src/htmlparser/statemachine.h:91: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 error_msg[STATEMACHINE_MAX_STR_ERROR]; data/ctemplate-2.4/src/make_tpl_varnames_h.cc:287:19: [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). FILE* outfile = fopen(output_file.c_str(), "wb"); data/ctemplate-2.4/src/template.cc:2140: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(buffer, content.data(), content_len); data/ctemplate-2.4/src/template.cc:2513: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(buffer, line, len); data/ctemplate-2.4/src/template_dictionary.cc:441: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 buffer[64]; // big enough for any int data/ctemplate-2.4/src/template_dictionary.cc:532: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(value_copy, value.ptr_, value.length_); data/ctemplate-2.4/src/template_dictionary.cc:556: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 index_str[64]; data/ctemplate-2.4/src/template_dictionary.cc:853: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[64]; // big enough for two ints data/ctemplate-2.4/src/template_modifiers.cc:236: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 tags[5]; data/ctemplate-2.4/src/template_modifiers.cc:529: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. static const char kCodeLengths[256] = { data/ctemplate-2.4/src/tests/htmlparser_cpp_test.cc:98: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 buffer[bufsize]; data/ctemplate-2.4/src/tests/htmlparser_cpp_test.cc:100:14: [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). FILE* fp = fopen(filename, "rb"); data/ctemplate-2.4/src/tests/statemachine_test.c:170: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 expected[STATEMACHINE_RECORD_BUFFER_SIZE]; data/ctemplate-2.4/src/tests/statemachine_test.c:225: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(expected, "0123456789ABCDEF"); data/ctemplate-2.4/src/tests/statemachine_test.c:227:3: [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(expected, "0123456789ABCDE"); data/ctemplate-2.4/src/tests/statemachine_test.c:313: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 encoded_char[10]; data/ctemplate-2.4/src/tests/template_dictionary_unittest.cc:149: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 expected[256]; data/ctemplate-2.4/src/tests/template_dictionary_unittest.cc:174: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 value[32]; data/ctemplate-2.4/src/tests/template_dictionary_unittest.cc:591: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 value[32]; data/ctemplate-2.4/src/tests/template_regtest.cc:147: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 buffer[bufsize]; data/ctemplate-2.4/src/tests/template_regtest.cc:149:14: [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). FILE* fp = fopen(filename.c_str(), "rb"); data/ctemplate-2.4/src/tests/template_test_util.cc:127:14: [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). FILE* fp = fopen(filename.c_str(), "wb"); data/ctemplate-2.4/src/tests/template_test_util.cc:150: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[16]; data/ctemplate-2.4/src/tests/template_unittest.cc:358: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[128]; data/ctemplate-2.4/src/tests/template_unittest.cc:399: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 expected[10240]; // 10k should be big enough! data/ctemplate-2.4/src/tests/template_unittest.cc:1514:14: [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). FILE* fp = fopen(f1_copy.c_str(), "ab"); data/ctemplate-2.4/src/windows/port.cc:75: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 tmppath_buffer[1024]; data/ctemplate-2.4/src/windows/port.h:75: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). #define open _open data/ctemplate-2.4/src/base/arena.h:527: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). return Memdup(s, strlen(s) + 1); data/ctemplate-2.4/src/base/arena.h:649: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). return Memdup(s, strlen(s) + 1); data/ctemplate-2.4/src/htmlparser/htmlparser.cc:90:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(dst, src, size); data/ctemplate-2.4/src/htmlparser/htmlparser.cc:276: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 (strncasecmp(value, "url", strlen("url")) != 0) data/ctemplate-2.4/src/htmlparser/htmlparser.cc:279:12: [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). value += strlen("url"); data/ctemplate-2.4/src/htmlparser/htmlparser.cc:940:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(ctx->value, statemachine_record_buffer(ctx->statemachine), data/ctemplate-2.4/src/htmlparser/htmlparser.h:432:69: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). static_cast<int>(strlen(b))); data/ctemplate-2.4/src/htmlparser/htmlparser.h:434:63: [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). #define htmlparser_parse_str(a,b) htmlparser_parse(a, b, (int)strlen(b)); data/ctemplate-2.4/src/htmlparser/jsparser.h:163:65: [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). static_cast<int>(strlen(b))); data/ctemplate-2.4/src/htmlparser/jsparser.h:165: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). #define jsparser_parse_str(a,b) jsparser_parse(a, b, (int)strlen(b)); data/ctemplate-2.4/src/htmlparser/statemachine.cc:334:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(output, "\\'", len); data/ctemplate-2.4/src/htmlparser/statemachine.cc:336:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(output, "\\\\", len); data/ctemplate-2.4/src/htmlparser/statemachine.cc:342:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(output, "\\n", len); data/ctemplate-2.4/src/htmlparser/statemachine.cc:344:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(output, "\\r", len); data/ctemplate-2.4/src/htmlparser/statemachine.cc:346:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(output, "\\t", len); data/ctemplate-2.4/src/template.cc:100:6: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). ( strlen(str) > (sizeof("" suffix "") - 1) && \ data/ctemplate-2.4/src/template.cc:101:19: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). strcmp(str + strlen(str) - (sizeof(suffix) - 1), suffix) == 0 ) data/ctemplate-2.4/src/template.cc:289:10: [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 ((strlen(g_pragmas[i].identifier) == id_len) && data/ctemplate-2.4/src/template.cc:304:10: [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 ((strlen(attr_name) == namelen) && data/ctemplate-2.4/src/template.cc:315: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). assert(IsValidAttribute(pragma_id_, attribute_name, strlen(attribute_name))); data/ctemplate-2.4/src/template.cc:2253:39: [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). kMainSectionName, strlen(kMainSectionName), NULL), data/ctemplate-2.4/src/tests/htmlparser_cpp_test.cc:295:29: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). strlen(kDirectiveBegin) + strlen(kDirectiveEnd)); data/ctemplate-2.4/src/tests/htmlparser_cpp_test.cc:295: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). strlen(kDirectiveBegin) + strlen(kDirectiveEnd)); data/ctemplate-2.4/src/tests/htmlparser_cpp_test.cc:299: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). return static_cast<int>(str.size() + strlen(kDirectiveEnd) - last_newline); data/ctemplate-2.4/src/tests/htmlparser_cpp_test.cc:561: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). start_annotation += strlen(kDirectiveBegin); data/ctemplate-2.4/src/tests/htmlparser_cpp_test.cc:573: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). start_html = end_annotation + strlen(kDirectiveEnd); data/ctemplate-2.4/src/tests/statemachine_test.c:82:62: [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). #define statemachine_parse_str(a,b) statemachine_parse(a, b, strlen(b)); data/ctemplate-2.4/src/tests/statemachine_test.c:215:10: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). strlen(statemachine_stop_record(sm))); data/ctemplate-2.4/src/tests/template_dictionary_unittest.cc:314: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). TemplateString("section1__ignored__", strlen("section1"))); data/ctemplate-2.4/src/tests/template_dictionary_unittest.cc:618: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). TemplateString("include1__ignored__", strlen("include1"))); data/ctemplate-2.4/src/tests/template_regtest.cc:120: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). const size_t exceptlen = strlen(except); data/ctemplate-2.4/src/tests/template_setglobals_unittest.cc:60:13: [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). EXPECT_EQ(strlen("/some/directory/path")+1, // assert they added a char data/ctemplate-2.4/src/tests/template_setglobals_unittest.cc:64: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). strlen("/some/directory/path"))); data/ctemplate-2.4/src/tests/template_unittest.cc:142: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). const size_t exceptlen = strlen(except); data/ctemplate-2.4/src/tests/template_unittest.cc:184: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). virtual void Emit(const char* s) { Emit(s, strlen(s)); } data/ctemplate-2.4/src/tests/template_unittest.cc:240:10: [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). i += strlen("Variable Node: "); data/ctemplate-2.4/src/tests/template_unittest.cc:1031:54: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). dict.SetValue("VAR", TemplateString("short-lived", strlen("short"))); data/ctemplate-2.4/src/tests/template_unittest.cc:2129:56: [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). dict.SetValue("VAR", TemplateString("short-lived", strlen("short"))); data/ctemplate-2.4/src/windows/ctemplate/str_ref.h:78:17: [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). assign(b, strlen(b)); data/ctemplate-2.4/src/windows/ctemplate/template.h:415: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). start_marker_len = strlen(start_marker); data/ctemplate-2.4/src/windows/ctemplate/template.h:417:24: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). end_marker_len = strlen(end_marker); data/ctemplate-2.4/src/windows/ctemplate/template_modifiers.h:212: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). unsafe_url_replacement_length_(strlen(unsafe_url_replacement)) { } data/ctemplate-2.4/src/windows/ctemplate/template_string.h:89:20: [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 Hash(s, strlen(s)); data/ctemplate-2.4/src/windows/ctemplate/template_string.h:160: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). : ptr_(s ? s : ""), length_(strlen(ptr_)), data/ctemplate-2.4/src/windows/port.h:76:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). #define read _read ANALYSIS SUMMARY: Hits = 128 Lines analyzed = 26923 in approximately 0.70 seconds (38556 lines/second) Physical Source Lines of Code (SLOC) = 16259 Hits@level = [0] 66 [1] 45 [2] 54 [3] 9 [4] 20 [5] 0 Hits@level+ = [0+] 194 [1+] 128 [2+] 83 [3+] 29 [4+] 20 [5+] 0 Hits/KSLOC@level+ = [0+] 11.9319 [1+] 7.87256 [2+] 5.10486 [3+] 1.78363 [4+] 1.23009 [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.