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/xcwd-0~2.gbpe2c777c/xcwd.c

FINAL RESULTS:

data/xcwd-0~2.gbpe2c777c/xcwd.c:236: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.
    if ((len = readlink(path, buf, 255)) != -1)
data/xcwd-0~2.gbpe2c777c/xcwd.c:32:21:  [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.
    do { if (DEBUG) fprintf(stderr, fmt, __VA_ARGS__); } while (0)
data/xcwd-0~2.gbpe2c777c/xcwd.c:243: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(buf, F_OK))
data/xcwd-0~2.gbpe2c777c/xcwd.c:252: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(proc->cwd, F_OK))
data/xcwd-0~2.gbpe2c777c/xcwd.c:322:13:  [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(key.name, strings + i);
data/xcwd-0~2.gbpe2c777c/xcwd.c:290:29:  [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.
    fprintf(stdout, "%s\n", getenv("HOME"));
data/xcwd-0~2.gbpe2c777c/xcwd.c:41: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 name[32];
data/xcwd-0~2.gbpe2c777c/xcwd.c:43: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 cwd[MAXPATHLEN];
data/xcwd-0~2.gbpe2c777c/xcwd.c:159: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 line[201] = {0};
data/xcwd-0~2.gbpe2c777c/xcwd.c:167: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 name[32];
data/xcwd-0~2.gbpe2c777c/xcwd.c:173:14:  [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).
        tn = fopen(name, "r");
data/xcwd-0~2.gbpe2c777c/xcwd.c:177:24:  [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).
        p->ps[j].pid = atoi(strtok(line, " "));
data/xcwd-0~2.gbpe2c777c/xcwd.c:181:25:  [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).
        p->ps[j].ppid = atoi(strtok(NULL, " "));
data/xcwd-0~2.gbpe2c777c/xcwd.c:231: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[255];
data/xcwd-0~2.gbpe2c777c/xcwd.c:232: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 path[64];
data/xcwd-0~2.gbpe2c777c/xcwd.c:216:13:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
            strncpy(p->ps[i].name, kp[i].ki_tdname, 32);
data/xcwd-0~2.gbpe2c777c/xcwd.c:217:13:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
            strncpy(p->ps[i].cwd, kif->kf_path, MAXPATHLEN);
data/xcwd-0~2.gbpe2c777c/xcwd.c:248:9:  [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(proc->cwd)) {
data/xcwd-0~2.gbpe2c777c/xcwd.c:320:35:  [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).
        for(i = 0; i < size; i += strlen(strings + i) + 1) {

ANALYSIS SUMMARY:

Hits = 19
Lines analyzed = 340 in approximately 0.02 seconds (18116 lines/second)
Physical Source Lines of Code (SLOC) = 298
Hits@level = [0]   7 [1]   4 [2]   9 [3]   1 [4]   4 [5]   1
Hits@level+ = [0+]  26 [1+]  19 [2+]  15 [3+]   6 [4+]   5 [5+]   1
Hits/KSLOC@level+ = [0+] 87.2483 [1+] 63.7584 [2+] 50.3356 [3+] 20.1342 [4+] 16.7785 [5+] 3.3557
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.