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/apophenia-1.0+ds/apop_asst.c Examining data/apophenia-1.0+ds/apop_bootstrap.c Examining data/apophenia-1.0+ds/apop_db.c Examining data/apophenia-1.0+ds/apop_db_sqlite.c Examining data/apophenia-1.0+ds/apop_fexact.c Examining data/apophenia-1.0+ds/apop_hist.c Examining data/apophenia-1.0+ds/apop_internal.h Examining data/apophenia-1.0+ds/apop_linear_algebra.c Examining data/apophenia-1.0+ds/apop_linear_constraint.c Examining data/apophenia-1.0+ds/apop_mapply.c Examining data/apophenia-1.0+ds/apop_mcmc.c Examining data/apophenia-1.0+ds/apop_missing_data.c Examining data/apophenia-1.0+ds/apop_mle.c Examining data/apophenia-1.0+ds/apop_model.c Examining data/apophenia-1.0+ds/apop_name.c Examining data/apophenia-1.0+ds/apop_output.c Examining data/apophenia-1.0+ds/apop_rake.c Examining data/apophenia-1.0+ds/apop_regression.c Examining data/apophenia-1.0+ds/apop_settings.c Examining data/apophenia-1.0+ds/apop_sort.c Examining data/apophenia-1.0+ds/apop_stats.c Examining data/apophenia-1.0+ds/apop_tests.c Examining data/apophenia-1.0+ds/apop_update.c Examining data/apophenia-1.0+ds/apop_vtables.c Examining data/apophenia-1.0+ds/asprintf.c Examining data/apophenia-1.0+ds/cmd/apop_db_to_crosstab.c Examining data/apophenia-1.0+ds/cmd/apop_plot_query.c Examining data/apophenia-1.0+ds/cmd/apop_text_to_db.c Examining data/apophenia-1.0+ds/docs/documentation.h Examining data/apophenia-1.0+ds/eg/apop_map_row.c Examining data/apophenia-1.0+ds/eg/banana.c Examining data/apophenia-1.0+ds/eg/binning.c Examining data/apophenia-1.0+ds/eg/boot_clt.c Examining data/apophenia-1.0+ds/eg/cross_models.c Examining data/apophenia-1.0+ds/eg/data_fill.c Examining data/apophenia-1.0+ds/eg/db_fns.c Examining data/apophenia-1.0+ds/eg/dconstrain.c Examining data/apophenia-1.0+ds/eg/dot_products.c Examining data/apophenia-1.0+ds/eg/draw_some_normals.c Examining data/apophenia-1.0+ds/eg/draw_to_db.c Examining data/apophenia-1.0+ds/eg/entropy_model.c Examining data/apophenia-1.0+ds/eg/entropy_vector.c Examining data/apophenia-1.0+ds/eg/f_test.c Examining data/apophenia-1.0+ds/eg/faithful.c Examining data/apophenia-1.0+ds/eg/fake_logit.c Examining data/apophenia-1.0+ds/eg/fix_params.c Examining data/apophenia-1.0+ds/eg/hills2.c Examining data/apophenia-1.0+ds/eg/iv.c Examining data/apophenia-1.0+ds/eg/jack.c Examining data/apophenia-1.0+ds/eg/jacobian.c Examining data/apophenia-1.0+ds/eg/kernel.c Examining data/apophenia-1.0+ds/eg/ks_tests.c Examining data/apophenia-1.0+ds/eg/logit.c Examining data/apophenia-1.0+ds/eg/ls_tables.c Examining data/apophenia-1.0+ds/eg/ml_imputation.c Examining data/apophenia-1.0+ds/eg/normalization_demo.c Examining data/apophenia-1.0+ds/eg/ols.c Examining data/apophenia-1.0+ds/eg/ols2.c Examining data/apophenia-1.0+ds/eg/ols_oneliner.c Examining data/apophenia-1.0+ds/eg/parameterization.c Examining data/apophenia-1.0+ds/eg/pmf_test.c Examining data/apophenia-1.0+ds/eg/simple_subsets.c Examining data/apophenia-1.0+ds/eg/some_cdfs.c Examining data/apophenia-1.0+ds/eg/sql_to_html.c Examining data/apophenia-1.0+ds/eg/t_test_by_rows.c Examining data/apophenia-1.0+ds/eg/test_distances.c Examining data/apophenia-1.0+ds/eg/test_fisher.c Examining data/apophenia-1.0+ds/eg/test_harmonic.c Examining data/apophenia-1.0+ds/eg/test_kl_divergence.c Examining data/apophenia-1.0+ds/eg/test_pruning.c Examining data/apophenia-1.0+ds/eg/test_ranks.c Examining data/apophenia-1.0+ds/eg/test_regex.c Examining data/apophenia-1.0+ds/eg/text_demo.c Examining data/apophenia-1.0+ds/eg/transform.c Examining data/apophenia-1.0+ds/eg/test_updating.c Examining data/apophenia-1.0+ds/model/apop_bernoulli.c Examining data/apophenia-1.0+ds/model/apop_beta.c Examining data/apophenia-1.0+ds/model/apop_dirichlet.c Examining data/apophenia-1.0+ds/model/apop_exponential.c Examining data/apophenia-1.0+ds/model/apop_gamma.c Examining data/apophenia-1.0+ds/model/apop_kerneld.c Examining data/apophenia-1.0+ds/model/apop_multinomial.c Examining data/apophenia-1.0+ds/model/apop_multivariate_normal.c Examining data/apophenia-1.0+ds/model/apop_normal.c Examining data/apophenia-1.0+ds/model/apop_pmf.c Examining data/apophenia-1.0+ds/model/apop_poisson.c Examining data/apophenia-1.0+ds/model/apop_probit.c Examining data/apophenia-1.0+ds/model/apop_t.c Examining data/apophenia-1.0+ds/model/apop_uniform.c Examining data/apophenia-1.0+ds/model/apop_wishart.c Examining data/apophenia-1.0+ds/model/apop_yule.c Examining data/apophenia-1.0+ds/model/apop_zipf.c Examining data/apophenia-1.0+ds/model/apop_ols.c Examining data/apophenia-1.0+ds/model/apop_loess.c Examining data/apophenia-1.0+ds/tests/db_tests.c Examining data/apophenia-1.0+ds/tests/distribution_tests.c Examining data/apophenia-1.0+ds/tests/error_test.c Examining data/apophenia-1.0+ds/tests/factors.c Examining data/apophenia-1.0+ds/tests/lognormal_test.c Examining data/apophenia-1.0+ds/tests/nist_tests.c Examining data/apophenia-1.0+ds/tests/rake_test.c Examining data/apophenia-1.0+ds/tests/sort_example.c Examining data/apophenia-1.0+ds/tests/sort_tests.c Examining data/apophenia-1.0+ds/tests/test_apop.c Examining data/apophenia-1.0+ds/tests/test_kernel_ll.c Examining data/apophenia-1.0+ds/tests/update_via_rng.c Examining data/apophenia-1.0+ds/transform/apop_coordinate_transform.c Examining data/apophenia-1.0+ds/transform/apop_cross.c Examining data/apophenia-1.0+ds/transform/apop_dconstrain.c Examining data/apophenia-1.0+ds/transform/apop_fix_params.c Examining data/apophenia-1.0+ds/transform/apop_mixture.c Examining data/apophenia-1.0+ds/apop_db_mysql.c Examining data/apophenia-1.0+ds/apop_conversions.c Examining data/apophenia-1.0+ds/apop_data.c Examining data/apophenia-1.0+ds/apop_arms.c FINAL RESULTS: data/apophenia-1.0+ds/apop_asst.c:25: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(*in+inlen, addme); data/apophenia-1.0+ds/apop_asst.c:202:15: [4] (shell) system: 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. int out = system(q); data/apophenia-1.0+ds/apop_name.c:52: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(n->vector, add_me); data/apophenia-1.0+ds/apop_name.c:59: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(n->row[n->rowct -1], add_me); data/apophenia-1.0+ds/apop_name.c:66: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(n->text[n->textct -1], add_me); data/apophenia-1.0+ds/apop_name.c:76: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(n->col[n->colct -1], add_me); data/apophenia-1.0+ds/apop_regression.c:273:17: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(n, "%s dummy %g", basename, gsl_vector_get(delmts,i)); data/apophenia-1.0+ds/apop_regression.c:275:17: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(n, "%s", telmts->text[0][i]); data/apophenia-1.0+ds/asprintf.c:50:22: [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. # define __printf__ printf data/apophenia-1.0+ds/asprintf.c:967:20: [4] (buffer) swprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. # define SNPRINTF swprintf data/apophenia-1.0+ds/asprintf.c:978:20: [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/apophenia-1.0+ds/asprintf.c:981:20: [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/apophenia-1.0+ds/asprintf.c:1461:12: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. count = sprintf (tmp, buf, arg); \ data/apophenia-1.0+ds/asprintf.c:1464:12: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. count = sprintf (tmp, buf, prefixes[0], arg); \ data/apophenia-1.0+ds/asprintf.c:1467:12: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. count = sprintf (tmp, buf, prefixes[0], prefixes[1],\ data/apophenia-1.0+ds/cmd/apop_db_to_crosstab.c:29:20: [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). if (c=='d') strcpy(apop_opts.output_delimiter,optarg); data/apophenia-1.0+ds/cmd/apop_db_to_crosstab.c:30:35: [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. else if (c=='h'||c=='-') {printf(msg, argv[0]); exit(0);} data/apophenia-1.0+ds/cmd/apop_plot_query.c:47: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. f = popen("`which gnuplot` -persist", "w"); data/apophenia-1.0+ds/cmd/apop_plot_query.c:60:9: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(q, "%s%s", q, in); data/apophenia-1.0+ds/cmd/apop_plot_query.c:62:5: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(q, "%s;\n", q); data/apophenia-1.0+ds/cmd/apop_plot_query.c:122:13: [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(msg, argv[0]); data/apophenia-1.0+ds/cmd/apop_text_to_db.c:73:26: [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). else if (c=='d') strcpy(apop_opts.input_delimiters, optarg); data/apophenia-1.0+ds/cmd/apop_text_to_db.c:77:20: [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). else if (c=='u') strcpy(apop_opts.db_user, optarg); data/apophenia-1.0+ds/cmd/apop_text_to_db.c:78:20: [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). else if (c=='p') strcpy(apop_opts.db_pass, optarg); data/apophenia-1.0+ds/eg/ols2.c:5:23: [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. char *datafile = (access("ss08pdc.csv", R_OK)!=-1) ? "ss08pdc.csv" : "data"; data/apophenia-1.0+ds/model/apop_loess.c:870: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(mess,s); data/apophenia-1.0+ds/model/apop_loess.c:873: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(mess,num); data/apophenia-1.0+ds/model/apop_loess.c:880: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(mess,s); data/apophenia-1.0+ds/model/apop_loess.c:883: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(mess,num); data/apophenia-1.0+ds/tests/test_apop.c:59:47: [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 Apop_assert(expr, ...) {if (!(expr)) {fprintf(stderr, __VA_ARGS__); abort();}} data/apophenia-1.0+ds/apop_db.c:42: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("APOP_DB_ENGINE") && (!strcasecmp(getenv("APOP_DB_ENGINE"), "mysql") || !strcasecmp(getenv("APOP_DB_ENGINE"), "mariadb"))) data/apophenia-1.0+ds/apop_db.c:42:50: [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("APOP_DB_ENGINE") && (!strcasecmp(getenv("APOP_DB_ENGINE"), "mysql") || !strcasecmp(getenv("APOP_DB_ENGINE"), "mariadb"))) data/apophenia-1.0+ds/apop_db.c:42:100: [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("APOP_DB_ENGINE") && (!strcasecmp(getenv("APOP_DB_ENGINE"), "mysql") || !strcasecmp(getenv("APOP_DB_ENGINE"), "mariadb"))) data/apophenia-1.0+ds/cmd/apop_db_to_crosstab.c:28:14: [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, "d:f:hv-")) != -1) data/apophenia-1.0+ds/cmd/apop_plot_query.c:113:14: [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, "ad:f:hH:nQ:q:st:-")) != -1) data/apophenia-1.0+ds/cmd/apop_text_to_db.c:59:14: [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, "n:d:e:f:hmp:ru:vN:O")) != -1) data/apophenia-1.0+ds/tests/distribution_tests.c:208:16: [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, opts))!=-1) data/apophenia-1.0+ds/tests/test_apop.c:1217:16: [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, opts))!=-1) data/apophenia-1.0+ds/apop_arms.c:41: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 ADHOC[64]; data/apophenia-1.0+ds/apop_arms.c:45: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 ADHOC[64]; data/apophenia-1.0+ds/apop_asst.c:295:21: [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((*substrings)->text[matchrow][i], string + result[i+1].rm_so, length_of_match); data/apophenia-1.0+ds/apop_conversions.c:219: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 sparerow[msize1 > 0 ? (int)log10(msize1)+1 : 0]; data/apophenia-1.0+ds/apop_conversions.c:220: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 sparecol[maxcol > 0 ? (int)log10(maxcol)+1 : 0]; data/apophenia-1.0+ds/apop_conversions.c:227:50: [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. rowname = (n->rowct > i) ? n->row[i] : (sprintf(sparerow, "r%i", i), sparerow); data/apophenia-1.0+ds/apop_conversions.c:229:53: [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. colname = (n->colct > j) ? n->col[j] : (sprintf(sparecol, "c%i", j), sparecol); data/apophenia-1.0+ds/apop_conversions.c:238:49: [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. rowname = (n->rowct > i) ? n->row[i] : (sprintf(sparerow, "r%i", i), sparerow); data/apophenia-1.0+ds/apop_conversions.c:240:55: [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. colname = (n->textct > j) ? n->text[j] : (sprintf(sparecol, "t%i", j), sparecol); data/apophenia-1.0+ds/apop_conversions.c:445:20: [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). : fopen(text_file, "r"); data/apophenia-1.0+ds/apop_conversions.c:647: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[bs]; data/apophenia-1.0+ds/apop_conversions.c:1191: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[bs]; data/apophenia-1.0+ds/apop_mcmc.c:14: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(m->parameters->vector->data, d, sizeof(double)*m->parameters->vector->size); data/apophenia-1.0+ds/apop_mle.c:755:9: [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(prm0->starting_pt, prm->starting_pt, sizeof(double)*size); data/apophenia-1.0+ds/apop_mle.c:760:9: [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(prm->starting_pt, v->data, sizeof(double)*v->size); data/apophenia-1.0+ds/apop_mle.c:765:9: [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(prm->starting_pt, v->data, sizeof(double)*v->size); data/apophenia-1.0+ds/apop_model.c:167: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(out, in, sizeof(apop_model)); data/apophenia-1.0+ds/apop_model.c:171:9: [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(out->more, in->more, in->more_size); data/apophenia-1.0+ds/apop_output.c:61:27: [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). ? fopen(output_name, *output_append == 'a' ? "a" : "w") data/apophenia-1.0+ds/apop_rake.c:153: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(d, is_margin ? index[0]->margin_ptrs: index[0]->fit_ptrs, len * sizeof(bool)); data/apophenia-1.0+ds/apop_regression.c:271:13: [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 n[1000]; data/apophenia-1.0+ds/apop_stats.c:427: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 rowname[10000]; //crashes on more than 10^9995 columns. data/apophenia-1.0+ds/apop_stats.c:445:4: [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(rowname, "col %zu", i); data/apophenia-1.0+ds/asprintf.c:1070:4: [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 (memory, result, length * sizeof (CHAR_T)); \ data/apophenia-1.0+ds/asprintf.c:1082:6: [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 + length, cp, n * sizeof (CHAR_T)); data/apophenia-1.0+ds/asprintf.c:1368: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 (p, dp->width_start, n * sizeof (CHAR_T)); data/apophenia-1.0+ds/asprintf.c:1373: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 (p, dp->precision_start, n * sizeof (CHAR_T)); data/apophenia-1.0+ds/asprintf.c:1649: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 (result + length, tmp, count * sizeof (CHAR_T)); data/apophenia-1.0+ds/cmd/apop_plot_query.c:43: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). f = fopen(outfile, "w"); data/apophenia-1.0+ds/cmd/apop_plot_query.c:53: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 in[1000]; data/apophenia-1.0+ds/cmd/apop_plot_query.c:56:17: [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 *inf = fopen(infile, "r"); data/apophenia-1.0+ds/cmd/apop_plot_query.c:119:27: [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). histobins = atoi(optarg); data/apophenia-1.0+ds/cmd/apop_text_to_db.c:15: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). out[ctr++] = atoi(cp); data/apophenia-1.0+ds/eg/fake_logit.c:9:15: [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(testfile, "w"); data/apophenia-1.0+ds/eg/kernel.c:30:20: [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 *outtab = fopen("kerneldata", "w"); data/apophenia-1.0+ds/eg/sql_to_html.c:20: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). FILE *outfile = fopen("yourdata.html", "w"); data/apophenia-1.0+ds/eg/test_updating.c:25:33: [2] (buffer) bcopy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. bin = apop_model_fix_params(bcopy); data/apophenia-1.0+ds/model/apop_loess.c:837: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 *mess, mess2[50]; data/apophenia-1.0+ds/model/apop_loess.c:863:10: [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. default: sprintf(mess=mess2,"Assert failed; error code %d\n",i); break; data/apophenia-1.0+ds/model/apop_loess.c:869: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 mess[4000], num[20]; data/apophenia-1.0+ds/model/apop_loess.c:872: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(num," %ld",i[j * inc]); data/apophenia-1.0+ds/model/apop_loess.c:879: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 mess[4000], num[30]; data/apophenia-1.0+ds/model/apop_loess.c:882: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(num," %.5g",x[j * inc]); data/apophenia-1.0+ds/model/apop_loess.c:2880: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(x_tmp, lo->in.x, N * D * sizeof(double)); data/apophenia-1.0+ds/model/apop_loess.c:3558:9: [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(lo->in.y, in.data->vector->data, n*sizeof(double)); data/apophenia-1.0+ds/model/apop_multinomial.c:182: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 name[100]; data/apophenia-1.0+ds/model/apop_multinomial.c:184:9: [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(name, "p%i", i); data/apophenia-1.0+ds/model/apop_ols.c:286:23: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. if (m->dsize > 1) memcpy(out+1, tempdata->data, sizeof(double)*tempdata->size); data/apophenia-1.0+ds/model/apop_probit.c:328:21: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. if (m->dsize>1) memcpy(out+1, x->vector->data, datasize *sizeof(double)); data/apophenia-1.0+ds/tests/db_tests.c:199:15: [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(outfile, "a"); data/apophenia-1.0+ds/tests/db_tests.c:201: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(apop_opts.output_delimiter, "\t| "); data/apophenia-1.0+ds/tests/db_tests.c:217:9: [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(outfile, "a"); data/apophenia-1.0+ds/tests/distribution_tests.c:211:49: [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). else if (c == 't') omp_set_num_threads(atoi(optarg)); data/apophenia-1.0+ds/tests/error_test.c:17:1: [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 errorbuff[10000]; data/apophenia-1.0+ds/tests/test_apop.c:206: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). assert(atoi(t1c->text[3][4])==12); data/apophenia-1.0+ds/tests/test_apop.c:213: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). assert(atoi(t1c->text[3][4])==16); data/apophenia-1.0+ds/tests/test_apop.c:223: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). assert(atoi(t3c->text[3][4])==12); data/apophenia-1.0+ds/tests/test_apop.c:224: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). assert(atoi(t3c->text[4][4])==20); data/apophenia-1.0+ds/tests/test_apop.c:225: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). assert(atoi(t3c->text[7][4])==36); data/apophenia-1.0+ds/tests/test_apop.c:256:12: [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). assert(atoi(t4->text[9][8])==72); data/apophenia-1.0+ds/tests/test_apop.c:1221:49: [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). else if (c == 't') omp_set_num_threads(atoi(optarg)); data/apophenia-1.0+ds/transform/apop_fix_params.c:193: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(new_start, ptv->data, ptv->size* sizeof(double)); data/apophenia-1.0+ds/apop_asst.c:22: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). size_t inlen = *in? strlen(*in): 0; data/apophenia-1.0+ds/apop_asst.c:23:31: [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 total_len= inlen + strlen(addme); data/apophenia-1.0+ds/apop_asst.c:294: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). (*substrings)->text[matchrow][i] = malloc(strlen(string)+1); data/apophenia-1.0+ds/apop_conversions.c:463:13: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int c = fgetc(infile); data/apophenia-1.0+ds/apop_conversions.c:486:13: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). c = fgetc(infile); data/apophenia-1.0+ds/apop_conversions.c:692: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). if (strlen(thisstr)){ data/apophenia-1.0+ds/apop_conversions.c:1080:30: [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 (!prepped || !strlen(prepped)) data/apophenia-1.0+ds/apop_conversions.c:1087: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). xprintf(&q, "%s%c %s", q, comma, (prepped && strlen(prepped) ? prepped : " NULL")); data/apophenia-1.0+ds/apop_db.c:519:18: [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(set->names->row[row])) field++; //leave NULL and cleared data/apophenia-1.0+ds/apop_db.c:535: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 (!strlen(set->text[row][col]) || (apop_opts.nan_string && !strcasecmp(apop_opts.nan_string, set->text[row][col]))) data/apophenia-1.0+ds/apop_db.c:562: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). int use_row = (apop_opts.db_name_column && strlen(apop_opts.db_name_column)) && set->names data/apophenia-1.0+ds/apop_db.c:602:13: [1] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source is a constant character. sprintf(q, " "); data/apophenia-1.0+ds/apop_mle.c:610: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(!m || strlen(m)==0) return 0; data/apophenia-1.0+ds/apop_mle.c:664: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). if (!mp->method || !strlen(mp->method)) mp->method = ms ? "FR cg" : "NM simplex"; data/apophenia-1.0+ds/apop_model.c:36: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). if (model->info->names->title && !strlen(model->info->names->title)) data/apophenia-1.0+ds/apop_model.c:137: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). if (strlen(model->name)) fprintf (output_pipe, "%s", model->name); data/apophenia-1.0+ds/apop_model.c:178: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). while (strlen(in->settings[i++].name)); data/apophenia-1.0+ds/apop_name.c:51: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). n->vector = realloc(n->vector, strlen(add_me) + 1); data/apophenia-1.0+ds/apop_name.c:58: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). n->row[n->rowct -1] = malloc(strlen(add_me) + 1); data/apophenia-1.0+ds/apop_name.c:65:34: [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). n->text[n->textct -1] = malloc(strlen(add_me) + 1); data/apophenia-1.0+ds/apop_name.c:75: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). n->col[n->colct -1] = malloc(strlen(add_me) + 1); data/apophenia-1.0+ds/apop_output.c:153: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). colsizes[i] = strlen(printout->text[0][i]); data/apophenia-1.0+ds/apop_output.c:155: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). colsizes[i] = GSL_MAX(colsizes[i], strlen(printout->text[j][i])); data/apophenia-1.0+ds/apop_output.c:159: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). if (in->names && in->names->title && strlen(in->names->title)) data/apophenia-1.0+ds/apop_output.c:163: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). white_pad(colsizes[i] - strlen(printout->text[j][i]) + 1);//one spare space. data/apophenia-1.0+ds/apop_output.c:235: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). max = GSL_MAX(max, strlen(names[i])); data/apophenia-1.0+ds/apop_output.c:254: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 (data->names && data->names->title && strlen(data->names->title)) data/apophenia-1.0+ds/apop_settings.c:54:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(model->settings[ct].name, type, 100); data/apophenia-1.0+ds/apop_settings.c:91: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). if (!copyme || !strlen(copyme)) return; //apop_settings_group_alloc takes care of the blank sentinel. data/apophenia-1.0+ds/apop_stats.c:436: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 (indata->names->title && strlen(indata->names->title)){ data/apophenia-1.0+ds/asprintf.c:935:24: [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). # define local_wcslen wcslen data/apophenia-1.0+ds/asprintf.c:1313: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). tmp_length = strlen (a.arg[dp->arg_index].a.a_string); data/apophenia-1.0+ds/cmd/apop_plot_query.c:59: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). q = realloc(q, strlen(q) + strlen(in) + 4); data/apophenia-1.0+ds/cmd/apop_plot_query.c:59:36: [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). q = realloc(q, strlen(q) + strlen(in) + 4); data/apophenia-1.0+ds/eg/test_regex.c:9: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). assert(!strlen(subs->text[0][1])); //The non-match to (xx)* has a zero-length blank data/apophenia-1.0+ds/model/apop_ols.c:105:13: [1] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source is a constant character. sprintf(d->names->col[0], "1"); data/apophenia-1.0+ds/tests/db_tests.c:220:5: [1] (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 character. strcpy(apop_opts.output_delimiter, "\t"); data/apophenia-1.0+ds/tests/test_apop.c:240: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). assert(!strlen(t1->text[7][11])); data/apophenia-1.0+ds/tests/test_apop.c:244: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). assert(!strlen(t1->text[11][7])); data/apophenia-1.0+ds/tests/test_apop.c:255: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). assert(!strlen(t4->text[11][7])); ANALYSIS SUMMARY: Hits = 140 Lines analyzed = 32024 in approximately 1.18 seconds (27223 lines/second) Physical Source Lines of Code (SLOC) = 19499 Hits@level = [0] 158 [1] 40 [2] 62 [3] 8 [4] 30 [5] 0 Hits@level+ = [0+] 298 [1+] 140 [2+] 100 [3+] 38 [4+] 30 [5+] 0 Hits/KSLOC@level+ = [0+] 15.2828 [1+] 7.17986 [2+] 5.12847 [3+] 1.94882 [4+] 1.53854 [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.