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/gnuboy-1.0.3/asm/i386/asmnames.h Examining data/gnuboy-1.0.3/asm/i386/asm.h Examining data/gnuboy-1.0.3/cpu.c Examining data/gnuboy-1.0.3/cpu.h Examining data/gnuboy-1.0.3/debug.c Examining data/gnuboy-1.0.3/emu.c Examining data/gnuboy-1.0.3/events.c Examining data/gnuboy-1.0.3/exports.c Examining data/gnuboy-1.0.3/hw.c Examining data/gnuboy-1.0.3/hw.h Examining data/gnuboy-1.0.3/input.h Examining data/gnuboy-1.0.3/keytable.c Examining data/gnuboy-1.0.3/lcd.c Examining data/gnuboy-1.0.3/lcd.h Examining data/gnuboy-1.0.3/newsound.c Examining data/gnuboy-1.0.3/loader.c Examining data/gnuboy-1.0.3/loader.h Examining data/gnuboy-1.0.3/main.c Examining data/gnuboy-1.0.3/mem.c Examining data/gnuboy-1.0.3/mem.h Examining data/gnuboy-1.0.3/palette.c Examining data/gnuboy-1.0.3/rc.h Examining data/gnuboy-1.0.3/rccmds.c Examining data/gnuboy-1.0.3/rcfile.c Examining data/gnuboy-1.0.3/rckeys.c Examining data/gnuboy-1.0.3/rcvars.c Examining data/gnuboy-1.0.3/regs.h Examining data/gnuboy-1.0.3/cpucore.h Examining data/gnuboy-1.0.3/path.c Examining data/gnuboy-1.0.3/lcdc.c Examining data/gnuboy-1.0.3/sys/x11/xlib.c Examining data/gnuboy-1.0.3/sys/x11/keymap.c Examining data/gnuboy-1.0.3/sys/oss/oss.c Examining data/gnuboy-1.0.3/sys/dummy/nosound.c Examining data/gnuboy-1.0.3/sys/dummy/nojoy.c Examining data/gnuboy-1.0.3/sys/svga/svgalib.c Examining data/gnuboy-1.0.3/sys/pc/keymap.c Examining data/gnuboy-1.0.3/sys/sdl/sdl.c Examining data/gnuboy-1.0.3/sys/sdl/keymap.c Examining data/gnuboy-1.0.3/sys/linux/fbdev.c Examining data/gnuboy-1.0.3/sys/linux/kb.c Examining data/gnuboy-1.0.3/sys/linux/joy.c Examining data/gnuboy-1.0.3/sys/linux/matrox.h Examining data/gnuboy-1.0.3/sys/thinlib/lib/thinlib.h Examining data/gnuboy-1.0.3/sys/thinlib/lib/thintest.cpp Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_bmp.c Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_bmp.h Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_djgpp.h Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_dpp.c Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_dpp.h Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_event.c Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_event.h Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_int.c Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_int.h Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_joy.c Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_joy.h Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_key.c Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_key.h Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_log.c Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_log.h Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_main.c Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_mouse.c Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_mouse.h Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_prof.c Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_prof.h Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_sb.c Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_sb.h Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_sound.c Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_sound.h Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_timer.c Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_timer.h Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_types.h Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_vesa.c Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_vesa.h Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_vga.c Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_vga.h Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_video.c Examining data/gnuboy-1.0.3/sys/thinlib/lib/tl_video.h Examining data/gnuboy-1.0.3/sys/thinlib/thinlib.c Examining data/gnuboy-1.0.3/sys/thinlib/keymap.c Examining data/gnuboy-1.0.3/sys/nix/nix.c Examining data/gnuboy-1.0.3/sys/nix/map.c Examining data/gnuboy-1.0.3/sys/windows/windows.c Examining data/gnuboy-1.0.3/sys/dos/dos.c Examining data/gnuboy-1.0.3/defs.h Examining data/gnuboy-1.0.3/fb.h Examining data/gnuboy-1.0.3/cpuregs.h Examining data/gnuboy-1.0.3/split.c Examining data/gnuboy-1.0.3/save.c Examining data/gnuboy-1.0.3/sound.c Examining data/gnuboy-1.0.3/pcm.h Examining data/gnuboy-1.0.3/sound.h Examining data/gnuboy-1.0.3/noise.h Examining data/gnuboy-1.0.3/rtc.h Examining data/gnuboy-1.0.3/rtc.c Examining data/gnuboy-1.0.3/fastmem.c Examining data/gnuboy-1.0.3/inflate.c Examining data/gnuboy-1.0.3/fastmem.h Examining data/gnuboy-1.0.3/refresh.c FINAL RESULTS: data/gnuboy-1.0.3/asm/i386/asmnames.h:39:9: [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 printf _printf data/gnuboy-1.0.3/loader.c:243:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(name, "%s.%03d", saveprefix, n); data/gnuboy-1.0.3/loader.c:262:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(name, "%s.%03d", saveprefix, n); data/gnuboy-1.0.3/loader.c:358:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(saveprefix, "%s/%s", savedir, name); data/gnuboy-1.0.3/loader.c:361:2: [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(sramfile, saveprefix); data/gnuboy-1.0.3/loader.c:365:2: [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(rtcfile, saveprefix); data/gnuboy-1.0.3/main.c:156:2: [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/gnuboy-1.0.3/main.c:238:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(cmd, "source %s", rom); data/gnuboy-1.0.3/main.c:250:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(cmd, "bind %s \"%s\"", argv[i+1], argv[i+2]); data/gnuboy-1.0.3/main.c:259:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(cmd, "source %s", argv[++i]); data/gnuboy-1.0.3/main.c:268:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(cmd, "set %s 0", opt); data/gnuboy-1.0.3/main.c:286:4: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(cmd, "set %s %s", opt, arg); data/gnuboy-1.0.3/path.c:37:3: [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(buf+l+1, name); data/gnuboy-1.0.3/rccmds.c:148:2: [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(linecopy, line); data/gnuboy-1.0.3/sys/dos/dos.c:67:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(buf, ".;%s/", home); data/gnuboy-1.0.3/sys/linux/fbdev.c:194:3: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf(cmd, FBSET_CMD " %.80s", fb_mode); data/gnuboy-1.0.3/sys/linux/fbdev.c:195:3: [4] (shell) system: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. system(cmd); data/gnuboy-1.0.3/sys/nix/map.c:56:2: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. sprintf(home, "%s/" DOTDIR, getenv(HOME)); data/gnuboy-1.0.3/sys/nix/map.c:58:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(saves, "%s/saves", home); data/gnuboy-1.0.3/sys/nix/map.c:60:6: [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(saves, X_OK|W_OK)) data/gnuboy-1.0.3/sys/nix/map.c:62:7: [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(home, X_OK|W_OK)) data/gnuboy-1.0.3/sys/nix/map.c:64: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(home, F_OK)) data/gnuboy-1.0.3/sys/nix/map.c:69:8: [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(saves, F_OK)) data/gnuboy-1.0.3/sys/nix/nix.c:66:6: [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(path, X_OK | (wr ? W_OK : 0))) data/gnuboy-1.0.3/sys/nix/nix.c:68:8: [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(path, F_OK)) data/gnuboy-1.0.3/sys/nix/nix.c:91:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(buf, "%s/" DOTDIR ":.", home); data/gnuboy-1.0.3/sys/nix/nix.c:93:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(buf, "%s/" DOTDIR "/saves" , home); data/gnuboy-1.0.3/sys/thinlib/lib/tl_log.c:20:52: [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. static int (*log_func)(const char *format, ... ) = printf; data/gnuboy-1.0.3/sys/thinlib/lib/tl_log.c:32:7: [4] (format) vsprintf: Potential format string problem (CWE-134). Make format string constant. vsprintf(buffer, format, arg); data/gnuboy-1.0.3/sys/windows/windows.c:66:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(buf, ".;%s/", home); data/gnuboy-1.0.3/loader.c:97:3: [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(memrand ? memrand : time(0)); data/gnuboy-1.0.3/sys/linux/fbdev.c:184:21: [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 (!(fb_device = getenv("FRAMEBUFFER"))) data/gnuboy-1.0.3/sys/nix/map.c:55: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. home = malloc(strlen(getenv("HOME")) + strlen(DOTDIR) + 2); data/gnuboy-1.0.3/sys/nix/map.c:56:30: [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. sprintf(home, "%s/" DOTDIR, getenv(HOME)); data/gnuboy-1.0.3/sys/nix/nix.c:82:21: [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. char *buf, *home = getenv("HOME"); data/gnuboy-1.0.3/sys/thinlib/lib/tl_sb.c:243:11: [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. penv = getenv("BLASTER"); data/gnuboy-1.0.3/sys/x11/xlib.c:242: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. x_displayname = getenv("DISPLAY"); data/gnuboy-1.0.3/debug.c:16: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 *mnemonic_table[256] = data/gnuboy-1.0.3/debug.c:276: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 *cb_mnemonic_table[256] = data/gnuboy-1.0.3/debug.c:573:9: [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 mnemonic[256]; data/gnuboy-1.0.3/debug.c:603:11: [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. j += sprintf(mnemonic + j, data/gnuboy-1.0.3/debug.c:610:11: [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. j += sprintf(mnemonic + j, "%04Xh", data/gnuboy-1.0.3/debug.c:617:11: [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. j += sprintf(mnemonic + j, "%+d", data/gnuboy-1.0.3/events.c:11: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 keystates[MAX_KEYS]; data/gnuboy-1.0.3/inflate.c:120:28: [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. get_tables (const unsigned char *data, long *p, data/gnuboy-1.0.3/inflate.c:121:6: [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 hlit_size_table[HLIT_TSIZE], data/gnuboy-1.0.3/inflate.c:123:6: [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 hdist_size_table[HDIST_TSIZE], data/gnuboy-1.0.3/inflate.c:132:3: [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 clen_size_table[CLEN_TSIZE]; data/gnuboy-1.0.3/inflate.c:251:17: [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 unsigned char buffer[BUFFER_SIZE]; data/gnuboy-1.0.3/inflate.c:270:26: [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. get_data (const unsigned char *data, long *p, data/gnuboy-1.0.3/inflate.c:271:10: [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 hlit_size_table[HLIT_TSIZE], data/gnuboy-1.0.3/inflate.c:273:10: [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 hdist_size_table[HDIST_TSIZE], data/gnuboy-1.0.3/inflate.c:391:3: [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 hlit_size_table[HLIT_TSIZE]; data/gnuboy-1.0.3/inflate.c:393:3: [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 hdist_size_table[HDIST_TSIZE]; data/gnuboy-1.0.3/input.h:114: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. extern char keystates[MAX_KEYS]; data/gnuboy-1.0.3/lcd.c:90:23: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. #define MEMCPY8(d, s) memcpy((d), (s), 8) data/gnuboy-1.0.3/lcd.c:250:2: [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(dest, src, 8-U); data/gnuboy-1.0.3/lcd.c:495:2: [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(VS, ts, sizeof VS); data/gnuboy-1.0.3/lcd.c:508:2: [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(bgdup, BUF, 256); data/gnuboy-1.0.3/lcd.c:709:5: [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(vdest, scalebuf, 160 * fb.pelsize * scale); data/gnuboy-1.0.3/loader.c:116:3: [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(d+p, buf, c); data/gnuboy-1.0.3/loader.c:157:32: [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 (strcmp(romfile, "-")) f = fopen(romfile, "rb"); data/gnuboy-1.0.3/loader.c:164:2: [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(rom.name, header+0x0134, 16); data/gnuboy-1.0.3/loader.c:209:6: [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(sramfile, "rb"); data/gnuboy-1.0.3/loader.c:226:6: [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(sramfile, "wb"); data/gnuboy-1.0.3/loader.c:245:11: [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(name, "wb"))) data/gnuboy-1.0.3/loader.c:264:11: [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(name, "rb"))) data/gnuboy-1.0.3/loader.c:280:12: [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(rtcfile, "wb"))) return; data/gnuboy-1.0.3/loader.c:289:12: [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(rtcfile, "r"))) return; data/gnuboy-1.0.3/loader.c:362:2: [2] (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). Risk is low because the source is a constant string. strcat(sramfile, ".sav"); data/gnuboy-1.0.3/loader.c:366:2: [2] (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). Risk is low because the source is a constant string. strcat(rtcfile, ".rtc"); data/gnuboy-1.0.3/main.c:241:2: [2] (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). Risk is low because the source is a constant string. strcat(cmd, ".rc"); data/gnuboy-1.0.3/mem.h:35:2: [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 name[20]; data/gnuboy-1.0.3/path.c:38:12: [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(buf, mode))) data/gnuboy-1.0.3/rccmds.c:90:24: [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). state_save(argc > 1 ? atoi(argv[1]) : -1); data/gnuboy-1.0.3/rccmds.c:96:24: [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). state_load(argc > 1 ? atoi(argv[1]) : -1); data/gnuboy-1.0.3/rccmds.c:145:2: [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 *argv[128], *linecopy; data/gnuboy-1.0.3/rcfile.c:21:2: [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], *p; data/gnuboy-1.0.3/rcfile.c:24:6: [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(name, "r"); data/gnuboy-1.0.3/rckeys.c:16: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 *keybind[MAX_KEYS]; data/gnuboy-1.0.3/rcvars.c:128: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. s = (char **)rcvars[i].mem; data/gnuboy-1.0.3/rcvars.c:141:16: [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). if (c < 1 || atoi(v[0]) || strchr("yYtT", v[0][0])) data/gnuboy-1.0.3/rcvars.c:209:12: [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. return *(char **)rcvars[i].mem; data/gnuboy-1.0.3/save.c:33:2: [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 key[4]; data/gnuboy-1.0.3/save.c:193:15: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. if (hramofs) memcpy(ram.hi+128, buf+hramofs, 127); data/gnuboy-1.0.3/save.c:195:13: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. if (hiofs) memcpy(ram.hi, buf+hiofs, sizeof ram.hi); data/gnuboy-1.0.3/save.c:196:14: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. if (palofs) memcpy(lcd.pal, buf+palofs, sizeof lcd.pal); data/gnuboy-1.0.3/save.c:197:14: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. if (oamofs) memcpy(lcd.oam.mem, buf+oamofs, sizeof lcd.oam); data/gnuboy-1.0.3/save.c:199:14: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. if (wavofs) memcpy(snd.wave, buf+wavofs, sizeof snd.wave); data/gnuboy-1.0.3/save.c:200:7: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. else memcpy(snd.wave, ram.hi+0x30, 16); /* patch data from older files */ data/gnuboy-1.0.3/save.c:251:2: [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(buf+hiofs, ram.hi, sizeof ram.hi); data/gnuboy-1.0.3/save.c:252:2: [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(buf+palofs, lcd.pal, sizeof lcd.pal); data/gnuboy-1.0.3/save.c:253:2: [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(buf+oamofs, lcd.oam.mem, sizeof lcd.oam); data/gnuboy-1.0.3/save.c:254:2: [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(buf+wavofs, snd.wave, sizeof snd.wave); data/gnuboy-1.0.3/sound.c:153:2: [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(WAVE, hw.cgb ? cgbwave : dmgwave, 16); data/gnuboy-1.0.3/sound.c:154:2: [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(ram.hi+0x30, WAVE, 16); data/gnuboy-1.0.3/sys/linux/fbdev.c:178:2: [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 cmd[256]; data/gnuboy-1.0.3/sys/linux/fbdev.c:186:9: [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). fbfd = open(fb_device, O_RDWR); data/gnuboy-1.0.3/sys/linux/joy.c:39:10: [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). joyfd = open(joydev, O_RDONLY|O_NONBLOCK); data/gnuboy-1.0.3/sys/linux/kb.c:60:9: [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). kbfd = open(TTY_DEVICE, O_RDWR); data/gnuboy-1.0.3/sys/nix/map.c:37:7: [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(romfile, O_READ); data/gnuboy-1.0.3/sys/oss/oss.c:65:8: [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). dsp = open(dsp_device, O_WRONLY); data/gnuboy-1.0.3/sys/sdl/sdl.c:456:2: [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(stream, pcm.buf, len); data/gnuboy-1.0.3/sys/thinlib/lib/thintest.cpp:134:10: [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(screen->line[y], buffer->line[y], screen->width); data/gnuboy-1.0.3/sys/thinlib/lib/tl_log.c:25: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. static char buffer[MAX_LOG_BUF_SIZE + 1]; data/gnuboy-1.0.3/sys/thinlib/lib/tl_sb.c:241: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 blaster[255 + 1], *penv; data/gnuboy-1.0.3/sys/thinlib/lib/tl_vesa.c:33: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 VESASignature[4] __PACKED__; data/gnuboy-1.0.3/sys/thinlib/lib/tl_vesa.c:36: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 Capabilities[4] __PACKED__; data/gnuboy-1.0.3/sys/thinlib/thinlib.c:86:2: [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(buf, pcm.buf, len); data/gnuboy-1.0.3/keytable.c:136:6: [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(name) == 1) data/gnuboy-1.0.3/loader.c:242: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). name = malloc(strlen(saveprefix) + 5); data/gnuboy-1.0.3/loader.c:261: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). name = malloc(strlen(saveprefix) + 5); data/gnuboy-1.0.3/loader.c:321: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). p = n = malloc(strlen(s)); data/gnuboy-1.0.3/loader.c:357: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). saveprefix = malloc(strlen(savedir) + strlen(name) + 2); data/gnuboy-1.0.3/loader.c:357: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). saveprefix = malloc(strlen(savedir) + strlen(name) + 2); data/gnuboy-1.0.3/loader.c:360: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). sramfile = malloc(strlen(saveprefix) + 5); data/gnuboy-1.0.3/loader.c:364: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). rtcfile = malloc(strlen(saveprefix) + 5); data/gnuboy-1.0.3/main.c:237: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). cmd = malloc(strlen(rom) + 11); data/gnuboy-1.0.3/main.c:249: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). cmd = malloc(strlen(argv[i+1]) + strlen(argv[i+2]) + 9); data/gnuboy-1.0.3/main.c:249:37: [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). cmd = malloc(strlen(argv[i+1]) + strlen(argv[i+2]) + 9); data/gnuboy-1.0.3/main.c:258: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). cmd = malloc(strlen(argv[i+1]) + 6); data/gnuboy-1.0.3/main.c:267: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). cmd = malloc(strlen(opt) + 7); data/gnuboy-1.0.3/main.c:285: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). cmd = malloc(strlen(opt) + strlen(arg) + 6); data/gnuboy-1.0.3/main.c:285:31: [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). cmd = malloc(strlen(opt) + strlen(arg) + 6); data/gnuboy-1.0.3/path.c:27: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). buf = malloc(strlen(path) + strlen(name) + 2); data/gnuboy-1.0.3/path.c:27: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). buf = malloc(strlen(path) + strlen(name) + 2); data/gnuboy-1.0.3/path.c:34: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). else l = strlen(p); data/gnuboy-1.0.3/path.c:35:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(buf, p, l); data/gnuboy-1.0.3/rccmds.c:147: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). linecopy = malloc(strlen(line)+1); data/gnuboy-1.0.3/sys/dos/dos.c:66: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). buf = malloc(strlen(home) + 8); data/gnuboy-1.0.3/sys/dos/dos.c:69:2: [1] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source is a constant character. sprintf(buf, "."); data/gnuboy-1.0.3/sys/linux/joy.c:55:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while (read(joyfd,&js,sizeof(struct js_event)) == sizeof(struct js_event)) data/gnuboy-1.0.3/sys/linux/kb.c:118:9: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while (read(kbfd, &k, 1) > 0) data/gnuboy-1.0.3/sys/nix/map.c:39:2: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). read(fd, &code, 1); data/gnuboy-1.0.3/sys/nix/map.c:55: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). home = malloc(strlen(getenv("HOME")) + strlen(DOTDIR) + 2); data/gnuboy-1.0.3/sys/nix/map.c:55: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). home = malloc(strlen(getenv("HOME")) + strlen(DOTDIR) + 2); data/gnuboy-1.0.3/sys/nix/map.c:57: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). saves = malloc(strlen(home) + 6); data/gnuboy-1.0.3/sys/nix/nix.c:57:2: [1] (obsolete) usleep: This C routine is considered obsolete (as opposed to the shell command by the same name). The interaction of this function with SIGALRM and other timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead. usleep(us); data/gnuboy-1.0.3/sys/nix/nix.c:90: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). buf = malloc(strlen(home) + strlen(DOTDIR) + 8); data/gnuboy-1.0.3/sys/nix/nix.c:90: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). buf = malloc(strlen(home) + strlen(DOTDIR) + 8); data/gnuboy-1.0.3/sys/thinlib/lib/tl_sb.c:250:4: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(blaster, penv, 255); data/gnuboy-1.0.3/sys/thinlib/lib/tl_vesa.c:139:4: [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(vesa_info.VESASignature, "VBE2", 4); data/gnuboy-1.0.3/sys/windows/windows.c:65: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). buf = malloc(strlen(home) + 8); data/gnuboy-1.0.3/sys/windows/windows.c:68:2: [1] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source is a constant character. sprintf(buf, ".", home); ANALYSIS SUMMARY: Hits = 144 Lines analyzed = 16826 in approximately 0.40 seconds (41974 lines/second) Physical Source Lines of Code (SLOC) = 12657 Hits@level = [0] 24 [1] 35 [2] 72 [3] 7 [4] 30 [5] 0 Hits@level+ = [0+] 168 [1+] 144 [2+] 109 [3+] 37 [4+] 30 [5+] 0 Hits/KSLOC@level+ = [0+] 13.2733 [1+] 11.3771 [2+] 8.61184 [3+] 2.92328 [4+] 2.37023 [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.