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/komi-1.04/bitmask.h Examining data/komi-1.04/declarations.h Examining data/komi-1.04/info.h Examining data/komi-1.04/keys.h Examining data/komi-1.04/loaders.h Examining data/komi-1.04/prototypes.h Examining data/komi-1.04/gfx.h Examining data/komi-1.04/komi.c Examining data/komi-1.04/sprites.h FINAL RESULTS: data/komi-1.04/info.h:55:4: [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(stdout, INFO_GPL_BRIEF); data/komi-1.04/info.h:63:4: [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(stdout, INFO_HELP); data/komi-1.04/komi.c:148:13: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(filepath, "%s", argv[n + 1]); data/komi-1.04/komi.c:2897: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(fullpath, directory); data/komi-1.04/komi.c:2898:4: [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(fullpath, filename); data/komi-1.04/komi.c:3300: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(fullpath, directory); data/komi-1.04/komi.c:3301:4: [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(fullpath, filename); data/komi-1.04/komi.c:3651: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(fullpath, directory); data/komi-1.04/komi.c:3652:4: [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(fullpath, filename); data/komi-1.04/komi.c:3690: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(fullpath, directory); data/komi-1.04/komi.c:3691:4: [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(fullpath, filename); data/komi-1.04/komi.c:3749:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(thestring, "Komi %s - High Score: %d - Last Score: %d", VERSION, highscore, lastscore); data/komi-1.04/komi.c:3770: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(fullpath, directory); data/komi-1.04/komi.c:3771:4: [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(fullpath, filename); data/komi-1.04/komi.c:3844:10: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(prefsdir, "%s/", dir); data/komi-1.04/komi.c:3856:10: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(prefsdir, "%s/", dir); data/komi-1.04/sprites.h:155: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(fullpath, directory); data/komi-1.04/sprites.h:156:4: [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(fullpath, filename); data/komi-1.04/komi.c:211:4: [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((int)time(NULL)); data/komi-1.04/komi.c:3838:15: [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. if ((dir = getenv("HOME")) != NULL) data/komi-1.04/komi.c:3850:15: [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. if ((dir = getenv("APPDATA")) != NULL) data/komi-1.04/declarations.h:429:1: [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 filepath[TEXTBUFFERSIZE] = DATAPATH; data/komi-1.04/declarations.h:430:1: [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 prefsdir[TEXTBUFFERSIZE] = DATAPATH; data/komi-1.04/declarations.h:432:1: [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 filepath[TEXTBUFFERSIZE] = "komidata/"; data/komi-1.04/declarations.h:433:1: [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 prefsdir[TEXTBUFFERSIZE] = "komidata/"; data/komi-1.04/komi.c:75:18: [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). delay = atoi(argv[n + 1]); data/komi-1.04/komi.c:2884:4: [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 fullpath[TEXTBUFFERSIZE]; data/komi-1.04/komi.c:2900:20: [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). if ((testopen = fopen(fullpath, "rb")) == NULL) data/komi-1.04/komi.c:3278:4: [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 thestring[TEXTBUFFERSIZE]; data/komi-1.04/komi.c:3280:4: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(thestring, "Komi - Level: %d - Score: %d - Lives: %d", level, score, lives); data/komi-1.04/komi.c:3289:4: [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 fullpath[TEXTBUFFERSIZE]; data/komi-1.04/komi.c:3638:4: [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 fullpath[TEXTBUFFERSIZE]; data/komi-1.04/komi.c:3654: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). if ((outfile = fopen(fullpath, "wb")) == NULL) data/komi-1.04/komi.c:3676:4: [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 fullpath[TEXTBUFFERSIZE]; data/komi-1.04/komi.c:3693:18: [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). if ((infile = fopen(fullpath, "rb")) == NULL) data/komi-1.04/komi.c:3747:4: [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 thestring[TEXTBUFFERSIZE]; data/komi-1.04/komi.c:3758:4: [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 fullpath[TEXTBUFFERSIZE]; data/komi-1.04/komi.c:3780:20: [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). if ((testopen = fopen(fullpath, "rb")) == NULL) data/komi-1.04/sprites.h:142:4: [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 fullpath[1024]; data/komi-1.04/sprites.h:158:18: [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). if ((infile = fopen(fullpath, "rb")) == NULL) data/komi-1.04/komi.c:146: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). if (strlen(argv[n + 1]) < sizeof(filepath)) // Check for buffer overrun... data/komi-1.04/komi.c:153: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). if (filepath[strlen(filepath) - 1] != '/') data/komi-1.04/komi.c:2888:8: [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(directory) + strlen(filename) >= sizeof(fullpath)) // Check for buffer overflow on fullpath data/komi-1.04/komi.c:2888:28: [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(directory) + strlen(filename) >= sizeof(fullpath)) // Check for buffer overflow on fullpath data/komi-1.04/komi.c:2892: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). (unsigned int) strlen(directory), (unsigned int) strlen(filename)); data/komi-1.04/komi.c:2892:53: [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). (unsigned int) strlen(directory), (unsigned int) strlen(filename)); data/komi-1.04/komi.c:3291:8: [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(directory) + strlen(filename) >= sizeof(fullpath)) // Check for buffer overflow on fullpath data/komi-1.04/komi.c:3291:28: [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(directory) + strlen(filename) >= sizeof(fullpath)) // Check for buffer overflow on fullpath data/komi-1.04/komi.c:3295: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). (unsigned int) strlen(directory), (unsigned int) strlen(filename)); data/komi-1.04/komi.c:3295:53: [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). (unsigned int) strlen(directory), (unsigned int) strlen(filename)); data/komi-1.04/komi.c:3642:8: [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(directory) + strlen(filename) >= sizeof(fullpath)) // Check for buffer overflow on fullpath data/komi-1.04/komi.c:3642:28: [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(directory) + strlen(filename) >= sizeof(fullpath)) // Check for buffer overflow on fullpath data/komi-1.04/komi.c:3646: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). (unsigned int) strlen(directory), (unsigned int) strlen(filename)); data/komi-1.04/komi.c:3646:53: [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). (unsigned int) strlen(directory), (unsigned int) strlen(filename)); data/komi-1.04/komi.c:3681:8: [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(directory) + strlen(filename) >= sizeof(fullpath)) // Check for buffer overflow on fullpath data/komi-1.04/komi.c:3681:28: [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(directory) + strlen(filename) >= sizeof(fullpath)) // Check for buffer overflow on fullpath data/komi-1.04/komi.c:3685: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). (unsigned int) strlen(directory), (unsigned int) strlen(filename)); data/komi-1.04/komi.c:3685:53: [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). (unsigned int) strlen(directory), (unsigned int) strlen(filename)); data/komi-1.04/komi.c:3703:23: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if ((nextchar = getc(infile)) != EOF) data/komi-1.04/komi.c:3715:23: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if ((nextchar = getc(infile)) != EOF) data/komi-1.04/komi.c:3723:23: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if ((nextchar = getc(infile)) != EOF) // Read highscore in byte by byte. data/komi-1.04/komi.c:3725:23: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if ((nextchar = getc(infile)) != EOF) data/komi-1.04/komi.c:3727:23: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if ((nextchar = getc(infile)) != EOF) data/komi-1.04/komi.c:3729:23: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if ((nextchar = getc(infile)) != EOF) data/komi-1.04/komi.c:3732:23: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if ((nextchar = getc(infile)) != EOF) data/komi-1.04/komi.c:3761:8: [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(directory) + strlen(filename) >= sizeof(fullpath)) // Check for buffer overflow on fullpath data/komi-1.04/komi.c:3761:28: [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(directory) + strlen(filename) >= sizeof(fullpath)) // Check for buffer overflow on fullpath data/komi-1.04/komi.c:3765: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). (unsigned int) strlen(directory), (unsigned int) strlen(filename)); data/komi-1.04/komi.c:3765:53: [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). (unsigned int) strlen(directory), (unsigned int) strlen(filename)); data/komi-1.04/komi.c:3840: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). if (strlen(dir) + 1 >= sizeof(prefsdir)) data/komi-1.04/komi.c:3852: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). if (strlen(dir) + 1 >= sizeof(prefsdir)) data/komi-1.04/sprites.h:146:8: [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(directory) + strlen(filename) >= sizeof(fullpath)) // Check for buffer overflow on fullpath data/komi-1.04/sprites.h:146:28: [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(directory) + strlen(filename) >= sizeof(fullpath)) // Check for buffer overflow on fullpath data/komi-1.04/sprites.h:150: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). (unsigned int) strlen(directory), (unsigned int) strlen(filename)); data/komi-1.04/sprites.h:150:53: [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). (unsigned int) strlen(directory), (unsigned int) strlen(filename)); data/komi-1.04/sprites.h:192:14: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). b = getc(infile); data/komi-1.04/sprites.h:193:14: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). g = getc(infile); data/komi-1.04/sprites.h:194:14: [1] (buffer) getc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). r = getc(infile); ANALYSIS SUMMARY: Hits = 78 Lines analyzed = 5769 in approximately 0.24 seconds (23702 lines/second) Physical Source Lines of Code (SLOC) = 4611 Hits@level = [0] 75 [1] 38 [2] 19 [3] 3 [4] 18 [5] 0 Hits@level+ = [0+] 153 [1+] 78 [2+] 40 [3+] 21 [4+] 18 [5+] 0 Hits/KSLOC@level+ = [0+] 33.1815 [1+] 16.9161 [2+] 8.67491 [3+] 4.55433 [4+] 3.90371 [5+] 0 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.