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/bosh-0.6/stray.c Examining data/bosh-0.6/rc.c Examining data/bosh-0.6/stray.h Examining data/bosh-0.6/list.h Examining data/bosh-0.6/list.c Examining data/bosh-0.6/misc.c Examining data/bosh-0.6/system.h Examining data/bosh-0.6/bosh.c Examining data/bosh-0.6/rc.h Examining data/bosh-0.6/misc.h Examining data/bosh-0.6/system.c Examining data/bosh-0.6/bosh.h FINAL RESULTS: data/bosh-0.6/system.c:307:5: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. chmod(bosh->tmpfscript,0700); /* we should probably set the umask first */ data/bosh-0.6/bosh.c:301:15: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(p,"%s | %s",bosh->command,bosh->pipe); data/bosh-0.6/bosh.c:305:15: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(p,"| %s",bosh->pipe); data/bosh-0.6/bosh.c:740:5: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(s,"%s [%s]",prompt,previous); data/bosh-0.6/misc.c:40:5: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(r,"%s%s",s1,s2); data/bosh-0.6/misc.c:101:3: [4] (format) vsprintf: Potential format string problem (CWE-134). Make format string constant. vsprintf(s,format,v); data/bosh-0.6/misc.c:107:3: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(stderr,format,v); data/bosh-0.6/misc.c:119:3: [4] (format) vsprintf: Potential format string problem (CWE-134). Make format string constant. vsprintf(s,format,v); data/bosh-0.6/misc.c:125:3: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(stream,format,v); data/bosh-0.6/misc.c:145:5: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(BOSHLOG,format,v); data/bosh-0.6/rc.c:112:9: [4] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). strcat(v,s); data/bosh-0.6/rc.c:133:11: [4] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). strcat(v,s); data/bosh-0.6/rc.c:155:9: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(p,"%s%s",a+1,v); data/bosh-0.6/rc.c:176:7: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(p,"--%s=%s",a,v); data/bosh-0.6/system.c:66:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(p,"%s[bash] ",logprefix ); data/bosh-0.6/system.c:315:5: [4] (shell) execv: 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. execv(a->v[0],a->v); data/bosh-0.6/system.c:367:9: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(action,"cat '%s'",confpath); data/bosh-0.6/system.c:385:9: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(BOSH+strlen(BOSH),"%s%s",p,seperator); data/bosh-0.6/rc.c:295:9: [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. n = getopt_long(argc,argv,"hv",opts,0); data/bosh-0.6/bosh.c:61: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 BOSHVARFILE[18]; data/bosh-0.6/bosh.c:192: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(r,&n,sizeof(int)); data/bosh-0.6/bosh.c:498:3: [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(BOSHVARFILE,"/tmp/boshv_XXXXXX"); data/bosh-0.6/bosh.c:499: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(BOSHVARFILE)); data/bosh-0.6/bosh.h:122: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 tmpfscript[18]; /* made with mkstmp so always fixed length */ data/bosh-0.6/bosh.h:123: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 tmpfpipe[18]; /* " */ data/bosh-0.6/bosh.h:169: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. extern char BOSHVARFILE[18]; data/bosh-0.6/list.c:82: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(l->last->data,data,size); data/bosh-0.6/list.c:139: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(l->iter->next->data,data,size); data/bosh-0.6/list.c:271: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 s[256]; data/bosh-0.6/misc.c:99: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 s[512]; data/bosh-0.6/misc.c:117: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 s[512]; data/bosh-0.6/misc.c:136: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). BOSHLOG = fopen("bosh.log",mode); data/bosh-0.6/rc.c:42: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 s[256],*p,*a,*v; data/bosh-0.6/rc.c:53: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(name,"r"); data/bosh-0.6/system.c:198:3: [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(bosh->tmpfscript,"/tmp/boshs_XXXXXX"); data/bosh-0.6/system.c:199: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(bosh->tmpfscript)); data/bosh-0.6/system.c:257: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(logprefix,"popen: [child:%d]",pid); data/bosh-0.6/system.c:279: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(bosh->tmpfpipe,"/tmp/bosht_XXXXXX"); data/bosh-0.6/system.c:283:18: [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(mkstemp(bosh->tmpfpipe),"w"); data/bosh-0.6/system.c:299: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(bosh->tmpfscript,"w"); data/bosh-0.6/system.c:608: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). b = fopen(BOSHVARFILE,"r"); data/bosh-0.6/bosh.c:99:8: [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(b->multilineseperator)) data/bosh-0.6/bosh.c:292: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). if(strlen(REPLY)) { data/bosh-0.6/bosh.c:300: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). p = malloc(strlen(bosh->command)+strlen(bosh->pipe) + 4); data/bosh-0.6/bosh.c:300: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). p = malloc(strlen(bosh->command)+strlen(bosh->pipe) + 4); data/bosh-0.6/bosh.c:304: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). p = malloc(strlen(bosh->pipe) + 3); data/bosh-0.6/bosh.c:336:10: [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(REPLY)) { data/bosh-0.6/bosh.c:406: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). if(bosh->width<strlen(bosh->command)) data/bosh-0.6/bosh.c:407: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). bosh->width = strlen(bosh->command); data/bosh-0.6/bosh.c:451:10: [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(REPLY)) { data/bosh-0.6/bosh.c:452: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). REPLY[strlen(REPLY)-1] = 0; data/bosh-0.6/bosh.c:461: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). REPLY[strlen(REPLY)] = key; data/bosh-0.6/bosh.c:506:20: [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(bosh->width<strlen(bosh->command)) data/bosh-0.6/bosh.c:507:21: [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). bosh->width = strlen(bosh->command); data/bosh-0.6/bosh.c:573:7: [1] (obsolete) usleep: This C routine is considered obsolete (as opposed to the shell command by the same name). The interaction of this function with SIGALRM and other timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead. usleep(BOSH_INPUTWAIT_USLEEP); data/bosh-0.6/bosh.c:664:20: [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). mvprintw(0,COLS-(strlen(PACKAGE)+strlen(VERSION)+1),"%s %s",PACKAGE,VERSION); data/bosh-0.6/bosh.c:664: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). mvprintw(0,COLS-(strlen(PACKAGE)+strlen(VERSION)+1),"%s %s",PACKAGE,VERSION); data/bosh-0.6/bosh.c:739: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 = malloc(strlen(prompt)+strlen(previous)+4); data/bosh-0.6/bosh.c:739:31: [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 = malloc(strlen(prompt)+strlen(previous)+4); data/bosh-0.6/list.c:284:37: [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). list_insdup(&l,s[0]-'0',s+1,strlen(s+1)+1); data/bosh-0.6/list.c:291: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). list_adddup(&l,s,strlen(s)+1); data/bosh-0.6/misc.c:38: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). r = malloc(strlen(s1)+strlen(s2)+1); data/bosh-0.6/misc.c:38: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). r = malloc(strlen(s1)+strlen(s2)+1); data/bosh-0.6/rc.c:100: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). while(v[strlen(v)-1]=='\\') { data/bosh-0.6/rc.c:101: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). v[strlen(v)-1]='\n'; data/bosh-0.6/rc.c:111:23: [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). v = realloc(v,strlen(v)+strlen(s)+1); data/bosh-0.6/rc.c:111: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). v = realloc(v,strlen(v)+strlen(s)+1); data/bosh-0.6/rc.c:132: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). v = realloc(v,strlen(v)+strlen(s)+1); data/bosh-0.6/rc.c:132:35: [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). v = realloc(v,strlen(v)+strlen(s)+1); data/bosh-0.6/rc.c:148:8: [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(a)==1) data/bosh-0.6/rc.c:151:8: [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(a)>2) { data/bosh-0.6/rc.c:154:20: [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). p = malloc(strlen(a+1)+strlen(v)+1); data/bosh-0.6/rc.c:154: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). p = malloc(strlen(a+1)+strlen(v)+1); data/bosh-0.6/rc.c:175: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). p = malloc(strlen(a)+strlen(v)+4); /* --(a)=(v)\0 */ data/bosh-0.6/rc.c:175:28: [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). p = malloc(strlen(a)+strlen(v)+4); /* --(a)=(v)\0 */ data/bosh-0.6/system.c:172:5: [1] (obsolete) usleep: This C routine is considered obsolete (as opposed to the shell command by the same name). The interaction of this function with SIGALRM and other timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead. usleep(500); data/bosh-0.6/system.c:219:5: [1] (obsolete) usleep: This C routine is considered obsolete (as opposed to the shell command by the same name). The interaction of this function with SIGALRM and other timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead. usleep(BOSH_PIPE_USLEEP); data/bosh-0.6/system.c:365:23: [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). action = malloc(strlen(confpath)+7); data/bosh-0.6/system.c:377: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). n += strlen(p) + strlen(seperator); data/bosh-0.6/system.c:377: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). n += strlen(p) + strlen(seperator); data/bosh-0.6/system.c:385: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). sprintf(BOSH+strlen(BOSH),"%s%s",p,seperator); data/bosh-0.6/system.c:508:12: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if(read(n,&c,1)>0) { data/bosh-0.6/system.c:616:8: [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(BOSHERR)) { data/bosh-0.6/system.c:629: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). if(!strlen(bosh->title)) { data/bosh-0.6/system.c:651: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). if(!strlen(boshuservar[i])) { ANALYSIS SUMMARY: Hits = 85 Lines analyzed = 3013 in approximately 0.08 seconds (36374 lines/second) Physical Source Lines of Code (SLOC) = 2008 Hits@level = [0] 29 [1] 44 [2] 22 [3] 1 [4] 17 [5] 1 Hits@level+ = [0+] 114 [1+] 85 [2+] 41 [3+] 19 [4+] 18 [5+] 1 Hits/KSLOC@level+ = [0+] 56.7729 [1+] 42.3307 [2+] 20.4183 [3+] 9.46215 [4+] 8.96414 [5+] 0.498008 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.