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/nix-2.3.7+dfsg1/src/build-remote/build-remote.cc
Examining data/nix-2.3.7+dfsg1/src/cpptoml/cpptoml.h
Examining data/nix-2.3.7+dfsg1/src/libexpr/attr-path.cc
Examining data/nix-2.3.7+dfsg1/src/libexpr/attr-set.cc
Examining data/nix-2.3.7+dfsg1/src/libexpr/common-eval-args.cc
Examining data/nix-2.3.7+dfsg1/src/libexpr/eval.cc
Examining data/nix-2.3.7+dfsg1/src/libexpr/function-trace.cc
Examining data/nix-2.3.7+dfsg1/src/libexpr/get-drvs.cc
Examining data/nix-2.3.7+dfsg1/src/libexpr/json-to-value.cc
Examining data/nix-2.3.7+dfsg1/src/libexpr/names.cc
Examining data/nix-2.3.7+dfsg1/src/libexpr/nixexpr.cc
Examining data/nix-2.3.7+dfsg1/src/libexpr/primops.cc
Examining data/nix-2.3.7+dfsg1/src/libexpr/primops/context.cc
Examining data/nix-2.3.7+dfsg1/src/libexpr/primops/fetchGit.cc
Examining data/nix-2.3.7+dfsg1/src/libexpr/primops/fetchMercurial.cc
Examining data/nix-2.3.7+dfsg1/src/libexpr/primops/fromTOML.cc
Examining data/nix-2.3.7+dfsg1/src/libexpr/value-to-json.cc
Examining data/nix-2.3.7+dfsg1/src/libexpr/value-to-xml.cc
Examining data/nix-2.3.7+dfsg1/src/libmain/common-args.cc
Examining data/nix-2.3.7+dfsg1/src/libmain/shared.cc
Examining data/nix-2.3.7+dfsg1/src/libmain/stack.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/binary-cache-store.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/build.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/builtins/buildenv.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/builtins/fetchurl.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/crypto.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/derivations.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/download.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/export-import.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/gc.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/globals.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/http-binary-cache-store.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/legacy-ssh-store.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/local-binary-cache-store.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/local-fs-store.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/local-store.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/machines.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/misc.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/nar-accessor.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/nar-info-disk-cache.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/nar-info.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/optimise-store.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/parsed-derivations.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/pathlocks.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/profiles.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/references.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/remote-fs-accessor.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/remote-store.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/s3-binary-cache-store.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/sqlite.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/ssh-store.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/ssh.cc
Examining data/nix-2.3.7+dfsg1/src/libstore/store-api.cc
Examining data/nix-2.3.7+dfsg1/src/libutil/affinity.cc
Examining data/nix-2.3.7+dfsg1/src/libutil/archive.cc
Examining data/nix-2.3.7+dfsg1/src/libutil/args.cc
Examining data/nix-2.3.7+dfsg1/src/libutil/compression.cc
Examining data/nix-2.3.7+dfsg1/src/libutil/config.cc
Examining data/nix-2.3.7+dfsg1/src/libutil/hash.cc
Examining data/nix-2.3.7+dfsg1/src/libutil/json.cc
Examining data/nix-2.3.7+dfsg1/src/libutil/logging.cc
Examining data/nix-2.3.7+dfsg1/src/libutil/serialise.cc
Examining data/nix-2.3.7+dfsg1/src/libutil/thread-pool.cc
Examining data/nix-2.3.7+dfsg1/src/libutil/util.cc
Examining data/nix-2.3.7+dfsg1/src/libutil/xml-writer.cc
Examining data/nix-2.3.7+dfsg1/src/nix-build/nix-build.cc
Examining data/nix-2.3.7+dfsg1/src/nix-channel/nix-channel.cc
Examining data/nix-2.3.7+dfsg1/src/nix-collect-garbage/nix-collect-garbage.cc
Examining data/nix-2.3.7+dfsg1/src/nix-copy-closure/nix-copy-closure.cc
Examining data/nix-2.3.7+dfsg1/src/nix-daemon/nix-daemon.cc
Examining data/nix-2.3.7+dfsg1/src/nix-env/nix-env.cc
Examining data/nix-2.3.7+dfsg1/src/nix-env/user-env.cc
Examining data/nix-2.3.7+dfsg1/src/nix-instantiate/nix-instantiate.cc
Examining data/nix-2.3.7+dfsg1/src/nix-prefetch-url/nix-prefetch-url.cc
Examining data/nix-2.3.7+dfsg1/src/nix-store/dotgraph.cc
Examining data/nix-2.3.7+dfsg1/src/nix-store/graphml.cc
Examining data/nix-2.3.7+dfsg1/src/nix-store/nix-store.cc
Examining data/nix-2.3.7+dfsg1/src/nix/add-to-store.cc
Examining data/nix-2.3.7+dfsg1/src/nix/build.cc
Examining data/nix-2.3.7+dfsg1/src/nix/cat.cc
Examining data/nix-2.3.7+dfsg1/src/nix/command.cc
Examining data/nix-2.3.7+dfsg1/src/nix/copy.cc
Examining data/nix-2.3.7+dfsg1/src/nix/doctor.cc
Examining data/nix-2.3.7+dfsg1/src/nix/dump-path.cc
Examining data/nix-2.3.7+dfsg1/src/nix/edit.cc
Examining data/nix-2.3.7+dfsg1/src/nix/eval.cc
Examining data/nix-2.3.7+dfsg1/src/nix/hash.cc
Examining data/nix-2.3.7+dfsg1/src/nix/installables.cc
Examining data/nix-2.3.7+dfsg1/src/nix/legacy.cc
Examining data/nix-2.3.7+dfsg1/src/nix/log.cc
Examining data/nix-2.3.7+dfsg1/src/nix/ls.cc
Examining data/nix-2.3.7+dfsg1/src/nix/main.cc
Examining data/nix-2.3.7+dfsg1/src/nix/optimise-store.cc
Examining data/nix-2.3.7+dfsg1/src/nix/path-info.cc
Examining data/nix-2.3.7+dfsg1/src/nix/ping-store.cc
Examining data/nix-2.3.7+dfsg1/src/nix/progress-bar.cc
Examining data/nix-2.3.7+dfsg1/src/nix/repl.cc
Examining data/nix-2.3.7+dfsg1/src/nix/run.cc
Examining data/nix-2.3.7+dfsg1/src/nix/search.cc
Examining data/nix-2.3.7+dfsg1/src/nix/show-config.cc
Examining data/nix-2.3.7+dfsg1/src/nix/show-derivation.cc
Examining data/nix-2.3.7+dfsg1/src/nix/sigs.cc
Examining data/nix-2.3.7+dfsg1/src/nix/upgrade-nix.cc
Examining data/nix-2.3.7+dfsg1/src/nix/verify.cc
Examining data/nix-2.3.7+dfsg1/src/nix/why-depends.cc
Examining data/nix-2.3.7+dfsg1/src/resolve-system-dependencies/resolve-system-dependencies.cc
Examining data/nix-2.3.7+dfsg1/tests/plugins/plugintest.cc

