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/spigot-0.2017-01-15.gdad1bbc6/algebraic.cpp Examining data/spigot-0.2017-01-15.gdad1bbc6/arithmetic.cpp Examining data/spigot-0.2017-01-15.gdad1bbc6/baseout.cpp Examining data/spigot-0.2017-01-15.gdad1bbc6/baseout.h Examining data/spigot-0.2017-01-15.gdad1bbc6/bi_gmp.h Examining data/spigot-0.2017-01-15.gdad1bbc6/bi_internal.h Examining data/spigot-0.2017-01-15.gdad1bbc6/bigint.h Examining data/spigot-0.2017-01-15.gdad1bbc6/cfracout.cpp Examining data/spigot-0.2017-01-15.gdad1bbc6/cfracout.h Examining data/spigot-0.2017-01-15.gdad1bbc6/consts.cpp Examining data/spigot-0.2017-01-15.gdad1bbc6/cr.h Examining data/spigot-0.2017-01-15.gdad1bbc6/enforce.cpp Examining data/spigot-0.2017-01-15.gdad1bbc6/erf.cpp Examining data/spigot-0.2017-01-15.gdad1bbc6/error.h Examining data/spigot-0.2017-01-15.gdad1bbc6/exp.cpp Examining data/spigot-0.2017-01-15.gdad1bbc6/expint.cpp Examining data/spigot-0.2017-01-15.gdad1bbc6/expr.cpp Examining data/spigot-0.2017-01-15.gdad1bbc6/expr.h Examining data/spigot-0.2017-01-15.gdad1bbc6/funcs.h Examining data/spigot-0.2017-01-15.gdad1bbc6/gamma.cpp Examining data/spigot-0.2017-01-15.gdad1bbc6/holefiller.h Examining data/spigot-0.2017-01-15.gdad1bbc6/io.cpp Examining data/spigot-0.2017-01-15.gdad1bbc6/lambertw.cpp Examining data/spigot-0.2017-01-15.gdad1bbc6/main.cpp Examining data/spigot-0.2017-01-15.gdad1bbc6/misc.cpp Examining data/spigot-0.2017-01-15.gdad1bbc6/monotone.cpp Examining data/spigot-0.2017-01-15.gdad1bbc6/noexcept.cpp Examining data/spigot-0.2017-01-15.gdad1bbc6/python/pyspig.cpp Examining data/spigot-0.2017-01-15.gdad1bbc6/spigot.cpp Examining data/spigot-0.2017-01-15.gdad1bbc6/spigot.h Examining data/spigot-0.2017-01-15.gdad1bbc6/sqrt.cpp Examining data/spigot-0.2017-01-15.gdad1bbc6/trig.cpp Examining data/spigot-0.2017-01-15.gdad1bbc6/trigint.cpp Examining data/spigot-0.2017-01-15.gdad1bbc6/unary.cpp Examining data/spigot-0.2017-01-15.gdad1bbc6/version.h Examining data/spigot-0.2017-01-15.gdad1bbc6/zeta.cpp FINAL RESULTS: data/spigot-0.2017-01-15.gdad1bbc6/baseout.cpp:1763: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/spigot-0.2017-01-15.gdad1bbc6/baseout.cpp:1763: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/spigot-0.2017-01-15.gdad1bbc6/error.h:14:9: [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(errmsg, pe.errmsg); data/spigot-0.2017-01-15.gdad1bbc6/error.h:59:15: [4] (format) vsnprintf: 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. len = vsnprintf(NULL, 0, fmt, ap); data/spigot-0.2017-01-15.gdad1bbc6/error.h:63:9: [4] (format) vsnprintf: 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. vsnprintf(errmsg, len+1, fmt, ap); data/spigot-0.2017-01-15.gdad1bbc6/error.h:77:9: [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(errmsg, filename); data/spigot-0.2017-01-15.gdad1bbc6/io.cpp:315: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/spigot-0.2017-01-15.gdad1bbc6/io.cpp:315: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/spigot-0.2017-01-15.gdad1bbc6/baseout.cpp:873: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). bool open; data/spigot-0.2017-01-15.gdad1bbc6/baseout.cpp:890:68: [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). if (sign < 0 || (sign == 0 && !cfmt.round_open && !open)) { data/spigot-0.2017-01-15.gdad1bbc6/baseout.cpp:1294: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 buf[256]; data/spigot-0.2017-01-15.gdad1bbc6/baseout.cpp:1295: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(buf, " (%u^%d)", ebase, exponent); data/spigot-0.2017-01-15.gdad1bbc6/baseout.cpp:1334: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 buf[256]; data/spigot-0.2017-01-15.gdad1bbc6/baseout.cpp:1335: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(buf, " (%u^-%d)", dbase, zeroes); data/spigot-0.2017-01-15.gdad1bbc6/baseout.cpp:1761: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 expbuf[256]; data/spigot-0.2017-01-15.gdad1bbc6/cfracout.cpp:402: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 buf[80]; data/spigot-0.2017-01-15.gdad1bbc6/cfracout.cpp:403: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(buf, " (10^%d)", digits); data/spigot-0.2017-01-15.gdad1bbc6/cfracout.cpp:412: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 buf[80]; data/spigot-0.2017-01-15.gdad1bbc6/cfracout.cpp:413: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(buf, "(10^%d)", digits); data/spigot-0.2017-01-15.gdad1bbc6/cfracout.cpp:489: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 buf[80]; data/spigot-0.2017-01-15.gdad1bbc6/cfracout.cpp:490: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(buf, " (10^%d)", digits); data/spigot-0.2017-01-15.gdad1bbc6/cfracout.cpp:494: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 buf[80]; data/spigot-0.2017-01-15.gdad1bbc6/cfracout.cpp:495: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(buf, "(10^%d)", digits); data/spigot-0.2017-01-15.gdad1bbc6/cfracout.cpp:570: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 buf[80]; data/spigot-0.2017-01-15.gdad1bbc6/cfracout.cpp:571: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(buf, " (10^%d)", digits); data/spigot-0.2017-01-15.gdad1bbc6/cfracout.cpp:577: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 buf[80]; data/spigot-0.2017-01-15.gdad1bbc6/cfracout.cpp:578: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(buf, " (10^%d)", digits); data/spigot-0.2017-01-15.gdad1bbc6/expr.cpp:391:17: [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 keyword[32]; data/spigot-0.2017-01-15.gdad1bbc6/expr.cpp:406:21: [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(keyword, "%.*s", (int)(p-q), q); data/spigot-0.2017-01-15.gdad1bbc6/expr.cpp:552: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). fd = atoi(p); data/spigot-0.2017-01-15.gdad1bbc6/expr.cpp:568:36: [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 base = atoi(q+4); data/spigot-0.2017-01-15.gdad1bbc6/io.cpp:23:14: [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 data[16384]; data/spigot-0.2017-01-15.gdad1bbc6/io.cpp:265:16: [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, "r"); data/spigot-0.2017-01-15.gdad1bbc6/io.cpp:275:16: [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, "r"); data/spigot-0.2017-01-15.gdad1bbc6/io.cpp:313:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char name[64]; data/spigot-0.2017-01-15.gdad1bbc6/main.cpp:109: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 opname[20]; data/spigot-0.2017-01-15.gdad1bbc6/main.cpp:127:5: [2] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). Risk is low because the source is a constant string. strcpy(opname, "cub1"); data/spigot-0.2017-01-15.gdad1bbc6/main.cpp:138:5: [2] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). Risk is low because the source is a constant string. strcpy(opname, "sgr0"); data/spigot-0.2017-01-15.gdad1bbc6/main.cpp:147:5: [2] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). Risk is low because the source is a constant string. strcpy(opname, "setaf"); data/spigot-0.2017-01-15.gdad1bbc6/main.cpp:528:45: [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). tentative_test_digits = atoi(val); data/spigot-0.2017-01-15.gdad1bbc6/main.cpp:592:36: [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). base = atoi(val); data/spigot-0.2017-01-15.gdad1bbc6/main.cpp:601:42: [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). digitlimit = atoi(val); data/spigot-0.2017-01-15.gdad1bbc6/main.cpp:605:44: [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). minintdigits = atoi(val); data/spigot-0.2017-01-15.gdad1bbc6/bi_internal.h:610:9: [1] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). Risk is low because the source is a constant character. strcpy(buf, "0"); data/spigot-0.2017-01-15.gdad1bbc6/bi_internal.h:636: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). fwrite(buf, 1, strlen(buf), stdout); data/spigot-0.2017-01-15.gdad1bbc6/bi_internal.h:644:9: [1] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). Risk is low because the source is a constant character. strcpy(ret, "0"); data/spigot-0.2017-01-15.gdad1bbc6/error.h:13: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). errmsg = (char *)malloc(1+strlen(pe.errmsg)); data/spigot-0.2017-01-15.gdad1bbc6/error.h:76: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). errmsg = (char *)malloc(1+strlen(filename)); data/spigot-0.2017-01-15.gdad1bbc6/expr.cpp:227: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). len = strlen(str); data/spigot-0.2017-01-15.gdad1bbc6/expr.cpp:280: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). int lenz = strlen(strz); data/spigot-0.2017-01-15.gdad1bbc6/expr.cpp:366: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). int oplen = strlen(operators[i].text); data/spigot-0.2017-01-15.gdad1bbc6/expr.cpp:404:21: [1] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). Risk is low because the source is a constant character. strcpy(keyword, "!"); data/spigot-0.2017-01-15.gdad1bbc6/expr.cpp:482: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). pos == (int)strlen(keyword)) { data/spigot-0.2017-01-15.gdad1bbc6/expr.cpp:501: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). pos == (int)strlen(keyword)) || data/spigot-0.2017-01-15.gdad1bbc6/expr.cpp:503: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). pos == (int)strlen(keyword))) { data/spigot-0.2017-01-15.gdad1bbc6/expr.cpp:505:43: [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). bool exact = (keyword[strlen(keyword)-5] == 'x'); data/spigot-0.2017-01-15.gdad1bbc6/expr.cpp:539: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). pos == (int)strlen(keyword))) { data/spigot-0.2017-01-15.gdad1bbc6/expr.cpp:1208: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). stack = (struct stack *)malloc(strlen(expr) * sizeof(struct stack)); data/spigot-0.2017-01-15.gdad1bbc6/io.cpp:83:17: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int c = fgetc(fp); ANALYSIS SUMMARY: Hits = 59 Lines analyzed = 15366 in approximately 0.43 seconds (35759 lines/second) Physical Source Lines of Code (SLOC) = 9516 Hits@level = [0] 71 [1] 16 [2] 35 [3] 0 [4] 8 [5] 0 Hits@level+ = [0+] 130 [1+] 59 [2+] 43 [3+] 8 [4+] 8 [5+] 0 Hits/KSLOC@level+ = [0+] 13.6612 [1+] 6.20008 [2+] 4.51871 [3+] 0.840689 [4+] 0.840689 [5+] 0 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.