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/pigz-2.4/pigz.c Examining data/pigz-2.4/try.c Examining data/pigz-2.4/try.h Examining data/pigz-2.4/yarn.c Examining data/pigz-2.4/yarn.h Examining data/pigz-2.4/zopfli/src/zopfli/blocksplitter.c Examining data/pigz-2.4/zopfli/src/zopfli/blocksplitter.h Examining data/pigz-2.4/zopfli/src/zopfli/cache.c Examining data/pigz-2.4/zopfli/src/zopfli/cache.h Examining data/pigz-2.4/zopfli/src/zopfli/deflate.c Examining data/pigz-2.4/zopfli/src/zopfli/deflate.h Examining data/pigz-2.4/zopfli/src/zopfli/hash.c Examining data/pigz-2.4/zopfli/src/zopfli/hash.h Examining data/pigz-2.4/zopfli/src/zopfli/katajainen.c Examining data/pigz-2.4/zopfli/src/zopfli/katajainen.h Examining data/pigz-2.4/zopfli/src/zopfli/lz77.c Examining data/pigz-2.4/zopfli/src/zopfli/lz77.h Examining data/pigz-2.4/zopfli/src/zopfli/squeeze.c Examining data/pigz-2.4/zopfli/src/zopfli/squeeze.h Examining data/pigz-2.4/zopfli/src/zopfli/tree.c Examining data/pigz-2.4/zopfli/src/zopfli/tree.h Examining data/pigz-2.4/zopfli/src/zopfli/util.c Examining data/pigz-2.4/zopfli/src/zopfli/util.h Examining data/pigz-2.4/zopfli/src/zopfli/zopfli.h FINAL RESULTS: data/pigz-2.4/pigz.c:384:11: [5] (race) chown: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchown( ) instead. # define chown(p,o,g) 0 data/pigz-2.4/pigz.c:3603:11: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. (void)chmod(to, st.st_mode & 07777); data/pigz-2.4/pigz.c:3606:11: [5] (race) chown: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchown( ) instead. (void)chown(to, st.st_uid, st.st_gid); data/pigz-2.4/pigz.c:566: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, fmt, ap); data/pigz-2.4/pigz.c:733: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(msg, MAXMSG, fmt, ap); data/pigz-2.4/pigz.c:736: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(me->msg, msg); data/pigz-2.4/pigz.c:2911: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(mod, ctime(&g.stamp)); data/pigz-2.4/pigz.c:2914: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(mod + 11, mod + 19); data/pigz-2.4/pigz.c:2955: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(sizeof(off_t) == sizeof(long) ? data/pigz-2.4/pigz.c:2959: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(sizeof(off_t) == sizeof(long) ? data/pigz-2.4/pigz.c:3869: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(g.outf + pre + len, sufx); data/pigz-2.4/try.c:59:15: [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. len = vsnprintf(nul, 1, fmt, ap1); data/pigz-2.4/try.c:65:13: [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(why, len + 1, fmt, ap2); data/pigz-2.4/pigz.c:4346: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. opts = getenv("GZIP"); data/pigz-2.4/pigz.c:4365: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. opts = getenv("PIGZ"); data/pigz-2.4/pigz.c:540: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 in_buf[BUF]; // input buffer data/pigz-2.4/pigz.c:551: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 in_buf2[BUF]; // second buffer for parallel reads data/pigz-2.4/pigz.c:727: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 msg[MAXMSG]; data/pigz-2.4/pigz.c:901: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(*mem + off, cpy, len); data/pigz-2.4/pigz.c:1688:21: [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(temp->buf, job->out->buf + (len - left), left); data/pigz-2.4/pigz.c:1705:17: [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(temp->buf + temp->len, job->in->buf, job->in->len); data/pigz-2.4/pigz.c:1792:21: [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(job->out->buf + job->out->len, out, outsize); data/pigz-2.4/pigz.c:2089:17: [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(curr->buf + curr->len, next->buf, len); data/pigz-2.4/pigz.c:2103:17: [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(next->buf, curr->buf + (curr->len - left), left); data/pigz-2.4/pigz.c:2131:17: [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(dict->buf, job->out->buf + (job->out->len - len), len); data/pigz-2.4/pigz.c:2132:17: [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(dict->buf + len, curr->buf, curr->len); data/pigz-2.4/pigz.c:2265:17: [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(next, in + ((start + more) - left), left); data/pigz-2.4/pigz.c:2299:21: [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(scan, next + start, left); data/pigz-2.4/pigz.c:2774:17: [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(next, g.in_next, g.in_left); data/pigz-2.4/pigz.c:2780: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(next, g.in_next, fname); data/pigz-2.4/pigz.c:2890: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 mod[26]; // modification time in text data/pigz-2.4/pigz.c:2891: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 tag[NAMEMAX1+1]; // header or file name, possibly truncated data/pigz-2.4/pigz.c:2907:9: [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(tag + max - 3, "..."); data/pigz-2.4/pigz.c:2917:9: [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(mod + 4, "------ -----"); data/pigz-2.4/pigz.c:2973: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 tail[8]; // trailer containing check and length data/pigz-2.4/pigz.c:3046: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(tail, g.in_next + (g.in_left - 8), 8); data/pigz-2.4/pigz.c:3056: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(tail, g.in_next + (g.in_left - n), n); data/pigz-2.4/pigz.c:3066:21: [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(tail, tail + n - (8 - g.in_left), 8 - g.in_left); data/pigz-2.4/pigz.c:3067:17: [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(tail + 8 - g.in_left, g.in_next, g.in_left); data/pigz-2.4/pigz.c:3071: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(tail, g.in_next + (g.in_left - 8), 8); data/pigz-2.4/pigz.c:3114:16: [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. local unsigned char out_buf[OUTSIZE]; data/pigz-2.4/pigz.c:3118:16: [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. local unsigned char out_copy[OUTSIZE]; data/pigz-2.4/pigz.c:3201: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(out_copy, buf, len); data/pigz-2.4/pigz.c:3404: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 suffix[65536]; // one-character LZW suffix data/pigz-2.4/pigz.c:3405: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 match[65280 + 2]; // buffer for reversed match data/pigz-2.4/pigz.c:3776: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). g.ind = open(g.inf, O_RDONLY, 0); data/pigz-2.4/pigz.c:3838:9: [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(g.outf, "<stdout>"); data/pigz-2.4/pigz.c:3867: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(g.outf, g.inf, pre); data/pigz-2.4/pigz.c:3868: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(g.outf + pre, to, len); data/pigz-2.4/pigz.c:3870: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). g.outd = open(g.outf, O_CREAT | O_TRUNC | O_WRONLY | data/pigz-2.4/pigz.c:3886:26: [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). g.outd = open(g.outf, O_CREAT | O_TRUNC | O_WRONLY, data/pigz-2.4/pigz.c:4135: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 bad[3] = "-X"; // for error messages (X is replaced) data/pigz-2.4/try.c:53: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 *why, nul[1]; data/pigz-2.4/zopfli/src/zopfli/squeeze.c:51:3: [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(dest->litlens, source->litlens, 288 * sizeof(dest->litlens[0])); data/pigz-2.4/zopfli/src/zopfli/squeeze.c:52:3: [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(dest->dists, source->dists, 32 * sizeof(dest->dists[0])); data/pigz-2.4/zopfli/src/zopfli/squeeze.c:54:3: [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(dest->ll_symbols, source->ll_symbols, data/pigz-2.4/zopfli/src/zopfli/squeeze.c:56:3: [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(dest->d_symbols, source->d_symbols, 32 * sizeof(dest->d_symbols[0])); data/pigz-2.4/pigz.c:735:27: [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). me->msg = alloc(NULL, strlen(msg) + 1); data/pigz-2.4/pigz.c:909: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). return vmemcpy(str, size, off, cpy, strlen(cpy) + 1); data/pigz-2.4/pigz.c:919:15: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ret = read(desc, buf, len); data/pigz-2.4/pigz.c:1045:45: [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). 2, (val_t)(g.name == NULL ? 1 : strlen(g.name)), // name length data/pigz-2.4/pigz.c:1051:44: [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). g.name == NULL ? 1 : strlen(g.name)); data/pigz-2.4/pigz.c:1088:43: [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). len += writen(g.outd, g.name, strlen(g.name) + 1); data/pigz-2.4/pigz.c:1122:45: [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). 2, (val_t)(g.name == NULL ? 1 : strlen(g.name)), // name length data/pigz-2.4/pigz.c:1133:45: [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). g.name == NULL ? 1 : strlen(g.name)); data/pigz-2.4/pigz.c:2857: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). len = strlen(nm); data/pigz-2.4/pigz.c:2897:9: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(tag, "<...>", max + 1); data/pigz-2.4/pigz.c:2899:13: [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). n = strlen(g.inf) - compressed_suffix(g.inf); data/pigz-2.4/pigz.c:2900:9: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(tag, g.inf, n > max + 1 ? max + 1 : n); data/pigz-2.4/pigz.c:2902:13: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). Risk is low because the source is a constant string. strncpy(tag + n, ".tar", max + 1 - n); data/pigz-2.4/pigz.c:2905:9: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(tag, g.hname, max + 1); data/pigz-2.4/pigz.c:3676:15: [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). len = strlen(g.inf); data/pigz-2.4/pigz.c:3700:19: [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). len = strlen(g.inf); data/pigz-2.4/pigz.c:3746:45: [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 (off = 0; roll[off]; off += strlen(roll + off) + 1) { data/pigz-2.4/pigz.c:3758:56: [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 (!(g.force || g.list || g.decode) && len >= strlen(g.sufx) && data/pigz-2.4/pigz.c:3759:38: [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). strcmp(g.inf + len - strlen(g.sufx), g.sufx) == 0) { data/pigz-2.4/pigz.c:3837: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). g.outf = alloc(NULL, strlen("<stdout>") + 1); data/pigz-2.4/pigz.c:3855:23: [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). len = strlen(to); data/pigz-2.4/pigz.c:3866:42: [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). g.outf = alloc(NULL, pre + len + strlen(sufx) + 1); data/pigz-2.4/pigz.c:3881:22: [1] (buffer) getchar: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). ch = getchar(); data/pigz-2.4/pigz.c:4389:18: [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 ((k = strlen(g.prog)) > 2 && strcmp(g.prog + k - 3, "cat") == 0) { ANALYSIS SUMMARY: Hits = 81 Lines analyzed = 9402 in approximately 0.30 seconds (31542 lines/second) Physical Source Lines of Code (SLOC) = 5876 Hits@level = [0] 24 [1] 24 [2] 42 [3] 2 [4] 10 [5] 3 Hits@level+ = [0+] 105 [1+] 81 [2+] 57 [3+] 15 [4+] 13 [5+] 3 Hits/KSLOC@level+ = [0+] 17.8693 [1+] 13.7849 [2+] 9.70048 [3+] 2.55276 [4+] 2.21239 [5+] 0.510551 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.