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/libctl-4.5.0/base/main.c Examining data/libctl-4.5.0/examples/example.c Examining data/libctl-4.5.0/src/cintegrator.c Examining data/libctl-4.5.0/src/ctl-f77-glue.c Examining data/libctl-4.5.0/src/ctl-math.c Examining data/libctl-4.5.0/src/ctl-math.h Examining data/libctl-4.5.0/src/ctl.c Examining data/libctl-4.5.0/src/integrator.c Examining data/libctl-4.5.0/src/subplex.c Examining data/libctl-4.5.0/utils/ctlgeom.h Examining data/libctl-4.5.0/utils/geom-ctl-io-defaults.c Examining data/libctl-4.5.0/utils/geom.c Examining data/libctl-4.5.0/utils/geomtst.c Examining data/libctl-4.5.0/utils/nlopt.c Examining data/libctl-4.5.0/utils/test-prism.c FINAL RESULTS: data/libctl-4.5.0/base/main.c:70:9: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. printf(VERSION_STRING); data/libctl-4.5.0/base/main.c:133: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(dir0, for_dir); data/libctl-4.5.0/base/main.c:139: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(base0, for_base); data/libctl-4.5.0/base/main.c:142: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(name, dir); data/libctl-4.5.0/base/main.c:144: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(name, base); data/libctl-4.5.0/base/main.c:227: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(definestr, verbose ? "true)" : "false)"); data/libctl-4.5.0/base/main.c:256:9: [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(stderr, __FILE__ ": out of memory!\n"); data/libctl-4.5.0/base/main.c:260:7: [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(definestr, argv[i]); data/libctl-4.5.0/base/main.c:268: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(definestr, argv[i]); data/libctl-4.5.0/base/main.c:275: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(stderr, __FILE__ ": out of memory!\n"); data/libctl-4.5.0/base/main.c:279:9: [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(remember_define, definestr); data/libctl-4.5.0/src/ctl.c:98:7: [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(newpath, dir); data/libctl-4.5.0/src/ctl.c:101:7: [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(newpath, path); data/libctl-4.5.0/src/ctl.c:106: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(newpath, path); data/libctl-4.5.0/utils/geom.c:67:5: [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(stderr, s "\n"); \ data/libctl-4.5.0/utils/geom.c:99:5: [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(fmt, ap); data/libctl-4.5.0/utils/geom.c:2129:15: [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 *s = getenv("LIBCTL_EXCLUDE_BOUNDARIES"); data/libctl-4.5.0/utils/geomtst.c:244:3: [3] (random) srand: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. srand(time(NULL)); data/libctl-4.5.0/utils/test-prism.c:285:17: [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 *s = getenv("LIBCTL_EXCLUDE_BOUNDARIES"); data/libctl-4.5.0/utils/test-prism.c:1136: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. char *s = getenv("LIBCTL_TEST_PRISM_LOG"); data/libctl-4.5.0/utils/test-prism.c:1182:3: [3] (random) srand: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. srand(time(NULL)); data/libctl-4.5.0/base/main.c:120:13: [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 *f = fopen(fname, "r"); data/libctl-4.5.0/base/main.c:226: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(definestr, "(define verbose? "); data/libctl-4.5.0/base/main.c:259:7: [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(definestr, "(define "); data/libctl-4.5.0/base/main.c:278:9: [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(remember_define, "(set! params-set-list (cons (quote "); data/libctl-4.5.0/base/main.c:280:9: [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(remember_define, ") params-set-list))"); data/libctl-4.5.0/src/cintegrator.c:849:20: [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). dim = argc > 1 ? atoi(argv[1]) : 2; data/libctl-4.5.0/src/cintegrator.c:851:32: [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). which_integrand = argc > 3 ? atoi(argv[3]) : 0; data/libctl-4.5.0/src/cintegrator.c:852:24: [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). maxEval = argc > 4 ? atoi(argv[4]) : 0; data/libctl-4.5.0/src/integrator.c:834:20: [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). dim = argc > 1 ? atoi(argv[1]) : 2; data/libctl-4.5.0/src/integrator.c:836:32: [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). which_integrand = argc > 3 ? atoi(argv[3]) : 0; data/libctl-4.5.0/src/integrator.c:837:24: [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). maxEval = argc > 4 ? atoi(argv[4]) : 0; data/libctl-4.5.0/utils/geom.c:2321: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(vps, prsm->vertices_top_p.items, num_vertices * sizeof(vector3)); data/libctl-4.5.0/utils/geom.c:2328: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(vps, prsm->vertices_p.items, num_vertices * sizeof(vector3)); data/libctl-4.5.0/utils/geom.c:2468:7: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(wedges_a, prsm->vertices_top_p.items, num_vertices * sizeof(vector3)); data/libctl-4.5.0/utils/geom.c:2469:7: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(wedges_b, prsm->vertices_top_p.items, num_vertices * sizeof(vector3)); data/libctl-4.5.0/utils/geom.c:2473:7: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(wedges_c, prsm->vertices_p.items, num_vertices * sizeof(vector3)); data/libctl-4.5.0/utils/geom.c:2477:7: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(wedges_a, prsm->vertices_p.items, num_vertices * sizeof(vector3)); data/libctl-4.5.0/utils/geom.c:2478:7: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(wedges_b, prsm->vertices_p.items, num_vertices * sizeof(vector3)); data/libctl-4.5.0/utils/geom.c:2482:7: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(wedges_c, prsm->vertices_top_p.items, num_vertices * sizeof(vector3)); data/libctl-4.5.0/utils/geom.c:2708: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(prsm->vertices_top_p.items, prsm->vertices_p.items, num_vertices * sizeof(vector3)); data/libctl-4.5.0/utils/geom.c:2847: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(prsm->vertices.items, vertices, num_vertices * sizeof(vector3)); data/libctl-4.5.0/utils/test-prism.c:195: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(vertices.items, prsm->vertices_p.items, num_vertices * sizeof(vector3)); data/libctl-4.5.0/utils/test-prism.c:204:13: [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 *f = fopen(filename, "w"); data/libctl-4.5.0/utils/test-prism.c:239:13: [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 *f = fopen(filename, "w"); data/libctl-4.5.0/utils/test-prism.c:275:25: [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 *f = write_log ? fopen("/tmp/test-prism.points", "w") : 0; data/libctl-4.5.0/utils/test-prism.c:311:25: [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 *f = write_log ? fopen("/tmp/test-prism.normals", "w") : 0; data/libctl-4.5.0/utils/test-prism.c:348:25: [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 *f = write_log ? fopen("/tmp/test-prism.segments", "w") : 0; data/libctl-4.5.0/utils/test-prism.c:416:25: [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 *f = write_log ? fopen("/tmp/test-prism.point-in-polygon", "w") : 0; data/libctl-4.5.0/utils/test-prism.c:1250:13: [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 *f = fopen(vertexfile, "r"); data/libctl-4.5.0/utils/test-prism.c:1252: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 Line[100]; data/libctl-4.5.0/utils/test-prism.c:1271:7: [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). f = fopen("test-point.gp", "w"); data/libctl-4.5.0/utils/test-prism.c:1279:7: [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). f = fopen("test-prism-bb.gp", "w"); data/libctl-4.5.0/base/main.c:85:48: [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). else if (!strncmp(argv[i], "--spec-file=", strlen("--spec-file="))) { data/libctl-4.5.0/base/main.c:86: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). ctl_include(argv[i] + strlen("--spec-file=")); data/libctl-4.5.0/base/main.c:131:41: [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). dir0 = (char *)malloc(sizeof(char) * (strlen(for_dir) + 1)); data/libctl-4.5.0/base/main.c:132: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). base0 = (char *)malloc(sizeof(char) * (strlen(for_base) + 1)); data/libctl-4.5.0/base/main.c:135: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). ndir = strlen(dir); data/libctl-4.5.0/base/main.c:141:43: [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). name = (char *)malloc(sizeof(char) * (strlen(dir) + 1 + strlen(base) + 1)); data/libctl-4.5.0/base/main.c:141: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). name = (char *)malloc(sizeof(char) * (strlen(dir) + 1 + strlen(base) + 1)); data/libctl-4.5.0/base/main.c:143: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(name, "/"); data/libctl-4.5.0/base/main.c:254: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). char *definestr = (char *)malloc(sizeof(char) * (strlen("(define ") + strlen(argv[i]) + 2)); data/libctl-4.5.0/base/main.c:254:77: [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 *definestr = (char *)malloc(sizeof(char) * (strlen("(define ") + strlen(argv[i]) + 2)); data/libctl-4.5.0/base/main.c:261:7: [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(definestr, ")"); data/libctl-4.5.0/base/main.c:272: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). sizeof(char) * (strlen("(set! params-set-list (cons (quote x) params-set-list))") + data/libctl-4.5.0/base/main.c:273: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(definestr))); data/libctl-4.5.0/src/ctl-f77-glue.c:166:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(fcp2ccp(result), r, *result_length); data/libctl-4.5.0/src/ctl-f77-glue.c:167: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). len = (int)strlen(r); data/libctl-4.5.0/src/ctl-f77-glue.c:257:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(fcp2ccp(value), v, *value_length); data/libctl-4.5.0/src/ctl-f77-glue.c:258: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). len = (int)strlen(v); data/libctl-4.5.0/src/ctl-f77-glue.c:354:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(fcp2ccp(result), r, *result_length); data/libctl-4.5.0/src/ctl-f77-glue.c:355: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). len = (int)strlen(r); data/libctl-4.5.0/src/ctl.c:97:48: [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). newpath = (char *)malloc(sizeof(char) * (strlen(dir) + strlen(path) + 2)); data/libctl-4.5.0/src/ctl.c:97: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). newpath = (char *)malloc(sizeof(char) * (strlen(dir) + strlen(path) + 2)); data/libctl-4.5.0/src/ctl.c:100: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 (newpath[0] && newpath[strlen(newpath) - 1] != '/') strcat(newpath, "/"); data/libctl-4.5.0/src/ctl.c:100:62: [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. if (newpath[0] && newpath[strlen(newpath) - 1] != '/') strcat(newpath, "/"); data/libctl-4.5.0/src/ctl.c:105:44: [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). newpath = (char *)malloc(sizeof(char) * (strlen(path) + 1)); data/libctl-4.5.0/src/ctl.c:288: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). SCM symbol = scm_intern_obarray_soft(name, strlen(name), scm_symhash, 0); ANALYSIS SUMMARY: Hits = 78 Lines analyzed = 10430 in approximately 0.43 seconds (24487 lines/second) Physical Source Lines of Code (SLOC) = 6914 Hits@level = [0] 147 [1] 25 [2] 32 [3] 5 [4] 16 [5] 0 Hits@level+ = [0+] 225 [1+] 78 [2+] 53 [3+] 21 [4+] 16 [5+] 0 Hits/KSLOC@level+ = [0+] 32.5427 [1+] 11.2815 [2+] 7.66561 [3+] 3.03732 [4+] 2.31415 [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.