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/libt3config-1.0.0/doc/examples/example.c Examining data/libt3config-1.0.0/doc/main_doc.h Examining data/libt3config-1.0.0/src/util.c Examining data/libt3config-1.0.0/src/write.c Examining data/libt3config-1.0.0/src/expression.c Examining data/libt3config-1.0.0/src/util.h Examining data/libt3config-1.0.0/src/config_shared.c Examining data/libt3config-1.0.0/src/expression.h Examining data/libt3config-1.0.0/src/config.c Examining data/libt3config-1.0.0/src/parser.c Examining data/libt3config-1.0.0/src/schema.c Examining data/libt3config-1.0.0/src/config_api.h Examining data/libt3config-1.0.0/src/lex_hide.h Examining data/libt3config-1.0.0/src/config_internal.h Examining data/libt3config-1.0.0/src/config.h Examining data/libt3config-1.0.0/src/lex.c Examining data/libt3config-1.0.0/src/config_errors.h Examining data/libt3config-1.0.0/src/pathsearch.c Examining data/libt3config-1.0.0/src/parser.h Examining data/libt3config-1.0.0/src/xdg.c FINAL RESULTS: data/libt3config-1.0.0/doc/examples/example.c:19:5: [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, fmt, args); data/libt3config-1.0.0/src/pathsearch.c:40:3: [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(file_name, name); data/libt3config-1.0.0/src/util.c:153:3: [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(buffer + idx, ldata->decimal_point); data/libt3config-1.0.0/src/xdg.c:159: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(pathname, dir); data/libt3config-1.0.0/src/xdg.c:161: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(pathname, xdg_dirs[xdg_dir].homedir_relative); data/libt3config-1.0.0/src/xdg.c:180: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(pathname, program_dir); data/libt3config-1.0.0/src/xdg.c:201:3: [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(pathname, file_name); data/libt3config-1.0.0/src/xdg.c:229:3: [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(pathname, file_name); data/libt3config-1.0.0/src/xdg.c:289:3: [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(pathname, dirsep == NULL ? file_name : dirsep + 1); data/libt3config-1.0.0/doc/examples/example.c:47:17: [3] (buffer) getopt: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. while ((c = getopt(argc, argv, "s:hi::")) >= 0) { data/libt3config-1.0.0/src/xdg.c:122: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. const char *env = getenv(xdg_dirs[xdg_dir].env_name); data/libt3config-1.0.0/src/xdg.c:145:13: [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. env = getenv("HOME"); data/libt3config-1.0.0/doc/examples/example.c:36: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 *path[2] = { NULL, NULL }; data/libt3config-1.0.0/doc/examples/example.c:54:36: [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 ((schema_file = fopen(optarg, "r")) == NULL) data/libt3config-1.0.0/doc/examples/example.c:79:21: [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 ((file = fopen(argv[optind], "r")) == NULL) data/libt3config-1.0.0/src/config.h:89: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). FILE *(*open)(const char *name, data/libt3config-1.0.0/src/parser.c:313:59: [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). new_file = _t3_config_data->opts->include_callback.user.open(include->value.string, data/libt3config-1.0.0/src/pathsearch.c:42:12: [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). result = fopen(file_name, "r"); data/libt3config-1.0.0/src/util.c:33: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(result, str, len); data/libt3config-1.0.0/src/util.c: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[160], *decimal_point; data/libt3config-1.0.0/src/util.c:150: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, text, decimal_point - text); data/libt3config-1.0.0/src/write.c:30:16: [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 tabs[8] = "\t\t\t\t\t\t\t\t"; data/libt3config-1.0.0/src/write.c:46: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[160]; data/libt3config-1.0.0/src/write.c:65:3: [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(buffer, "%.18g", value); data/libt3config-1.0.0/src/write.c:71:36: [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. if (strchr(buffer, '.') == NULL) strcat(buffer, ".0"); data/libt3config-1.0.0/src/write.c:78: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[160], *decimal_point; data/libt3config-1.0.0/src/write.c:93:3: [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(buffer, "%.18g", value); data/libt3config-1.0.0/src/write.c:106: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(buffer, ".0"); data/libt3config-1.0.0/src/xdg.c:138: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[4096]; data/libt3config-1.0.0/src/xdg.c:203:12: [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). result = fopen(pathname, "r"); data/libt3config-1.0.0/src/xdg.c:228: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(pathname, "/."); data/libt3config-1.0.0/src/xdg.c:230: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(pathname, "XXXXXX"); data/libt3config-1.0.0/src/xdg.c:231:13: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). if ((fd = mkstemp(pathname)) < 0) { data/libt3config-1.0.0/src/xdg.c:277: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(pathname, file_name, length); data/libt3config-1.0.0/src/xdg.c:290: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(pathname, "XXXXXX"); data/libt3config-1.0.0/src/xdg.c:291:13: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). if ((fd = mkstemp(pathname)) < 0) { data/libt3config-1.0.0/src/config.c:276: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). strlen(name) && data/libt3config-1.0.0/src/lex.c:935: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/libt3config-1.0.0/src/lex.c:1990:37: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner); data/libt3config-1.0.0/src/parser.c:184: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). char *value = malloc(strlen(text)); data/libt3config-1.0.0/src/parser.c:217: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). memmove(list->name, list->name + 1, strlen(list->name)); data/libt3config-1.0.0/src/parser.c:542: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). char *value = realloc(item->value.string, strlen(text) + strlen(item->value.string)); data/libt3config-1.0.0/src/parser.c:542:61: [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). char *value = realloc(item->value.string, strlen(text) + strlen(item->value.string)); data/libt3config-1.0.0/src/parser.c:547: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). value += strlen(value); data/libt3config-1.0.0/src/parser.c:1137: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). top->value.operand[1]->value.string[strlen(top->value.operand[1]->value.string) - 1] = 0; data/libt3config-1.0.0/src/pathsearch.c:29: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). len = dir_len + strlen(name) + 2; data/libt3config-1.0.0/src/pathsearch.c:35:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(file_name, dir, dir_len); data/libt3config-1.0.0/src/pathsearch.c:38:5: [1] (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 character. strcat(file_name, "/"); data/libt3config-1.0.0/src/pathsearch.c:70:9: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). len = strlen(name); data/libt3config-1.0.0/src/pathsearch.c:97:14: [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 ((len = strlen(name)) == 0 || is_dirsep(name[len - 1])) { data/libt3config-1.0.0/src/pathsearch.c:147:47: [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 ((result = try_open(search_from, strlen(search_from), name)) != NULL || data/libt3config-1.0.0/src/pathsearch.c:158:37: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). if ((result = try_open(*path, strlen(*path), name)) != NULL || errno == ENOMEM) { data/libt3config-1.0.0/src/schema.c:192: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). context.buffer_size = strlen(constraint); data/libt3config-1.0.0/src/util.c:28: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(str) + 1; data/libt3config-1.0.0/src/util.c:114:7: [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(ldata->decimal_point) == 1) { data/libt3config-1.0.0/src/util.c:154: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). idx += strlen(ldata->decimal_point); data/libt3config-1.0.0/src/write.c:98:50: [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). memmove(decimal_point + 1, decimal_point + strlen(ldata->decimal_point), data/libt3config-1.0.0/src/write.c:99:15: [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(decimal_point + strlen(ldata->decimal_point)) + 1); data/libt3config-1.0.0/src/write.c:99:38: [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(decimal_point + strlen(ldata->decimal_point)) + 1); data/libt3config-1.0.0/src/write.c:153: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). fwrite(value, 1, strlen(value), file); data/libt3config-1.0.0/src/xdg.c:131: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). if (env != NULL && strlen(env) > 0) { data/libt3config-1.0.0/src/xdg.c:146: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). if (env == NULL || strlen(env) == 0) { data/libt3config-1.0.0/src/xdg.c:155: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). if ((pathname = malloc(strlen(dir) + 1 + strlen(xdg_dirs[xdg_dir].homedir_relative) + 1)) == data/libt3config-1.0.0/src/xdg.c:155: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). if ((pathname = malloc(strlen(dir) + 1 + strlen(xdg_dirs[xdg_dir].homedir_relative) + 1)) == data/libt3config-1.0.0/src/xdg.c:160:5: [1] (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 character. strcat(pathname, "/"); data/libt3config-1.0.0/src/xdg.c:169: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). extra_size += 1 + strlen(program_dir); data/libt3config-1.0.0/src/xdg.c:172: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). if ((tmp = realloc(pathname, strlen(pathname) + extra_size + 1)) == NULL) { data/libt3config-1.0.0/src/xdg.c:179:5: [1] (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 character. strcat(pathname, "/"); data/libt3config-1.0.0/src/xdg.c:196:64: [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 ((pathname = t3_config_xdg_get_path(xdg_dir, program_dir, strlen(file_name))) == NULL) { data/libt3config-1.0.0/src/xdg.c:200:3: [1] (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 character. strcat(pathname, "/"); data/libt3config-1.0.0/src/xdg.c:219:64: [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 ((pathname = t3_config_xdg_get_path(xdg_dir, program_dir, strlen(file_name) + 7)) == NULL) { data/libt3config-1.0.0/src/xdg.c:274: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). if ((pathname = malloc(strlen(file_name) + 1 + 7)) == NULL) { data/libt3config-1.0.0/src/xdg.c:286:5: [1] (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 character. strcat(pathname, "/"); data/libt3config-1.0.0/src/xdg.c:288:3: [1] (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 character. strcat(pathname, "."); data/libt3config-1.0.0/src/xdg.c:349: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). file_name_len = strlen(target_path) - (last_slash - target_path) - 8; data/libt3config-1.0.0/src/xdg.c:353: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). file_name_len = strlen(target_path) - 7; ANALYSIS SUMMARY: Hits = 76 Lines analyzed = 8055 in approximately 0.21 seconds (37679 lines/second) Physical Source Lines of Code (SLOC) = 5507 Hits@level = [0] 9 [1] 40 [2] 24 [3] 3 [4] 9 [5] 0 Hits@level+ = [0+] 85 [1+] 76 [2+] 36 [3+] 12 [4+] 9 [5+] 0 Hits/KSLOC@level+ = [0+] 15.4349 [1+] 13.8006 [2+] 6.53713 [3+] 2.17904 [4+] 1.63428 [5+] 0 Symlinks skipped = 1 (--allowlink overrides but see doc for security issue) Dot directories skipped = 1 (--followdotdir overrides) Minimum risk level = 1 Not every hit is necessarily a security vulnerability. There may be other security vulnerabilities; review your code! See 'Secure Programming HOWTO' (https://dwheeler.com/secure-programs) for more information.