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/gmp-ecm-7.0.4+ds/aprtcle/mpz_aprcl.h Examining data/gmp-ecm-7.0.4+ds/aprtcle/jacobi_sum.h Examining data/gmp-ecm-7.0.4+ds/aprtcle/mpz_aprcl.c Examining data/gmp-ecm-7.0.4+ds/aprtcle/aprcl.c Examining data/gmp-ecm-7.0.4+ds/arm/params.h Examining data/gmp-ecm-7.0.4+ds/athlon/params.h Examining data/gmp-ecm-7.0.4+ds/athlon/mulredc.h Examining data/gmp-ecm-7.0.4+ds/generic/params.h Examining data/gmp-ecm-7.0.4+ds/hppa/params.h Examining data/gmp-ecm-7.0.4+ds/ia64/params.h Examining data/gmp-ecm-7.0.4+ds/mips/params.h Examining data/gmp-ecm-7.0.4+ds/pentium4/params.h Examining data/gmp-ecm-7.0.4+ds/pentium4/mulredc.h Examining data/gmp-ecm-7.0.4+ds/powerpc32/params.h Examining data/gmp-ecm-7.0.4+ds/powerpc64/params.h Examining data/gmp-ecm-7.0.4+ds/powerpc64/mulredc.h Examining data/gmp-ecm-7.0.4+ds/sparc64/params.h Examining data/gmp-ecm-7.0.4+ds/x86/params.h Examining data/gmp-ecm-7.0.4+ds/x86_64/core2/params.h Examining data/gmp-ecm-7.0.4+ds/x86_64/corei7/params.h Examining data/gmp-ecm-7.0.4+ds/x86_64/k8/params.h Examining data/gmp-ecm-7.0.4+ds/x86_64/mulredc.h Examining data/gmp-ecm-7.0.4+ds/ecm.h Examining data/gmp-ecm-7.0.4+ds/basicdefs.h Examining data/gmp-ecm-7.0.4+ds/ecm-impl.h Examining data/gmp-ecm-7.0.4+ds/ecm-gmp.h Examining data/gmp-ecm-7.0.4+ds/ecm-ecm.h Examining data/gmp-ecm-7.0.4+ds/sp.h Examining data/gmp-ecm-7.0.4+ds/longlong.h Examining data/gmp-ecm-7.0.4+ds/ecm-params.h Examining data/gmp-ecm-7.0.4+ds/mpmod.h Examining data/gmp-ecm-7.0.4+ds/ecm-gpu.h Examining data/gmp-ecm-7.0.4+ds/cudakernel.h Examining data/gmp-ecm-7.0.4+ds/addlaws.h Examining data/gmp-ecm-7.0.4+ds/getprime_r.h Examining data/gmp-ecm-7.0.4+ds/ecm_int.h Examining data/gmp-ecm-7.0.4+ds/ecm.c Examining data/gmp-ecm-7.0.4+ds/ecm2.c Examining data/gmp-ecm-7.0.4+ds/pm1.c Examining data/gmp-ecm-7.0.4+ds/pp1.c Examining data/gmp-ecm-7.0.4+ds/getprime_r.c Examining data/gmp-ecm-7.0.4+ds/listz.c Examining data/gmp-ecm-7.0.4+ds/lucas.c Examining data/gmp-ecm-7.0.4+ds/stage2.c Examining data/gmp-ecm-7.0.4+ds/mpmod.c Examining data/gmp-ecm-7.0.4+ds/mul_lo.c Examining data/gmp-ecm-7.0.4+ds/polyeval.c Examining data/gmp-ecm-7.0.4+ds/median.c Examining data/gmp-ecm-7.0.4+ds/schoen_strass.c Examining data/gmp-ecm-7.0.4+ds/ks-multiply.c Examining data/gmp-ecm-7.0.4+ds/rho.c Examining data/gmp-ecm-7.0.4+ds/bestd.c Examining data/gmp-ecm-7.0.4+ds/auxlib.c Examining data/gmp-ecm-7.0.4+ds/random.c Examining data/gmp-ecm-7.0.4+ds/factor.c Examining data/gmp-ecm-7.0.4+ds/sp.c Examining data/gmp-ecm-7.0.4+ds/spv.c Examining data/gmp-ecm-7.0.4+ds/spm.c Examining data/gmp-ecm-7.0.4+ds/mpzspm.c Examining data/gmp-ecm-7.0.4+ds/mpzspv.c Examining data/gmp-ecm-7.0.4+ds/ntt_gfp.c Examining data/gmp-ecm-7.0.4+ds/ecm_ntt.c Examining data/gmp-ecm-7.0.4+ds/pm1fs2.c Examining data/gmp-ecm-7.0.4+ds/sets_long.c Examining data/gmp-ecm-7.0.4+ds/auxarith.c Examining data/gmp-ecm-7.0.4+ds/batch.c Examining data/gmp-ecm-7.0.4+ds/parametrizations.c Examining data/gmp-ecm-7.0.4+ds/cudawrapper.c Examining data/gmp-ecm-7.0.4+ds/Fgw.c Examining data/gmp-ecm-7.0.4+ds/bench_mulredc.c Examining data/gmp-ecm-7.0.4+ds/auxi.c Examining data/gmp-ecm-7.0.4+ds/b1_ainc.c Examining data/gmp-ecm-7.0.4+ds/candi.c Examining data/gmp-ecm-7.0.4+ds/eval.c Examining data/gmp-ecm-7.0.4+ds/main.c Examining data/gmp-ecm-7.0.4+ds/resume.c Examining data/gmp-ecm-7.0.4+ds/champions.h Examining data/gmp-ecm-7.0.4+ds/memusage.c Examining data/gmp-ecm-7.0.4+ds/test_mulredc.c Examining data/gmp-ecm-7.0.4+ds/tune.c Examining data/gmp-ecm-7.0.4+ds/build.vc12/config.h Examining data/gmp-ecm-7.0.4+ds/build.vc12/getopt.c Examining data/gmp-ecm-7.0.4+ds/build.vc12/getopt.h Examining data/gmp-ecm-7.0.4+ds/build.vc12/getrusage.c Examining data/gmp-ecm-7.0.4+ds/build.vc12/getrusage.h Examining data/gmp-ecm-7.0.4+ds/build.vc12/gettimeofday.c Examining data/gmp-ecm-7.0.4+ds/build.vc12/gettimeofday.h Examining data/gmp-ecm-7.0.4+ds/build.vc12/vacopy.c Examining data/gmp-ecm-7.0.4+ds/build.vc12/assembler/test_mulredc.c Examining data/gmp-ecm-7.0.4+ds/build.vc12/assembler/mulredc.h Examining data/gmp-ecm-7.0.4+ds/ecmfactor.c FINAL RESULTS: data/gmp-ecm-7.0.4+ds/build.vc12/config.h:241:11: [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. # define access _access data/gmp-ecm-7.0.4+ds/candi.c:104:7: [4] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). strcpy (n->cpExpr, cpExpr); data/gmp-ecm-7.0.4+ds/candi.c:165:7: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf (cp, "(%s)/%s", n->cpExpr, cp1); data/gmp-ecm-7.0.4+ds/ecm_ntt.c:328:11: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf (TreeFilename, "%s.%d", TreeFilenameStem, level); data/gmp-ecm-7.0.4+ds/ecm_ntt.c:385:11: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf (TreeFilename, "%s.%d", TreeFilenameStem, level); data/gmp-ecm-7.0.4+ds/main.c:764:4: [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 (go.cpOrigExpr, argv[2]); data/gmp-ecm-7.0.4+ds/main.c:840:7: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf (Gmp_version, "GMP %s", gmp_version); data/gmp-ecm-7.0.4+ds/main.c:843:14: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. out += sprintf (out, "GMP-ECM %s [configured with %s", data/gmp-ecm-7.0.4+ds/main.c:847:14: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. out += sprintf (out, ", GWNUM %s", GWNUM_VERSION); data/gmp-ecm-7.0.4+ds/main.c:1065:26: [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. if (!saveappend && access (savefilename, F_OK) == 0) data/gmp-ecm-7.0.4+ds/polyeval.c:260:13: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf (fullname, "%s.%d", TreeFilename, i); data/gmp-ecm-7.0.4+ds/rho.c:394:11: [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 (stderr, "rhoinit: rhotable[%d] = %.16f\n", i, data/gmp-ecm-7.0.4+ds/stage2.c:448:11: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf (fullname, "%s.%lu", TreeFilename, i - 1); data/gmp-ecm-7.0.4+ds/tune.c:54:5: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. fprintf (stderr, #x "(%2ld) = %f\n", (long)n, (double) __k / (double) __st); \ data/gmp-ecm-7.0.4+ds/build.vc12/getopt.c:221: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. #ifndef getenv data/gmp-ecm-7.0.4+ds/build.vc12/getopt.c:222:14: [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. extern char *getenv (); data/gmp-ecm-7.0.4+ds/build.vc12/getopt.c:407:21: [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. posixly_correct = getenv ("POSIXLY_CORRECT"); data/gmp-ecm-7.0.4+ds/build.vc12/getopt.c:1197:1: [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. getopt (argc, argv, optstring) data/gmp-ecm-7.0.4+ds/build.vc12/getopt.c:1227:11: [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. c = getopt (argc, argv, "abc:d:0123456789"); data/gmp-ecm-7.0.4+ds/build.vc12/getopt.h:145:12: [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. extern int getopt (int ___argc, char *const *___argv, const char *__shortopts); data/gmp-ecm-7.0.4+ds/build.vc12/getopt.h:147:12: [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. extern int getopt (); data/gmp-ecm-7.0.4+ds/build.vc12/getopt.h:151:12: [3] (buffer) getopt_long: 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. extern int getopt_long (int ___argc, char *const *___argv, data/gmp-ecm-7.0.4+ds/build.vc12/getopt.h:165:12: [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. extern int getopt (); data/gmp-ecm-7.0.4+ds/build.vc12/getopt.h:167:12: [3] (buffer) getopt_long: 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. extern int getopt_long (); data/gmp-ecm-7.0.4+ds/resume.c:483: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. uname = getenv ("LOGNAME"); data/gmp-ecm-7.0.4+ds/resume.c:485:13: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. uname = getenv ("USERNAME"); data/gmp-ecm-7.0.4+ds/Fgw.c:234: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 strk[11]; data/gmp-ecm-7.0.4+ds/Fgw.c:235: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 strb[11]; data/gmp-ecm-7.0.4+ds/Fgw.c:236: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 strn[11]; data/gmp-ecm-7.0.4+ds/Fgw.c:237: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 strc[11]; data/gmp-ecm-7.0.4+ds/aprtcle/aprcl.c:76: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 input[MAXDIGITS]; data/gmp-ecm-7.0.4+ds/aprtcle/aprcl.c:94:10: [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(argv[2], "r"); data/gmp-ecm-7.0.4+ds/auxi.c:105: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 Line[500], *cp; data/gmp-ecm-7.0.4+ds/auxlib.c:240: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). chkfile = fopen (chkfilename, "w"); data/gmp-ecm-7.0.4+ds/bench_mulredc.c:743:15: [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). minsize = atoi (argv[1]); data/gmp-ecm-7.0.4+ds/bench_mulredc.c:745:15: [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). maxsize = atoi (argv[2]); data/gmp-ecm-7.0.4+ds/build.vc12/assembler/test_mulredc.c:218: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). len = atoi (argv[1]); data/gmp-ecm-7.0.4+ds/champions.h:5:8: [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 *champion_keeper[3] = data/gmp-ecm-7.0.4+ds/champions.h:9:8: [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 *champion_url[3] = data/gmp-ecm-7.0.4+ds/ecm-gmp.h:47:25: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. #define MPN_COPY(d,s,n) memcpy((d),(s),(n)*sizeof(mp_limb_t)) data/gmp-ecm-7.0.4+ds/ecm.c:852: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 sep, outs[128], flt[16]; data/gmp-ecm-7.0.4+ds/ecm.c:865: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. j += sprintf (outs + j, "%u%c", i, (i < DIGITS_END) ? '\t' : '\n'); data/gmp-ecm-7.0.4+ds/ecm.c:883:15: [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. if (sprintf (flt, "%.2g", floor (1. / prob + .5)) == 8) data/gmp-ecm-7.0.4+ds/ecm.c:898: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 sep, outs[128]; data/gmp-ecm-7.0.4+ds/ecm.c:911: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. j += sprintf (outs + j, "%u%c", i, (i < DIGITS_END) ? '\t' : '\n'); data/gmp-ecm-7.0.4+ds/ecm_ntt.c:330: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). TreeFile = fopen (TreeFilename, "rb"); data/gmp-ecm-7.0.4+ds/ecm_ntt.c:387: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). TreeFile = fopen (TreeFilename, "rb"); data/gmp-ecm-7.0.4+ds/eval.c:464: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 op_stack[4]; data/gmp-ecm-7.0.4+ds/longlong.h:2202:23: [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. extern const unsigned char __GMP_DECLSPEC __clz_tab[129]; data/gmp-ecm-7.0.4+ds/main.c:378: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 rtime[256] = "", who[256] = "", comment[256] = "", program[256] = ""; data/gmp-ecm-7.0.4+ds/main.c:573:28: [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). if (param != atoi (argv[2])) data/gmp-ecm-7.0.4+ds/main.c:581:23: [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). param = atoi (argv[2]); data/gmp-ecm-7.0.4+ds/main.c:597:32: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). if (param != atoi (argv[2])) data/gmp-ecm-7.0.4+ds/main.c:605: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). param = atoi (argv[2]) ; data/gmp-ecm-7.0.4+ds/main.c:649: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). S = abs (atoi (argv[2])); data/gmp-ecm-7.0.4+ds/main.c:656:23: [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). S = - abs ( atoi (argv[2])); data/gmp-ecm-7.0.4+ds/main.c:663:8: [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). k = atol (argv[2]); data/gmp-ecm-7.0.4+ds/main.c:670: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). count = atoi (argv[2]); data/gmp-ecm-7.0.4+ds/main.c:709: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). int b = atoi (argv[2]); data/gmp-ecm-7.0.4+ds/main.c:729: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). infile = fopen (infilename, "r"); data/gmp-ecm-7.0.4+ds/main.c:791:23: [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). gpudevice = atoi (argv[2]); data/gmp-ecm-7.0.4+ds/main.c:797:23: [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). gpucurves = atoi (argv[2]); data/gmp-ecm-7.0.4+ds/main.c:833: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 Gmp_version[64]; data/gmp-ecm-7.0.4+ds/main.c:834: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 out0[128], *out = out0; data/gmp-ecm-7.0.4+ds/main.c:837:7: [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 (Gmp_version, "MPIR %d.%d.%d", __MPIR_VERSION, data/gmp-ecm-7.0.4+ds/main.c:851:14: [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. out += sprintf (out, ", --enable-asm-redc"); data/gmp-ecm-7.0.4+ds/main.c:855:14: [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. out += sprintf (out, ", --enable-gpu"); data/gmp-ecm-7.0.4+ds/main.c:859:14: [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. out += sprintf (out, ", --enable-assert"); data/gmp-ecm-7.0.4+ds/main.c:863:14: [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. out += sprintf (out, ", --enable-openmp"); data/gmp-ecm-7.0.4+ds/main.c:887: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 mname[MNAMESIZE]; data/gmp-ecm-7.0.4+ds/main.c:1047: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). resumefile = fopen (resumefilename, "r"); data/gmp-ecm-7.0.4+ds/main.c:1072:18: [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). savefile = fopen (savefilename, "a"); data/gmp-ecm-7.0.4+ds/memusage.c:39: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 str[1024]; data/gmp-ecm-7.0.4+ds/memusage.c:44:10: [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 = fopen (str, "r"); data/gmp-ecm-7.0.4+ds/polyeval.c:262: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). TreeFile = fopen (fullname, "rb"); data/gmp-ecm-7.0.4+ds/random.c:133:11: [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). rndfd = fopen ("/dev/urandom", "rb"); data/gmp-ecm-7.0.4+ds/resume.c:130: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 tag[16]; data/gmp-ecm-7.0.4+ds/resume.c:310:15: [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 (program, "Prime95"); data/gmp-ecm-7.0.4+ds/resume.c:420: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 text[256]; data/gmp-ecm-7.0.4+ds/resume.c:421: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 *uname, mname[32]; data/gmp-ecm-7.0.4+ds/resume.c:497:5: [2] (buffer) TCHAR: 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. TCHAR T[MAX_COMPUTERNAME_LENGTH+2]; data/gmp-ecm-7.0.4+ds/resume.c:500:7: [2] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). Risk is low because the source is a constant string. strcpy(mname, "localPC"); data/gmp-ecm-7.0.4+ds/resume.c:565:10: [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 = fopen (fn, "a"); data/gmp-ecm-7.0.4+ds/resume.c:674:10: [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 = fopen (fn, "wb"); data/gmp-ecm-7.0.4+ds/resume.c:705:10: [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 = fopen (fn, "rb"); data/gmp-ecm-7.0.4+ds/rho.c:88: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. const unsigned char primemap[667] = { data/gmp-ecm-7.0.4+ds/rho.c:939: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). S = atoi (argv[5]); data/gmp-ecm-7.0.4+ds/rho.c:943: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). r = atoi (argv[6]); data/gmp-ecm-7.0.4+ds/rho.c:944: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). m = atoi (argv[7]); data/gmp-ecm-7.0.4+ds/sets_long.c:685:14: [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). beta = atol (argv[1]); data/gmp-ecm-7.0.4+ds/stage2.c:450: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). TreeFile = fopen (fullname, "wb"); data/gmp-ecm-7.0.4+ds/test_mulredc.c:294: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). len = atoi (argv[1]); data/gmp-ecm-7.0.4+ds/tune.c:489:26: [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). max_log2_len = atoi (argv[2]); data/gmp-ecm-7.0.4+ds/Fgw.c:246: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). for (i = 0; i < strlen(z); i++) data/gmp-ecm-7.0.4+ds/aprtcle/aprcl.c:107:11: [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(input) == 0) continue; data/gmp-ecm-7.0.4+ds/auxi.c:80:7: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). c = fgetc (fd); data/gmp-ecm-7.0.4+ds/auxi.c:86:13: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). c = fgetc (fd); data/gmp-ecm-7.0.4+ds/build.vc12/getopt.c:244:51: [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 (!defined __STDC__ || !__STDC__) && !defined strlen data/gmp-ecm-7.0.4+ds/build.vc12/getopt.c:247:12: [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). extern int strlen (const char *); data/gmp-ecm-7.0.4+ds/build.vc12/getopt.c:438:44: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int len = nonoption_flags_max_len = strlen (orig_str); data/gmp-ecm-7.0.4+ds/build.vc12/getopt.c:666: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). == (unsigned int) strlen (p->name)) data/gmp-ecm-7.0.4+ds/build.vc12/getopt.c:711: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). nextchar += strlen (nextchar); data/gmp-ecm-7.0.4+ds/build.vc12/getopt.c:777: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). nextchar += strlen (nextchar); data/gmp-ecm-7.0.4+ds/build.vc12/getopt.c:811: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). nextchar += strlen (nextchar); data/gmp-ecm-7.0.4+ds/build.vc12/getopt.c:816: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). nextchar += strlen (nextchar); data/gmp-ecm-7.0.4+ds/build.vc12/getopt.c:1003:51: [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 ((unsigned int) (nameend - nextchar) == strlen (p->name)) data/gmp-ecm-7.0.4+ds/build.vc12/getopt.c:1043: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). nextchar += strlen (nextchar); data/gmp-ecm-7.0.4+ds/build.vc12/getopt.c:1081: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). nextchar += strlen (nextchar); data/gmp-ecm-7.0.4+ds/build.vc12/getopt.c:1113: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). nextchar += strlen (nextchar); data/gmp-ecm-7.0.4+ds/build.vc12/getopt.c:1117: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). nextchar += strlen (nextchar); data/gmp-ecm-7.0.4+ds/candi.c:46: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). if (n->cpExpr && n->nexprlen != strlen(n->cpExpr)) data/gmp-ecm-7.0.4+ds/candi.c:101: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). n->nexprlen = strlen (cpExpr); data/gmp-ecm-7.0.4+ds/candi.c:163: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). cp = (char *) malloc(n->nexprlen+1 + 3 + strlen(cp1)); /* +1 for null, +3 for ()/ */ data/gmp-ecm-7.0.4+ds/candi.c:168: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). n->nexprlen += (3+strlen(cp1)); data/gmp-ecm-7.0.4+ds/candi.c:220:45: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). len = NumNs * mpz_sizeinbase (n->n, 10) + strlen (cp) + 100; data/gmp-ecm-7.0.4+ds/ecm.c:884:40: [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). memmove (&flt[5], &flt[6], strlen(flt) - 5); data/gmp-ecm-7.0.4+ds/ecm_ntt.c:307: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). TreeFilename = (char *) malloc (strlen (TreeFilenameStem) + 1 + 2 + 1); data/gmp-ecm-7.0.4+ds/eval.c:87:7: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). c = fgetc (fd); data/gmp-ecm-7.0.4+ds/eval.c:92:13: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). c = fgetc (fd); data/gmp-ecm-7.0.4+ds/eval.c:104:17: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int peek_c = fgetc (fd); data/gmp-ecm-7.0.4+ds/eval.c:125:11: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). c = fgetc (fd); data/gmp-ecm-7.0.4+ds/main.c:758: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). go.cpOrigExpr = malloc (strlen (argv[2]) + 1); data/gmp-ecm-7.0.4+ds/polyeval.c:254: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). char *fullname = (char *) malloc (strlen (TreeFilename) + 1 + 2 + 1); data/gmp-ecm-7.0.4+ds/resume.c:51:28: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while (s[i] != 0 && (c = fgetc (fd)) != EOF) data/gmp-ecm-7.0.4+ds/resume.c:71:7: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). c = fgetc (fd); data/gmp-ecm-7.0.4+ds/resume.c:74:11: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). c = fgetc (fd); data/gmp-ecm-7.0.4+ds/resume.c:100:30: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while (i + 1 < len && (c = fgetc (fd)) != EOF) data/gmp-ecm-7.0.4+ds/resume.c:143:13: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). fgetc (fd); data/gmp-ecm-7.0.4+ds/resume.c:404:9: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). fgetc (fd); data/gmp-ecm-7.0.4+ds/resume.c:526:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (text, ctime (&t), 255); data/gmp-ecm-7.0.4+ds/resume.c:528:8: [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). text[strlen (text) - 1] = 0; /* Remove newline */ data/gmp-ecm-7.0.4+ds/stage2.c:440:41: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). char *fullname = (char *) malloc (strlen (TreeFilename) + 1 + 2 + 1); ANALYSIS SUMMARY: Hits = 132 Lines analyzed = 44812 in approximately 1.46 seconds (30744 lines/second) Physical Source Lines of Code (SLOC) = 34232 Hits@level = [0] 558 [1] 39 [2] 67 [3] 12 [4] 14 [5] 0 Hits@level+ = [0+] 690 [1+] 132 [2+] 93 [3+] 26 [4+] 14 [5+] 0 Hits/KSLOC@level+ = [0+] 20.1566 [1+] 3.85604 [2+] 2.71676 [3+] 0.759523 [4+] 0.408974 [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.