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/silversearcher-ag-2.2.0+git20200805/src/log.c
Examining data/silversearcher-ag-2.2.0+git20200805/src/decompress.h
Examining data/silversearcher-ag-2.2.0+git20200805/src/util.h
Examining data/silversearcher-ag-2.2.0+git20200805/src/print.h
Examining data/silversearcher-ag-2.2.0+git20200805/src/util.c
Examining data/silversearcher-ag-2.2.0+git20200805/src/uthash.h
Examining data/silversearcher-ag-2.2.0+git20200805/src/options.h
Examining data/silversearcher-ag-2.2.0+git20200805/src/ignore.c
Examining data/silversearcher-ag-2.2.0+git20200805/src/main.c
Examining data/silversearcher-ag-2.2.0+git20200805/src/print_w32.c
Examining data/silversearcher-ag-2.2.0+git20200805/src/decompress.c
Examining data/silversearcher-ag-2.2.0+git20200805/src/search.c
Examining data/silversearcher-ag-2.2.0+git20200805/src/log.h
Examining data/silversearcher-ag-2.2.0+git20200805/src/ignore.h
Examining data/silversearcher-ag-2.2.0+git20200805/src/zfile.c
Examining data/silversearcher-ag-2.2.0+git20200805/src/print.c
Examining data/silversearcher-ag-2.2.0+git20200805/src/options.c
Examining data/silversearcher-ag-2.2.0+git20200805/src/scandir.h
Examining data/silversearcher-ag-2.2.0+git20200805/src/win32/config.h
Examining data/silversearcher-ag-2.2.0+git20200805/src/scandir.c
Examining data/silversearcher-ag-2.2.0+git20200805/src/lang.h
Examining data/silversearcher-ag-2.2.0+git20200805/src/lang.c
Examining data/silversearcher-ag-2.2.0+git20200805/src/search.h

FINAL RESULTS:

