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/qiskit-aer-0.4.1/contrib/standalone/qasm_simulator.cpp
Examining data/qiskit-aer-0.4.1/qiskit/providers/aer/backends/wrappers/bindings.cc
Examining data/qiskit-aer-0.4.1/qiskit/providers/aer/pulse/qutip_lite/cy/src/zspmv.cpp
Examining data/qiskit-aer-0.4.1/qiskit/providers/aer/pulse/qutip_lite/cy/src/zspmv.hpp
Examining data/qiskit-aer-0.4.1/src/controllers/controller.hpp
Examining data/qiskit-aer-0.4.1/src/controllers/controller_execute.hpp
Examining data/qiskit-aer-0.4.1/src/controllers/qasm_controller.hpp
Examining data/qiskit-aer-0.4.1/src/controllers/statevector_controller.hpp
Examining data/qiskit-aer-0.4.1/src/controllers/unitary_controller.hpp
Examining data/qiskit-aer-0.4.1/src/framework/circuit.hpp
Examining data/qiskit-aer-0.4.1/src/framework/creg.hpp
Examining data/qiskit-aer-0.4.1/src/framework/json.hpp
Examining data/qiskit-aer-0.4.1/src/framework/linalg/almost_equal.hpp
Examining data/qiskit-aer-0.4.1/src/framework/linalg/enable_if_numeric.hpp
Examining data/qiskit-aer-0.4.1/src/framework/linalg/linalg.hpp
Examining data/qiskit-aer-0.4.1/src/framework/linalg/linops/linops_array.hpp
Examining data/qiskit-aer-0.4.1/src/framework/linalg/linops/linops_generic.hpp
Examining data/qiskit-aer-0.4.1/src/framework/linalg/linops/linops_json.hpp
Examining data/qiskit-aer-0.4.1/src/framework/linalg/linops/linops_map.hpp
Examining data/qiskit-aer-0.4.1/src/framework/linalg/linops/linops_matrix.hpp
Examining data/qiskit-aer-0.4.1/src/framework/linalg/linops/linops_unordered_map.hpp
Examining data/qiskit-aer-0.4.1/src/framework/linalg/linops/linops_vector.hpp
Examining data/qiskit-aer-0.4.1/src/framework/linalg/square.hpp
Examining data/qiskit-aer-0.4.1/src/framework/matrix.hpp
Examining data/qiskit-aer-0.4.1/src/framework/operations.hpp
Examining data/qiskit-aer-0.4.1/src/framework/pybind_json.hpp
Examining data/qiskit-aer-0.4.1/src/framework/qobj.hpp
Examining data/qiskit-aer-0.4.1/src/framework/results/data/average_data.hpp
Examining data/qiskit-aer-0.4.1/src/framework/results/data/average_snapshot.hpp
Examining data/qiskit-aer-0.4.1/src/framework/results/data/pershot_data.hpp
Examining data/qiskit-aer-0.4.1/src/framework/results/data/pershot_snapshot.hpp
Examining data/qiskit-aer-0.4.1/src/framework/results/experiment_data.hpp
Examining data/qiskit-aer-0.4.1/src/framework/results/experiment_result.hpp
Examining data/qiskit-aer-0.4.1/src/framework/results/result.hpp
Examining data/qiskit-aer-0.4.1/src/framework/rng.hpp
Examining data/qiskit-aer-0.4.1/src/framework/types.hpp
Examining data/qiskit-aer-0.4.1/src/framework/utils.hpp
Examining data/qiskit-aer-0.4.1/src/misc/clang_omp_symbols.hpp
Examining data/qiskit-aer-0.4.1/src/misc/gcc_omp_symbols.hpp
Examining data/qiskit-aer-0.4.1/src/misc/hacks.hpp
Examining data/qiskit-aer-0.4.1/src/noise/noise_model.hpp
Examining data/qiskit-aer-0.4.1/src/noise/quantum_error.hpp
Examining data/qiskit-aer-0.4.1/src/noise/readout_error.hpp
Examining data/qiskit-aer-0.4.1/src/open_pulse/iterators.hpp
Examining data/qiskit-aer-0.4.1/src/open_pulse/log.hpp
Examining data/qiskit-aer-0.4.1/src/open_pulse/numeric_integrator.cpp
Examining data/qiskit-aer-0.4.1/src/open_pulse/numeric_integrator.hpp
Examining data/qiskit-aer-0.4.1/src/open_pulse/ordered_map.hpp
Examining data/qiskit-aer-0.4.1/src/open_pulse/python_to_cpp.hpp
Examining data/qiskit-aer-0.4.1/src/open_pulse/test_python_to_cpp.hpp
Examining data/qiskit-aer-0.4.1/src/open_pulse/types.hpp
Examining data/qiskit-aer-0.4.1/src/open_pulse/eval_hamiltonian.hpp
Examining data/qiskit-aer-0.4.1/src/simulators/density_matrix/densitymatrix.hpp
Examining data/qiskit-aer-0.4.1/src/simulators/density_matrix/densitymatrix_state.hpp
Examining data/qiskit-aer-0.4.1/src/simulators/density_matrix/densitymatrix_thrust.hpp
Examining data/qiskit-aer-0.4.1/src/simulators/extended_stabilizer/ch_runner.hpp
Examining data/qiskit-aer-0.4.1/src/simulators/extended_stabilizer/chlib/chstabilizer.hpp
Examining data/qiskit-aer-0.4.1/src/simulators/extended_stabilizer/chlib/core.hpp
Examining data/qiskit-aer-0.4.1/src/simulators/extended_stabilizer/extended_stabilizer_state.hpp
Examining data/qiskit-aer-0.4.1/src/simulators/extended_stabilizer/gates.hpp
Examining data/qiskit-aer-0.4.1/src/simulators/matrix_product_state/matrix_product_state.hpp
Examining data/qiskit-aer-0.4.1/src/simulators/matrix_product_state/matrix_product_state_internal.cpp
Examining data/qiskit-aer-0.4.1/src/simulators/matrix_product_state/matrix_product_state_internal.hpp
Examining data/qiskit-aer-0.4.1/src/simulators/matrix_product_state/matrix_product_state_tensor.hpp
Examining data/qiskit-aer-0.4.1/src/simulators/matrix_product_state/svd.cpp
Examining data/qiskit-aer-0.4.1/src/simulators/matrix_product_state/svd.hpp
Examining data/qiskit-aer-0.4.1/src/simulators/stabilizer/binary_vector.hpp
Examining data/qiskit-aer-0.4.1/src/simulators/stabilizer/clifford.hpp
Examining data/qiskit-aer-0.4.1/src/simulators/stabilizer/pauli.hpp
Examining data/qiskit-aer-0.4.1/src/simulators/stabilizer/stabilizer_state.hpp
Examining data/qiskit-aer-0.4.1/src/simulators/state.hpp
Examining data/qiskit-aer-0.4.1/src/simulators/statevector/qubitvector.hpp
Examining data/qiskit-aer-0.4.1/src/simulators/statevector/qubitvector_thrust.hpp
Examining data/qiskit-aer-0.4.1/src/simulators/statevector/statevector_state.hpp
Examining data/qiskit-aer-0.4.1/src/simulators/superoperator/superoperator.hpp
Examining data/qiskit-aer-0.4.1/src/simulators/superoperator/superoperator_state.hpp
Examining data/qiskit-aer-0.4.1/src/simulators/unitary/unitary_state.hpp
Examining data/qiskit-aer-0.4.1/src/simulators/unitary/unitarymatrix.hpp
Examining data/qiskit-aer-0.4.1/src/simulators/unitary/unitarymatrix_thrust.hpp
Examining data/qiskit-aer-0.4.1/src/third-party/headers/nlohmann_json.hpp
Examining data/qiskit-aer-0.4.1/src/third-party/macos/lib/omp.h
Examining data/qiskit-aer-0.4.1/src/transpile/basic_opts.hpp
Examining data/qiskit-aer-0.4.1/src/transpile/circuitopt.hpp
Examining data/qiskit-aer-0.4.1/src/transpile/delay_measure.hpp
Examining data/qiskit-aer-0.4.1/src/transpile/fusion.hpp
Examining data/qiskit-aer-0.4.1/src/transpile/truncate_qubits.hpp
Examining data/qiskit-aer-0.4.1/test/src/test_snapshot.cpp
Examining data/qiskit-aer-0.4.1/test/src/test_snapshot_bdd.cpp
Examining data/qiskit-aer-0.4.1/test/src/test_utils.cpp
Examining data/qiskit-aer-0.4.1/test/src/utils.hpp
Examining data/qiskit-aer-0.4.1/test/third-party/catch.hpp

