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/empire-lafe-1.1/lafe.c Examining data/empire-lafe-1.1/lafe.h Examining data/empire-lafe-1.1/alias.c Examining data/empire-lafe-1.1/parse.c Examining data/empire-lafe-1.1/history.c Examining data/empire-lafe-1.1/var.c Examining data/empire-lafe-1.1/game.c FINAL RESULTS: data/empire-lafe-1.1/alias.c:150: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(newline,alias); data/empire-lafe-1.1/alias.c:152: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(newline+len+1,line+j); data/empire-lafe-1.1/lafe.c:348:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(prompt,"%s [%d:%d] Command: ",buffer+2,timeleft,btus); data/empire-lafe-1.1/lafe.c:350:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(prompt,"%s : ",buffer+2); data/empire-lafe-1.1/lafe.c:465:11: [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. out = popen(buffer+i,"w"); data/empire-lafe-1.1/lafe.c:688:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(buffer,"user %s\ncoun \"%s\"\npass %s\nclient lafe %s\nplay\n", data/empire-lafe-1.1/parse.c:23:5: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(buffer,"%s%s",getenv("HOME"),path+1); data/empire-lafe-1.1/parse.c:46:7: [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. if (system(arg)) perror("system"); data/empire-lafe-1.1/parse.c:56:10: [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. pipe = popen(arg,"r"); data/empire-lafe-1.1/lafe.c:141: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. tgetent(termstrbuf,getenv("TERM")); data/empire-lafe-1.1/lafe.c:732:10: [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. host=getenv("EMPIREHOST"); data/empire-lafe-1.1/lafe.c:733:10: [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. port=getenv("EMPIREPORT"); data/empire-lafe-1.1/lafe.c:756: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. country=getenv("COUNTRY"); /* not advised for security reasons */ data/empire-lafe-1.1/lafe.c:757: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. password=getenv("REPRESENTATIVE"); data/empire-lafe-1.1/lafe.c:758:10: [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. host=getenv("EMPIREHOST"); data/empire-lafe-1.1/lafe.c:759:10: [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. port=getenv("EMPIREPORT"); data/empire-lafe-1.1/lafe.c:792:32: [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=empconnect(host,atoi(port),getenv("USER"),country,password); data/empire-lafe-1.1/parse.c:21:18: [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. len = strlen(getenv("HOME")) + strlen(path); data/empire-lafe-1.1/parse.c:23:27: [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. sprintf(buffer,"%s%s",getenv("HOME"),path+1); data/empire-lafe-1.1/var.c:26:7: [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. v = getenv(name); data/empire-lafe-1.1/alias.c:78: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 c,buffer[8]; data/empire-lafe-1.1/alias.c:91: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(buffer,"%d",++i); data/empire-lafe-1.1/alias.c:98:3: [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(buffer,"%d",++i); data/empire-lafe-1.1/lafe.c:387:5: [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(prompt,buffer+2,len-3); data/empire-lafe-1.1/lafe.c:429:5: [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(prompt,"[%d:%d] Command: ",timeleft,btus); data/empire-lafe-1.1/lafe.c:451: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). out = fopen(buffer+j,"a"); data/empire-lafe-1.1/lafe.c:453: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). out = fopen(buffer+j,"w"); data/empire-lafe-1.1/lafe.c:509:2: [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(buffer,buffer+start,end-start); data/empire-lafe-1.1/lafe.c:533: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 buffer[2048]; data/empire-lafe-1.1/lafe.c:598: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 buffer[2048]; data/empire-lafe-1.1/lafe.c:658: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 buffer[1024]; data/empire-lafe-1.1/lafe.c:788: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). log = fopen(logfile,"a"); data/empire-lafe-1.1/lafe.c:792:21: [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=empconnect(host,atoi(port),getenv("USER"),country,password); data/empire-lafe-1.1/parse.c:52: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 buffer[4096]; data/empire-lafe-1.1/parse.c:82: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 buffer[4096]; data/empire-lafe-1.1/parse.c:97: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). fp = fopen(filename,"r"); data/empire-lafe-1.1/alias.c:57:5: [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). w=strlen(name); data/empire-lafe-1.1/alias.c:148: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). len=strlen(alias); data/empire-lafe-1.1/alias.c:149:24: [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). newline=malloc(len+strlen(line+j)+2); data/empire-lafe-1.1/game.c:30:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(t,*str,i); data/empire-lafe-1.1/lafe.c:690: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). write(s,buffer,strlen(buffer)); data/empire-lafe-1.1/parse.c:21: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). len = strlen(getenv("HOME")) + strlen(path); data/empire-lafe-1.1/parse.c:21: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). len = strlen(getenv("HOME")) + strlen(path); data/empire-lafe-1.1/parse.c:243: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). len=strlen(line); data/empire-lafe-1.1/var.c:69:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(var,oldline+src,i-src); data/empire-lafe-1.1/var.c:77:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(var,oldline+src,i-src); ANALYSIS SUMMARY: Hits = 46 Lines analyzed = 1617 in approximately 0.06 seconds (26509 lines/second) Physical Source Lines of Code (SLOC) = 1108 Hits@level = [0] 64 [1] 10 [2] 16 [3] 11 [4] 9 [5] 0 Hits@level+ = [0+] 110 [1+] 46 [2+] 36 [3+] 20 [4+] 9 [5+] 0 Hits/KSLOC@level+ = [0+] 99.278 [1+] 41.5162 [2+] 32.491 [3+] 18.0505 [4+] 8.12274 [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.