data/silversearcher-ag-2.2.0+git20200805/src/lang.c:174: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(regex + regex_length, extension);
data/silversearcher-ag-2.2.0+git20200805/src/log.c:66:5:  [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(stream, fmt, args);
data/silversearcher-ag-2.2.0+git20200805/src/options.c:644:18:  [4] (shell) popen:
  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.
        out_fd = popen(opts.pager, "w");
data/silversearcher-ag-2.2.0+git20200805/src/options.c:701:26:  [4] (shell) popen:
  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.
        gitconfig_file = popen("git config -z --path --get core.excludesfile 2>NUL", "r");
data/silversearcher-ag-2.2.0+git20200805/src/options.c:703:26:  [4] (shell) popen:
  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.
        gitconfig_file = popen("git config -z --path --get core.excludesfile 2>/dev/null", "r");
data/silversearcher-ag-2.2.0+git20200805/src/print.c:14:9:  [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.
#define fprintf(...) fprintf_w32(__VA_ARGS__)
data/silversearcher-ag-2.2.0+git20200805/src/print_w32.c:57:14:  [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.
        rv = vfprintf(fp, format, args);
data/silversearcher-ag-2.2.0+git20200805/src/print_w32.c:66:5:  [4] (format) vsnprintf:
  If format strings can be influenced by an attacker, they can be exploited,
  and note that sprintf variations do not always \0-terminate (CWE-134). Use
  a constant for the format specification.
    vsnprintf(buf, BUF_SIZE - 1, format, args);
data/silversearcher-ag-2.2.0+git20200805/src/uthash.h:283:9:  [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, __VA_ARGS__); \
data/silversearcher-ag-2.2.0+git20200805/src/util.c:497:5:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
    sprintf(full_path, "%s\\%s", path, d->d_name);
data/silversearcher-ag-2.2.0+git20200805/src/util.c:699:10:  [4] (format) vsnprintf:
  If format strings can be influenced by an attacker, they can be exploited,
  and note that sprintf variations do not always \0-terminate (CWE-134). Use
  a constant for the format specification.
    rv = vsnprintf(NULL, 0, fmt, args);
data/silversearcher-ag-2.2.0+git20200805/src/util.c:708:10:  [4] (format) vsnprintf:
  If format strings can be influenced by an attacker, they can be exploited,
  and note that sprintf variations do not always \0-terminate (CWE-134). Use
  a constant for the format specification.
    rv = vsnprintf(*ret, rv, fmt, args2);
data/silversearcher-ag-2.2.0+git20200805/src/options.c:148: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.
    char *term = getenv("TERM");
data/silversearcher-ag-2.2.0+git20200805/src/options.c:221:28:  [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 *home_dir = getenv("HOME");
data/silversearcher-ag-2.2.0+git20200805/src/options.c:382:18:  [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 ((ch = getopt_long(argc, argv, "A:aB:C:cDG:g:FfHhiLlm:nop:QRrSsvVtuUwW:z0", longopts, &opt_index)) != -1) {
data/silversearcher-ag-2.2.0+git20200805/src/options.c:713:43:  [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 *config_home = getenv("XDG_CONFIG_HOME");
data/silversearcher-ag-2.2.0+git20200805/src/options.c:822:25:  [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.
            base_path = realpath(path, tmp);
data/silversearcher-ag-2.2.0+git20200805/src/options.c:824:25:  [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.
            base_path = realpath(path, NULL);
data/silversearcher-ag-2.2.0+git20200805/src/options.c:846:28:  [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.
        (*base_paths)[0] = realpath(path, tmp);
data/silversearcher-ag-2.2.0+git20200805/src/options.c:848:28:  [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.
        (*base_paths)[0] = realpath(path, NULL);
data/silversearcher-ag-2.2.0+git20200805/src/util.c:639:7:  [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.
char *realpath(const char *path, char *resolved_path) {
data/silversearcher-ag-2.2.0+git20200805/src/util.h:110:7:  [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.
char *realpath(const char *path, char *resolved_path);
data/silversearcher-ag-2.2.0+git20200805/src/ignore.c:175:10:  [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).
    fp = fopen(path, "r");
data/silversearcher-ag-2.2.0+git20200805/src/lang.c:160:5:  [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(regex, "\\.(");
data/silversearcher-ag-2.2.0+git20200805/src/lang.h:9:11:  [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.
    const char *extensions[MAX_EXTENSIONS];
data/silversearcher-ag-2.2.0+git20200805/src/options.c:341: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(longopts, base_longopts, sizeof(base_longopts));
data/silversearcher-ag-2.2.0+git20200805/src/options.c:465:45:  [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).
                opts.max_matches_per_file = atoi(optarg);
data/silversearcher-ag-2.2.0+git20200805/src/options.c:530:45:  [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).
                    opts.max_search_depth = atoi(optarg);
data/silversearcher-ag-2.2.0+git20200805/src/options.c:559:36:  [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).
                    opts.workers = atoi(optarg);
data/silversearcher-ag-2.2.0+git20200805/src/print_w32.c:35: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[BUF_SIZE] = { 0 }, *ptr = buf;
data/silversearcher-ag-2.2.0+git20200805/src/scandir.c:51: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(d, entry, sizeof(struct dirent));
data/silversearcher-ag-2.2.0+git20200805/src/scandir.c:53: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(d, entry, entry->d_reclen);
data/silversearcher-ag-2.2.0+git20200805/src/search.c:287: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(file_full_path, O_RDONLY);
data/silversearcher-ag-2.2.0+git20200805/src/search.c:499: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(&new_item->key, outkey, sizeof(dirkey_t));
data/silversearcher-ag-2.2.0+git20200805/src/util.c:167: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(&word.as_chars, find + i, sizeof(uint16_t));
data/silversearcher-ag-2.2.0+git20200805/src/util.c:496: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 full_path[MAX_PATH + 1] = { 0 };
data/silversearcher-ag-2.2.0+git20200805/src/util.c:612: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(*lineptr, srcln, len);
data/silversearcher-ag-2.2.0+git20200805/src/util.c:641: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 tmp[_MAX_PATH + 1];
data/silversearcher-ag-2.2.0+git20200805/src/util.c:697: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(args2, args, sizeof(va_list));
data/silversearcher-ag-2.2.0+git20200805/src/util.h:58: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 as_chars[sizeof(uint16_t)];
data/silversearcher-ag-2.2.0+git20200805/src/zfile.c:250: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(buf, &cookie->outbuf[cookie->outbuf_start],
data/silversearcher-ag-2.2.0+git20200805/src/ignore.c:109:24:  [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 (pattern_len = strlen(pattern); pattern_len > 0; pattern_len--) {
data/silversearcher-ag-2.2.0+git20200805/src/ignore.c:205:63:  [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 pcre_exec(opts.ackmate_dir_filter, NULL, dir_name, strlen(dir_name), 0, 0, NULL, 0);
data/silversearcher-ag-2.2.0+git20200805/src/ignore.c:248:24:  [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).
                pos += strlen(ig->names[i]);
data/silversearcher-ag-2.2.0+git20200805/src/ignore.c:341:24:  [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).
        filename_len = strlen(filename);
data/silversearcher-ag-2.2.0+git20200805/src/ignore.c:365:32:  [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).
                filename_len = strlen(filename);
data/silversearcher-ag-2.2.0+git20200805/src/lang.c:164:32:  [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).
        int extension_length = strlen(extension);
data/silversearcher-ag-2.2.0+git20200805/src/lang.c:202:13:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
            strncpy(pos, ext, strlen(ext));
data/silversearcher-ag-2.2.0+git20200805/src/lang.c:202:31:  [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(pos, ext, strlen(ext));
data/silversearcher-ag-2.2.0+git20200805/src/main.c:141: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).
            opts.query_len = strlen(opts.query);
data/silversearcher-ag-2.2.0+git20200805/src/options.c:777:29:  [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 (!needs_query && strlen(argv[0]) == 0) {
data/silversearcher-ag-2.2.0+git20200805/src/options.c:790: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).
    opts.query_len = strlen(opts.query);
data/silversearcher-ag-2.2.0+git20200805/src/options.c:814:24:  [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).
            path_len = strlen(path);
data/silversearcher-ag-2.2.0+git20200805/src/options.c:827:33:  [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).
                base_path_len = strlen(base_path);
data/silversearcher-ag-2.2.0+git20200805/src/print.c:362: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(path) < 3) {
data/silversearcher-ag-2.2.0+git20200805/src/search.c:375:27:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
            bytes_read += read(fd, buf, ag_min(f_len, 512));
data/silversearcher-ag-2.2.0+git20200805/src/search.c:384:27:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
            bytes_read += read(fd, buf + bytes_read, f_len);
data/silversearcher-ag-2.2.0+git20200805/src/search.c:564:33:  [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).
    base_path_len = base_path ? strlen(base_path) : 0;
data/silversearcher-ag-2.2.0+git20200805/src/search.c:629:77:  [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).
                rc = pcre_exec(opts.file_search_regex, NULL, dir_full_path, strlen(dir_full_path),
data/silversearcher-ag-2.2.0+git20200805/src/search.c:664:57:  [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).
                child_ig = init_ignore(ig, dir->d_name, strlen(dir->d_name));
data/silversearcher-ag-2.2.0+git20200805/src/uthash.h:257:34:  [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).
    HASH_FIND(hh, head, findstr, strlen(findstr), out)
data/silversearcher-ag-2.2.0+git20200805/src/uthash.h:259:37:  [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).
    HASH_ADD(hh, head, strfield[0], strlen(add->strfield), add)
data/silversearcher-ag-2.2.0+git20200805/src/uthash.h:261:41:  [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).
    HASH_REPLACE(hh, head, strfield[0], strlen(add->strfield), add, replaced)
data/silversearcher-ag-2.2.0+git20200805/src/util.c:15:26:  [1] (buffer) getc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
#define getc_unlocked(x) getc(x)

ANALYSIS SUMMARY:

Hits = 64
Lines analyzed = 6098 in approximately 0.22 seconds (27543 lines/second)
Physical Source Lines of Code (SLOC) = 5005
Hits@level = [0]  43 [1]  23 [2]  19 [3]  10 [4]  12 [5]   0
Hits@level+ = [0+] 107 [1+]  64 [2+]  41 [3+]  22 [4+]  12 [5+]   0
Hits/KSLOC@level+ = [0+] 21.3786 [1+] 12.7872 [2+] 8.19181 [3+] 4.3956 [4+] 2.3976 [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.