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/xstow-1.0.2/src/leoini.cpp
Examining data/xstow-1.0.2/src/tree.h
Examining data/xstow-1.0.2/src/debug.cpp
Examining data/xstow-1.0.2/src/setup.cpp
Examining data/xstow-1.0.2/src/leoini.h
Examining data/xstow-1.0.2/src/main.cpp
Examining data/xstow-1.0.2/src/debug.h
Examining data/xstow-1.0.2/src/tree.cpp
Examining data/xstow-1.0.2/src/file_option.h
Examining data/xstow-1.0.2/src/iterator.h
Examining data/xstow-1.0.2/src/merge_info.cpp
Examining data/xstow-1.0.2/src/arg.cpp
Examining data/xstow-1.0.2/src/copy.cpp
Examining data/xstow-1.0.2/src/cppdir.cpp
Examining data/xstow-1.0.2/src/setup_config.h
Examining data/xstow-1.0.2/src/ref.h
Examining data/xstow-1.0.2/src/file_option.cpp
Examining data/xstow-1.0.2/src/cppdir.h
Examining data/xstow-1.0.2/src/backtrace.cpp
Examining data/xstow-1.0.2/src/arg.h
Examining data/xstow-1.0.2/src/range.h
Examining data/xstow-1.0.2/src/format.cpp
Examining data/xstow-1.0.2/src/nignore.h
Examining data/xstow-1.0.2/src/setup.h
Examining data/xstow-1.0.2/src/format.h
Examining data/xstow-1.0.2/src/backtrace.h
Examining data/xstow-1.0.2/src/local_config.h
Examining data/xstow-1.0.2/src/string_utils.cpp
Examining data/xstow-1.0.2/src/nignore.cpp
Examining data/xstow-1.0.2/src/setup_config.cpp
Examining data/xstow-1.0.2/src/string_utils.h

FINAL RESULTS:

