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/gkermit-1.0/gproto.c Examining data/gkermit-1.0/gwart.c Examining data/gkermit-1.0/gcmdline.c Examining data/gkermit-1.0/gkermit.c Examining data/gkermit-1.0/gkermit.h Examining data/gkermit-1.0/gunixio.c FINAL RESULTS: data/gkermit-1.0/gunixio.c:508:5: [4] (shell) system: 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. system("stty raw -echo"); data/gkermit-1.0/gunixio.c:530:6: [4] (shell) system: 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. x = system("stty -raw echo"); data/gkermit-1.0/gunixio.c:886:9: [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 (access(fn,R_OK) < 0) { data/gkermit-1.0/gunixio.c:927:9: [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. x = access(s,W_OK); /* Check access of path. */ data/gkermit-1.0/gwart.c:609: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(new,s); data/gkermit-1.0/gcmdline.c:78: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. if ((p = getenv("GKERMIT"))) { data/gkermit-1.0/gcmdline.c:61: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 gbuf[GBUFSIZ], *gargs[GARGC], *gptr = NULL; data/gkermit-1.0/gcmdline.c:226:8: [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). db = fopen("debug.log","w"); data/gkermit-1.0/gcmdline.c:229:8: [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). db = fopen(*xargv,"w"); data/gkermit-1.0/gcmdline.c:260:10: [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). z = atoi(*xargv); /* Convert to number. */ data/gkermit-1.0/gcmdline.c:274:10: [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). z = atoi(*xargv); /* Convert to number */ data/gkermit-1.0/gkermit.c:144:1: [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 filnam[MAXPATHLEN+1]; /* Name of current file. */ data/gkermit-1.0/gkermit.c:145:1: [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 ttname[DEVNAMLEN+1]; /* Name of communication device. */ data/gkermit-1.0/gkermit.c:349: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 pktnam[MAXPATHLEN]; data/gkermit-1.0/gkermit.c:401:2: [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((char *) &xdata[i+2],"%ld",filelength); data/gkermit-1.0/gkermit.c:417: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. static char ftbuf[FTBUFL+1]; data/gkermit-1.0/gkermit.c:581: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 pbc[5]; /* Packet block check */ data/gkermit-1.0/gkermit.c:702: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. static char remain[6] = { NUL, NUL, NUL, NUL, NUL, NUL }; data/gkermit-1.0/gkermit.c:957:2: [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[16]; data/gkermit-1.0/gkermit.c:1065: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 myname[MAXPATHLEN+1]; /* Local name buffer */ data/gkermit-1.0/gunixio.c:183:1: [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 zinbuf[MAXRECORD+1]; /* File input buffer */ data/gkermit-1.0/gunixio.c:192: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 tinbuf[TINBUFSIZ+16]; /* Communications input buffer */ data/gkermit-1.0/gunixio.c:198: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 work[MAXPATHLEN+1]; /* Filename conversion buffer */ data/gkermit-1.0/gunixio.c:386:16: [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 ((ofd = open("/dev/tty", O_WRONLY, 0)) == -1) data/gkermit-1.0/gunixio.c:876:1: [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 ofile[MAXPATHLEN]; /* Output filename */ data/gkermit-1.0/gunixio.c:934: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). ifp = fopen(name,"r"); data/gkermit-1.0/gunixio.c:947: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). ofp = fopen(name,"w"); data/gkermit-1.0/gunixio.c:1028: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 *p, newname[MAXPATHLEN+12]; data/gkermit-1.0/gunixio.c:1084:2: [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(&newname[x],".~%d~",i); /* Make a backup name */ data/gkermit-1.0/gwart.c:114:1: [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 tokval[MAXWORD]; data/gkermit-1.0/gwart.c:203: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 wordbuf[MAXWORD]; data/gkermit-1.0/gwart.c:253: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 wordbuf[MAXWORD]; data/gkermit-1.0/gwart.c:437: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). if ((infile = fopen(argv[1],"r")) == NULL) { data/gkermit-1.0/gwart.c:444: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). if ((outfile = fopen(argv[2],"w")) == NULL) { data/gkermit-1.0/gcmdline.c:82:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(gbuf,p,GBUFSIZ-1); /* Make a pokeable copy */ data/gkermit-1.0/gkermit.c:191:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(ttname,dftty,DEVNAMLEN); /* Default device name. */ data/gkermit-1.0/gkermit.c:288: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). x = spacket('Y',seq,strlen(s),s); /* Send the packet */ data/gkermit-1.0/gkermit.c:323:26: [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). spacket('E',seq,(int)strlen(s),s); /* Send Error packet. */ data/gkermit-1.0/gkermit.c:343:26: [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). return(spacket(c,seq,strlen(s),s)); /* Send S or I packet */ data/gkermit-1.0/gkermit.c:358:7: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(pktnam,cmarg2,MAXPATHLEN); data/gkermit-1.0/gkermit.c:402:13: [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). aln = (int)strlen((char *)(xdata+i+2)); data/gkermit-1.0/gkermit.c:407: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). aln = (int)strlen((char *)xdata); /* Get overall length of attributes */ data/gkermit-1.0/gkermit.c:478: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). x = spacket('Z',seq,strlen(s),s); /* Send EOF packet */ data/gkermit-1.0/gkermit.c:963:6: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(buf,(char *)s+z+10,x); data/gkermit-1.0/gkermit.c:1055:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(filnam,*cmlist++,MAXPATHLEN); data/gkermit-1.0/gkermit.c:1069:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(myname,cmarg2,MAXPATHLEN); /* Use it */ data/gkermit-1.0/gkermit.c:1077:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(filnam,myname,MAXPATHLEN); data/gkermit-1.0/gunixio.c:545:6: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). x = read(0,&tinbuf[tlast],TINBUFSIZ-tlast); data/gkermit-1.0/gunixio.c:635:10: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). x = read(0,&c,1); /* Dumb blocking read byte loop */ data/gkermit-1.0/gunixio.c:643:10: [1] (buffer) getchar: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). x = getchar(); /* Buffered read with getchar() */ data/gkermit-1.0/gunixio.c:657:16: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). tincnt = read(0,tinbuf,TINBUFSIZ); data/gkermit-1.0/gunixio.c:671:17: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). tincnt = read(0,tinbuf,1); data/gkermit-1.0/gunixio.c:703:7: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). x = read(0,&c,1); /* Dumb read byte loop */ data/gkermit-1.0/gunixio.c:914:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(work,fn,MAXPATHLEN); data/gkermit-1.0/gunixio.c:917: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). for (i = (int)strlen(s); i > 0; i--) { /* Strip filename from right */ data/gkermit-1.0/gunixio.c:950:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(ofile,name,MAXPATHLEN); data/gkermit-1.0/gunixio.c:974:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(pktnam,dirp,maxlen); data/gkermit-1.0/gunixio.c:1017:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(cp,work,maxlen); data/gkermit-1.0/gunixio.c:1037:9: [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). i = strlen(fn); /* Get length */ data/gkermit-1.0/gunixio.c:1043:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(work,fn,MAXPATHLEN); /* Make pokeable copy of name */ data/gkermit-1.0/gunixio.c:1072:9: [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). j = strlen(p); data/gkermit-1.0/gunixio.c:1073:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(newname,p,MAXPATHLEN); data/gkermit-1.0/gunixio.c:1113:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(lclnam,pktnam,maxlen); data/gkermit-1.0/gunixio.c:1131:6: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(lclnam,"NONAME",maxlen); /* do this... */ data/gkermit-1.0/gunixio.c:1172:35: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). zincnt < MAXRECORD - 1 && (c = getc(ifp)) != EOF && c != '\n'; data/gkermit-1.0/gwart.c:204:17: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while ((c = getc(infp)) != EOF) { data/gkermit-1.0/gwart.c:241:23: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while (isword(c = getc(fp)) && ++len < MAXWORD) *buf++ = (char) c; data/gkermit-1.0/gwart.c:254:17: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while ((c = getc(fp)) != EOF && c != '\n') { data/gkermit-1.0/gwart.c:302:13: [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 ((int)strlen(tokval) != 1) data/gkermit-1.0/gwart.c:352:16: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while (c = getc(inp), (isspace(c) || c == C_L)) data/gkermit-1.0/gwart.c:357:26: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while (bcnt > 0 && (c = getc(inp)) != EOF) { data/gkermit-1.0/gwart.c:367:10: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). c = getc(inp); data/gkermit-1.0/gwart.c:494:17: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while ((c = getc(in)) != EOF) putc(c,out); data/gkermit-1.0/gwart.c:508:10: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). c = getc(fp); data/gkermit-1.0/gwart.c:515:15: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if ((c = getc(fp)) == '%') return(SEP); data/gkermit-1.0/gwart.c:527:15: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if ((c = getc(fp)) == '*') { data/gkermit-1.0/gwart.c:554:19: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while (!((c = getc(fp)) == '/' && star)) { data/gkermit-1.0/gwart.c:608:32: [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). new = (char *) malloc((int)strlen(s) + 1); ANALYSIS SUMMARY: Hits = 78 Lines analyzed = 3917 in approximately 0.14 seconds (28224 lines/second) Physical Source Lines of Code (SLOC) = 3170 Hits@level = [0] 156 [1] 44 [2] 28 [3] 1 [4] 5 [5] 0 Hits@level+ = [0+] 234 [1+] 78 [2+] 34 [3+] 6 [4+] 5 [5+] 0 Hits/KSLOC@level+ = [0+] 73.817 [1+] 24.6057 [2+] 10.7256 [3+] 1.89274 [4+] 1.57729 [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.