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/libconfig-1.5/lib/scanner.c Examining data/libconfig-1.5/lib/scanctx.c Examining data/libconfig-1.5/lib/strbuf.h Examining data/libconfig-1.5/lib/libconfig.c Examining data/libconfig-1.5/lib/grammar.c Examining data/libconfig-1.5/lib/strbuf.c Examining data/libconfig-1.5/lib/scanctx.h Examining data/libconfig-1.5/lib/libconfig.h Examining data/libconfig-1.5/lib/libconfigcpp.c++ Examining data/libconfig-1.5/lib/grammar.h Examining data/libconfig-1.5/lib/parsectx.h Examining data/libconfig-1.5/lib/libconfigcpp.cc Examining data/libconfig-1.5/lib/wincompat.h Examining data/libconfig-1.5/lib/scanner.h Examining data/libconfig-1.5/tests/tests.c Examining data/libconfig-1.5/contrib/cmake/src/main.cpp Examining data/libconfig-1.5/contrib/cmake/CMakeFiles/CompilerIdCXX/CMakeCXXCompilerId.cpp Examining data/libconfig-1.5/contrib/cmake/CMakeFiles/CompilerIdC/CMakeCCompilerId.c Examining data/libconfig-1.5/contrib/copy_setting.c Examining data/libconfig-1.5/contrib/libconfig-ruby/ext/rconfig.c Examining data/libconfig-1.5/examples/c/example2.c Examining data/libconfig-1.5/examples/c/example1.c Examining data/libconfig-1.5/examples/c/example3.c Examining data/libconfig-1.5/examples/c++/example4.cpp Examining data/libconfig-1.5/examples/c++/example2.cpp Examining data/libconfig-1.5/examples/c++/example3.cpp Examining data/libconfig-1.5/examples/c++/example1.cpp Examining data/libconfig-1.5/tinytest/tinytest.c Examining data/libconfig-1.5/tinytest/tinytest.h FINAL RESULTS: data/libconfig-1.5/lib/grammar.c:698:21: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. # define YYFPRINTF fprintf data/libconfig-1.5/lib/libconfig.c:211:11: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. fprintf(stream, INT64_FMT "L", value->llval); data/libconfig-1.5/lib/scanctx.c:114:5: [4] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). strcpy(full_file, ctx->config->include_dir); data/libconfig-1.5/lib/scanctx.c:115:5: [4] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). strcat(full_file, FILE_SEPARATOR); data/libconfig-1.5/lib/scanctx.c:116:5: [4] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). strcat(full_file, file); data/libconfig-1.5/lib/strbuf.c:53: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->string + buf->length, text); data/libconfig-1.5/lib/wincompat.h:37:9: [4] (format) snprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. #define snprintf _snprintf data/libconfig-1.5/lib/wincompat.h:37:19: [4] (format) _snprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. #define snprintf _snprintf data/libconfig-1.5/tests/tests.c:28:9: [4] (format) snprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. #define snprintf _snprintf data/libconfig-1.5/tests/tests.c:28:18: [4] (format) _snprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. #define snprintf _snprintf data/libconfig-1.5/tinytest/tinytest.c:621:3: [4] (format) vprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vprintf(message, vp); data/libconfig-1.5/tinytest/tinytest.c:631:10: [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(file, F_OK) == 0); data/libconfig-1.5/lib/grammar.c:947: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 const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; data/libconfig-1.5/lib/grammar.c:1141: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 yymsgbuf[128]; data/libconfig-1.5/lib/libconfig.c:177: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 fbuf[64]; data/libconfig-1.5/lib/libconfig.c:229:11: [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(fbuf, ".0"); data/libconfig-1.5/lib/libconfig.c:687:18: [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 *stream = fopen(filename, "rt"); data/libconfig-1.5/lib/libconfig.c:722:18: [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 *stream = fopen(filename, "wt"); data/libconfig-1.5/lib/libconfig.c:1204:48: [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). found = config_setting_get_elem(setting, atoi(++p)); data/libconfig-1.5/lib/scanctx.c:119:8: [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). fp = fopen(full_file ? full_file : file, "rt"); data/libconfig-1.5/lib/scanctx.h:38: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. const char *files[MAX_INCLUDE_DEPTH]; data/libconfig-1.5/lib/scanner.c:1027: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. char c[2] = { (char)(strtol(yytext + 2, NULL, 16) & 0xFF), data/libconfig-1.5/lib/scanner.c:1146:18: [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). { yylval->ival = atoi(yytext); return(TOK_INTEGER); } data/libconfig-1.5/tests/tests.c: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 actual_error[128]; data/libconfig-1.5/tests/tests.c: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 expected_error[128]; data/libconfig-1.5/tests/tests.c:87: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 actual_error[128]; data/libconfig-1.5/tests/tests.c:88: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_error[128]; data/libconfig-1.5/tests/tests.c:117:8: [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). fp = fopen(file, "rt"); data/libconfig-1.5/tests/tests.c:137: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 input_file[128], output_file[128]; data/libconfig-1.5/tests/tests.c:138:5: [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(input_file, "testdata/input_%d.cfg", i); data/libconfig-1.5/tests/tests.c:139:5: [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(output_file, "testdata/output_%d.cfg", i); data/libconfig-1.5/tests/tests.c:157: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 input_file[128], error_file[128]; data/libconfig-1.5/tests/tests.c:158: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_text[128]; data/libconfig-1.5/tests/tests.c:161:5: [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(input_file, "testdata/bad_input_%d.cfg", i); data/libconfig-1.5/tests/tests.c:162:5: [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(error_file, "testdata/parse_error_%d.txt", i); data/libconfig-1.5/tests/tests.c:167:10: [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). fp = fopen(error_file, "rt"); data/libconfig-1.5/tests/tests.c:184: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 input_file[128], error_file[128]; data/libconfig-1.5/tests/tests.c:186: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_text[128]; data/libconfig-1.5/tests/tests.c:189:5: [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(input_file, "testdata/bad_input_%d.cfg", i); data/libconfig-1.5/tests/tests.c:190:5: [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(error_file, "testdata/parse_error_%d.txt", i); data/libconfig-1.5/tests/tests.c:197:10: [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). fp = fopen(error_file, "rt"); data/libconfig-1.5/tinytest/tinytest.c: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 buf1[4096], buf2[4096]; data/libconfig-1.5/tinytest/tinytest.c:78: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). if(!(fp1 = fopen(file1, "rt"))) data/libconfig-1.5/tinytest/tinytest.c:84: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). if(!(fp2 = fopen(file2, "rt"))) data/libconfig-1.5/tinytest/tinytest.c: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 buf1[4096], buf2[4096]; data/libconfig-1.5/tinytest/tinytest.c:156: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). if(!(fp1 = fopen(file1, "rb"))) data/libconfig-1.5/tinytest/tinytest.c:162: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). if(!(fp2 = fopen(file2, "rb"))) data/libconfig-1.5/contrib/libconfig-ruby/ext/rconfig.c:694: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). rSettingNameRegexp = rb_reg_new(settingNameRegexp, strlen(settingNameRegexp), 0); data/libconfig-1.5/lib/grammar.c:847:21: [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 yystrlen strlen data/libconfig-1.5/lib/libconfig.c:235: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). for(p = fbuf + strlen(fbuf) - 1; p > fbuf; --p) data/libconfig-1.5/lib/libconfigcpp.c++:412:14: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). void Config::read(FILE *stream) data/libconfig-1.5/lib/scanctx.c:112: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). full_file = (char *)malloc(strlen(ctx->config->include_dir) + strlen(file) data/libconfig-1.5/lib/scanctx.c:112:67: [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). full_file = (char *)malloc(strlen(ctx->config->include_dir) + strlen(file) data/libconfig-1.5/lib/scanner.c:777:14: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ data/libconfig-1.5/lib/scanner.c:1961: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). return libconfig_yy_scan_bytes(yystr,strlen(yystr) ,yyscanner); data/libconfig-1.5/lib/strbuf.c:44: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). size_t len = strlen(text); data/libconfig-1.5/tinytest/tinytest.c:55: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). size_t len = strlen(s); ANALYSIS SUMMARY: Hits = 57 Lines analyzed = 11991 in approximately 0.29 seconds (41151 lines/second) Physical Source Lines of Code (SLOC) = 7924 Hits@level = [0] 57 [1] 10 [2] 35 [3] 0 [4] 12 [5] 0 Hits@level+ = [0+] 114 [1+] 57 [2+] 47 [3+] 12 [4+] 12 [5+] 0 Hits/KSLOC@level+ = [0+] 14.3867 [1+] 7.19334 [2+] 5.93135 [3+] 1.51439 [4+] 1.51439 [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.