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/patchelf-0.12/src/elf.h
Examining data/patchelf-0.12/src/patchelf.cc
Examining data/patchelf-0.12/tests/bar.c
Examining data/patchelf-0.12/tests/foo.c
Examining data/patchelf-0.12/tests/main.c
Examining data/patchelf-0.12/tests/no-rpath.c
Examining data/patchelf-0.12/tests/simple.c

FINAL RESULTS:

data/patchelf-0.12/src/patchelf.cc:263:9:  [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, format, ap);
data/patchelf-0.12/src/patchelf.cc:1432: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(rpath, newRPath.c_str());
data/patchelf-0.12/src/patchelf.cc:1935:13:  [4] (format) printf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
            printf(PACKAGE_STRING "\n");
data/patchelf-0.12/src/patchelf.cc:1842:9:  [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("PATCHELF_DEBUG") != 0) debugMode = true;
data/patchelf-0.12/src/elf.h:69: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	e_ident[EI_NIDENT];	/* Magic number and other info */
data/patchelf-0.12/src/elf.h:87: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	e_ident[EI_NIDENT];	/* Magic number and other info */
data/patchelf-0.12/src/patchelf.cc:334: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).
    int fd = open(fileName.c_str(), O_RDONLY);
data/patchelf-0.12/src/patchelf.cc:527: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).
    int fd = open(fileName.c_str(), O_CREAT | O_TRUNC | O_WRONLY, 0777);
data/patchelf-0.12/src/patchelf.cc:679: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(contents + curOff, (unsigned char *) i.second.c_str(),
data/patchelf-0.12/src/patchelf.cc:1853:30:  [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).
            forcedPageSize = atoi(argv[i]);
data/patchelf-0.12/tests/main.c:3:1:  [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 * 1024 * 1024];
data/patchelf-0.12/tests/simple.c:3:1:  [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 * 1024 * 1024];
data/patchelf-0.12/src/patchelf.cc:339:23:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
    while ((portion = read(fd, contents->data() + bytesRead, size - bytesRead)) > 0)
data/patchelf-0.12/src/patchelf.cc:1424: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).
        rpathSize = strlen(rpath);

ANALYSIS SUMMARY:

Hits = 14
Lines analyzed = 5319 in approximately 0.17 seconds (30411 lines/second)
Physical Source Lines of Code (SLOC) = 3927
Hits@level = [0]  13 [1]   2 [2]   8 [3]   1 [4]   3 [5]   0
Hits@level+ = [0+]  27 [1+]  14 [2+]  12 [3+]   4 [4+]   3 [5+]   0
Hits/KSLOC@level+ = [0+] 6.87548 [1+] 3.56506 [2+] 3.05577 [3+] 1.01859 [4+] 0.763942 [5+]   0
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.