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/nqp-2020.10+dfsg/src/vm/moar/runner/main.c Examining data/nqp-2020.10+dfsg/tools/templates/unix/nqp-m-build.c Examining data/nqp-2020.10+dfsg/tools/templates/windows/nqp-m-build.c FINAL RESULTS: data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:114:9: [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(*out_home, env_home); data/nqp-2020.10+dfsg/tools/templates/unix/nqp-m-build.c:35:5: [4] (shell) execv: 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. execv(moar, exec_argv); data/nqp-2020.10+dfsg/tools/templates/windows/nqp-m-build.c:17:18: [4] (buffer) wcscpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using a function version that stops copying at the end of the buffer. if (out) wcscpy(out, in); data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:109:32: [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 *env_home = getenv(env_var); data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:258:9: [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. if (getenv("MVM_TELEMETRY_LOG")) { data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:261:38: [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. snprintf(path, 255, "%s.%d", getenv("MVM_TELEMETRY_LOG"), data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:346:9: [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. if (getenv("MVM_TELEMETRY_LOG") && telemeh_inited) { data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:164: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 nqp_rel_path[14] = "/../share/nqp"; data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:166: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 nqp_check_path[28] = "/lib/NQPCORE.setting.moarvm"; data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:170: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 *lib_path[1]; data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:259: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 path[256]; data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:268: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). fp = fopen(path, "w"); data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:279: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(exec_dir_path_temp, exec_path, exec_path_size + 1); data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:290: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(exec_dir_path, exec_dir_path_temp, exec_dir_path_size + 1); data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:308: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(lib_path[0], nqp_home, nqp_home_size); data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:309: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(nqp_file, nqp_home, nqp_home_size); data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:312:5: [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(lib_path[0] + nqp_home_size, "\\lib"); data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:313:5: [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(nqp_file + nqp_home_size, "\\lib\\nqp.moarvm"); data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:315:5: [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(lib_path[0] + nqp_home_size, "/lib"); data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:316:5: [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(nqp_file + nqp_home_size, "/lib/nqp.moarvm"); data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:49: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). size_t str_len = strlen(str); data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:50: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). size_t want_len = strlen(want); data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:112: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). home_size = strlen(env_home); data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:127:9: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(*out_home, exec_dir_path, home_size); data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:128:9: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(*out_home, rel_home, rel_home_size); data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:133:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(check_file_path, *out_home, home_size + check_file_size); data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:134:5: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(check_file_path, check_file, check_file_size); data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:194: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). exec_path_size = strlen(exec_path); data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:230: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 *portstr = argv[argi] + strlen("--debug-port="); data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:288: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). exec_dir_path_size = strlen(exec_dir_path_temp); data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:293: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). exec_dir_path_size = strlen(exec_dir_path); data/nqp-2020.10+dfsg/src/vm/moar/runner/main.c:301: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). nqp_home_size = strlen(nqp_home); data/nqp-2020.10+dfsg/tools/templates/windows/nqp-m-build.c:18:16: [1] (buffer) wcslen: 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 wcslen(in) + 1; ANALYSIS SUMMARY: Hits = 33 Lines analyzed = 571 in approximately 0.54 seconds (1067 lines/second) Physical Source Lines of Code (SLOC) = 450 Hits@level = [0] 8 [1] 13 [2] 13 [3] 4 [4] 3 [5] 0 Hits@level+ = [0+] 41 [1+] 33 [2+] 20 [3+] 7 [4+] 3 [5+] 0 Hits/KSLOC@level+ = [0+] 91.1111 [1+] 73.3333 [2+] 44.4444 [3+] 15.5556 [4+] 6.66667 [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.