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/gtkballs-3.1.5/src/gtkballs.c Examining data/gtkballs-3.1.5/src/gtkballs.h Examining data/gtkballs-3.1.5/src/gfx.c Examining data/gtkballs-3.1.5/src/gfx.h Examining data/gtkballs-3.1.5/src/license.c Examining data/gtkballs-3.1.5/src/license.h Examining data/gtkballs-3.1.5/src/path.c Examining data/gtkballs-3.1.5/src/path.h Examining data/gtkballs-3.1.5/src/preferences.c Examining data/gtkballs-3.1.5/src/preferences.h Examining data/gtkballs-3.1.5/src/scoreboard.c Examining data/gtkballs-3.1.5/src/scoreboard.h Examining data/gtkballs-3.1.5/src/themerc.c Examining data/gtkballs-3.1.5/src/themerc.h Examining data/gtkballs-3.1.5/src/gtkutils.h Examining data/gtkballs-3.1.5/src/mainmenu.c Examining data/gtkballs-3.1.5/src/mainmenu.h Examining data/gtkballs-3.1.5/src/rules.c Examining data/gtkballs-3.1.5/src/rules.h Examining data/gtkballs-3.1.5/src/about.c Examining data/gtkballs-3.1.5/src/about.h Examining data/gtkballs-3.1.5/src/child.c Examining data/gtkballs-3.1.5/src/child.h Examining data/gtkballs-3.1.5/src/theme.c Examining data/gtkballs-3.1.5/src/theme.h Examining data/gtkballs-3.1.5/src/savegame.h Examining data/gtkballs-3.1.5/src/savedialog.c Examining data/gtkballs-3.1.5/src/savedialog.h Examining data/gtkballs-3.1.5/src/halloffame.c Examining data/gtkballs-3.1.5/src/halloffame.h Examining data/gtkballs-3.1.5/src/inputname.c Examining data/gtkballs-3.1.5/src/inputname.h Examining data/gtkballs-3.1.5/src/rulesdialog.c Examining data/gtkballs-3.1.5/src/rulesdialog.h Examining data/gtkballs-3.1.5/src/game.c Examining data/gtkballs-3.1.5/src/game.h Examining data/gtkballs-3.1.5/src/mainwin.h Examining data/gtkballs-3.1.5/src/prefs.c Examining data/gtkballs-3.1.5/src/prefs.h Examining data/gtkballs-3.1.5/src/mainwin.c Examining data/gtkballs-3.1.5/src/gtkutils.c Examining data/gtkballs-3.1.5/src/savegame.c FINAL RESULTS: data/gtkballs-3.1.5/src/savegame.c:167:17: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. chmod(fname, 0600); data/gtkballs-3.1.5/src/game.c:179:12: [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. If the scanf format is influenceable by an attacker, it's exploitable. sscanf(rstr, _save_fmt, &r.width, &r.height, &r.colors, &r.next, &r.destroy) != 5 || data/gtkballs-3.1.5/src/game.c:189:2: [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. If the scanf format is influenceable by an attacker, it's exploitable. sscanf(s, _save_fmt, width, height, colors, next, destroy); data/gtkballs-3.1.5/src/gtkballs.c:135: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((unsigned int)tv.tv_usec); data/gtkballs-3.1.5/src/gtkballs.c:176:31: [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. mapfile = g_strconcat(getenv("HOME"), G_DIR_SEPARATOR_S, ".gtkballs", data/gtkballs-3.1.5/src/inputname.c:99:25: [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((s = getenv("USER"))) { data/gtkballs-3.1.5/src/prefs.c:118:7: [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(getenv("HOME")) { data/gtkballs-3.1.5/src/prefs.c:119:38: [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. rc_file = g_strdup_printf("%s/%s", getenv ("HOME"), CONFIG_FILE_NAME); data/gtkballs-3.1.5/src/savegame.c:129:32: [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. datapath = g_strconcat(getenv("HOME"), G_DIR_SEPARATOR_S, ".gtkballs", NULL); data/gtkballs-3.1.5/src/savegame.c:164:29: [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. fname = g_strconcat(getenv("HOME"), G_DIR_SEPARATOR_S, ".gtkballs", data/gtkballs-3.1.5/src/theme.c:61:18: [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((homedir = getenv("HOME")) && data/gtkballs-3.1.5/src/theme.c:332:12: [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(getenv("HOME")) { data/gtkballs-3.1.5/src/theme.c:333: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. hdir = g_strconcat(getenv("HOME"), THEMEPREFIX, NULL); data/gtkballs-3.1.5/src/child.c:61:11: [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(score_file_full, O_WRONLY | O_TRUNC); data/gtkballs-3.1.5/src/game.c:236: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(_board_undo, _board, sizeof(gint) * _rules.width * _rules.height); data/gtkballs-3.1.5/src/game.c:237: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(_next_colors_undo, _next_colors, sizeof(gint) * _rules.next); data/gtkballs-3.1.5/src/game.c:246: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(_board, _board_undo, sizeof(gint) * _rules.width * _rules.height); data/gtkballs-3.1.5/src/game.c:247: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(_next_colors, _next_colors_undo, sizeof(gint) * _rules.next); data/gtkballs-3.1.5/src/game.c:266: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(_board, balls, sizeof(gint) * _rules.width * _rules.height); data/gtkballs-3.1.5/src/game.c:271: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_colors, nextballs, sizeof(gint) * _rules.next); data/gtkballs-3.1.5/src/game.c:294: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(b, _board, sizeof(gint) * _rules.width * _rules.height); data/gtkballs-3.1.5/src/game.c:302: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(n, _next_colors, sizeof(gint) * _rules.next); data/gtkballs-3.1.5/src/license.c:37:11: [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). if((fd=open(license_file, O_RDONLY))<0) { data/gtkballs-3.1.5/src/prefs.c:155:13: [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((fp = fopen(rc_file, "r"))) { data/gtkballs-3.1.5/src/prefs.c:176:36: [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). rules_set_width(atoi(prop_val[1])); data/gtkballs-3.1.5/src/prefs.c:178:37: [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). rules_set_height(atoi(prop_val[1])); data/gtkballs-3.1.5/src/prefs.c:180:37: [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). rules_set_colors(atoi(prop_val[1])); data/gtkballs-3.1.5/src/prefs.c:182: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). rules_set_next(atoi(prop_val[1])); data/gtkballs-3.1.5/src/prefs.c:184:38: [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). rules_set_destroy(atoi(prop_val[1])); data/gtkballs-3.1.5/src/prefs.c:186:57: [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). timer_set_limit(atoi(prop_val[1])); data/gtkballs-3.1.5/src/prefs.c:188:36: [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). prefs_set_hl_dr(atoi(prop_val[1])); data/gtkballs-3.1.5/src/prefs.c:190:36: [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). prefs_set_hl_dg(atoi(prop_val[1])); data/gtkballs-3.1.5/src/prefs.c:192:36: [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). prefs_set_hl_db(atoi(prop_val[1])); data/gtkballs-3.1.5/src/prefs.c:218:13: [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((fp = fopen(rc_file, "w"))) { data/gtkballs-3.1.5/src/savedialog.c:212: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(str1, gamelist[i * 2], 19 * sizeof(gchar)); data/gtkballs-3.1.5/src/savegame.c:28:17: [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). (f = fopen(sgame, "r")) == NULL) { data/gtkballs-3.1.5/src/savegame.c:44: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(srules, sdata, rlen); data/gtkballs-3.1.5/src/savegame.c:166:17: [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((f = fopen(fname, "w")) != NULL) { data/gtkballs-3.1.5/src/scoreboard.c:103: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). if(!(fp = fopen(LOCALSTATEDIR SCORE_FILE, "r"))) { data/gtkballs-3.1.5/src/themerc.c:27:16: [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). if((fd=open(fname, O_RDONLY))==-1) { data/gtkballs-3.1.5/src/themerc.c:102:13: [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). ret=atoi(val); data/gtkballs-3.1.5/src/child.c:51:28: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if(read(chfd, &sz, sizeof(sz)) <= 0) { data/gtkballs-3.1.5/src/child.c:81:19: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). read(chfd, buf, sz); data/gtkballs-3.1.5/src/child.c:86:19: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). read(chfd, &sz, sizeof(sz)); data/gtkballs-3.1.5/src/game.c:174: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). if(strlen(rstr) != _save_fmt_len || data/gtkballs-3.1.5/src/inputname.c:35:6: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(current_entry.name, tstr && *tstr ? tstr : _("Anonymous"), sizeof(current_entry.name)); data/gtkballs-3.1.5/src/inputname.c:36:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(_last_player_name, current_entry.name, sizeof(_last_player_name)); data/gtkballs-3.1.5/src/inputname.c:42:17: [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(current_entry.date, _("Unknown"), sizeof(current_entry.date)); data/gtkballs-3.1.5/src/inputname.c:46:25: [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(current_entry.date, _("Unknown"), sizeof(current_entry.date)); data/gtkballs-3.1.5/src/inputname.c:50:33: [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(current_entry.date, _("Unknown"), sizeof(current_entry.date)); data/gtkballs-3.1.5/src/inputname.c:52:26: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(current_entry.date, tstr, sizeof(current_entry.date)); data/gtkballs-3.1.5/src/inputname.c:100:6: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(_last_player_name, s, sizeof(_last_player_name)); data/gtkballs-3.1.5/src/license.c:42:4: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). read(fd, license_buf, buf.st_size); data/gtkballs-3.1.5/src/savedialog.c:215:35: [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). (strlen(gamelist[i * 2]) - 22) * sizeof(gchar)); data/gtkballs-3.1.5/src/savegame.c:97:20: [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(name + strlen(name) - 4, ".sav") != 0)) { data/gtkballs-3.1.5/src/scoreboard.c:50: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). if(strlen(b[i].name)) { data/gtkballs-3.1.5/src/scoreboard.c:61: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). sz = strlen(buf); data/gtkballs-3.1.5/src/scoreboard.c:63: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). write(_score_fd, buf, strlen(buf)); data/gtkballs-3.1.5/src/scoreboard.c:71: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). if(strlen(bf[i].name)) { data/gtkballs-3.1.5/src/scoreboard.c:73: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). sz = strlen(buf); data/gtkballs-3.1.5/src/scoreboard.c:75: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). write(_score_fd, buf, strlen(buf)); data/gtkballs-3.1.5/src/scoreboard.c:152:35: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(b[sc].name, tstr, sizeof(b[sc].name)); data/gtkballs-3.1.5/src/scoreboard.c:155:35: [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(b[sc].name, _("Unknown"), sizeof(b[sc].name)); data/gtkballs-3.1.5/src/scoreboard.c:167:35: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(b[sc].date, tstr, sizeof(b[sc].date)); data/gtkballs-3.1.5/src/scoreboard.c:170:35: [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(b[sc].date, _("Unknown"), sizeof(b[sc].date)); data/gtkballs-3.1.5/src/scoreboard.c:175:34: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy((*bf)[fsc].name, str_val[0], sizeof((*bf)[fsc].name)); data/gtkballs-3.1.5/src/scoreboard.c:180:34: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy((*bf)[fsc].date, str_val[2], sizeof((*bf)[fsc].date)); data/gtkballs-3.1.5/src/scoreboard.c:216:9: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(board[j + 1].name, board[j].name, sizeof(board[j + 1].name)); data/gtkballs-3.1.5/src/scoreboard.c:217:9: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(board[j + 1].date, board[j].date, sizeof(board[j + 1].date)); data/gtkballs-3.1.5/src/scoreboard.c:221:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(board[i].name, entry.name, sizeof(board[i].name)); data/gtkballs-3.1.5/src/scoreboard.c:222:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(board[i].date, entry.date, sizeof(board[i].date)); data/gtkballs-3.1.5/src/themerc.c:46:16: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if((rb=read(fd, rc, fds.st_size))!=fds.st_size) { ANALYSIS SUMMARY: Hits = 72 Lines analyzed = 4443 in approximately 0.52 seconds (8470 lines/second) Physical Source Lines of Code (SLOC) = 3508 Hits@level = [0] 23 [1] 31 [2] 28 [3] 10 [4] 2 [5] 1 Hits@level+ = [0+] 95 [1+] 72 [2+] 41 [3+] 13 [4+] 3 [5+] 1 Hits/KSLOC@level+ = [0+] 27.081 [1+] 20.5245 [2+] 11.6876 [3+] 3.70582 [4+] 0.855188 [5+] 0.285063 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.