FINAL RESULTS:

data/qiskit-aer-0.4.1/src/framework/pybind_json.hpp:19:9:  [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/qiskit-aer-0.4.1/src/framework/pybind_json.hpp:19:18:  [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/qiskit-aer-0.4.1/src/framework/pybind_json.hpp:21:8:  [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.
#undef snprintf
data/qiskit-aer-0.4.1/src/simulators/statevector/qubitvector_thrust.hpp:1643:11:  [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.
    str = getenv("AER_MULTI_GPU");
data/qiskit-aer-0.4.1/src/simulators/statevector/qubitvector_thrust.hpp:1649: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.
  str = getenv("AER_HOST_ONLY");
data/qiskit-aer-0.4.1/src/simulators/statevector/qubitvector_thrust.hpp:1659: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.
  str = getenv("AER_CHUNK_BITS");
data/qiskit-aer-0.4.1/src/simulators/statevector/qubitvector_thrust.hpp:1711: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.
  str = getenv("AER_TEST_HYBRID");  //use only for debugging
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:8533:18:  [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.
            std::srand( config.rngSeed() );
data/qiskit-aer-0.4.1/src/framework/json.hpp:165:13:  [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).
      ifile.open(name);
data/qiskit-aer-0.4.1/src/simulators/statevector/qubitvector_thrust.hpp:1661:22:  [2] (integer) atol:
  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).
    m_maxChunkBits = atol(str);
data/qiskit-aer-0.4.1/src/simulators/statevector/qubitvector_thrust.hpp:4477:7:  [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 bin[64];
data/qiskit-aer-0.4.1/src/third-party/headers/nlohmann_json.hpp:5676:14:  [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(&result, vec.data(), sizeof(NumberType));
data/qiskit-aer-0.4.1/src/third-party/headers/nlohmann_json.hpp:6900:14:  [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(vec.data(), &n, sizeof(NumberType));
data/qiskit-aer-0.4.1/src/third-party/headers/nlohmann_json.hpp:7179: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(&target, &source, sizeof(Source));
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:1323: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 timeStamp[timeStampSize];
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:3605:29:  [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.
        alignas(alignof(T)) char storage[sizeof(T)];
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:4064:16:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
        static char line[CATCH_CONFIG_CONSOLE_WIDTH] = {0};
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:4632:14:  [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).
        void open();
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:8020:14:  [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(&i, &f, sizeof(f));
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:8029:14:  [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(&i, &d, sizeof(d));
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:8351:9:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
        char m_buffer[L_tmpnam] = { 0 };
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:8428: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 buffer[100];
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:8437:23:  [2] (tmpfile) tmpfile:
  Function tmpfile() has a security flaw on some systems (e.g., older System
  V systems) (CWE-377).
        m_file = std::tmpfile();
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:8461:9:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
        char buffer[100] = {};
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:9524:31:  [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 **utf8Argv = new char *[ argc ];
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:9646: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 data[bufferSize];
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:9695:23:  [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).
                m_ofs.open( filename.c_str() );
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:9948:13:  [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_data, m_start, m_size );
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:10463:23:  [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).
    void TrackerBase::open() {
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:10552:13:  [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).
            open();
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:10591:22:  [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).
            tracker->open();
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:10881:21:  [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 asChar[sizeof (int)];
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:11525:9:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
        char buffer[maxDoubleSize];
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:11532: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(buffer, "%.3f", duration);
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:12098: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).
    void open() {
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:12127:12:  [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).
        tp.open();
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:12473: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 timeStamp[timeStampSize];
data/qiskit-aer-0.4.1/src/simulators/matrix_product_state/svd.cpp:512:8:  [1] (buffer) equal:
  Function does not check the second iterator for over-read conditions
  (CWE-126). This function is often discouraged by most C++ coding standards
  in favor of its safer alternatives provided since C++14. Consider using a
  form of this function that checks the second iterator before potentially
  overflowing it.
	if( ! equal )
data/qiskit-aer-0.4.1/src/third-party/headers/nlohmann_json.hpp:1775: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).
                        std::strlen(reinterpret_cast<const char*>(b))) {}
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:9547:36:  [1] (buffer) getchar:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
            static_cast<void>(std::getchar());
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:9552:36:  [1] (buffer) getchar:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
            static_cast<void>(std::getchar());
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:9839:50:  [1] (buffer) equal:
  Function does not check the second iterator for over-read conditions
  (CWE-126). This function is often discouraged by most C++ coding standards
  in favor of its safer alternatives provided since C++14. Consider using a
  form of this function that checks the second iterator before potentially
  overflowing it.
        return s.size() >= prefix.size() && std::equal(prefix.begin(), prefix.end(), s.begin());
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:9845:50:  [1] (buffer) equal:
  Function does not check the second iterator for over-read conditions
  (CWE-126). This function is often discouraged by most C++ coding standards
  in favor of its safer alternatives provided since C++14. Consider using a
  form of this function that checks the second iterator before potentially
  overflowing it.
        return s.size() >= suffix.size() && std::equal(suffix.rbegin(), suffix.rend(), s.rbegin());
data/qiskit-aer-0.4.1/test/third-party/catch.hpp:9916:67:  [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).
    : StringRef( rawChars, static_cast<StringRef::size_type>(std::strlen(rawChars) ) )

ANALYSIS SUMMARY:

Hits = 44
Lines analyzed = 66939 in approximately 1.55 seconds (43257 lines/second)
Physical Source Lines of Code (SLOC) = 43306
Hits@level = [0]  31 [1]   7 [2]  29 [3]   5 [4]   3 [5]   0
Hits@level+ = [0+]  75 [1+]  44 [2+]  37 [3+]   8 [4+]   3 [5+]   0
Hits/KSLOC@level+ = [0+] 1.73186 [1+] 1.01603 [2+] 0.854385 [3+] 0.184732 [4+] 0.0692745 [5+]   0
Dot directories skipped = 2 (--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.