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/zbackup-1.4.4/appendallocator.cc
Examining data/zbackup-1.4.4/backup_creator.cc
Examining data/zbackup-1.4.4/backup_exchanger.cc
Examining data/zbackup-1.4.4/backup_file.cc
Examining data/zbackup-1.4.4/backup_restorer.cc
Examining data/zbackup-1.4.4/bundle.cc
Examining data/zbackup-1.4.4/chunk_id.cc
Examining data/zbackup-1.4.4/chunk_index.cc
Examining data/zbackup-1.4.4/chunk_storage.cc
Examining data/zbackup-1.4.4/compression.cc
Examining data/zbackup-1.4.4/debug.cc
Examining data/zbackup-1.4.4/dir.cc
Examining data/zbackup-1.4.4/encrypted_file.cc
Examining data/zbackup-1.4.4/encryption.cc
Examining data/zbackup-1.4.4/encryption_key.cc
Examining data/zbackup-1.4.4/file.cc
Examining data/zbackup-1.4.4/hex.cc
Examining data/zbackup-1.4.4/index_file.cc
Examining data/zbackup-1.4.4/message.cc
Examining data/zbackup-1.4.4/mt.cc
Examining data/zbackup-1.4.4/objectcache.cc
Examining data/zbackup-1.4.4/page_size.cc
Examining data/zbackup-1.4.4/random.cc
Examining data/zbackup-1.4.4/rolling_hash.cc
Examining data/zbackup-1.4.4/sha256.cc
Examining data/zbackup-1.4.4/storage_info_file.cc
Examining data/zbackup-1.4.4/tartool/tartool.cc
Examining data/zbackup-1.4.4/tests/bundle/test_bundle.cc
Examining data/zbackup-1.4.4/tests/encrypted_file/test_encrypted_file.cc
Examining data/zbackup-1.4.4/tests/rolling_hash/test_rolling_hash.cc
Examining data/zbackup-1.4.4/tmp_mgr.cc
Examining data/zbackup-1.4.4/unbuffered_file.cc
Examining data/zbackup-1.4.4/zbackup_base.cc
Examining data/zbackup-1.4.4/zcollector.cc
Examining data/zbackup-1.4.4/zbackup.cc

FINAL RESULTS:

data/zbackup-1.4.4/file.cc:199:14:  [5] (buffer) gets:
  Does not check for buffer overflows (CWE-120, CWE-20). Use fgets() instead.
char * File::gets( char * s, int size, bool stripNl )
data/zbackup-1.4.4/file.cc:227:19:  [5] (buffer) gets:
  Does not check for buffer overflows (CWE-120, CWE-20). Use fgets() instead.
std::string File::gets( bool stripNl ) throw( exReadError, exWriteError )
data/zbackup-1.4.4/file.cc:231:9:  [5] (buffer) gets:
  Does not check for buffer overflows (CWE-120, CWE-20). Use fgets() instead.
  if ( !gets( buf, sizeof( buf ), stripNl ) )
