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/open-adventure-1.8/actions.c Examining data/open-adventure-1.8/advent.h Examining data/open-adventure-1.8/cheat.c Examining data/open-adventure-1.8/init.c Examining data/open-adventure-1.8/main.c Examining data/open-adventure-1.8/misc.c Examining data/open-adventure-1.8/saveresume.c Examining data/open-adventure-1.8/score.c FINAL RESULTS: data/open-adventure-1.8/cheat.c:68:13: [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, data/open-adventure-1.8/cheat.c:77: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, data/open-adventure-1.8/main.c:83:13: [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, data/open-adventure-1.8/misc.c:79:27: [4] (format) snprintf: 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. int ret = snprintf(renderp, size, "%" PRId32, arg); data/open-adventure-1.8/misc.c:108:17: [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(renderp, VERSION); data/open-adventure-1.8/misc.c:137:5: [4] (format) vprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vprintf(arbitrary_messages[msg], ap); data/open-adventure-1.8/misc.c:184: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(prompt_and_input, input_prompt); data/open-adventure-1.8/misc.c:185:5: [4] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). strcat(prompt_and_input, input); data/open-adventure-1.8/misc.c:269:9: [4] (buffer) sscanf: The scanf() family's %s operation, without a limit specification, permits buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a different input function. sscanf(reply, "%s", firstword); data/open-adventure-1.8/misc.c:323:9: [4] (buffer) sscanf: The scanf() family's %s operation, without a limit specification, permits buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a different input function. sscanf(reply, "%s", firstword); data/open-adventure-1.8/misc.c:487:5: [4] (buffer) sscanf: The scanf() family's %s operation, without a limit specification, permits buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a different input function. sscanf(raw, "%s%s", cmd->word[0].raw, cmd->word[1].raw); data/open-adventure-1.8/cheat.c:42:18: [3] (buffer) getopt: 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(argc, argv, opts)) != EOF) { data/open-adventure-1.8/init.c:51: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(time(NULL)); data/open-adventure-1.8/main.c:59:18: [3] (buffer) getopt: 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(argc, argv, opts)) != EOF) { data/open-adventure-1.8/actions.c:1581:48: [2] (integer) atol: 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). return waste(command.verb, (turn_t)atol(command.word[1].raw)); data/open-adventure-1.8/advent.h:175: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 zzword[TOKLEN + 1]; // randomly generated magic word from bird data/open-adventure-1.8/advent.h:200: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 raw[LINESIZE]; data/open-adventure-1.8/cheat.c:45:35: [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). game.numdie = (turn_t)atoi(optarg); data/open-adventure-1.8/cheat.c:49:34: [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). game.limit = (turn_t)atoi(optarg); data/open-adventure-1.8/cheat.c:53:31: [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). game.saved = (int)atoi(optarg); data/open-adventure-1.8/cheat.c:57:34: [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). game.turns = (turn_t)atoi(optarg); data/open-adventure-1.8/cheat.c:61:23: [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). version = atoi(optarg); data/open-adventure-1.8/cheat.c:84: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(savefilename, WRITE_MODE); data/open-adventure-1.8/main.c:62:30: [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). settings.logfp = fopen(optarg, "w"); data/open-adventure-1.8/main.c:75:19: [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). rfp = fopen(optarg, "r"); data/open-adventure-1.8/misc.c:66:17: [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(renderp, "ground"); data/open-adventure-1.8/misc.c:520: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 inputbuf[LINESIZE]; data/open-adventure-1.8/saveresume.c:80: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). fp = fopen(name, WRITE_MODE); data/open-adventure-1.8/saveresume.c:113: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). fp = fopen(name, READ_MODE); data/open-adventure-1.8/actions.c:1089:22: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). static phase_codes_t read(command_t command) data/open-adventure-1.8/actions.c:1455:24: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). return read(command); data/open-adventure-1.8/actions.c:1554:20: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). return read(command); data/open-adventure-1.8/main.c:1049:21: [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(command->word[0].raw, "pour", LINESIZE - 1); data/open-adventure-1.8/misc.c:44: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(msg) == 0) data/open-adventure-1.8/misc.c:50: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). int msglen = strlen(msg); data/open-adventure-1.8/misc.c:90:17: [1] (buffer) strncat: Easily used incorrectly (e.g., incorrectly computing the correct maximum size to add) [MS-banned] (CWE-120). Consider strcat_s, strlcat, snprintf, or automatically resizing strings. strncat(renderp, arg, size - 1); data/open-adventure-1.8/misc.c:91: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). size_t len = strlen(renderp); data/open-adventure-1.8/misc.c:109: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). size_t len = strlen(VERSION); data/open-adventure-1.8/misc.c:182: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). size_t len = strlen(input_prompt) + strlen(input) + 1; data/open-adventure-1.8/misc.c:182: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). size_t len = strlen(input_prompt) + strlen(input) + 1; data/open-adventure-1.8/misc.c:262: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(reply) == 0) { data/open-adventure-1.8/misc.c:268: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). char* firstword = (char*) xcalloc(strlen(reply) + 1); data/open-adventure-1.8/misc.c:273: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). for (int i = 0; i < (int)strlen(firstword); ++i) data/open-adventure-1.8/misc.c:316: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(reply) == 0) { data/open-adventure-1.8/misc.c:322: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). char* firstword = (char*) xcalloc(strlen(reply) + 1); data/open-adventure-1.8/misc.c:327: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). for (int i = 0; i < (int)strlen(firstword); ++i) data/open-adventure-1.8/misc.c:362:78: [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 (strncasecmp(word, motions[i].words.strs[j], TOKLEN) == 0 && (strlen(word) > 1 || data/open-adventure-1.8/misc.c:390:78: [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 (strncasecmp(word, actions[i].words.strs[j], TOKLEN) == 0 && (strlen(word) > 1 || data/open-adventure-1.8/misc.c:505: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). for (size_t i = 0; i < strlen(cmd->word[0].raw); i++) data/open-adventure-1.8/misc.c:507: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). for (size_t i = 0; i < strlen(cmd->word[1].raw); i++) data/open-adventure-1.8/misc.c:537:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(inputbuf, input, LINESIZE - 1); ANALYSIS SUMMARY: Hits = 51 Lines analyzed = 4452 in approximately 0.18 seconds (24581 lines/second) Physical Source Lines of Code (SLOC) = 3379 Hits@level = [0] 26 [1] 22 [2] 15 [3] 3 [4] 11 [5] 0 Hits@level+ = [0+] 77 [1+] 51 [2+] 29 [3+] 14 [4+] 11 [5+] 0 Hits/KSLOC@level+ = [0+] 22.7878 [1+] 15.0932 [2+] 8.58242 [3+] 4.14324 [4+] 3.2554 [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.