FINAL RESULTS:

data/nix-2.3.7+dfsg1/src/libstore/build.cc:1836:9:  [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(path.c_str(), mode) == -1)
data/nix-2.3.7+dfsg1/src/libstore/build.cc:2082:26:  [5] (race) chown:
  This accepts filename arguments; if an attacker can move those files, a
  race condition results. (CWE-362). Use fchown( ) instead.
        if (buildUser && chown(chrootRootDir.c_str(), 0, buildUser->getGID()) == -1)
data/nix-2.3.7+dfsg1/src/libstore/build.cc:2126:26:  [5] (race) chown:
  This accepts filename arguments; if an attacker can move those files, a
  race condition results. (CWE-362). Use fchown( ) instead.
        if (buildUser && chown(chrootStoreDir.c_str(), 0, buildUser->getGID()) == -1)
data/nix-2.3.7+dfsg1/src/libstore/build.cc:2251:13:  [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(slaveName.c_str(), 0600))
data/nix-2.3.7+dfsg1/src/libstore/build.cc:2254:13:  [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(slaveName.c_str(), buildUser->getUID(), 0))
data/nix-2.3.7+dfsg1/src/libstore/build.cc:2657:9:  [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(path.c_str(), buildUser->getUID(), buildUser->getGID()) == -1)
data/nix-2.3.7+dfsg1/src/libstore/build.cc:2690:67:  [5] (race) chmod:
  This accepts filename arguments; if an attacker can move those files, a
  race condition results. (CWE-362). Use fchmod( ) instead.
        if (seccomp_rule_add(ctx, SCMP_ACT_ERRNO(EPERM), SCMP_SYS(chmod), 1,
data/nix-2.3.7+dfsg1/src/libstore/build.cc:3688:13:  [5] (race) chmod:
  This accepts filename arguments; if an attacker can move those files, a
  race condition results. (CWE-362). Use fchmod( ) instead.
            chmod(tmpDir.c_str(), 0755);
data/nix-2.3.7+dfsg1/src/libstore/builtins/fetchurl.cc:56:17:  [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(storePath.c_str(), 0755) == -1)
data/nix-2.3.7+dfsg1/src/libstore/gc.cc:349:16:  [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.
    auto res = readlink(file.c_str(), buf, bufsiz);
data/nix-2.3.7+dfsg1/src/libstore/gc.cc:556:17:  [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(realPath.c_str(), st.st_mode | S_IWUSR) == -1)
data/nix-2.3.7+dfsg1/src/libstore/local-store.cc:75:13:  [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(perUserDir.c_str(), 0755) == -1)
data/nix-2.3.7+dfsg1/src/libstore/local-store.cc:96:21:  [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(realStoreDir.c_str(), 0, gr->gr_gid) == -1)
data/nix-2.3.7+dfsg1/src/libstore/local-store.cc:98:21:  [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(realStoreDir.c_str(), perm) == -1)
data/nix-2.3.7+dfsg1/src/libstore/local-store.cc:395:17:  [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(path.c_str(), mode) == -1)
data/nix-2.3.7+dfsg1/src/libstore/local-store.cc:504:13:  [5] (race) chown:
  This accepts filename arguments; if an attacker can move those files, a
  race condition results. (CWE-362). Use fchown( ) instead.
            chown(path.c_str(), geteuid(), getegid()) == -1)
data/nix-2.3.7+dfsg1/src/libstore/local-store.cc:1445:13:  [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(dir.c_str(), 0755) == -1)
data/nix-2.3.7+dfsg1/src/libstore/local-store.cc:1447:13:  [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(dir.c_str(), userId, getgid()) == -1)
data/nix-2.3.7+dfsg1/src/libstore/optimise-store.cc:23:9:  [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(path.c_str(), st.st_mode | S_IWUSR) == -1)
data/nix-2.3.7+dfsg1/src/libutil/util.cc:249:26:  [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.
        ssize_t rlSize = readlink(path.c_str(), buf.data(), bufSize);
data/nix-2.3.7+dfsg1/src/libutil/util.cc:406:17:  [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(path.c_str(), st.st_mode | PERM_MASK) == -1)
data/nix-2.3.7+dfsg1/src/libutil/util.cc:467:17:  [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(tmpDir.c_str(), (uid_t) -1, getegid()) != 0)
data/nix-2.3.7+dfsg1/src/libexpr/get-drvs.cc:63:12:  [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.
    return system;
data/nix-2.3.7+dfsg1/src/libmain/shared.cc:275:5:  [4] (shell) execlp:
  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.
    execlp("man", "man", name.c_str(), nullptr);
data/nix-2.3.7+dfsg1/src/libmain/shared.cc:337:13:  [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("/bin/sh", "sh", "-c", pager, nullptr);
data/nix-2.3.7+dfsg1/src/libmain/shared.cc:338:9:  [4] (shell) execlp:
  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.
        execlp("pager", "pager", nullptr);
data/nix-2.3.7+dfsg1/src/libmain/shared.cc:339:9:  [4] (shell) execlp:
  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.
        execlp("less", "less", nullptr);
data/nix-2.3.7+dfsg1/src/libmain/shared.cc:340:9:  [4] (shell) execlp:
  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.
        execlp("more", "more", nullptr);
data/nix-2.3.7+dfsg1/src/libstore/build.cc:699:9:  [4] (shell) execv:
  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.
        execv(settings.buildHook.get().c_str(), stringsToCharPtrs(args).data());
data/nix-2.3.7+dfsg1/src/libstore/globals.cc:100:9:  [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("/dev/kvm", R_OK | W_OK) == 0)
data/nix-2.3.7+dfsg1/src/libstore/local-store.cc:293:9:  [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(dbDir.c_str(), R_OK | W_OK))
data/nix-2.3.7+dfsg1/src/libstore/nar-info.cc:104:10:  [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.
    if (!system.empty())
data/nix-2.3.7+dfsg1/src/libstore/remote-store.cc:121:5:  [4] (buffer) strcpy:
  Does not check for buffer overflows when copying to destination [MS-banned]
  (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy
  easily misused).
    strcpy(addr.sun_path, socketPath.c_str());
data/nix-2.3.7+dfsg1/src/libstore/ssh.cc:66: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(args.begin()->c_str(), stringsToCharPtrs(args).data());
data/nix-2.3.7+dfsg1/src/libstore/ssh.cc:116: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(args.begin()->c_str(), stringsToCharPtrs(args).data());
data/nix-2.3.7+dfsg1/src/libstore/store-api.cc:918:13:  [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(stateDir.c_str(), R_OK | W_OK) == 0)
data/nix-2.3.7+dfsg1/src/libutil/util.cc:1076:13:  [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(options.program.c_str(), stringsToCharPtrs(args_).data());
data/nix-2.3.7+dfsg1/src/libutil/util.cc:1078:13:  [4] (shell) execv:
  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.
            execv(options.program.c_str(), stringsToCharPtrs(args_).data());
data/nix-2.3.7+dfsg1/src/nix-build/nix-build.cc:453: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(shell.c_str(), argPtrs.data());
data/nix-2.3.7+dfsg1/src/nix-collect-garbage/nix-collect-garbage.cc:22:9:  [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(dir.c_str(), R_OK) != 0) return;
data/nix-2.3.7+dfsg1/src/nix-collect-garbage/nix-collect-garbage.cc:24:21:  [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.
    bool canWrite = access(dir.c_str(), W_OK) == 0;
data/nix-2.3.7+dfsg1/src/nix-daemon/nix-daemon.cc:972:9:  [4] (buffer) strcpy:
  Does not check for buffer overflows when copying to destination [MS-banned]
  (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy
  easily misused).
        strcpy(addr.sun_path, socketPathRel.c_str());
data/nix-2.3.7+dfsg1/src/nix-daemon/nix-daemon.cc:1110:17:  [4] (buffer) strcpy:
  Does not check for buffer overflows when copying to destination [MS-banned]
  (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy
  easily misused).
                strcpy(addr.sun_path, socketName.c_str());
data/nix-2.3.7+dfsg1/src/nix-env/user-env.cc:61:14:  [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.
        if (!system.empty())
data/nix-2.3.7+dfsg1/src/nix-env/user-env.cc:62:58:  [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.
            mkString(*state.allocAttr(v, state.sSystem), system);
data/nix-2.3.7+dfsg1/src/nix/edit.cc:75: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(args.front().c_str(), stringsToCharPtrs(args).data());
data/nix-2.3.7+dfsg1/src/nix/repl.cc:390: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(program.c_str(), stringsToCharPtrs(args2).data());
data/nix-2.3.7+dfsg1/src/nix/run.cc:174:13:  [4] (shell) execv:
  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.
            execv(readLink("/proc/self/exe").c_str(), stringsToCharPtrs(helperArgs).data());
data/nix-2.3.7+dfsg1/src/nix/run.cc:179: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(cmd.c_str(), stringsToCharPtrs(args).data());
data/nix-2.3.7+dfsg1/src/nix/run.cc:253: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(cmd.c_str(), stringsToCharPtrs(args).data());
data/nix-2.3.7+dfsg1/src/cpptoml/cpptoml.h:1863:23:  [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.
                input.setstate(std::ios::eofbit);
data/nix-2.3.7+dfsg1/src/libexpr/eval.cc:222:10:  [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.
    if (!getenv("GC_INITIAL_HEAP_SIZE")) {
data/nix-2.3.7+dfsg1/src/libmain/shared.cc:152:5:  [3] (random) srandom:
  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.
    srandom(tv.tv_usec);
data/nix-2.3.7+dfsg1/src/libmain/shared.cc:323: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 * pager = getenv("NIX_PAGER");
data/nix-2.3.7+dfsg1/src/libmain/shared.cc:324: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.
    if (!pager) pager = getenv("PAGER");
data/nix-2.3.7+dfsg1/src/libmain/shared.cc:333: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.
        if (!getenv("LESS"))
data/nix-2.3.7+dfsg1/src/libstore/build.cc:1532:72:  [3] (random) random:
  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.
    Path oldPath = (format("%1%.old-%2%-%3%") % storePath % getpid() % random()).str();
data/nix-2.3.7+dfsg1/src/libstore/build.cc:2909:17:  [3] (misc) chroot:
  chroot can be very helpful, but is hard to use correctly (CWE-250, CWE-22).
  Make sure the program immediately chdir("/"), closes file descriptors, and
  drops root privileges, and that all necessary files (and no more!) are in
  the new root.
            if (chroot(".") == -1)
data/nix-2.3.7+dfsg1/src/libstore/gc.cc:63:29:  [3] (random) random:
  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.
        % link % getpid() % random()).str();
data/nix-2.3.7+dfsg1/src/libstore/optimise-store.cc:215:37:  [3] (random) random:
  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.
        % realStoreDir % getpid() % random()).str();
data/nix-2.3.7+dfsg1/src/libstore/sqlite.cc:194:18:  [3] (random) random:
  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.
    t.tv_nsec = (random() % 100) * 1000 * 1000; /* <= 0.1s */
data/nix-2.3.7+dfsg1/src/libutil/util.cc:61: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 * value = getenv(key.c_str());
data/nix-2.3.7+dfsg1/src/nix-build/nix-build.cc:434:18:  [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.
                (getenv("TZ") ? (string("export TZ='") + getenv("TZ") + "'; ") : ""),
data/nix-2.3.7+dfsg1/src/nix-build/nix-build.cc:434:58:  [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.
                (getenv("TZ") ? (string("export TZ='") + getenv("TZ") + "'; ") : ""),
data/nix-2.3.7+dfsg1/src/nix/run.cc:109:26:  [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.
                auto s = getenv(var.c_str());
data/nix-2.3.7+dfsg1/src/nix/run.cc:240:13:  [3] (misc) chroot:
  chroot can be very helpful, but is hard to use correctly (CWE-250, CWE-22).
  Make sure the program immediately chdir("/"), closes file descriptors, and
  drops root privileges, and that all necessary files (and no more!) are in
  the new root.
        if (chroot(tmpDir.c_str()) == -1)
data/nix-2.3.7+dfsg1/src/cpptoml/cpptoml.h:137: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 buf[16];
data/nix-2.3.7+dfsg1/src/libexpr/eval.cc:1373:13:  [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 + pos, lists[n]->listElems(), l * sizeof(Value *));
data/nix-2.3.7+dfsg1/src/libexpr/eval.cc:1778: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).
            fs.open(outPath, std::fstream::out);
data/nix-2.3.7+dfsg1/src/libexpr/primops.cc:1645: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(vRight->listElems(), right.data(), sizeof(Value *) * rsize);
data/nix-2.3.7+dfsg1/src/libexpr/primops.cc:1651: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(vWrong->listElems(), wrong.data(), sizeof(Value *) * wsize);
data/nix-2.3.7+dfsg1/src/libexpr/primops.cc:1680:13:  [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 + pos, lists[n].listElems(), l * sizeof(Value *));
data/nix-2.3.7+dfsg1/src/libmain/shared.cc:106: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.
    static char buf[1024];
data/nix-2.3.7+dfsg1/src/libstore/build.cc:463:21:  [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 fdDevNull = open(pathNullDevice.c_str(), O_RDWR);
data/nix-2.3.7+dfsg1/src/libstore/build.cc:579:30:  [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).
            AutoCloseFD fd = open(fnUserLock.c_str(), O_RDWR | O_CREAT | O_CLOEXEC, 0600);
data/nix-2.3.7+dfsg1/src/libstore/build.cc:2271:28:  [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).
    builderOut.writeSide = open(slaveName.c_str(), O_RDWR | O_NOCTTY);
data/nix-2.3.7+dfsg1/src/libstore/build.cc:2767:17:  [2] (buffer) strcpy:
  Does not check for buffer overflows when copying to destination [MS-banned]
  (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy
  easily misused). Risk is low because the source is a constant string.
                strcpy(ifr.ifr_name, "lo");
data/nix-2.3.7+dfsg1/src/libstore/build.cc:3655:17:  [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).
    fdLogFile = open(logFileName.c_str(), O_CREAT | O_WRONLY | O_TRUNC | O_CLOEXEC, 0666);
data/nix-2.3.7+dfsg1/src/libstore/crypto.cc:51: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 sig[crypto_sign_BYTES];
data/nix-2.3.7+dfsg1/src/libstore/crypto.cc:64: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 pk[crypto_sign_PUBLICKEYBYTES];
data/nix-2.3.7+dfsg1/src/libstore/derivations.cc:66: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 s2[s.size()];
data/nix-2.3.7+dfsg1/src/libstore/download.cc:236:13:  [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(buffer, request.data->data() + readOffset, count);
data/nix-2.3.7+dfsg1/src/libstore/download.cc:560:17:  [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/nix-2.3.7+dfsg1/src/libstore/gc.cc:39:28:  [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).
    AutoCloseFD fdGCLock = open(fnGCLock.c_str(), O_RDWR | O_CREAT | O_CLOEXEC, 0600);
data/nix-2.3.7+dfsg1/src/libstore/gc.cc:213:34:  [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).
        FDPtr fd(new AutoCloseFD(open(path.c_str(), O_CLOEXEC | O_RDWR, 0666)));
data/nix-2.3.7+dfsg1/src/libstore/gc.cc:348: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[bufsiz];
data/nix-2.3.7+dfsg1/src/libstore/local-store.cc:129:30:  [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).
            AutoCloseFD fd = open(reservedPath.c_str(), O_WRONLY | O_CREAT | O_CLOEXEC, 0600);
data/nix-2.3.7+dfsg1/src/libstore/local-store.cc:1366:22:  [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).
    AutoCloseFD fd = open(path.c_str(), O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
data/nix-2.3.7+dfsg1/src/libstore/pathlocks.cc:21: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).
    fd = open(path.c_str(), O_CLOEXEC | O_RDWR | (create ? O_CREAT : 0), 0600);
data/nix-2.3.7+dfsg1/src/libstore/remote-fs-accessor.cc:71:38:  [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).
                    AutoCloseFD fd = open(cacheFile.c_str(), O_RDONLY | O_CLOEXEC);
data/nix-2.3.7+dfsg1/src/libutil/archive.cc:48:22:  [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).
    AutoCloseFD fd = open(path.c_str(), O_RDONLY | O_CLOEXEC);
data/nix-2.3.7+dfsg1/src/libutil/archive.cc:312: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).
        fd = open(p.c_str(), O_CREAT | O_EXCL | O_WRONLY | O_CLOEXEC, 0666);
data/nix-2.3.7+dfsg1/src/libutil/hash.cc:63: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[hash.hashSize * 2];
data/nix-2.3.7+dfsg1/src/libutil/hash.cc:201: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(hash, d.data(), hashSize);
data/nix-2.3.7+dfsg1/src/libutil/hash.cc:263:22:  [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).
    AutoCloseFD fd = open(path.c_str(), O_RDONLY | O_CLOEXEC);
data/nix-2.3.7+dfsg1/src/libutil/json.cc:88: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).
void JSONList::open()
data/nix-2.3.7+dfsg1/src/libutil/json.cc:119: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).
void JSONObject::open()
data/nix-2.3.7+dfsg1/src/libutil/serialise.cc:29: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(buffer.get() + bufPos, data, n);
data/nix-2.3.7+dfsg1/src/libutil/serialise.cc:118: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(data, buffer.get() + bufPosOut, n);
data/nix-2.3.7+dfsg1/src/libutil/serialise.cc:204:13:  [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, (unsigned char *) cur.data() + pos, n);
data/nix-2.3.7+dfsg1/src/libutil/serialise.cc:218:18:  [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 zero[8];
data/nix-2.3.7+dfsg1/src/libutil/serialise.cc:263:18:  [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 zero[8];
data/nix-2.3.7+dfsg1/src/libutil/util.cc:107:13:  [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/nix-2.3.7+dfsg1/src/libutil/util.cc:320:22:  [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).
    AutoCloseFD fd = open(path.c_str(), O_RDONLY | O_CLOEXEC);
data/nix-2.3.7+dfsg1/src/libutil/util.cc:329:22:  [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).
    AutoCloseFD fd = open(path.c_str(), O_RDONLY | O_CLOEXEC);
data/nix-2.3.7+dfsg1/src/libutil/util.cc:337:22:  [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).
    AutoCloseFD fd = open(path.c_str(), O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, mode);
data/nix-2.3.7+dfsg1/src/libutil/util.cc:346:22:  [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).
    AutoCloseFD fd = open(path.c_str(), O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, mode);
data/nix-2.3.7+dfsg1/src/libutil/util.cc:941:30:  [2] (race) vfork:
  On some old systems, vfork() permits race conditions, and it's very
  difficult to use correctly (CWE-362). Use fork() instead.
    pid_t pid = allowVfork ? vfork() : fork();
data/nix-2.3.7+dfsg1/src/libutil/util.cc:1406: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 decode[256];
data/nix-2.3.7+dfsg1/src/nix-channel/nix-channel.cc:38:35:  [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 channelsFD = AutoCloseFD{open(channelsList.c_str(), O_WRONLY | O_CLOEXEC | O_CREAT | O_TRUNC, 0644)};
data/nix-2.3.7+dfsg1/src/nix-prefetch-url/nix-prefetch-url.cc:177:34:  [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).
                AutoCloseFD fd = open(tmpFile.c_str(), O_WRONLY | O_CREAT | O_EXCL, 0600);
data/nix-2.3.7+dfsg1/src/nix-store/nix-store.cc:993: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 pk[crypto_sign_PUBLICKEYBYTES];
data/nix-2.3.7+dfsg1/src/nix-store/nix-store.cc:994: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 sk[crypto_sign_SECRETKEYBYTES];
data/nix-2.3.7+dfsg1/src/nix/search.cc:252:31:  [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).
                jsonCacheFile.open(tmpFile);
data/nix-2.3.7+dfsg1/src/resolve-system-dependencies/resolve-system-dependencies.cc:33:22:  [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).
    AutoCloseFD fd = open(filename.c_str(), O_RDONLY);
data/nix-2.3.7+dfsg1/src/libexpr/eval.cc:1882: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).
        return strlen(s) + 1;
data/nix-2.3.7+dfsg1/src/libmain/shared.cc:147:5:  [1] (access) umask:
  Ensure that umask is given most restrictive possible setting (e.g., 066 or
  077) (CWE-732).
    umask(0022);
data/nix-2.3.7+dfsg1/src/libmain/stack.cc:33:54:  [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).
            [[gnu::unused]] auto res = write(2, msg, strlen(msg));
data/nix-2.3.7+dfsg1/src/libstore/build.cc:4493:30:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
                ssize_t rd = read(k, buffer.data(), buffer.size());
data/nix-2.3.7+dfsg1/src/libstore/derivations.cc:67:9:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    str.read(s2, s.size());
data/nix-2.3.7+dfsg1/src/libstore/download.cc:561:28:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
                auto res = read(extraFDs[0].fd, buf, sizeof(buf));
data/nix-2.3.7+dfsg1/src/libstore/local-store.cc:1015:35:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
                size_t n = source.read(data, len);
data/nix-2.3.7+dfsg1/src/libstore/remote-store.cc:762:44:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
            writeString(buf.get(), source->read(buf.get(), len), to);
data/nix-2.3.7+dfsg1/src/libutil/archive.cc:369:25:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
        auto n = source.read(data, len);
data/nix-2.3.7+dfsg1/src/libutil/hash.cc:268:17:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    while ((n = read(fd.get(), buf.data(), buf.size()))) {
data/nix-2.3.7+dfsg1/src/libutil/json.cc:24:52:  [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 (!s) str << "null"; else toJSON(str, s, s + strlen(s));
data/nix-2.3.7+dfsg1/src/libutil/serialise.cc:87:20:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
        size_t n = read(data, len);
data/nix-2.3.7+dfsg1/src/libutil/serialise.cc:100:17:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
            n = read(buf.data(), buf.size());
data/nix-2.3.7+dfsg1/src/libutil/serialise.cc:110:24:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
size_t BufferedSource::read(unsigned char * data, size_t len)
data/nix-2.3.7+dfsg1/src/libutil/serialise.cc:136:15:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
        n = ::read(fd, (char *) data, len);
data/nix-2.3.7+dfsg1/src/libutil/serialise.cc:151:22:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
size_t StringSource::read(unsigned char * data, size_t len)
data/nix-2.3.7+dfsg1/src/libutil/serialise.cc:185:16:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
        size_t read(unsigned char * data, size_t len) override
data/nix-2.3.7+dfsg1/src/libutil/util.cc:354:29:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
            auto n = source.read(buf.data(), buf.size());
data/nix-2.3.7+dfsg1/src/libutil/util.cc:368:22:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
        ssize_t rd = read(fd, &ch, 1);
data/nix-2.3.7+dfsg1/src/libutil/util.cc:595:23:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
        ssize_t res = read(fd, (char *) buf, count);
data/nix-2.3.7+dfsg1/src/libutil/util.cc:656:22:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
        ssize_t rd = read(fd, buf.data(), buf.size());
data/nix-2.3.7+dfsg1/src/libutil/util.cc:1103:37:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
                        n = source->read(buf.data(), buf.size());
data/nix-2.3.7+dfsg1/src/nix-daemon/nix-daemon.cc:42:23:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    auto read_count = read(fd_in, buf.data(), buf.size());
data/nix-2.3.7+dfsg1/src/nix-daemon/nix-daemon.cc:979:26:  [1] (access) umask:
  Ensure that umask is given most restrictive possible setting (e.g., 066 or
  077) (CWE-732).
        mode_t oldMode = umask(0111);
data/nix-2.3.7+dfsg1/src/nix-daemon/nix-daemon.cc:981:9:  [1] (access) umask:
  Ensure that umask is given most restrictive possible setting (e.g., 066 or
  077) (CWE-732).
        umask(oldMode);
data/nix-2.3.7+dfsg1/src/nix-daemon/nix-daemon.cc:1053:21:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
                    strncpy(argv[1], processName.c_str(), strlen(argv[1]));
data/nix-2.3.7+dfsg1/src/nix-daemon/nix-daemon.cc:1053:59:  [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).
                    strncpy(argv[1], processName.c_str(), strlen(argv[1]));
data/nix-2.3.7+dfsg1/src/nix-store/nix-store.cc:999:5:  [1] (access) umask:
  Ensure that umask is given most restrictive possible setting (e.g., 066 or
  077) (CWE-732).
    umask(0077);
data/nix-2.3.7+dfsg1/src/nix/repl.cc:147:52:  [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).
    auto *res = strdup(possible.begin()->c_str() + strlen(s));
data/nix-2.3.7+dfsg1/src/nix/repl.cc:159:20:  [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 start = strlen(s);

ANALYSIS SUMMARY:

Hits = 145
Lines analyzed = 40699 in approximately 1.31 seconds (31051 lines/second)
Physical Source Lines of Code (SLOC) = 30116
Hits@level = [0]   0 [1]  30 [2]  49 [3]  16 [4]  28 [5]  22
Hits@level+ = [0+] 145 [1+] 145 [2+] 115 [3+]  66 [4+]  50 [5+]  22
Hits/KSLOC@level+ = [0+] 4.81472 [1+] 4.81472 [2+] 3.81857 [3+] 2.19153 [4+] 1.66025 [5+] 0.730509
Dot directories skipped = 2 (--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.