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/xcowsay-1.5.1/src/Cowsay_glue.h Examining data/xcowsay-1.5.1/src/bubblegen.c Examining data/xcowsay-1.5.1/src/settings.c Examining data/xcowsay-1.5.1/src/xcowsay.c Examining data/xcowsay-1.5.1/src/i18n.h Examining data/xcowsay-1.5.1/src/display_cow.h Examining data/xcowsay-1.5.1/src/config_file.h Examining data/xcowsay-1.5.1/src/config_file.c Examining data/xcowsay-1.5.1/src/floating_shape.h Examining data/xcowsay-1.5.1/src/xcowsayd.c Examining data/xcowsay-1.5.1/src/display_cow.c Examining data/xcowsay-1.5.1/src/floating_shape.c Examining data/xcowsay-1.5.1/src/settings.h Examining data/xcowsay-1.5.1/src/xcowsayd.h FINAL RESULTS: data/xcowsay-1.5.1/src/display_cow.c:97:7: [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, i18n("Failed to load cow image: %s\n"), cow_path); data/xcowsay-1.5.1/src/display_cow.h:27:35: [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. #define debug_msg(...) if (debug) printf(__VA_ARGS__); data/xcowsay-1.5.1/src/xcowsay.c:177:7: [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, i18n("Error: %s is not a valid integer\n"), optarg); data/xcowsay-1.5.1/src/xcowsay.c:188:7: [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, failmsg, optarg); data/xcowsay-1.5.1/src/xcowsay.c:195:7: [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, failmsg, optarg); data/xcowsay-1.5.1/src/xcowsay.c:201:7: [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, failmsg, optarg); data/xcowsay-1.5.1/src/xcowsay.c:221:7: [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(p, argv[i]); data/xcowsay-1.5.1/src/xcowsay.c:354:14: [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(abs_path, R_OK) != 0) { data/xcowsay-1.5.1/src/xcowsayd.c:81:4: [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(req->message, mess); data/xcowsay-1.5.1/src/config_file.c:177:23: [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 = getenv("HOME"); data/xcowsay-1.5.1/src/config_file.c:182:34: [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 *xdg_config_home = getenv("XDG_CONFIG_HOME"); data/xcowsay-1.5.1/src/display_cow.c:257:14: [3] (random) random: 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. pick = random() % n_monitors; data/xcowsay-1.5.1/src/display_cow.c:302:15: [3] (random) random: 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. cow_x = random() % area_w; data/xcowsay-1.5.1/src/display_cow.c:308:15: [3] (random) random: 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. cow_y = random() % area_h; data/xcowsay-1.5.1/src/xcowsay.c:262:16: [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 ((c = getopt_long(argc, argv, spec, long_options, &index)) != -1) { data/xcowsay-1.5.1/src/xcowsay.c:336:4: [3] (random) srandom: 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. srandom(tv.tv_sec ^ tv.tv_usec ^ getpid()); data/xcowsay-1.5.1/src/xcowsay.c:348:27: [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 *abs_path = realpath(dream_file, NULL); data/xcowsay-1.5.1/src/config_file.c:146:12: [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). *ival = atoi(s); data/xcowsay-1.5.1/src/config_file.c:215:16: [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). FILE *frc = fopen(fname, "r"); data/xcowsay-1.5.1/src/xcowsayd.c:246:12: [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("/dev/null", O_RDWR); // fd = stdin data/xcowsay-1.5.1/src/config_file.c:81:19: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). char next = fgetc(f); data/xcowsay-1.5.1/src/display_cow.c:191:17: [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_t len = strlen(text_copy); data/xcowsay-1.5.1/src/xcowsay.c:214:14: [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(argv[i]) + (i < argc - 1 ? 1 : 0); data/xcowsay-1.5.1/src/xcowsay.c:222:12: [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(argv[i]); data/xcowsay-1.5.1/src/xcowsayd.c:78: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). req->message = malloc(strlen(mess)+1); ANALYSIS SUMMARY: Hits = 25 Lines analyzed = 2361 in approximately 0.07 seconds (33958 lines/second) Physical Source Lines of Code (SLOC) = 1748 Hits@level = [0] 17 [1] 5 [2] 3 [3] 8 [4] 9 [5] 0 Hits@level+ = [0+] 42 [1+] 25 [2+] 20 [3+] 17 [4+] 9 [5+] 0 Hits/KSLOC@level+ = [0+] 24.0275 [1+] 14.3021 [2+] 11.4416 [3+] 9.7254 [4+] 5.14874 [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.