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/muchsync-6/sql_db.cc
Examining data/muchsync-6/cleanup.h
Examining data/muchsync-6/sql_db.h
Examining data/muchsync-6/notmuch_db.cc
Examining data/muchsync-6/muchsync.cc
Examining data/muchsync-6/protocol.cc
Examining data/muchsync-6/xapian_sync.cc
Examining data/muchsync-6/misc.cc
Examining data/muchsync-6/infinibuf.cc
Examining data/muchsync-6/notmuch_db.h
Examining data/muchsync-6/sqlstmt.cc
Examining data/muchsync-6/infinibuf.h
Examining data/muchsync-6/muchsync.h
Examining data/muchsync-6/sqlstmt.h
Examining data/muchsync-6/misc.h

FINAL RESULTS:

data/muchsync-6/muchsync.cc:59:8:  [4] (race) access:
  This usually indicates a security flaw. If an attacker can change anything
  along the path between the call to access() and the file's actual use
  (e.g., by moving files), the attacker can exploit the race condition
  (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid())
  and try to open the file directly.
  if (!access ((maildir + muchsync_tmpdir).c_str(), 0)
data/muchsync-6/muchsync.cc:60:11:  [4] (race) access:
  This usually indicates a security flaw. If an attacker can change anything
  along the path between the call to access() and the file's actual use
  (e.g., by moving files), the attacker can exploit the race condition
  (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid())
  and try to open the file directly.
      && !access ((trashbase + "ff").c_str(), 0))
data/muchsync-6/muchsync.cc:69:17:  [4] (race) access:
  This usually indicates a security flaw. If an attacker can change anything
  along the path between the call to access() and the file's actual use
  (e.g., by moving files), the attacker can exploit the race condition
  (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid())
  and try to open the file directly.
  if (create && access (notmuchdir.c_str(), 0) && errno == ENOENT) {
data/muchsync-6/muchsync.cc:241:5:  [4] (shell) execl:
  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.
    execl (shell, shell, "-c", cmd.c_str(), nullptr);
data/muchsync-6/notmuch_db.cc:206: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("notmuch", const_cast<char *const*> (av));
data/muchsync-6/sql_db.cc:117:7:  [4] (race) access:
  This usually indicates a security flaw. If an attacker can change anything
  along the path between the call to access() and the file's actual use
  (e.g., by moving files), the attacker can exploit the race condition
  (CWE-362/CWE-367!). Set up the correct permissions (e.g., using setuid())
  and try to open the file directly.
  if (access (path, 0) && errno == ENOENT)
data/muchsync-6/misc.cc:76:8:  [3] (random) setstate:
  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.
    in.setstate (std::ios_base::failbit);
data/muchsync-6/muchsync.cc:281:21:  [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 = getenv("PWD");
data/muchsync-6/muchsync.cc:410: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.
  while ((opt = getopt_long(argc, argv, "+C:Fr:s:v",
data/muchsync-6/notmuch_db.cc:104:13:  [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 *p = getenv("NOTMUCH_CONFIG");
data/muchsync-6/notmuch_db.cc:107:7:  [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.
  p = getenv("HOME");
data/muchsync-6/sql_db.cc:179:10:  [3] (random) setstate:
  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.
      in.setstate (ios_base::failbit);
data/muchsync-6/sql_db.cc:256:8:  [3] (random) setstate:
  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.
    is.setstate (ios_base::failbit);
data/muchsync-6/infinibuf.cc:49: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(chunk, data_.back() + chunksize_ - startpos_, startpos_);
data/muchsync-6/misc.cc:111: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 resbuf[output_bytes];
data/muchsync-6/muchsync.cc:273: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).
  int fd = open(opt_notmuch_config.c_str(), O_CREAT|O_TRUNC|O_WRONLY|O_EXCL,
data/muchsync-6/notmuch_db.cc:203:9:  [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("/dev/null", O_WRONLY);
data/muchsync-6/protocol.cc:79: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[257];
data/muchsync-6/protocol.cc:534: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 buf[16384];
data/muchsync-6/sql_db.cc:400: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).
  int fd = open (path.c_str(), O_RDWR);
data/muchsync-6/sql_db.cc:414: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[16384];
data/muchsync-6/sql_db.cc:443: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).
    content_.open (link_path(i));
data/muchsync-6/xapian_sync.cc:70: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).
  int dot = open(".", O_RDONLY);
data/muchsync-6/xapian_sync.cc:82:48:  [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 with_cwd<int>(dfd, -1, [=]() { return open(entry, mode); });
data/muchsync-6/xapian_sync.cc:110: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[32768];
data/muchsync-6/xapian_sync.cc:494: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).
    int dfd = open(dirpath.c_str(), O_RDONLY);
data/muchsync-6/infinibuf.cc:119:15:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  ssize_t n = read(fd, p, nmax);
data/muchsync-6/muchsync.cc:270:11:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  if (!in.read(&conf.front(), len))
data/muchsync-6/muchsync.cc:404:3:  [1] (access) umask:
  Ensure that umask is given most restrictive possible setting (e.g., 066 or
  077) (CWE-732).
  umask (077);
data/muchsync-6/muchsync.cc:494:7:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
      read(fds[0], &c, 1);
data/muchsync-6/protocol.cc:536:8:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    in.read(buf, n);
data/muchsync-6/sql_db.cc:416:15:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  while ((n = read(fd, buf, sizeof(buf))) > 0)
data/muchsync-6/xapian_sync.cc:113:15:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  while ((n = read (fd, buf, sizeof (buf))) > 0) {

ANALYSIS SUMMARY:

Hits = 33
Lines analyzed = 4477 in approximately 0.13 seconds (35780 lines/second)
Physical Source Lines of Code (SLOC) = 3749
Hits@level = [0]   0 [1]   7 [2]  13 [3]   7 [4]   6 [5]   0
Hits@level+ = [0+]  33 [1+]  33 [2+]  26 [3+]  13 [4+]   6 [5+]   0
Hits/KSLOC@level+ = [0+] 8.80235 [1+] 8.80235 [2+] 6.93518 [3+] 3.46759 [4+] 1.60043 [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.