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/libquantum-1.1.1/qft.c Examining data/libquantum-1.1.1/density.c Examining data/libquantum-1.1.1/ising.c Examining data/libquantum-1.1.1/objcode.h Examining data/libquantum-1.1.1/qtime.h Examining data/libquantum-1.1.1/qureg.c Examining data/libquantum-1.1.1/qft.h Examining data/libquantum-1.1.1/objcode.c Examining data/libquantum-1.1.1/qtime.c Examining data/libquantum-1.1.1/qureg.h Examining data/libquantum-1.1.1/omuln.h Examining data/libquantum-1.1.1/density.h Examining data/libquantum-1.1.1/gates.h Examining data/libquantum-1.1.1/oaddn.c Examining data/libquantum-1.1.1/classic.c Examining data/libquantum-1.1.1/quobdump.c Examining data/libquantum-1.1.1/decoherence.h Examining data/libquantum-1.1.1/error.c Examining data/libquantum-1.1.1/error.h Examining data/libquantum-1.1.1/grover.c Examining data/libquantum-1.1.1/qec.c Examining data/libquantum-1.1.1/measure.h Examining data/libquantum-1.1.1/quobprint.c Examining data/libquantum-1.1.1/shor.c Examining data/libquantum-1.1.1/qec.h Examining data/libquantum-1.1.1/oaddn.h Examining data/libquantum-1.1.1/omuln.c Examining data/libquantum-1.1.1/lapack.h Examining data/libquantum-1.1.1/decoherence.c Examining data/libquantum-1.1.1/energy.h Examining data/libquantum-1.1.1/complex.c Examining data/libquantum-1.1.1/version.c Examining data/libquantum-1.1.1/energy.c Examining data/libquantum-1.1.1/defs.h Examining data/libquantum-1.1.1/matrix.h Examining data/libquantum-1.1.1/expn.h Examining data/libquantum-1.1.1/complex.h Examining data/libquantum-1.1.1/classic.h Examining data/libquantum-1.1.1/version.h Examining data/libquantum-1.1.1/measure.c Examining data/libquantum-1.1.1/expn.c Examining data/libquantum-1.1.1/lapack.c Examining data/libquantum-1.1.1/matrix.c Examining data/libquantum-1.1.1/gates.c FINAL RESULTS: data/libquantum-1.1.1/grover.c:131: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(0)); data/libquantum-1.1.1/qureg.c:135:7: [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. c = getenv("QUOBFILE"); data/libquantum-1.1.1/shor.c:40: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(0)); data/libquantum-1.1.1/energy.c:174: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(d, a, n*sizeof(double)); data/libquantum-1.1.1/grover.c:139:5: [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/libquantum-1.1.1/grover.c:142:13: [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). width = atoi(argv[2]); data/libquantum-1.1.1/objcode.c:169:12: [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. unsigned char buf[80]; data/libquantum-1.1.1/objcode.c:279: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). fhd = fopen(file, "w"); data/libquantum-1.1.1/objcode.c:317:12: [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. unsigned char buf[OBJBUF_SIZE]; data/libquantum-1.1.1/objcode.c:321: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). fhd = fopen(file, "r"); data/libquantum-1.1.1/qtime.c:167: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(reg->amplitude, old.amplitude, data/libquantum-1.1.1/qtime.c:169: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(reg2.amplitude, old.amplitude, data/libquantum-1.1.1/qtime.c:172: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(reg->state, old.state, reg->size*sizeof(MAX_UNSIGNED)); data/libquantum-1.1.1/qtime.c:174: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(reg2.state, old.state, reg->size*sizeof(MAX_UNSIGNED)); data/libquantum-1.1.1/quobprint.c:36:12: [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. unsigned char buf[OBJBUF_SIZE]; data/libquantum-1.1.1/quobprint.c:37: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 output[OBJBUF_SIZE]; data/libquantum-1.1.1/quobprint.c:38: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 opname[256][25]; data/libquantum-1.1.1/quobprint.c:67: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). fhd = fopen(argv[1], "r"); data/libquantum-1.1.1/qureg.c:279: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(dst->amplitude, src->amplitude, src->size*sizeof(COMPLEX_FLOAT)); data/libquantum-1.1.1/qureg.c:290: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(dst->state, src->state, src->size*sizeof(MAX_UNSIGNED)); data/libquantum-1.1.1/shor.c:48:5: [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/libquantum-1.1.1/shor.c:63: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). x = atoi(argv[2]); data/libquantum-1.1.1/objcode.c:335:19: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). operation = fgetc(fhd); data/libquantum-1.1.1/quobdump.c:42:19: [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). envstr = malloc(strlen(argv[1]) + 20); data/libquantum-1.1.1/quobdump.c:44:20: [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). snprintf(envstr, strlen(argv[1]) + 19, "QUOBFILE=%s", argv[1]); data/libquantum-1.1.1/quobprint.c:42:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(opname[INIT], "init", 24); data/libquantum-1.1.1/quobprint.c:43:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(opname[CNOT], "cnot", 24); data/libquantum-1.1.1/quobprint.c:44:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(opname[TOFFOLI], "toffoli", 24); data/libquantum-1.1.1/quobprint.c:45:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(opname[SIGMA_X], "sigma_x", 24); data/libquantum-1.1.1/quobprint.c:46:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(opname[SIGMA_Y], "sigma_y", 24); data/libquantum-1.1.1/quobprint.c:47:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(opname[SIGMA_Z], "sigma_z", 24); data/libquantum-1.1.1/quobprint.c:48:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(opname[HADAMARD], "hadamard", 24); data/libquantum-1.1.1/quobprint.c:49:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(opname[ROT_X], "rotate_x", 24); data/libquantum-1.1.1/quobprint.c:50:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(opname[ROT_Y], "rotate_y", 24); data/libquantum-1.1.1/quobprint.c:51:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(opname[ROT_Z], "rotate_z", 24); data/libquantum-1.1.1/quobprint.c:52:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(opname[PHASE_KICK], "phase_kick", 24); data/libquantum-1.1.1/quobprint.c:53:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(opname[PHASE_SCALE], "phase_scale", 24); data/libquantum-1.1.1/quobprint.c:54:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(opname[COND_PHASE], "cond_phase", 24); data/libquantum-1.1.1/quobprint.c:55:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(opname[CPHASE_KICK], "cond_phase_kick", 24); data/libquantum-1.1.1/quobprint.c:56:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(opname[MEASURE], "measure", 24); data/libquantum-1.1.1/quobprint.c:57:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(opname[BMEASURE], "bmeasure", 24); data/libquantum-1.1.1/quobprint.c:58:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(opname[BMEASURE_P], "bmeasure_preserve", 24); data/libquantum-1.1.1/quobprint.c:59:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(opname[SWAPLEADS], "swaptheleads", 24); data/libquantum-1.1.1/quobprint.c:60:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(opname[NOP], "nop", 24); data/libquantum-1.1.1/quobprint.c:83:19: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). operation = fgetc(fhd); ANALYSIS SUMMARY: Hits = 45 Lines analyzed = 6508 in approximately 0.28 seconds (23436 lines/second) Physical Source Lines of Code (SLOC) = 3849 Hits@level = [0] 80 [1] 23 [2] 19 [3] 3 [4] 0 [5] 0 Hits@level+ = [0+] 125 [1+] 45 [2+] 22 [3+] 3 [4+] 0 [5+] 0 Hits/KSLOC@level+ = [0+] 32.476 [1+] 11.6913 [2+] 5.71577 [3+] 0.779423 [4+] 0 [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.