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/jgraph-83/draw.c Examining data/jgraph-83/edit.c Examining data/jgraph-83/exit.c Examining data/jgraph-83/general.h Examining data/jgraph-83/jgraph.c Examining data/jgraph-83/jgraph.h Examining data/jgraph-83/jmalloc.c Examining data/jgraph-83/list.c Examining data/jgraph-83/list.h Examining data/jgraph-83/printline.c Examining data/jgraph-83/prio_list.c Examining data/jgraph-83/prio_list.h Examining data/jgraph-83/process.c Examining data/jgraph-83/show.c Examining data/jgraph-83/sin.c Examining data/jgraph-83/sin2.c Examining data/jgraph-83/token.c FINAL RESULTS: data/jgraph-83/draw.c:298:17: [4] (buffer) fscanf: The scanf() family's %s operation, without a limit specification, permits buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a different input function. fscanf(f, "%s", inp); data/jgraph-83/draw.c:328:15: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(inp, "Including eps file %s", c->eps); data/jgraph-83/edit.c:47: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(txt, inp_str); data/jgraph-83/edit.c:590: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(c->eps, inp_str); data/jgraph-83/edit.c:608: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(c->postscript, inp_str); data/jgraph-83/edit.c:1087: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(the_g->preamble, inp_str); data/jgraph-83/edit.c:1098: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(the_g->epilogue, inp_str); data/jgraph-83/token.c:53: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(FILENAME, s); data/jgraph-83/token.c:60:5: [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->filename, s); data/jgraph-83/token.c:134:3: [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->filename, FILENAME); data/jgraph-83/token.c:137:25: [4] (shell) popen: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. IOSTREAM = (FILE *) popen(INPUT, "r"); data/jgraph-83/token.c:148:3: [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(FILENAME, INPUT); data/jgraph-83/token.c:174:3: [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(FILENAME, n->filename); data/jgraph-83/token.c:232:3: [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(s, INPUT); data/jgraph-83/token.c:320: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(out_str, INPUT); data/jgraph-83/token.c:325:7: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(&(out_str[len]), "\n%s", INPUT); data/jgraph-83/draw.c:686:15: [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. s=(char *)getenv("JGRAPH_BORDER"); data/jgraph-83/draw.c:710:17: [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. s=(char *)getenv("JGRAPH_ENCODING"); data/jgraph-83/draw.c:266: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 inp[100]; data/jgraph-83/draw.c:279:19: [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). f = fopen(c->eps, "r"); data/jgraph-83/draw.c:345: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). f = fopen(c->postscript, "r"); data/jgraph-83/draw.c:688: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). expandborder=atoi(s); data/jgraph-83/draw.c:794: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). f = fopen(gs->preamble, "r"); data/jgraph-83/draw.c:816: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). f = fopen(gs->epilogue, "r"); data/jgraph-83/edit.c:16: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 *txt, inp_str[80]; data/jgraph-83/edit.c:369: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 inp_str[256], *txt; data/jgraph-83/edit.c:591:12: [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). fi = fopen(c->eps, "r"); data/jgraph-83/edit.c:609:14: [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). fi = fopen(c->postscript, "r"); data/jgraph-83/edit.c:664: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 inp_str[256]; data/jgraph-83/edit.c:712: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 inp_str[256]; data/jgraph-83/edit.c:887: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 inp_str[256]; data/jgraph-83/edit.c:953: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 inp_str[80]; data/jgraph-83/edit.c:1027: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 inp_str[80]; data/jgraph-83/jmalloc.c:206: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 *bufs[100]; data/jgraph-83/printline.c:257: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. sprintf(s_7bit+j,"\\%03o",(unsigned char)s[i]); data/jgraph-83/process.c:445:23: [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. case 'G': sprintf(s->s->label, "%.*G", prec, t1); break; data/jgraph-83/process.c:446:23: [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. case 'g': sprintf(s->s->label, "%.*g", prec, t1); break; data/jgraph-83/process.c:447:23: [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. case 'E': sprintf(s->s->label, "%.*E", prec, t1); break; data/jgraph-83/process.c:448:23: [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. case 'e': sprintf(s->s->label, "%.*e", prec, t1); break; data/jgraph-83/process.c:449:23: [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. case 'f': sprintf(s->s->label, "%.*f", prec, t1); break; data/jgraph-83/token.c:24: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 INPUT[1000]; data/jgraph-83/token.c:35: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 FILENAME[300]; data/jgraph-83/token.c:46: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(FILENAME, "<stdin>"); data/jgraph-83/token.c:48: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). IOSTREAM = fopen(s, "r"); data/jgraph-83/token.c:139: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). IOSTREAM = fopen(INPUT, "r"); data/jgraph-83/token.c:167: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). n->stream = fopen(n->filename, "r"); data/jgraph-83/token.c:242:8: [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). *i = atoi(INPUT); data/jgraph-83/draw.c:290:24: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ch = getc(f); data/jgraph-83/draw.c:334:25: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). for (ch = getc(f); ch != real_eof; ch = getc(f)) putchar(ch); data/jgraph-83/draw.c:334:55: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). for (ch = getc(f); ch != real_eof; ch = getc(f)) putchar(ch); data/jgraph-83/draw.c:352:27: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). for (ch = getc(f); ch != real_eof; ch = getc(f)) putchar(ch); data/jgraph-83/draw.c:352:57: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). for (ch = getc(f); ch != real_eof; ch = getc(f)) putchar(ch); data/jgraph-83/draw.c:711: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). if ((s!=NULL) && (strlen(s)>0)) { data/jgraph-83/draw.c:800:16: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). for (c = getc(f); c != real_eof; c = getc(f)) putchar(c); data/jgraph-83/draw.c:800:44: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). for (c = getc(f); c != real_eof; c = getc(f)) putchar(c); data/jgraph-83/draw.c:822:16: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). for (c = getc(f); c != real_eof; c = getc(f)) putchar(c); data/jgraph-83/draw.c:822:44: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). for (c = getc(f); c != real_eof; c = getc(f)) putchar(c); data/jgraph-83/edit.c:46: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). txt = (char *) malloc (sizeof(char)*strlen(inp_str)+2); data/jgraph-83/edit.c:589:34: [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). c->eps = (char *) malloc ((strlen(inp_str)+1)*sizeof(char)); data/jgraph-83/edit.c:607: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). c->postscript = (char *) malloc ((strlen(inp_str)+1)*sizeof(char)); data/jgraph-83/edit.c:1086:58: [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). the_g->preamble = (char *) malloc (sizeof(char)*(strlen(inp_str)+1)); data/jgraph-83/edit.c:1097:58: [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). the_g->epilogue = (char *) malloc (sizeof(char)*(strlen(inp_str)+1)); data/jgraph-83/printline.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). len=strlen(s); data/jgraph-83/printline.c:275: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). f = strlen(s); data/jgraph-83/process.c:594: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). tmp = l->fontsize * FCPI / FPPI * strlen(s) * 0.8; data/jgraph-83/process.c:597: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). f = strlen(s); data/jgraph-83/token.c:59:50: [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->filename = (char *) malloc (sizeof(char)*(strlen(s)+2)); data/jgraph-83/token.c:76:36: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (oldcharvalid == 0) oldchar = getc(IOSTREAM); data/jgraph-83/token.c:129: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). n->filename = (char *) malloc (sizeof(char)*(strlen(FILENAME)+2)); ANALYSIS SUMMARY: Hits = 69 Lines analyzed = 5253 in approximately 0.22 seconds (23375 lines/second) Physical Source Lines of Code (SLOC) = 4596 Hits@level = [0] 382 [1] 22 [2] 29 [3] 2 [4] 16 [5] 0 Hits@level+ = [0+] 451 [1+] 69 [2+] 47 [3+] 18 [4+] 16 [5+] 0 Hits/KSLOC@level+ = [0+] 98.1288 [1+] 15.0131 [2+] 10.2263 [3+] 3.91645 [4+] 3.48129 [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.