data/zbackup-1.4.4/file.cc:386:19:  [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.
  int pathChars = readlink( procFdLink, path, sizeof( path ) );
data/zbackup-1.4.4/dir.cc:51:19:  [3] (buffer) realpath:
  This function does not protect against buffer overflows, and some
  implementations can overflow internally (CWE-120/CWE-785!). Ensure that the
  destination buffer is at least of size MAXPATHLEN, andto protect against
  implementation problems, the input argument should also be checked to
  ensure it is no larger than MAXPATHLEN.
  if ( char * r = realpath( path.c_str(), NULL ) )
data/zbackup-1.4.4/backup_creator.cc:129:14:  [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.
    unsigned char sha1Value[ SHA_DIGEST_LENGTH ];
data/zbackup-1.4.4/backup_creator.cc:180: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( chunkToSave.data() + chunkToSaveFill, tail, toMove );
data/zbackup-1.4.4/backup_creator.cc:188: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( chunkToSave.data() + chunkToSaveFill, tail, firstPart );
data/zbackup-1.4.4/backup_creator.cc:195:7:  [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( chunkToSave.data() + chunkToSaveFill + firstPart, begin,
data/zbackup-1.4.4/backup_creator.cc:228:14:  [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.
    unsigned char sha1Value[ SHA_DIGEST_LENGTH ];
data/zbackup-1.4.4/bundle.cc:68:9:  [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( bufPrev, bufCurr, sizeCurr );
data/zbackup-1.4.4/bundle.cc:75:9:  [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( bufPrev, bufCurr, sizeCurr );
data/zbackup-1.4.4/bundle.cc:240: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( &chunkData[ 0 ], i->second.first, sz );
data/zbackup-1.4.4/chunk_id.cc:25: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( out, cryptoHash, sizeof( cryptoHash ) );
data/zbackup-1.4.4/chunk_id.cc:26: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( out + sizeof( cryptoHash ), &v, sizeof( v ) );
data/zbackup-1.4.4/chunk_index.cc:49:9:  [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( savedId, &bundleId, sizeof( bundleId ) );
data/zbackup-1.4.4/chunk_index.cc:180:7:  [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( allocatedId, &bundleId, Bundle::IdSize );
data/zbackup-1.4.4/chunk_storage.cc:82:14:  [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.
    unsigned char buf[ 24 ]; // Same comments as for Bundle::IdSize
data/zbackup-1.4.4/compression.cc:241:9:  [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( dataOut, accDataOut.data() + posInAccDataOut, sz );
data/zbackup-1.4.4/compression.cc:418: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(dataOut, "ABCDEFGHIJKLMNOP", 16);
data/zbackup-1.4.4/encrypted_file.cc:147:7:  [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( n, data, size );
data/zbackup-1.4.4/encrypted_file.cc:153:7:  [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( n, data, avail );
data/zbackup-1.4.4/encrypted_file.cc:173: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 iv[ Encryption::IvSize ];
data/zbackup-1.4.4/encrypted_file.cc:228: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 newIv[ Encryption::IvSize ];
data/zbackup-1.4.4/encrypted_file.cc:320:7:  [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( data, n, size );
data/zbackup-1.4.4/encrypted_file.cc:326:7:  [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( data, n, avail );
data/zbackup-1.4.4/encrypted_file.cc:343: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 iv[ Encryption::IvSize ];
data/zbackup-1.4.4/encryption.cc:12: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 const ZeroIv[ IvSize ] = { 0, 0, 0, 0,
data/zbackup-1.4.4/encryption.cc:20:12:  [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.
  unsigned char block[ BlockSize ];
data/zbackup-1.4.4/encryption_key.cc:28: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 result[ EVP_MAX_MD_SIZE ];
data/zbackup-1.4.4/encryption_key.cc: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 derivedKey[ KeySize ];
data/zbackup-1.4.4/encryption_key.cc:72: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 buf[ 16 ];
data/zbackup-1.4.4/encryption_key.cc:78: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 derivedKey[ KeySize ];
data/zbackup-1.4.4/encryption_key.cc:81: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 key[ KeySize ];
data/zbackup-1.4.4/encryption_key.cc:94: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 encryptedKey[ sizeof( key ) ];
data/zbackup-1.4.4/file.cc:60:19:  [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).
      read_fd = ::open( from.c_str(), O_RDONLY );
data/zbackup-1.4.4/file.cc:65: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).
      write_fd = ::open( to.c_str(), O_WRONLY | O_CREAT, stat_buf.st_mode );
data/zbackup-1.4.4/file.cc:85: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).
void File::open( char const * filename, OpenMode mode ) throw( exCantOpen )
data/zbackup-1.4.4/file.cc:101: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, m );
data/zbackup-1.4.4/file.cc:110: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/zbackup-1.4.4/file.cc:116: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.c_str(), mode );
data/zbackup-1.4.4/file.cc:173: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( writeBuffer + ( WriteBufferSize - writeBufferLeft ),
data/zbackup-1.4.4/file.cc:185:7:  [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( writeBuffer, (char const *)buf + toAdd, size );
data/zbackup-1.4.4/file.cc:229: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 buf[ 1024 ];
data/zbackup-1.4.4/file.cc:382: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 path[ PATH_MAX ];
data/zbackup-1.4.4/file.cc:383: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 procFdLink[ 48 ];
data/zbackup-1.4.4/file.cc:384:3:  [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( procFdLink, "/proc/self/fd/%d", fd );
data/zbackup-1.4.4/sha256.cc:23: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 buf[ Size ];
data/zbackup-1.4.4/tests/bundle/test_bundle.cc:20: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 tmpbuf[100];
data/zbackup-1.4.4/tests/bundle/test_bundle.cc:107:7:  [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(tmpbuf, "0x%08x", rand());
data/zbackup-1.4.4/tests/encrypted_file/test_encrypted_file.cc:12: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 rnd[ 16384 ];
data/zbackup-1.4.4/tests/encrypted_file/test_encrypted_file.cc:37: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 iv[ Encryption::IvSize ];
data/zbackup-1.4.4/tests/encrypted_file/test_encrypted_file.cc:69:7:  [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( data, next, toWrite );
data/zbackup-1.4.4/tmp_mgr.cc:46: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).
  int fd = mkstemp( &name[ 0 ] );
data/zbackup-1.4.4/unbuffered_file.cc:30: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).
  fd = open( fileName, flags, 0666 );
data/zbackup-1.4.4/zbackup.cc:106:7:  [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( backupCreator.getInputBuffer(), ptr, toCopy );
data/zbackup-1.4.4/zbackup.cc:408:9:  [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 suffix[ 16 ];
data/zbackup-1.4.4/encrypted_file.cc:61:19:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
      fill = file.read( start + remainder, buffer.size() - remainder ) +
data/zbackup-1.4.4/encrypted_file.cc:135:19:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
void InputStream::read( void * buf, size_t size )
data/zbackup-1.4.4/encrypted_file.cc:164:3:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  read( &r, sizeof( r ) );
data/zbackup-1.4.4/encrypted_file.cc:174:5:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    read( iv, sizeof( iv ) ); // read() can throw exceptions, Skip() can't
data/zbackup-1.4.4/file.cc:119:12:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
void File::read( void * buf, size_t size ) throw( exReadError, exWriteError )
data/zbackup-1.4.4/file.cc:209: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).
    size_t len = strlen( result );
data/zbackup-1.4.4/unbuffered_file.cc:35:24:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
size_t UnbufferedFile::read( void * buf, size_t size )
data/zbackup-1.4.4/unbuffered_file.cc:43:20:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    ssize_t rd = ::read( fd, next, left );
data/zbackup-1.4.4/zbackup.cc:355:13:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
          f.read( &passwordData[ 0 ], passwordData.size() );
data/zbackup-1.4.4/zbackup.cc:410:14:  [1] (buffer) sscanf:
  It's unclear if the %s limit in the format string is small enough
  (CWE-120). Check that the limit is sufficiently small, or use a different
  input function.
        if ( sscanf( argv[ x + 1 ], "%zu %15s %n",

ANALYSIS SUMMARY:

Hits = 67
Lines analyzed = 5424 in approximately 0.13 seconds (42269 lines/second)
Physical Source Lines of Code (SLOC) = 4042
Hits@level = [0]  37 [1]  10 [2]  52 [3]   1 [4]   0 [5]   4
Hits@level+ = [0+] 104 [1+]  67 [2+]  57 [3+]   5 [4+]   4 [5+]   4
Hits/KSLOC@level+ = [0+] 25.7298 [1+] 16.576 [2+] 14.1019 [3+] 1.23701 [4+] 0.989609 [5+] 0.989609
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.