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/hmat-oss-1.2.0/examples/c-cholesky.c Examining data/hmat-oss-1.2.0/examples/c-cylinder.c Examining data/hmat-oss-1.2.0/examples/c-simple-cylinder.c Examining data/hmat-oss-1.2.0/examples/c-simple-kriging.c Examining data/hmat-oss-1.2.0/examples/cylinder.cpp Examining data/hmat-oss-1.2.0/examples/kriging.cpp Examining data/hmat-oss-1.2.0/include/hmat/hmat.h Examining data/hmat-oss-1.2.0/src/admissibility.cpp Examining data/hmat-oss-1.2.0/src/admissibility.hpp Examining data/hmat-oss-1.2.0/src/assembly.cpp Examining data/hmat-oss-1.2.0/src/assembly.hpp Examining data/hmat-oss-1.2.0/src/blas_overloads.hpp Examining data/hmat-oss-1.2.0/src/c_wrapping.hpp Examining data/hmat-oss-1.2.0/src/cluster_tree.cpp Examining data/hmat-oss-1.2.0/src/cluster_tree.hpp Examining data/hmat-oss-1.2.0/src/clustering.cpp Examining data/hmat-oss-1.2.0/src/clustering.hpp Examining data/hmat-oss-1.2.0/src/common/chrono.h Examining data/hmat-oss-1.2.0/src/common/context.cpp Examining data/hmat-oss-1.2.0/src/common/context.hpp Examining data/hmat-oss-1.2.0/src/common/memory_instrumentation.hpp Examining data/hmat-oss-1.2.0/src/common/my_assert.h Examining data/hmat-oss-1.2.0/src/common/memory_instrumentation.cpp Examining data/hmat-oss-1.2.0/src/compression.cpp Examining data/hmat-oss-1.2.0/src/compression.hpp Examining data/hmat-oss-1.2.0/src/coordinates.cpp Examining data/hmat-oss-1.2.0/src/coordinates.hpp Examining data/hmat-oss-1.2.0/src/data_types.cpp Examining data/hmat-oss-1.2.0/src/data_types.hpp Examining data/hmat-oss-1.2.0/src/default_engine.cpp Examining data/hmat-oss-1.2.0/src/default_engine.hpp Examining data/hmat-oss-1.2.0/src/disable_threading.cpp Examining data/hmat-oss-1.2.0/src/disable_threading.hpp Examining data/hmat-oss-1.2.0/src/fromdouble.cpp Examining data/hmat-oss-1.2.0/src/fromdouble.hpp Examining data/hmat-oss-1.2.0/src/full_matrix.hpp Examining data/hmat-oss-1.2.0/src/h_matrix.cpp Examining data/hmat-oss-1.2.0/src/h_matrix.hpp Examining data/hmat-oss-1.2.0/src/hmat_cpp_interface.cpp Examining data/hmat-oss-1.2.0/src/hmat_cpp_interface.hpp Examining data/hmat-oss-1.2.0/src/lapack_exception.hpp Examining data/hmat-oss-1.2.0/src/lapack_operations.cpp Examining data/hmat-oss-1.2.0/src/lapack_operations.hpp Examining data/hmat-oss-1.2.0/src/lapack_overloads.hpp Examining data/hmat-oss-1.2.0/src/postscript.cpp Examining data/hmat-oss-1.2.0/src/postscript.hpp Examining data/hmat-oss-1.2.0/src/recursion.cpp Examining data/hmat-oss-1.2.0/src/recursion.hpp Examining data/hmat-oss-1.2.0/src/rk_matrix.cpp Examining data/hmat-oss-1.2.0/src/rk_matrix.hpp Examining data/hmat-oss-1.2.0/src/system_types.h Examining data/hmat-oss-1.2.0/src/tree.hpp Examining data/hmat-oss-1.2.0/src/uncompressed_block.hpp Examining data/hmat-oss-1.2.0/src/uncompressed_values.cpp Examining data/hmat-oss-1.2.0/src/uncompressed_values.hpp Examining data/hmat-oss-1.2.0/src/c_default_interface.cpp Examining data/hmat-oss-1.2.0/src/full_matrix.cpp FINAL RESULTS: data/hmat-oss-1.2.0/src/common/my_assert.h:65: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, format, arglist); data/hmat-oss-1.2.0/src/common/memory_instrumentation.cpp:57: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 * ws = getenv("HMAT_MEMINSTR_WS"); data/hmat-oss-1.2.0/src/common/memory_instrumentation.cpp:59: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 * mi = getenv("HMAT_MEMINSTR_MI"); data/hmat-oss-1.2.0/src/lapack_operations.cpp:281:28: [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. static char * useGESSD = getenv("HMAT_GESSD"); data/hmat-oss-1.2.0/examples/c-cholesky.c:55: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 * fp = fopen(filename, "w"); data/hmat-oss-1.2.0/examples/c-cholesky.c:232:7: [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). n = atoi(argv[1]); data/hmat-oss-1.2.0/examples/c-cholesky.c:325: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(frhsCopy2, frhs, n*sizeof(float)); data/hmat-oss-1.2.0/examples/c-cholesky.c:326: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(drhsCopy2, drhs, n*sizeof(double)); data/hmat-oss-1.2.0/examples/c-cholesky.c:338: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(frhs, frhsCopy1, n*sizeof(float)); data/hmat-oss-1.2.0/examples/c-cholesky.c:339: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(drhs, drhsCopy1, n*sizeof(double)); data/hmat-oss-1.2.0/examples/c-cholesky.c:340: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(frhsCopy3, frhsCopy1, n*sizeof(float)); data/hmat-oss-1.2.0/examples/c-cholesky.c:341: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(drhsCopy3, drhsCopy1, n*sizeof(double)); data/hmat-oss-1.2.0/examples/c-cholesky.c:366: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(frhsCopy3, frhs, n*sizeof(float)); data/hmat-oss-1.2.0/examples/c-cholesky.c:367: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(drhsCopy3, drhs, n*sizeof(double)); data/hmat-oss-1.2.0/examples/c-cylinder.c:73: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 * fp = fopen(filename, "w"); data/hmat-oss-1.2.0/examples/c-cylinder.c:231:7: [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). n = atoi(argv[1]); data/hmat-oss-1.2.0/examples/c-simple-cylinder.c:73: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 * fp = fopen(filename, "w"); data/hmat-oss-1.2.0/examples/c-simple-cylinder.c:138:7: [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). n = atoi(argv[1]); data/hmat-oss-1.2.0/examples/c-simple-kriging.c:107: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 * fp = fopen(filename, "w"); data/hmat-oss-1.2.0/examples/c-simple-kriging.c:124:8: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). fp = fopen(filename, "r"); data/hmat-oss-1.2.0/examples/cylinder.cpp:196:11: [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). int n = atoi(argv[1]); data/hmat-oss-1.2.0/src/cluster_tree.cpp:86: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(group_index_, group_index, sizeof(int) * size); data/hmat-oss-1.2.0/src/cluster_tree.cpp:107: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->perm_i2e_, perm_i2e_, sizeof(int) * coordinates_->size()); data/hmat-oss-1.2.0/src/cluster_tree.cpp:108: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->perm_e2i_, perm_e2i_, sizeof(int) * coordinates_->size()); data/hmat-oss-1.2.0/src/cluster_tree.cpp:186: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(&bbMin[0], &coord[dimension_*myIndices[0]], sizeof(double) * dimension_); data/hmat-oss-1.2.0/src/cluster_tree.cpp:187: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(&bbMax[0], &coord[dimension_*myIndices[0]], sizeof(double) * dimension_); data/hmat-oss-1.2.0/src/cluster_tree.cpp:204: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(&bbMin[0], bboxMin, sizeof(double) * dimension_); data/hmat-oss-1.2.0/src/cluster_tree.cpp:205: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(&bbMax[0], bboxMax, sizeof(double) * dimension_); data/hmat-oss-1.2.0/src/common/context.cpp:186: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, "Worker #%03d - %p", index, enclosing); data/hmat-oss-1.2.0/src/common/memory_instrumentation.cpp:48: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 * statm_file = fopen("/proc/self/statm", "r"); data/hmat-oss-1.2.0/src/common/memory_instrumentation.cpp:58: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). write_sampling = ws ? atoi(ws) : 1; data/hmat-oss-1.2.0/src/common/memory_instrumentation.cpp:60:30: [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). mallinfo_sampling = mi ? atoi(mi) : 100; data/hmat-oss-1.2.0/src/common/memory_instrumentation.cpp:96: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). output_ = fopen(filename.c_str(), "w+"); data/hmat-oss-1.2.0/src/common/memory_instrumentation.cpp:102:22: [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 * labelsf = fopen((filename_+".labels").c_str(), "w"); data/hmat-oss-1.2.0/src/compression.cpp:378: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(tmpA.m + nu * tmpA.rows, m->m + j_nu * m->rows, data/hmat-oss-1.2.0/src/compression.cpp:424: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(newA->m, tmpA.m, sizeof(dp_t) * tmpA.rows * nu); data/hmat-oss-1.2.0/src/compression.cpp:427: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(newB->m, tmpB.m, sizeof(dp_t) * tmpB.rows * nu); data/hmat-oss-1.2.0/src/compression.cpp:532: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(newA->m + (i * newA->rows), aCols[i]->v, sizeof(dp_t) * newA->rows); data/hmat-oss-1.2.0/src/compression.cpp:538: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(newB->m + (i * newB->rows), bCols[i]->v, sizeof(dp_t) * newB->rows); data/hmat-oss-1.2.0/src/compression.cpp:688: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(newA->m + (i * newA->rows), aCols[i]->v, sizeof(dp_t) * newA->rows); data/hmat-oss-1.2.0/src/compression.cpp:694: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(newB->m + (i * newB->rows), bCols[i]->v, sizeof(dp_t) * newB->rows); data/hmat-oss-1.2.0/src/coordinates.cpp:41:10: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. std::memcpy(v_, coord, sizeof(double) * size_ * dimension_); data/hmat-oss-1.2.0/src/coordinates.cpp:53:8: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. std::memcpy(v_, other.v_, sizeof(double) * size_ * dimension_); data/hmat-oss-1.2.0/src/full_matrix.cpp:271: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(result->m, m, size); data/hmat-oss-1.2.0/src/full_matrix.cpp:276: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->m + resultOffset, m + offset, rows * sizeof(T)); data/hmat-oss-1.2.0/src/full_matrix.cpp:283: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(result->diagonal->v, diagonal->v, rows * sizeof(T)); data/hmat-oss-1.2.0/src/full_matrix.cpp:347: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(diag, d->v, d->rows * sizeof(T)); data/hmat-oss-1.2.0/src/full_matrix.cpp:590: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, a->m, size * sizeof(T)); data/hmat-oss-1.2.0/src/full_matrix.cpp:652: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). FILE * f = fopen(filename, "rb"); data/hmat-oss-1.2.0/src/full_matrix.cpp:680:8: [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). fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, (mode_t)0600); data/hmat-oss-1.2.0/src/full_matrix.cpp:698: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(mat, m, size - 5 * sizeof(int)); data/hmat-oss-1.2.0/src/full_matrix.cpp:752:8: [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). fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, (mode_t)0600); data/hmat-oss-1.2.0/src/full_matrix.cpp:789:16: [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). result->fd = open(filename, O_RDONLY); data/hmat-oss-1.2.0/src/h_matrix.cpp:81: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(column, tmp.v, sizeof(T) * n); data/hmat-oss-1.2.0/src/h_matrix.cpp:97: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(column, tmp.v, sizeof(T) * n); data/hmat-oss-1.2.0/src/h_matrix.cpp:1360:11: [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(full()->diagonal->v, oF->diagonal->v, oF->rows * sizeof(T)); data/hmat-oss-1.2.0/src/h_matrix.cpp:1397:8: [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(filename.c_str()); data/hmat-oss-1.2.0/src/h_matrix.cpp:2097: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(diag, full()->diagonal->v, full()->rows * sizeof(T)); data/hmat-oss-1.2.0/src/postscript.cpp:132:10: [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(filename.c_str()); data/hmat-oss-1.2.0/examples/c-simple-kriging.c:60:9: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). c = fgetc(stream); data/hmat-oss-1.2.0/examples/c-simple-kriging.c:84:13: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). c = fgetc(stream); data/hmat-oss-1.2.0/examples/c-simple-kriging.c:120:11: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ssize_t read; ANALYSIS SUMMARY: Hits = 62 Lines analyzed = 16762 in approximately 0.49 seconds (34304 lines/second) Physical Source Lines of Code (SLOC) = 10916 Hits@level = [0] 96 [1] 3 [2] 55 [3] 3 [4] 1 [5] 0 Hits@level+ = [0+] 158 [1+] 62 [2+] 59 [3+] 4 [4+] 1 [5+] 0 Hits/KSLOC@level+ = [0+] 14.4742 [1+] 5.67974 [2+] 5.40491 [3+] 0.366435 [4+] 0.0916086 [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.