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/zutils-1.9/zcat.cc
Examining data/zutils-1.9/arg_parser.h
Examining data/zutils-1.9/ztest.cc
Examining data/zutils-1.9/arg_parser.cc
Examining data/zutils-1.9/zcmpdiff.cc
Examining data/zutils-1.9/zcmp.cc
Examining data/zutils-1.9/zutils.cc
Examining data/zutils-1.9/zgrep.cc
Examining data/zutils-1.9/zcatgrep.cc
Examining data/zutils-1.9/recursive.cc
Examining data/zutils-1.9/zupdate.cc
Examining data/zutils-1.9/rc.h
Examining data/zutils-1.9/zdiff.cc
Examining data/zutils-1.9/rc.cc
Examining data/zutils-1.9/zutils.h

FINAL RESULTS:

data/zutils-1.9/zupdate.cc:117:7:  [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( rname, in_stats.st_uid, in_stats.st_gid ) == 0 )
data/zutils-1.9/zupdate.cc:118:11:  [5] (race) chmod:
  This accepts filename arguments; if an attacker can move those files, a
  race condition results. (CWE-362). Use fchmod( ) instead.
    { if( chmod( rname, mode ) != 0 ) warning = true; }
data/zutils-1.9/zupdate.cc:121: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( rname, mode & ~( S_ISUID | S_ISGID | S_ISVTX ) ) != 0 )
data/zutils-1.9/zdiff.cc:207:9:  [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( argv[0], (char **)argv );
data/zutils-1.9/zdiff.cc:420:5:  [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( argv[0], (char **)argv );
data/zutils-1.9/zgrep.cc:126: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( argv[0], (char **)argv );
data/zutils-1.9/zgrep.cc:167: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( argv[0], (char **)argv );
data/zutils-1.9/ztest.cc:146: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( argv[0], (char **)argv );
data/zutils-1.9/ztest.cc:180:27:  [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.
      disable_xz = ( std::system( command.c_str() ) != 0 );
data/zutils-1.9/ztest.cc:203:5:  [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( argv[0], (char **)argv );
data/zutils-1.9/zupdate.cc:200:27:  [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.
      disable_xz = ( std::system( command.c_str() ) != 0 );
data/zutils-1.9/zupdate.cc:229:9:  [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( argv[0], (char **)argv );
data/zutils-1.9/zupdate.cc:255:9:  [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( argv[0], (char **)argv );
data/zutils-1.9/zupdate.cc:289:21:  [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.
  int status = std::system( zcmp_command.c_str() );
data/zutils-1.9/zutils.cc:210:9:  [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( argv[0], (char **)argv );
data/zutils-1.9/rc.cc:281:25:  [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 * p = std::getenv( "HOME" ); if( p ) name = p;
data/zutils-1.9/zdiff.cc:124:25:  [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 * p = std::getenv( "TMPDIR" );
data/zutils-1.9/rc.cc:192:25:  [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 * const f = std::fopen( name.c_str(), "r" );
data/zutils-1.9/rc.h:19:7:  [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.
const char * const format_names[num_formats] = { "bz2", "gz", "lz", "xz" };
data/zutils-1.9/rc.h:20:7:  [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.
const char * const simple_extensions[num_formats] =
data/zutils-1.9/zcat.cc:83:10:  [2] (buffer) memcpy:
  Does not check for buffer overflows when copying to destination (CWE-120).
  Make sure destination can always hold the source data.
    std::memcpy( buf, str.c_str(), str.size() );
data/zutils-1.9/zcatgrep.cc:39: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).
  int infd = open( input_filename.c_str(), O_RDONLY | O_BINARY );
data/zutils-1.9/zcatgrep.cc:50:18:  [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).
          infd = open( name.c_str(), O_RDONLY | O_BINARY );
data/zutils-1.9/zcmp.cc:149:34:  [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.
void parse_ignore_initial( const char * const arg, long long ignore_initial[2] )
data/zutils-1.9/zcmp.cc:270:11:  [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 buf0[5], buf1[5];
data/zutils-1.9/zcmp.cc:292:15:  [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 buf0[5], buf1[5];
data/zutils-1.9/zcmpdiff.cc:25:20:  [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).
  const int infd = open( input_filename.c_str(), O_RDONLY | O_BINARY );
data/zutils-1.9/zcmpdiff.cc:39:12:  [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).
    return open( name.c_str(), O_RDONLY | O_BINARY );
data/zutils-1.9/zcmpdiff.cc:46:26:  [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).
        const int infd = open( s.c_str(), O_RDONLY | O_BINARY );
data/zutils-1.9/zdiff.cc:185:25:  [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).
      const int outfd = open( fifoname.c_str(), O_WRONLY | O_BINARY );
data/zutils-1.9/zdiff.cc:201:46:  [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.
        const char ** const argv = new const char *[size+3];
data/zutils-1.9/zdiff.cc:224:25:  [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).
      const int outfd = open( fifoname.c_str(), O_WRONLY | O_BINARY );
data/zutils-1.9/zdiff.cc:412:42:  [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.
    const char ** const argv = new const char *[diff_args.size()+5];
data/zutils-1.9/zgrep.cc:121:44:  [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.
      const char ** const argv = new const char *[grep_args.size()+2];
data/zutils-1.9/zgrep.cc:162:44:  [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.
      const char ** const argv = new const char *[grep_args.size()+2];
data/zutils-1.9/ztest.cc:94:20:  [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).
  const int infd = open( input_filename.c_str(), O_RDONLY | O_BINARY );
data/zutils-1.9/ztest.cc:138:44:  [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.
      const char ** const argv = new const char *[size+size2+3];
data/zutils-1.9/ztest.cc:193:42:  [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.
    const char ** const argv = new const char *[size+size2+5];
data/zutils-1.9/zupdate.cc:222:46:  [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.
        const char ** const argv = new const char *[size+5];
data/zutils-1.9/zupdate.cc:247:46:  [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.
        const char ** const argv = new const char *[size+size2+5];
data/zutils-1.9/zutils.cc:204:46:  [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.
        const char ** const argv = new const char *[size+3];
data/zutils-1.9/arg_parser.cc:40: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).
      if( std::strlen( options[i].name ) == len )	// Exact match found
data/zutils-1.9/rc.cc:72:15:  [1] (buffer) fgetc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    ch = std::fgetc( f );
data/zutils-1.9/rc.cc:77:26:  [1] (buffer) fgetc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
      const int c = std::fgetc( f );
data/zutils-1.9/zcmp.cc:134:11:  [1] (obsolete) ulimit:
  This C routine is considered obsolete (as opposed to the shell command by
  the same name, which is NOT obsolete) (CWE-676). Use getrlimit(2),
  setrlimit(2), and sysconf(3) instead.
      if( ulimit / factor >= result ) result *= factor;
data/zutils-1.9/zcmp.cc:138:47:  [1] (obsolete) ulimit:
  This C routine is considered obsolete (as opposed to the shell command by
  the same name, which is NOT obsolete) (CWE-676). Use getrlimit(2),
  setrlimit(2), and sysconf(3) instead.
  if( !errno && ( result < llimit || result > ulimit ) ) errno = ERANGE;
data/zutils-1.9/zcmpdiff.cc:37: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).
    name.resize( name.size() - std::strlen( extension_from( eindex ) ) );
data/zutils-1.9/zupdate.cc:153:47:  [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).
    rname.assign( name, 0, name.size() - std::strlen( extension_from( eindex ) ) );
data/zutils-1.9/zutils.cc:85:19:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    const int n = read( fd, buf + sz, size - sz );

ANALYSIS SUMMARY:

Hits = 49
Lines analyzed = 3771 in approximately 0.15 seconds (25632 lines/second)
Physical Source Lines of Code (SLOC) = 3051
Hits@level = [0]  45 [1]   8 [2]  24 [3]   2 [4]  12 [5]   3
Hits@level+ = [0+]  94 [1+]  49 [2+]  41 [3+]  17 [4+]  15 [5+]   3
Hits/KSLOC@level+ = [0+] 30.8096 [1+] 16.0603 [2+] 13.4382 [3+] 5.57194 [4+] 4.91642 [5+] 0.983284
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.