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/colorize-0.65/colorize.c FINAL RESULTS: data/colorize-0.65/colorize.c:410:13: [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 (conf_file, F_OK) == -1) data/colorize-0.65/colorize.c:415:9: [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 (conf_file, F_OK) != -1) data/colorize-0.65/colorize.c:1468:11: [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 (formats[FMT_GENERIC], line); data/colorize-0.65/colorize.c:1676:5: [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 (log, format_debug, program_name, "malloc'ed", (unsigned long)size, file, line); data/colorize-0.65/colorize.c:1686:5: [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 (log, format_debug, program_name, "calloc'ed", (unsigned long)(nmemb * size), file, line); data/colorize-0.65/colorize.c:1696:5: [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 (log, format_debug, program_name, "realloc'ed", (unsigned long)size, file, line); data/colorize-0.65/colorize.c:1826: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 (stderr, fmt, ap); \ data/colorize-0.65/colorize.c:509:19: [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 ((opt = getopt_long (argc, argv, "c:hV", long_opts, NULL)) != -1) data/colorize-0.65/colorize.c:1393:5: [3] (random) srand: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. srand (tv.tv_usec * tv.tv_sec); data/colorize-0.65/colorize.c:279:8: [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. static char attr[MAX_ATTRIBUTE_CHARS + 1]; data/colorize-0.65/colorize.c:470: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 str[128]; data/colorize-0.65/colorize.c:570: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 *desc_type[2] = { "--attr switch", "attr conf option" }; data/colorize-0.65/colorize.c:672: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[256 + 1]; data/colorize-0.65/colorize.c:1202: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 + 1]; data/colorize-0.65/colorize.c:1565:19: [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 val[3]; data/colorize-0.65/colorize.c:1572:27: [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). value = atoi (val); data/colorize-0.65/colorize.c:1815: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). stream = fopen (file, mode); data/colorize-0.65/colorize.c:397:16: [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). size = strlen (passwd->pw_dir) + 1 + strlen (CONF_FILE) + 1; data/colorize-0.65/colorize.c:397:46: [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). size = strlen (passwd->pw_dir) + 1 + strlen (CONF_FILE) + 1; data/colorize-0.65/colorize.c:589: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). const size_t name_len = strlen (attrs[i].name); data/colorize-0.65/colorize.c:601:17: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (attr_invalid, s, p - s); data/colorize-0.65/colorize.c:622: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). snprintf (attr + strlen (attr), 3, "%u;", val); data/colorize-0.65/colorize.c:686: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). if (strlen (line) > (sizeof (line) - 2)) data/colorize-0.65/colorize.c:729:16: [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). p += strlen (p); data/colorize-0.65/colorize.c:739: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). val = strlen (value) ? xstrdup (value) : NULL; data/colorize-0.65/colorize.c:826:70: [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). code, toupper (*name), *name, name + 1, 10 - (int)strlen (name), " ", name); data/colorize-0.65/colorize.c:828: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). printf ("\t\t{-} %s%*s%s\n", name, 13 - (int)strlen (name), " ", name); data/colorize-0.65/colorize.c:830:95: [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). printf ("\t\t{*} [Rr]%s%*s%s [--exclude-random=<foreground color>]\n", "andom", 10 - (int)strlen ("random"), " ", "random"); data/colorize-0.65/colorize.c:1004: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). else if (p == color_string + strlen (color_string) - 1) data/colorize-0.65/colorize.c:1096: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). color += strlen (entry->name); data/colorize-0.65/colorize.c:1103: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). color += strlen ("random"); data/colorize-0.65/colorize.c:1154: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). p = color + strlen (color); data/colorize-0.65/colorize.c:1173:36: [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). snprintf (attr + strlen (attr), 3, "1;"); data/colorize-0.65/colorize.c:1345:18: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if ((c = fgetc (stream)) != EOF) data/colorize-0.65/colorize.c:1510: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). return end ? end + 1 : p + strlen (p); data/colorize-0.65/colorize.c:1524: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). return start ? start : p + strlen (p); data/colorize-0.65/colorize.c:1717: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). const size_t len = strlen (str) + 1; data/colorize-0.65/colorize.c:1719:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (p, str, len); data/colorize-0.65/colorize.c:1726: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). const size_t len = strlen (str1) + strlen (str2) + 1; data/colorize-0.65/colorize.c:1726:40: [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). const size_t len = strlen (str1) + strlen (str2) + 1; data/colorize-0.65/colorize.c:1730:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (p, str1, strlen (str1)); data/colorize-0.65/colorize.c:1730: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). strncpy (p, str1, strlen (str1)); data/colorize-0.65/colorize.c:1731:10: [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). p += strlen (str1); data/colorize-0.65/colorize.c:1732:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (p, str2, strlen (str2)); data/colorize-0.65/colorize.c:1732: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). strncpy (p, str2, strlen (str2)); data/colorize-0.65/colorize.c:1733:10: [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). p += strlen (str2); data/colorize-0.65/colorize.c:1797: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). assert (strlen (str) > 0); data/colorize-0.65/colorize.c:1798: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). assert (strlen (name) > 0); ANALYSIS SUMMARY: Hits = 48 Lines analyzed = 1881 in approximately 0.08 seconds (23288 lines/second) Physical Source Lines of Code (SLOC) = 1635 Hits@level = [0] 39 [1] 31 [2] 8 [3] 2 [4] 7 [5] 0 Hits@level+ = [0+] 87 [1+] 48 [2+] 17 [3+] 9 [4+] 7 [5+] 0 Hits/KSLOC@level+ = [0+] 53.211 [1+] 29.3578 [2+] 10.3976 [3+] 5.50459 [4+] 4.28135 [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.