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/peg-0.1.18/examples/accept.c Examining data/peg-0.1.18/examples/dcv.c Examining data/peg-0.1.18/examples/rule.c Examining data/peg-0.1.18/examples/localpeg.c Examining data/peg-0.1.18/examples/left.c Examining data/peg-0.1.18/examples/dc.c Examining data/peg-0.1.18/examples/test.c Examining data/peg-0.1.18/win/getopt.c Examining data/peg-0.1.18/win/libgen.h Examining data/peg-0.1.18/win/getopt.h Examining data/peg-0.1.18/win/unistd.h Examining data/peg-0.1.18/src/compile.c Examining data/peg-0.1.18/src/tree.c Examining data/peg-0.1.18/src/tree.h Examining data/peg-0.1.18/src/leg.c Examining data/peg-0.1.18/src/version.h Examining data/peg-0.1.18/src/peg.c FINAL RESULTS: data/peg-0.1.18/examples/left.c:14:3: [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(yyparse() ? "success\n" : "failure\n"); data/peg-0.1.18/src/compile.c:828:3: [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(output, footer, start->rule.name); data/peg-0.1.18/src/leg.c:92:25: [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. # define yyprintf(args) fprintf args data/peg-0.1.18/src/tree.c:148:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(name, "_%d_%s", ++actionCount, thisRule->rule.name); data/peg-0.1.18/win/getopt.c:121:11: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. (void)vfprintf(stderr,fmt,ap); data/peg-0.1.18/src/leg.c:1471:20: [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. while (-1 != (c= getopt(argc, argv, "PVho:v"))) data/peg-0.1.18/src/peg.c:106:20: [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. while (-1 != (c= getopt(argc, argv, "PVho:v"))) data/peg-0.1.18/win/getopt.c:348:22: [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") != NULL); data/peg-0.1.18/win/getopt.c:523: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(int nargc, char * const *nargv, const char *options) data/peg-0.1.18/win/getopt.c:543:1: [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. getopt_long(int nargc, char * const *nargv, const char *options, data/peg-0.1.18/win/getopt.h:29: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 nargc, char * const *nargv, const char *options); data/peg-0.1.18/win/getopt.h:77: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 nargc, char * const *nargv, const char *options, data/peg-0.1.18/src/compile.c:94: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 bits[32]; data/peg-0.1.18/src/compile.c:97:10: [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 string[256]; data/peg-0.1.18/src/compile.c:130:12: [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. ptr += sprintf(ptr, "\\%03o", bits[c]); data/peg-0.1.18/src/leg.c:260: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(yy->__text, yy->__buf + begin, yyleng); data/peg-0.1.18/src/leg.c:1484: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). if (!(output= fopen(optarg, "w"))) data/peg-0.1.18/src/leg.c:1518:21: [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). if (!(input= fopen(*argv, "r"))) data/peg-0.1.18/src/peg.c:119: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). if (!(output= fopen(optarg, "w"))) data/peg-0.1.18/src/peg.c:153:21: [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). if (!(input= fopen(*argv, "r"))) data/peg-0.1.18/src/tree.c:146: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 name[1024]; data/peg-0.1.18/win/getopt.c:182:6: [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 **) nargv)[pos] = nargv[cstart]; data/peg-0.1.18/win/getopt.c:184:6: [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 **)nargv)[cstart] = swap; data/peg-0.1.18/examples/left.c:5:10: [1] (buffer) getchar: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int c= getchar(); \ data/peg-0.1.18/src/compile.c:165: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). int len= strlen(node->string.value); data/peg-0.1.18/src/compile.c:764: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). case String: return strlen(node->string.value) > 0; data/peg-0.1.18/src/leg.c:47:12: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int c= getc(input); \ data/peg-0.1.18/src/leg.c:143:14: [1] (buffer) getchar: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int yyc= getchar(); \ data/peg-0.1.18/src/leg.c:158:14: [1] (buffer) getchar: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int yyc= getchar(); \ data/peg-0.1.18/src/leg.c:1417:22: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while (EOF != (c= fgetc(input)) && '\n' != c && '\r' != c) data/peg-0.1.18/src/peg.c:41:10: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int c= getc(input); \ data/peg-0.1.18/src/peg.c:67:22: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while (EOF != (c= fgetc(input)) && '\n' != c && '\r' != c) data/peg-0.1.18/win/getopt.c:218:22: [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). current_argv_len = strlen(current_argv); data/peg-0.1.18/win/getopt.c:226:7: [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(long_options[i].name) == current_argv_len) { ANALYSIS SUMMARY: Hits = 34 Lines analyzed = 3824 in approximately 0.14 seconds (27096 lines/second) Physical Source Lines of Code (SLOC) = 3032 Hits@level = [0] 140 [1] 11 [2] 11 [3] 7 [4] 5 [5] 0 Hits@level+ = [0+] 174 [1+] 34 [2+] 23 [3+] 12 [4+] 5 [5+] 0 Hits/KSLOC@level+ = [0+] 57.3879 [1+] 11.2137 [2+] 7.58575 [3+] 3.95778 [4+] 1.64908 [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.