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/binfmtc-0.17/tests/print.c Examining data/binfmtc-0.17/tests/multisource.c Examining data/binfmtc-0.17/tests/wrongcode.c Examining data/binfmtc-0.17/tests/cxxprint.cxx Examining data/binfmtc-0.17/tests/wrongmagic.c Examining data/binfmtc-0.17/tests/multisource1.c Examining data/binfmtc-0.17/realcxxsh.cc Examining data/binfmtc-0.17/binfmtc-lang-f.c Examining data/binfmtc-0.17/binfmtc-lang-f95.c Examining data/binfmtc-0.17/binfmtc-lang-c.c Examining data/binfmtc-0.17/binfmtc-interpreter.c Examining data/binfmtc-0.17/realcsh.c Examining data/binfmtc-0.17/binfmtc.h Examining data/binfmtc-0.17/binfmtc-lang-asm.c Examining data/binfmtc-0.17/realksh.c Examining data/binfmtc-0.17/upaccho2/upaccho2-webservice.h Examining data/binfmtc-0.17/upaccho2/upaccho2.c Examining data/binfmtc-0.17/upaccho2/upaccho2-webservice.c Examining data/binfmtc-0.17/binfmtc-lang-gcj.c Examining data/binfmtc-0.17/binfmtc-lang-cxx.c FINAL RESULTS: data/binfmtc-0.17/binfmtc-interpreter.c:123: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(gcccommandline)) data/binfmtc-0.17/binfmtc-interpreter.c:188:7: [4] (shell) execvp: 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. execvp(filename, argv); data/binfmtc-0.17/realcsh.c:126: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. system (tempfilename); data/binfmtc-0.17/realcxxsh.cc:104: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. system (tempfilename); data/binfmtc-0.17/realksh.c:113:2: [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(stderr, PRGNAME ": asprintf failed\n"); data/binfmtc-0.17/realksh.c:165:7: [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(stderr, PRGNAME ": asprintf failed\n"); data/binfmtc-0.17/realksh.c:195:7: [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(stderr, PRGNAME ": Warning: root privilege is probably required for most operation\n"); data/binfmtc-0.17/realksh.c:272:16: [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 ((ret=system (commandline))) data/binfmtc-0.17/realksh.c:274:4: [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(stderr, data/binfmtc-0.17/realksh.c:286:16: [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 ((ret=system (commandline))) data/binfmtc-0.17/realksh.c:288:4: [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(stderr, PRGNAME ": non-zero return code from rmmod: %i\n", ret); data/binfmtc-0.17/realksh.c:311: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(commandline)) data/binfmtc-0.17/realksh.c:313:7: [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(stderr, PRGNAME ": Warning: Failed execution: %s\n", data/binfmtc-0.17/binfmtc-interpreter.c:32:24: [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. #define BINFMTC_DEBUG (getenv("BINFMTC_DEBUG")) data/binfmtc-0.17/binfmtc-interpreter.c:47:5: [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. getenv("BINFMTCTMPDIR")?: data/binfmtc-0.17/binfmtc-interpreter.c:48:5: [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. getenv("TMPDIR")?: data/binfmtc-0.17/binfmtc-interpreter.c:49:5: [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. getenv("TEMPDIR")?: data/binfmtc-0.17/binfmtc-lang-asm.c:32: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. return getenv("GAS")?: data/binfmtc-0.17/binfmtc-lang-asm.c:33:5: [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. getenv("AS")?: data/binfmtc-0.17/binfmtc-lang-asm.c:34:5: [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. getenv("GCC")?: data/binfmtc-0.17/binfmtc-lang-asm.c:35:5: [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. getenv("CC")?: data/binfmtc-0.17/binfmtc-lang-asm.c:41: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. return getenv("BINFMTASM_GAS_OPTS")?: data/binfmtc-0.17/binfmtc-lang-c.c:32: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. return getenv("GCC")?: data/binfmtc-0.17/binfmtc-lang-c.c:33:5: [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. getenv("CC")?: data/binfmtc-0.17/binfmtc-lang-c.c:39: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. return getenv("BINFMTC_GCC_OPTS")?: data/binfmtc-0.17/binfmtc-lang-cxx.c:32: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. return getenv("GXX")?: data/binfmtc-0.17/binfmtc-lang-cxx.c:33:5: [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. getenv("CXX")?: data/binfmtc-0.17/binfmtc-lang-cxx.c:34:5: [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. getenv("GCC")?: data/binfmtc-0.17/binfmtc-lang-cxx.c:35:5: [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. getenv("CC")?: data/binfmtc-0.17/binfmtc-lang-cxx.c:41: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. return getenv("BINFMTCXX_GXX_OPTS")?: data/binfmtc-0.17/binfmtc-lang-f.c:32:11: [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. return getenv("G77")?: data/binfmtc-0.17/binfmtc-lang-f.c:38: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. return getenv("BINFMTC_G77_OPTS")?: data/binfmtc-0.17/binfmtc-lang-f95.c:32:11: [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. return getenv("GFORTRAN")?: data/binfmtc-0.17/binfmtc-lang-f95.c:38: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. return getenv("BINFMTC_GFORTRAN_OPTS")?: data/binfmtc-0.17/binfmtc-lang-gcj.c:32: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. return getenv("GCJ")?: data/binfmtc-0.17/binfmtc-lang-gcj.c:38: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. return getenv("BINFMTC_GCJ_OPTS")?: data/binfmtc-0.17/realcsh.c:97:9: [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. getenv("BINFMTCTMPDIR")?: data/binfmtc-0.17/realcsh.c:98:9: [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. getenv("TMPDIR")?: data/binfmtc-0.17/realcsh.c:99:9: [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. getenv("TEMPDIR")?: data/binfmtc-0.17/realcxxsh.cc:92:9: [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. getenv("BINFMTCTMPDIR")?: data/binfmtc-0.17/realcxxsh.cc:93:9: [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. getenv("TMPDIR")?: data/binfmtc-0.17/realcxxsh.cc:94:9: [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. getenv("TEMPDIR")?: data/binfmtc-0.17/realksh.c:159:5: [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. getenv("BINFMTCTMPDIR")?: data/binfmtc-0.17/realksh.c:160:5: [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. getenv("TMPDIR")?: data/binfmtc-0.17/realksh.c:161:5: [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. getenv("TEMPDIR")?: data/binfmtc-0.17/binfmtc-interpreter.c:62:9: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). close(mkstemp(tempfilename)); /* get temporary filename */ data/binfmtc-0.17/binfmtc-interpreter.c:63: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). if (!(f=fopen(sourcename,"rt"))) data/binfmtc-0.17/realcsh.c:102:21: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). f = fdopen(fd=mkstemp(tempfilename), "w"); data/binfmtc-0.17/realcxxsh.cc:99:10: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). fd=mkstemp(tempfilename); data/binfmtc-0.17/realksh.c:84: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 log_buffer[ 64 * 1024 ]; data/binfmtc-0.17/realksh.c:179:5: [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 (kbuildfilename, "w"); data/binfmtc-0.17/realksh.c:237:9: [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(tempfilename, "w"); data/binfmtc-0.17/upaccho2/upaccho2-webservice.c:148: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 buf[TMPBUFSIZE+2] ; /* incoming buffer */ data/binfmtc-0.17/upaccho2/upaccho2-webservice.c:178: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 localhostname [MAXHOSTNAMELEN + 1] ; data/binfmtc-0.17/upaccho2/upaccho2-webservice.c:251:27: [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). http_initiate_webserver(atoi(av[1])); data/binfmtc-0.17/upaccho2/upaccho2.c:56: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). FILE* f=fopen(filename, "r"); data/binfmtc-0.17/upaccho2/upaccho2.c:58: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 buf[TMPBUFSIZE+1]; data/binfmtc-0.17/upaccho2/upaccho2.c:96:14: [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). port = atoi(av[1]); data/binfmtc-0.17/binfmtc-interpreter.c:31:27: [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). #define BINFMTC_MAGIC_LEN strlen(binfmtc_magic) data/binfmtc-0.17/binfmtc-interpreter.c:94: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). for(i=strlen(s)-1; i; --i) data/binfmtc-0.17/upaccho2/upaccho2-webservice.c:42: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). write(sock, buf, strlen(buf)); data/binfmtc-0.17/upaccho2/upaccho2-webservice.c:59: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). write(sock, buf, strlen(buf)); data/binfmtc-0.17/upaccho2/upaccho2-webservice.c:76: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). write(sock, buf, strlen(buf)); data/binfmtc-0.17/upaccho2/upaccho2-webservice.c:135:33: [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 (!strncmp(u->path,path,strlen(u->path))) data/binfmtc-0.17/upaccho2/upaccho2-webservice.c:137:29: [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). u->func(sock, path, path+strlen(u->path)); data/binfmtc-0.17/upaccho2/upaccho2-webservice.c:153:10: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if ((i=read(sock, buf, TMPBUFSIZE))<=0) data/binfmtc-0.17/upaccho2/upaccho2-webservice.c:158: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 (buf) > 4) ANALYSIS SUMMARY: Hits = 67 Lines analyzed = 1519 in approximately 0.08 seconds (18880 lines/second) Physical Source Lines of Code (SLOC) = 974 Hits@level = [0] 40 [1] 9 [2] 13 [3] 32 [4] 13 [5] 0 Hits@level+ = [0+] 107 [1+] 67 [2+] 58 [3+] 45 [4+] 13 [5+] 0 Hits/KSLOC@level+ = [0+] 109.856 [1+] 68.7885 [2+] 59.5483 [3+] 46.2012 [4+] 13.347 [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.