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/zim-tools-2.1.0/test/tools-test.cpp
Examining data/zim-tools-2.1.0/test/zimcheck-test.cpp
Examining data/zim-tools-2.1.0/test/zimwriterfs-zimcreatorfs.cpp
Examining data/zim-tools-2.1.0/test/zimwriterfs-article.cpp
Examining data/zim-tools-2.1.0/src/zimpatch.cpp
Examining data/zim-tools-2.1.0/src/zimbench.cpp
Examining data/zim-tools-2.1.0/src/zimcheck/main.cpp
Examining data/zim-tools-2.1.0/src/zimcheck/checks.cpp
Examining data/zim-tools-2.1.0/src/zimcheck/checks.h
Examining data/zim-tools-2.1.0/src/tools.h
Examining data/zim-tools-2.1.0/src/zimdiff.cpp
Examining data/zim-tools-2.1.0/src/zimsplit.cpp
Examining data/zim-tools-2.1.0/src/zimdump.cpp
Examining data/zim-tools-2.1.0/src/zimsearch.cpp
Examining data/zim-tools-2.1.0/src/tools.cpp
Examining data/zim-tools-2.1.0/src/progress.h
Examining data/zim-tools-2.1.0/src/zimrecreate.cpp
Examining data/zim-tools-2.1.0/src/zimwriterfs/zimcreatorfs.h
Examining data/zim-tools-2.1.0/src/zimwriterfs/tools.h
Examining data/zim-tools-2.1.0/src/zimwriterfs/mimetypecounter.h
Examining data/zim-tools-2.1.0/src/zimwriterfs/article.h
Examining data/zim-tools-2.1.0/src/zimwriterfs/article.cpp
Examining data/zim-tools-2.1.0/src/zimwriterfs/zimwriterfs.cpp
Examining data/zim-tools-2.1.0/src/zimwriterfs/tools.cpp
Examining data/zim-tools-2.1.0/src/zimwriterfs/mimetypecounter.cpp
Examining data/zim-tools-2.1.0/src/zimwriterfs/zimcreatorfs.cpp
Examining data/zim-tools-2.1.0/src/version.h

FINAL RESULTS:

data/zim-tools-2.1.0/src/zimbench.cpp:61:15:  [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.
      int c = getopt_long(argc, argv, "vsn:r:d:",
data/zim-tools-2.1.0/src/zimbench.cpp:113:5:  [3] (random) srand:
  This function is not sufficiently random for security-related functions
  such as key and nonce creation (CWE-327). Use a more secure technique for
  acquiring random values.
    srand(time(0));
data/zim-tools-2.1.0/src/zimcheck/main.cpp:127:17:  [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.
        int c = getopt_long (argc, argv, "ACIMFPRUXEDHBVacimfpruxedhbv",
data/zim-tools-2.1.0/src/zimwriterfs/zimcreatorfs.cpp:44:7:  [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 (realpath(directoryPath.c_str(), buf) != buf) {
data/zim-tools-2.1.0/src/zimwriterfs/zimcreatorfs.cpp:196:7:  [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 (realpath(symlink_path.c_str(), resolved) != resolved) {
data/zim-tools-2.1.0/src/zimwriterfs/zimwriterfs.cpp:215: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.
    c = getopt_long(
data/zim-tools-2.1.0/src/zimwriterfs/zimwriterfs.cpp:361:7:  [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 (realpath(zimdir.c_str(), buf) != buf) {
data/zim-tools-2.1.0/src/tools.cpp:54:7:  [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).
  fin.open(path.c_str(), std::ios::in);
data/zim-tools-2.1.0/src/tools.cpp:81: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 char_array_3[3];
data/zim-tools-2.1.0/src/tools.cpp:82: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 char_array_4[4];
data/zim-tools-2.1.0/src/zimbench.cpp:70:21:  [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).
            count = atoi(optarg);
data/zim-tools-2.1.0/src/zimbench.cpp:80:27:  [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).
            randomCount = atoi(optarg);
data/zim-tools-2.1.0/src/zimbench.cpp:87:29:  [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).
            distinctCount = atoi(optarg);
data/zim-tools-2.1.0/src/zimdump.cpp:349:15:  [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).
    auto fd = open(fullpath.c_str(), O_WRONLY | O_CREAT | O_TRUNC,
data/zim-tools-2.1.0/src/zimpatch.cpp:173: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 tempArray[16];
data/zim-tools-2.1.0/src/zimpatch.cpp:178:37:  [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).
                tempArray[k]=(char) atoi(temp.c_str());
data/zim-tools-2.1.0/src/zimpatch.cpp:377: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 tempArray[16];
data/zim-tools-2.1.0/src/zimpatch.cpp:382:33:  [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).
            tempArray[k]=(char) atoi(temp.c_str());
data/zim-tools-2.1.0/src/zimsplit.cpp:92:15:  [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).
        ofile.open(part_name, std::ios::binary);
data/zim-tools-2.1.0/src/zimwriterfs/tools.cpp:134: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 outbuffer[32768];
data/zim-tools-2.1.0/src/zimwriterfs/zimcreatorfs.cpp: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 buf[PATH_MAX];
data/zim-tools-2.1.0/src/zimwriterfs/zimcreatorfs.cpp:63:13:  [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).
  in_stream.open(path.c_str());
data/zim-tools-2.1.0/src/zimwriterfs/zimcreatorfs.cpp:195: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 resolved[PATH_MAX];
data/zim-tools-2.1.0/src/zimwriterfs/zimwriterfs.cpp:256:26:  [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).
          minChunkSize = atoi(optarg);
data/zim-tools-2.1.0/src/zimwriterfs/zimwriterfs.cpp:356: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[MAXPATHLEN];
data/zim-tools-2.1.0/src/zimsplit.cpp:103:18:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
           ifile.read(batch_buffer, size_to_copy);
data/zim-tools-2.1.0/src/zimwriterfs/tools.cpp:179:8:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    in.read(&contents[0], contents.size());
data/zim-tools-2.1.0/src/zimwriterfs/zimwriterfs.cpp:357:3:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
  strncpy(buf, zimPath.c_str(), sizeof(buf)-1);

ANALYSIS SUMMARY:

Hits = 28
Lines analyzed = 5978 in approximately 0.17 seconds (35388 lines/second)
Physical Source Lines of Code (SLOC) = 4498
Hits@level = [0]   1 [1]   3 [2]  18 [3]   7 [4]   0 [5]   0
Hits@level+ = [0+]  29 [1+]  28 [2+]  25 [3+]   7 [4+]   0 [5+]   0
Hits/KSLOC@level+ = [0+] 6.44731 [1+] 6.22499 [2+] 5.55803 [3+] 1.55625 [4+]   0 [5+]   0
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.