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/choosewm-0.1.6/global.h Examining data/choosewm-0.1.6/backend.c Examining data/choosewm-0.1.6/main.c FINAL RESULTS: data/choosewm-0.1.6/backend.c:98:16: [5] (race) readlink: This accepts filename arguments; if an attacker can move those files or change the link content, a race condition results. Also, it does not terminate with ASCII NUL. (CWE-362, CWE-20). Reconsider approach. while( (len = readlink(path,result,size)) >= size ) { data/choosewm-0.1.6/backend.c:793:2: [4] (shell) execlp: 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. execlp(wm->path,wm->path,NULL); data/choosewm-0.1.6/backend.c:233: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. path = getenv("PATH"); data/choosewm-0.1.6/backend.c:560:12: [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( trywm(getenv("DEFAULTWINDOWMANAGER")) ) data/choosewm-0.1.6/backend.c:562:12: [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( trywm(getenv("DEFAULTWINDOWMANAGER")) ) data/choosewm-0.1.6/backend.c:581: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. findwm(getenv("DEFAULTWINDOWMANAGER")); data/choosewm-0.1.6/backend.c:590: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. const char *homeenv = getenv("HOME"); data/choosewm-0.1.6/backend.c:722: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. const char *homeenv = getenv("HOME"); data/choosewm-0.1.6/main.c:262:16: [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. while( (opt = getopt_long(argc,argv,"dcfpht",longopts,NULL)) != -1 ) { data/choosewm-0.1.6/main.c:299:20: [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( configmode && getenv("DISPLAY") == NULL && !isatty(0) ) { data/choosewm-0.1.6/main.c:322:19: [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( textmode || (getenv("DISPLAY") == NULL && configmode) ) { data/choosewm-0.1.6/backend.c:246:3: [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(fullfilename, pb, (size_t)(pe-pb)); data/choosewm-0.1.6/backend.c:248:3: [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(fullfilename + (pe-pb) + 1, filename, l+1); data/choosewm-0.1.6/backend.c:462:6: [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(filename,"r"); data/choosewm-0.1.6/backend.c:464: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[1000]; data/choosewm-0.1.6/backend.c:606:6: [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(SYSTEMWMFILE,"r"); data/choosewm-0.1.6/backend.c:608: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[1000]; data/choosewm-0.1.6/backend.c:655: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(filename,"r")) != NULL ) { data/choosewm-0.1.6/backend.c:669: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(filename,"r")) != NULL ) { data/choosewm-0.1.6/backend.c:670: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 lastdecision[4001]; data/choosewm-0.1.6/backend.c:733:7: [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(filename,"w"); data/choosewm-0.1.6/backend.c:755:7: [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(filename,"w"); data/choosewm-0.1.6/main.c:54: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 *stringvalues[STRINGS_count]; data/choosewm-0.1.6/main.c:324: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[100], *s, *e; data/choosewm-0.1.6/backend.c:232:6: [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). l = strlen(filename); data/choosewm-0.1.6/backend.c:242:14: [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). pe = pb + strlen(pb); data/choosewm-0.1.6/backend.c:384: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). #define stroption(x,y) if( strncasecmp(buffer,x,strlen(x)) == 0 ) { \ data/choosewm-0.1.6/backend.c:385: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). start=buffer+strlen(x); \ data/choosewm-0.1.6/backend.c:393:51: [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 booloption(x,y) if( strncasecmp(buffer,x,strlen(x)) == 0 ) { \ data/choosewm-0.1.6/backend.c:394: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). start=buffer+strlen(x); \ data/choosewm-0.1.6/backend.c:403:53: [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 calloption(x,func) if( strncasecmp(buffer,x,strlen(x)) == 0 ) { \ data/choosewm-0.1.6/backend.c:404: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). start=buffer+strlen(x); \ data/choosewm-0.1.6/backend.c:438:17: [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). size_t l = strlen(stringkeys[i]); data/choosewm-0.1.6/backend.c:468:17: [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). size_t len = strlen(buffer); data/choosewm-0.1.6/backend.c:612:17: [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). size_t len = strlen(buffer); data/choosewm-0.1.6/backend.c:673:15: [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). size_t l = strlen(lastdecision); data/choosewm-0.1.6/backend.c:748: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). } else if( (finalfilename = strndup(filename, strlen(filename)-4)) == NULL ) { data/choosewm-0.1.6/main.c:335: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). s = buffer + strlen(buffer); ANALYSIS SUMMARY: Hits = 38 Lines analyzed = 1236 in approximately 0.06 seconds (21657 lines/second) Physical Source Lines of Code (SLOC) = 1013 Hits@level = [0] 28 [1] 14 [2] 13 [3] 9 [4] 1 [5] 1 Hits@level+ = [0+] 66 [1+] 38 [2+] 24 [3+] 11 [4+] 2 [5+] 1 Hits/KSLOC@level+ = [0+] 65.153 [1+] 37.5123 [2+] 23.692 [3+] 10.8588 [4+] 1.97433 [5+] 0.987167 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.