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/charliecloud-0.20/bin/ch-checkns.c
Examining data/charliecloud-0.20/bin/ch-run.c
Examining data/charliecloud-0.20/bin/ch-ssh.c
Examining data/charliecloud-0.20/bin/ch_core.c
Examining data/charliecloud-0.20/bin/ch_core.h
Examining data/charliecloud-0.20/bin/ch_misc.c
Examining data/charliecloud-0.20/bin/ch_misc.h
Examining data/charliecloud-0.20/examples/chtest/chroot-escape.c
Examining data/charliecloud-0.20/examples/chtest/mknods.c
Examining data/charliecloud-0.20/examples/chtest/setgroups.c
Examining data/charliecloud-0.20/examples/chtest/setuid.c
Examining data/charliecloud-0.20/examples/mpihello/hello.c
Examining data/charliecloud-0.20/test/sotest/libsotest.c
Examining data/charliecloud-0.20/test/sotest/sotest.c
Examining data/charliecloud-0.20/test/unused/echo-euid.c

FINAL RESULTS:

data/charliecloud-0.20/bin/ch_core.c:179:17:  [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 len = readlink("/proc/self/exe", chrun_file, PATH_CHARS);
data/charliecloud-0.20/bin/ch-checkns.c:82:7:  [4] (format) fprintf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
      fprintf(stderr, usage);
data/charliecloud-0.20/bin/ch-ssh.c:41:7:  [4] (format) fprintf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
      fprintf(stderr, usage);
data/charliecloud-0.20/bin/ch-ssh.c:45:7:  [4] (format) fprintf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
      fprintf(stderr, usage);
data/charliecloud-0.20/bin/ch-ssh.c:81:4:  [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("ssh", args);
data/charliecloud-0.20/bin/ch_core.c:198:26:  [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 (!c->writable && !(access(c->newroot, W_OK) == -1 && errno == EROFS)) {
data/charliecloud-0.20/bin/ch_core.c:327:4:  [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(argv[0], argv);  // only returns if error
data/charliecloud-0.20/bin/ch_misc.c:100:7:  [4] (format) vfprintf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
      vfprintf(stderr, fmt, ap);
data/charliecloud-0.20/examples/mpihello/hello.c:85:4:  [4] (format) vfprintf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
   vfprintf(stderr, fmt, ap);
data/charliecloud-0.20/bin/ch-checkns.c:132:9:  [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.
   TRY (chroot("."));
data/charliecloud-0.20/bin/ch-checkns.c:145:9:  [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.
   TRY (chroot("."));
data/charliecloud-0.20/bin/ch-run.c:123:63:  [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.
                                                  .old_home = getenv("HOME"),
data/charliecloud-0.20/bin/ch-run.c:132:8:  [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("ARGP_HELP_FMT"))
data/charliecloud-0.20/bin/ch-run.c:143:21:  [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.
   args.c.newroot = realpath(argv[arg_next], NULL);
data/charliecloud-0.20/bin/ch-run.c:194:19:  [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.
      old_value = getenv("USER");
data/charliecloud-0.20/bin/ch-run.c:204:16:  [3] (buffer) getenv:
  Environment variables are untrustable input if they can be set by an
  attacker. They can have any content and length, and the same variable can
  be set more than once (CWE-807, CWE-20). Check environment variables
  carefully before using them.
   old_value = getenv("PATH");
data/charliecloud-0.20/bin/ch-run.c:293:16:  [3] (buffer) getenv:
  Environment variables are untrustable input if they can be set by an
  attacker. They can have any content and length, and the same variable can
  be set more than once (CWE-807, CWE-20). Check environment variables
  carefully before using them.
      *value = getenv(*name);
data/charliecloud-0.20/bin/ch-ssh.c:67: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.
   ch_run_args = getenv("CH_RUN_ARGS");
data/charliecloud-0.20/bin/ch_core.c:172:31:  [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.
      newhome = cat("/home/", getenv("USER"));
data/charliecloud-0.20/bin/ch_core.c:194:8:  [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.
   Z_ (chroot("."));
data/charliecloud-0.20/bin/ch_core.c:211:8:  [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.
   Zf (chroot("."), "can't chroot(2) into new root");
data/charliecloud-0.20/bin/ch_core.c:418:37:  [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->pw_gecos, getenv("USER")));
data/charliecloud-0.20/examples/chtest/chroot-escape.c:45:8:  [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_name)) {
data/charliecloud-0.20/examples/chtest/chroot-escape.c:61:11:  [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(".")) fatal("chroot");
data/charliecloud-0.20/bin/ch-run.c:219:19:  [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).
         Tf (fp = fopen(arg, "r"), "--set-env: can't open: %s", arg);
data/charliecloud-0.20/bin/ch-ssh.c:38:4:  [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 *args[ARGS_MAX+1];
data/charliecloud-0.20/bin/ch_core.c:178:7:  [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 chrun_file[PATH_CHARS];
data/charliecloud-0.20/bin/ch_core.c:292: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).
   fd = open(path, O_RDONLY);
data/charliecloud-0.20/bin/ch_core.c:371: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).
   T_ (-1 != (fd = open("/proc/self/uid_map", O_WRONLY)));
data/charliecloud-0.20/bin/ch_core.c:376: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).
   T_ (-1 != (fd = open("/proc/self/setgroups", O_WRONLY)));
data/charliecloud-0.20/bin/ch_core.c:379: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).
   T_ (-1 != (fd = open("/proc/self/gid_map", O_WRONLY)));
data/charliecloud-0.20/bin/ch_core.c:408:20:  [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).
   T_ (-1 != (fd = mkstemp(path)));  // mkstemp(3) writes path
data/charliecloud-0.20/bin/ch_core.c:435:20:  [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).
   T_ (-1 != (fd = mkstemp(path)));
data/charliecloud-0.20/bin/ch_misc.c:179:4:  [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 delstr[2] = { del, 0 };
data/charliecloud-0.20/examples/chtest/chroot-escape.c:43: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).
   if ((fd = open(".", O_RDONLY)) < 0) fatal("open");
data/charliecloud-0.20/examples/chtest/mknods.c:59: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).
            if (open(path, O_RDONLY) != -1) {
data/charliecloud-0.20/examples/mpihello/hello.c:28:4:  [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 hostname[HOST_NAME_MAX+1];
data/charliecloud-0.20/examples/mpihello/hello.c:29:4:  [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 mpi_version[MPI_MAX_LIBRARY_VERSION_STRING];
data/charliecloud-0.20/bin/ch-run.c:230:17:  [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 (strlen(line) == 0 || line[0] == '\n')
data/charliecloud-0.20/bin/ch-run.c:232:22:  [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 (line[strlen(line) - 1] == '\n')
data/charliecloud-0.20/bin/ch-run.c:233:21:  [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).
               line[strlen(line) - 1] = 0;  // remove newline
data/charliecloud-0.20/bin/ch-run.c:236:17:  [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).
            Te (strlen(name) != 0, "--set-env: empty name: %s:%d", arg, j);
data/charliecloud-0.20/bin/ch-run.c:237: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).
            if (   strlen(new_value) >= 2
data/charliecloud-0.20/bin/ch-run.c:239:30:  [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).
                && new_value[strlen(new_value) - 1] == '\'') {
data/charliecloud-0.20/bin/ch-run.c:240:26:  [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).
               new_value[strlen(new_value) - 1] = 0;  // strip trailing quote
data/charliecloud-0.20/bin/ch-run.c:395:11:  [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).
      Te (strlen(arg) > 0, "--unset-env: GLOB must have non-zero length");

ANALYSIS SUMMARY:

Hits = 46
Lines analyzed = 1868 in approximately 0.12 seconds (15796 lines/second)
Physical Source Lines of Code (SLOC) = 1248
Hits@level = [0]  50 [1]   8 [2]  14 [3]  15 [4]   8 [5]   1
Hits@level+ = [0+]  96 [1+]  46 [2+]  38 [3+]  24 [4+]   9 [5+]   1
Hits/KSLOC@level+ = [0+] 76.9231 [1+] 36.859 [2+] 30.4487 [3+] 19.2308 [4+] 7.21154 [5+] 0.801282
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.