data/xstow-1.0.2/src/cppdir.cpp:238:12:  [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.
    return readlink( concat_dir( path, name ) );
data/xstow-1.0.2/src/cppdir.cpp:493:21:  [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.
std::string CppDir::readlink( const std::string &path )
data/xstow-1.0.2/src/cppdir.cpp:510:21:  [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( ( (ret = ::readlink( path.c_str(), buffer, path_max ) ) == -1 ) && 
data/xstow-1.0.2/src/cppdir.h:195:15:  [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.
  std::string readlink( const std::string &path );
data/xstow-1.0.2/src/format.h:686:24:  [4] (format) snprintf:
  If format strings can be influenced by an attacker, they can be exploited,
  and note that sprintf variations do not always \0-terminate (CWE-134). Use
  a constant for the format specification.
		    case 1: n = std::snprintf( buffer, buffer_size, format.c_str(),
data/xstow-1.0.2/src/format.h:688:24:  [4] (format) snprintf:
  If format strings can be influenced by an attacker, they can be exploited,
  and note that sprintf variations do not always \0-terminate (CWE-134). Use
  a constant for the format specification.
		    case 2: n = std::snprintf( buffer, buffer_size, format.c_str(),
data/xstow-1.0.2/src/format.h:690:24:  [4] (format) snprintf:
  If format strings can be influenced by an attacker, they can be exploited,
  and note that sprintf variations do not always \0-terminate (CWE-134). Use
  a constant for the format specification.
		    case 3: n = std::snprintf( buffer, buffer_size, format.c_str(),
data/xstow-1.0.2/src/format.h:692:24:  [4] (format) snprintf:
  If format strings can be influenced by an attacker, they can be exploited,
  and note that sprintf variations do not always \0-terminate (CWE-134). Use
  a constant for the format specification.
		    case 4: n = std::snprintf( buffer, buffer_size, format.c_str(),
data/xstow-1.0.2/src/format.h:694:24:  [4] (format) snprintf:
  If format strings can be influenced by an attacker, they can be exploited,
  and note that sprintf variations do not always \0-terminate (CWE-134). Use
  a constant for the format specification.
		    case 5: n = std::snprintf( buffer, buffer_size, format.c_str(),
data/xstow-1.0.2/src/format.h:696:24:  [4] (format) snprintf:
  If format strings can be influenced by an attacker, they can be exploited,
  and note that sprintf variations do not always \0-terminate (CWE-134). Use
  a constant for the format specification.
		    case 6: n = std::snprintf( buffer, buffer_size, format.c_str(),
data/xstow-1.0.2/src/format.h:790:9:  [4] (format) printf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
	PrintF printf( *this );
data/xstow-1.0.2/src/format.h:791:2:  [4] (format) printf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
	printf.module = module_;
data/xstow-1.0.2/src/format.h:793:9:  [4] (format) printf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
	return printf;
data/xstow-1.0.2/src/format.h:798:9:  [4] (format) printf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
	PrintF printf( *this );
data/xstow-1.0.2/src/format.h:799:2:  [4] (format) printf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
	printf.level = level_;
data/xstow-1.0.2/src/format.h:801:9:  [4] (format) printf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
	return printf;
data/xstow-1.0.2/src/tree.cpp:1076:17:  [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 ret = system( com.c_str() );
data/xstow-1.0.2/src/arg.cpp:30:23:  [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 *tm  = getenv( "TERM" );
data/xstow-1.0.2/src/main.cpp:34:14:  [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.
  char *dl = getenv( "XSTOW_DEBUG_LEVEL" );
data/xstow-1.0.2/src/main.cpp:35:14:  [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.
  char *dm = getenv( "XSTOW_DEBUG_MODULE" );
data/xstow-1.0.2/src/main.cpp:36:14:  [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.
  char *uc = getenv( "XSTOW_USE_CURSES" );
data/xstow-1.0.2/src/main.cpp:596:39:  [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.
  char *xstow_dont_read_sysconf_ini = getenv("XSTOW_DONT_READ_SYSCONF_INI");
data/xstow-1.0.2/src/merge_info.cpp:387:16:  [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.
    char *uc = getenv( "XSTOW_USE_CURSES" );
data/xstow-1.0.2/src/setup.cpp:277: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.
      char *home = getenv( "HOME" );
data/xstow-1.0.2/src/copy.cpp:37:15:  [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( ( o = fopen( origin.c_str(), "rb" ) ) == NULL )
data/xstow-1.0.2/src/copy.cpp:42:15:  [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( ( t = fopen( target.c_str(), "w+b" ) ) == NULL )
data/xstow-1.0.2/src/copy.cpp:48:5:  [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[SIZE];
data/xstow-1.0.2/src/cppdir.cpp:247:11:  [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).
  valid = open( pname );
data/xstow-1.0.2/src/cppdir.cpp:255:11:  [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).
  valid = open( file );
data/xstow-1.0.2/src/cppdir.cpp:264: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).
bool CppDir::Directory::open( File file )
data/xstow-1.0.2/src/cppdir.cpp:286:10:  [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( concat_dir( file.get_path(), file.get_name() ) );
data/xstow-1.0.2/src/cppdir.cpp:289: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).
bool CppDir::Directory::open( std::string fname )
data/xstow-1.0.2/src/cppdir.h:170: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).
      bool open( File file ); /// opens the directory
data/xstow-1.0.2/src/cppdir.h:171: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).
      bool open( std::string fname ); /// opens the directory
data/xstow-1.0.2/src/format.cpp:43:10:  [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).
  return atoi( s.substr( start, start-pos ).c_str() );
data/xstow-1.0.2/src/leoini.cpp:106:3:  [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).
  open( filename, mode );
data/xstow-1.0.2/src/leoini.cpp:114:16:  [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).
bool Leo::Ini::open( std::string f, int mode )
data/xstow-1.0.2/src/leoini.cpp:126:8:  [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).
  file.open( file_name.c_str() , static_cast<std::ios_base::openmode>( mode ));
data/xstow-1.0.2/src/leoini.cpp:550:8:  [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).
  file.open( file_name.c_str(), std::ios_base::trunc | std::ios_base::in | std::ios_base::out );
data/xstow-1.0.2/src/leoini.cpp:553:8:  [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).
  file.open( file_name.c_str(), static_cast<std::ios_base::openmode>(openmode) );
data/xstow-1.0.2/src/leoini.h:144:10:  [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).
    bool open( std::string filename, int mode = std::ios::in | std::ios::out );
data/xstow-1.0.2/src/leoini.cpp:212:16:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
bool Leo::Ini::read()
data/xstow-1.0.2/src/leoini.cpp:365:16:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
bool Leo::Ini::read( Element& element )
data/xstow-1.0.2/src/leoini.cpp:368:10:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    if( !read() )
data/xstow-1.0.2/src/leoini.h:154:10:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    bool read(); 
data/xstow-1.0.2/src/leoini.h:158:10:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    bool read( Element& element );
data/xstow-1.0.2/src/setup.cpp:209:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
      ini.read();
data/xstow-1.0.2/src/setup.cpp:449:14:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    if( !ini.read( isections ) )
data/xstow-1.0.2/src/setup.cpp:525:14:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    if( !ini.read( isections ) )
data/xstow-1.0.2/src/setup_config.cpp:26:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  if( ini.read( el ) )
data/xstow-1.0.2/src/setup_config.cpp:45:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  if( ini.read( el ) )

ANALYSIS SUMMARY:

Hits = 51
Lines analyzed = 10392 in approximately 0.22 seconds (47857 lines/second)
Physical Source Lines of Code (SLOC) = 7268
Hits@level = [0]   1 [1]  10 [2]  17 [3]   7 [4]  13 [5]   4
Hits@level+ = [0+]  52 [1+]  51 [2+]  41 [3+]  24 [4+]  17 [5+]   4
Hits/KSLOC@level+ = [0+] 7.15465 [1+] 7.01706 [2+] 5.64117 [3+] 3.30215 [4+] 2.33902 [5+] 0.550358
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.