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/tofrodos-1.7.13+ds/src/config.h Examining data/tofrodos-1.7.13+ds/src/emsg.c Examining data/tofrodos-1.7.13+ds/src/emsg.h Examining data/tofrodos-1.7.13+ds/src/init.c Examining data/tofrodos-1.7.13+ds/src/lib/getopt.c Examining data/tofrodos-1.7.13+ds/src/lib/getopt.h Examining data/tofrodos-1.7.13+ds/src/lib/mktemp.c Examining data/tofrodos-1.7.13+ds/src/lib/mktemp.h Examining data/tofrodos-1.7.13+ds/src/tofrodos.c Examining data/tofrodos-1.7.13+ds/src/tofrodos.h Examining data/tofrodos-1.7.13+ds/src/utility.c Examining data/tofrodos-1.7.13+ds/src/utility.h Examining data/tofrodos-1.7.13+ds/src/version.h FINAL RESULTS: data/tofrodos-1.7.13+ds/src/tofrodos.c:444:14: [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. if ((len = readlink( filename, realfilepath, statbuf.st_size )) != -1) { data/tofrodos-1.7.13+ds/src/tofrodos.c:661:13: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. chmod( bakfilename, S_IRUSR|S_IWUSR ); /* make it writeable (in case it's not) so that it can be deleted */ data/tofrodos-1.7.13+ds/src/tofrodos.c:672:13: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. chmod( filename, S_IRUSR|S_IWUSR ); /* make it writeable (in case it's not) so that it can be deleted. */ data/tofrodos-1.7.13+ds/src/tofrodos.c:703:8: [5] (race) chown: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchown( ) instead. if (chown( filename, ownerid, groupid ) && verbose) data/tofrodos-1.7.13+ds/src/tofrodos.c:709:9: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. chmod( filename, origfilemode ); data/tofrodos-1.7.13+ds/src/config.h:140:24: [4] (tmpfile) mktemp: Temporary file race condition (CWE-377). #define MKTEMP_HEADER <mktemp.h> data/tofrodos-1.7.13+ds/src/emsg.c:44:5: [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, EMSG_ERRORLOG, progname, errorlogfilename ); data/tofrodos-1.7.13+ds/src/emsg.c:55:2: [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( errorfp, message, argp ); data/tofrodos-1.7.13+ds/src/init.c:199:3: [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, VERFMT, VERSN_PROGNAME, VERSN_MAJOR, VERSN_MINOR, VERSN_PATCH ); data/tofrodos-1.7.13+ds/src/init.c:213: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, HELPFMT, progname ); data/tofrodos-1.7.13+ds/src/lib/getopt.c:255:2: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf( buf, msgfmt, optopt ); data/tofrodos-1.7.13+ds/src/lib/getopt.c:260:3: [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, ERR_PREFIX, optprogname ); data/tofrodos-1.7.13+ds/src/lib/getopt.c:261: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, msgfmt, optopt ); data/tofrodos-1.7.13+ds/src/tofrodos.c:557:3: [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( tempfilename, t ); /* add the path leading to filename */ data/tofrodos-1.7.13+ds/src/tofrodos.c:558:3: [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( tempfilename, MKTEMP_TEMPL ); /* add the filename */ data/tofrodos-1.7.13+ds/src/tofrodos.c:563:4: [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( bakfilename, filename ); data/tofrodos-1.7.13+ds/src/tofrodos.c:564:4: [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( bakfilename, BAKEXT ); /* append the extension to existing filename to create name of backup file */ data/tofrodos-1.7.13+ds/src/init.c:145:14: [3] (buffer) getopt: 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 ((c = getopt( argc, argv, OPTLIST )) != -1) { data/tofrodos-1.7.13+ds/src/lib/getopt.c:161:5: [3] (buffer) getopt: 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. int getopt ( int argc, char * const * argv, const char * optlist ) data/tofrodos-1.7.13+ds/src/lib/getopt.h:34:12: [3] (buffer) getopt: 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. extern int getopt (int argc, char * const * argv, const char * optlist ); data/tofrodos-1.7.13+ds/src/emsg.c:42:14: [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). errorfp = fopen ( errorlogfilename, ERROR_LOG_MODE ); data/tofrodos-1.7.13+ds/src/init.c:79: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 filename[MAXFILESIZE]; data/tofrodos-1.7.13+ds/src/lib/getopt.c:252: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[MESSAGEMAX]; data/tofrodos-1.7.13+ds/src/lib/mktemp.c:54:5: [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). int mkstemp ( char * templ ) data/tofrodos-1.7.13+ds/src/lib/mktemp.c:91:14: [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 ((fd = open( templ, O_CREAT | O_EXCL | O_BINARY | O_RDWR, S_IRUSR | S_IWUSR )) != -1) { data/tofrodos-1.7.13+ds/src/lib/mktemp.h:22:12: [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). extern int mkstemp ( char * templ ); data/tofrodos-1.7.13+ds/src/tofrodos.c:487: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 drv[_MAX_DRIVE]; data/tofrodos-1.7.13+ds/src/tofrodos.c:488: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 dir[MAXDIRSIZE]; data/tofrodos-1.7.13+ds/src/tofrodos.c:489: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 fname[MAXFILESIZE]; data/tofrodos-1.7.13+ds/src/tofrodos.c:490: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 tempname[MAXPATHSIZE]; data/tofrodos-1.7.13+ds/src/tofrodos.c:569:25: [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). if ((tempfiledes = mkstemp( tempfilename )) == -1) { data/tofrodos-1.7.13+ds/src/tofrodos.c:584:18: [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 ((infp = fopen( filename, INFILEMODE )) == NULL) { data/tofrodos-1.7.13+ds/src/lib/mktemp.c:71: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 ((len = strlen(templ)) < 6 || data/tofrodos-1.7.13+ds/src/tofrodos.c:321:16: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while ( (c = getc( infp )) != EOF ) { data/tofrodos-1.7.13+ds/src/tofrodos.c:338: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/tofrodos-1.7.13+ds/src/tofrodos.c:373:16: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while ((c = getc( infp )) != EOF) { data/tofrodos-1.7.13+ds/src/tofrodos.c:547: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). len = strlen( filename ) ; data/tofrodos-1.7.13+ds/src/tofrodos.c:562: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). bakfilename = xmalloc( strlen( filename ) + sizeof( BAKEXT ) ); ANALYSIS SUMMARY: Hits = 38 Lines analyzed = 1827 in approximately 0.07 seconds (24582 lines/second) Physical Source Lines of Code (SLOC) = 992 Hits@level = [0] 1 [1] 6 [2] 12 [3] 3 [4] 12 [5] 5 Hits@level+ = [0+] 39 [1+] 38 [2+] 32 [3+] 20 [4+] 17 [5+] 5 Hits/KSLOC@level+ = [0+] 39.3145 [1+] 38.3065 [2+] 32.2581 [3+] 20.1613 [4+] 17.1371 [5+] 5.04032 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.