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/hoichess-0.22.0/src/uint64_table.cc Examining data/hoichess-0.22.0/src/common.h Examining data/hoichess-0.22.0/src/spinlock.cc Examining data/hoichess-0.22.0/src/common/shell.cc Examining data/hoichess-0.22.0/src/common/hash.h Examining data/hoichess-0.22.0/src/common/parallelsearch.cc Examining data/hoichess-0.22.0/src/common/epd.cc Examining data/hoichess-0.22.0/src/common/search_util.cc Examining data/hoichess-0.22.0/src/common/eval.cc Examining data/hoichess-0.22.0/src/common/epd.h Examining data/hoichess-0.22.0/src/common/node.h Examining data/hoichess-0.22.0/src/common/movelist.h Examining data/hoichess-0.22.0/src/common/movelist.cc Examining data/hoichess-0.22.0/src/common/pgn.h Examining data/hoichess-0.22.0/src/common/historytable.h Examining data/hoichess-0.22.0/src/common/pawnhash.cc Examining data/hoichess-0.22.0/src/common/shell_cmd.cc Examining data/hoichess-0.22.0/src/common/pawnhash.h Examining data/hoichess-0.22.0/src/common/hash.cc Examining data/hoichess-0.22.0/src/common/evalcache.cc Examining data/hoichess-0.22.0/src/common/node.cc Examining data/hoichess-0.22.0/src/common/parallelsearch.h Examining data/hoichess-0.22.0/src/common/shell_util.cc Examining data/hoichess-0.22.0/src/common/game.h Examining data/hoichess-0.22.0/src/common/search.h Examining data/hoichess-0.22.0/src/common/book.h Examining data/hoichess-0.22.0/src/common/book.cc Examining data/hoichess-0.22.0/src/common/shell.h Examining data/hoichess-0.22.0/src/common/game.cc Examining data/hoichess-0.22.0/src/common/shell_option_defs.h Examining data/hoichess-0.22.0/src/common/clock.cc Examining data/hoichess-0.22.0/src/common/pgn.cc Examining data/hoichess-0.22.0/src/common/search.cc Examining data/hoichess-0.22.0/src/common/clock.h Examining data/hoichess-0.22.0/src/common/evalcache.h Examining data/hoichess-0.22.0/src/util.cc Examining data/hoichess-0.22.0/src/thread.h Examining data/hoichess-0.22.0/src/mutex.cc Examining data/hoichess-0.22.0/src/version.cc Examining data/hoichess-0.22.0/src/lib/snprintf.h Examining data/hoichess-0.22.0/src/lib/my_getopt.cc Examining data/hoichess-0.22.0/src/lib/strtok_r.cc Examining data/hoichess-0.22.0/src/lib/strtok_r.h Examining data/hoichess-0.22.0/src/lib/snprintf.cc Examining data/hoichess-0.22.0/src/lib/my_getopt_wrapper.h Examining data/hoichess-0.22.0/src/lib/my_getopt.h Examining data/hoichess-0.22.0/src/xiangqi/move.h Examining data/hoichess-0.22.0/src/xiangqi/board_util.cc Examining data/hoichess-0.22.0/src/xiangqi/eval.cc Examining data/hoichess-0.22.0/src/xiangqi/board.h Examining data/hoichess-0.22.0/src/xiangqi/eval.h Examining data/hoichess-0.22.0/src/xiangqi/board_init.cc Examining data/hoichess-0.22.0/src/xiangqi/basic.h Examining data/hoichess-0.22.0/src/xiangqi/board_generate.cc Examining data/hoichess-0.22.0/src/xiangqi/board_attack.cc Examining data/hoichess-0.22.0/src/xiangqi/move.cc Examining data/hoichess-0.22.0/src/xiangqi/basic.cc Examining data/hoichess-0.22.0/src/xiangqi/board.cc Examining data/hoichess-0.22.0/src/queue.cc Examining data/hoichess-0.22.0/src/version.h Examining data/hoichess-0.22.0/src/sparc32/leon/inttypes.h Examining data/hoichess-0.22.0/src/sparc32/leon/usleep.h Examining data/hoichess-0.22.0/src/sparc32/leon/usleep.cc Examining data/hoichess-0.22.0/src/sparc32/leon/pthread.h Examining data/hoichess-0.22.0/src/sparc32/leon/printf.h Examining data/hoichess-0.22.0/src/sparc32/leon/stdio.cc Examining data/hoichess-0.22.0/src/sparc32/leon/arpa/inet.h Examining data/hoichess-0.22.0/src/debug.cc Examining data/hoichess-0.22.0/src/spinlock.h Examining data/hoichess-0.22.0/src/queue.h Examining data/hoichess-0.22.0/src/main.cc Examining data/hoichess-0.22.0/src/mutex.h Examining data/hoichess-0.22.0/src/chess/move.h Examining data/hoichess-0.22.0/src/chess/board_util.cc Examining data/hoichess-0.22.0/src/chess/eval.cc Examining data/hoichess-0.22.0/src/chess/board.h Examining data/hoichess-0.22.0/src/chess/eval.h Examining data/hoichess-0.22.0/src/chess/i386/bitboard_asm.h Examining data/hoichess-0.22.0/src/chess/x86_64/bitboard_asm.h Examining data/hoichess-0.22.0/src/chess/board_init.cc Examining data/hoichess-0.22.0/src/chess/bitboard_rotated.cc Examining data/hoichess-0.22.0/src/chess/basic.h Examining data/hoichess-0.22.0/src/chess/bitboard.cc Examining data/hoichess-0.22.0/src/chess/bitboard.h Examining data/hoichess-0.22.0/src/chess/board_generate.cc Examining data/hoichess-0.22.0/src/chess/board_attack.cc Examining data/hoichess-0.22.0/src/chess/move.cc Examining data/hoichess-0.22.0/src/chess/win32/bitboard_asm.h Examining data/hoichess-0.22.0/src/chess/basic.cc Examining data/hoichess-0.22.0/src/chess/board.cc Examining data/hoichess-0.22.0/src/chess/bitboard_inlines.h Examining data/hoichess-0.22.0/src/config.h Examining data/hoichess-0.22.0/src/thread.cc Examining data/hoichess-0.22.0/src/util.h Examining data/hoichess-0.22.0/src/init.cc Examining data/hoichess-0.22.0/src/debug.h FINAL RESULTS: data/hoichess-0.22.0/src/common/epd.cc:38: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(s, _s.c_str()); data/hoichess-0.22.0/src/common/eval.cc:168:2: [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(fp, INFO_PRFX "eval_material_white=%d" data/hoichess-0.22.0/src/common/eval.cc:171:2: [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(fp, INFO_PRFX "eval_material_difference=%d\n", data/hoichess-0.22.0/src/common/eval.cc:173:2: [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(fp, INFO_PRFX "eval_material_balance=%d\n", data/hoichess-0.22.0/src/common/eval.cc:176:2: [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(fp, INFO_PRFX "eval_phase=%u eval_isdraw=%d\n", data/hoichess-0.22.0/src/common/eval.cc:192:3: [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(fp, INFO_PRFX "eval_plugin_%s_white=%d" data/hoichess-0.22.0/src/common/eval.cc:210:3: [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(fp, INFO_PRFX "eval_plugin2_%s_white=%d" data/hoichess-0.22.0/src/common/eval.cc:247:2: [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(fp, INFO_PRFX "evals=%lu evals_phase1=%lu evals_phase2=%lu\n", data/hoichess-0.22.0/src/common/evalcache.cc:90:2: [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(fp, INFO_PRFX "evalcache_size_entries=%lu" data/hoichess-0.22.0/src/common/evalcache.cc:98:2: [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(fp, INFO_PRFX "evalcache_probes=%lu evalcache_hits=%lu\n", data/hoichess-0.22.0/src/common/hash.cc:166:2: [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(fp, INFO_PRFX "hash_size_entries=%lu hash_size_bytes=%lu" data/hoichess-0.22.0/src/common/hash.cc:174:2: [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(fp, INFO_PRFX "hash_probes=%lu hash_hits=%lu" data/hoichess-0.22.0/src/common/parallelsearch.cc:676:2: [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. printf(INFO_PRFX "=== parallel search statistics ===\n"); data/hoichess-0.22.0/src/common/parallelsearch.cc:677:2: [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. printf(INFO_PRFX "--- master ---\n"); data/hoichess-0.22.0/src/common/parallelsearch.cc:680:3: [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. printf(INFO_PRFX "--- slave %u ---\n", i); data/hoichess-0.22.0/src/common/parallelsearch.cc:681:3: [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. printf(INFO_PRFX "calls=%u\n", slaves[i].calls); data/hoichess-0.22.0/src/common/parallelsearch.cc:688:2: [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. printf(INFO_PRFX "==================================\n"); data/hoichess-0.22.0/src/common/pawnhash.cc:85:2: [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(fp, INFO_PRFX "pawnhash_size_entries=%lu" data/hoichess-0.22.0/src/common/pawnhash.cc:93:2: [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(fp, INFO_PRFX "pawnhash_probes=%lu" data/hoichess-0.22.0/src/common/search_util.cc:46:2: [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. printf(INFO_PRFX "nodes_total=%llu nodes_fullwidth=%llu" data/hoichess-0.22.0/src/common/search_util.cc:49:2: [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. printf(INFO_PRFX "searchtime=%.2f nps=%.0f\n", data/hoichess-0.22.0/src/common/search_util.cc:53:2: [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. printf(INFO_PRFX "cuts_beta=%ld cuts_null=%ld cuts_fut=%ld" data/hoichess-0.22.0/src/common/search_util.cc:57:2: [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. printf(INFO_PRFX "avg_branchfactor_fullwidth=%.2f" data/hoichess-0.22.0/src/common/shell.cc:481: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(ret, p); data/hoichess-0.22.0/src/common/shell.cc:644:3: [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. printf(INFO_PRFX "bookmove=%d\n", bookmove); data/hoichess-0.22.0/src/debug.cc:55: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(fp, fmt, args); data/hoichess-0.22.0/src/debug.cc:80: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(fp, fmt, args); data/hoichess-0.22.0/src/debug.cc:105: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(fp, fmt, args); data/hoichess-0.22.0/src/lib/snprintf.cc:75:8: [4] (format) vsnprintf: 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. #undef vsnprintf data/hoichess-0.22.0/src/lib/snprintf.cc:76:8: [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. #undef snprintf data/hoichess-0.22.0/src/lib/snprintf.cc:77:8: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. #undef sprintf data/hoichess-0.22.0/src/lib/snprintf.cc:78:8: [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. #undef fprintf data/hoichess-0.22.0/src/lib/snprintf.cc:79:8: [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. #undef printf data/hoichess-0.22.0/src/lib/snprintf.cc:676:11: [4] (format) sprintf: Potential format string problem (CWE-134). Make format string constant. vallen = sprintf(convert, fmt, value); data/hoichess-0.22.0/src/lib/snprintf.h:18:9: [4] (format) vsnprintf: 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. #define vsnprintf pg_vsnprintf data/hoichess-0.22.0/src/lib/snprintf.h:19:9: [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. #define snprintf pg_snprintf data/hoichess-0.22.0/src/sparc32/leon/printf.h:2:9: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. #define sprintf pg_sprintf data/hoichess-0.22.0/src/sparc32/leon/printf.h:3: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. #define fprintf pg_fprintf data/hoichess-0.22.0/src/sparc32/leon/printf.h:4: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 pg_printf data/hoichess-0.22.0/src/sparc32/leon/printf.h:5:9: [4] (format) vsnprintf: 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. #define vsnprintf pg_vsnprintf data/hoichess-0.22.0/src/sparc32/leon/printf.h:6:9: [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. #define snprintf pg_snprintf data/hoichess-0.22.0/src/util.cc:49:12: [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. int ret = vfprintf(stdout, fmt, args); data/hoichess-0.22.0/src/util.cc:63:12: [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. int ret = vfprintf(fp, fmt, args); data/hoichess-0.22.0/src/util.cc:106:12: [4] (format) vsnprintf: 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 = vsnprintf(buf, sizeof(buf), fmt, args); data/hoichess-0.22.0/src/util.h:34:23: [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 atomic_printf printf data/hoichess-0.22.0/src/util.h:35:24: [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. #define atomic_fprintf fprintf data/hoichess-0.22.0/src/common/shell.cc:344:23: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. const char * tmp = getenv(var.c_str()); data/hoichess-0.22.0/src/init.cc:55:2: [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/hoichess-0.22.0/src/lib/my_getopt.cc:52:9: [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("POSIXLY_CORRECT")) data/hoichess-0.22.0/src/lib/my_getopt.cc:162:9: [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("POSIXLY_CORRECT")) data/hoichess-0.22.0/src/lib/my_getopt_wrapper.h:31:8: [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. #undef getopt data/hoichess-0.22.0/src/lib/my_getopt_wrapper.h:32:9: [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. #define getopt my_getopt data/hoichess-0.22.0/src/lib/my_getopt_wrapper.h:33:8: [3] (buffer) getopt_long: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. #undef getopt_long data/hoichess-0.22.0/src/lib/my_getopt_wrapper.h:34:9: [3] (buffer) getopt_long: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. #define getopt_long my_getopt_long data/hoichess-0.22.0/src/main.cc:138:14: [3] (buffer) getopt_long: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. while ((c = getopt_long(argc, argv, short_opts, long_options, data/hoichess-0.22.0/src/main.cc:296:23: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. const char * home = getenv("HOME"); data/hoichess-0.22.0/src/main.cc:304:26: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. const char * profile = getenv("USERPROFILE"); data/hoichess-0.22.0/src/queue.h:71:2: [3] (misc) InitializeCriticalSection: Exceptions can be thrown in low-memory situations. Use InitializeCriticalSectionAndSpinCount instead. InitializeCriticalSection(&cs); /* void */ data/hoichess-0.22.0/src/queue.h:104:2: [3] (misc) EnterCriticalSection: On some versions of Windows, exceptions can be thrown in low-memory situations. Use InitializeCriticalSectionAndSpinCount instead. EnterCriticalSection(&cs); /* void */ data/hoichess-0.22.0/src/queue.h:130:2: [3] (misc) EnterCriticalSection: On some versions of Windows, exceptions can be thrown in low-memory situations. Use InitializeCriticalSectionAndSpinCount instead. EnterCriticalSection(&cs); /* void */ data/hoichess-0.22.0/src/queue.h:186:2: [3] (misc) EnterCriticalSection: On some versions of Windows, exceptions can be thrown in low-memory situations. Use InitializeCriticalSectionAndSpinCount instead. EnterCriticalSection(&cs); /* void */ data/hoichess-0.22.0/src/spinlock.h:55:2: [3] (misc) EnterCriticalSection: On some versions of Windows, exceptions can be thrown in low-memory situations. Use InitializeCriticalSectionAndSpinCount instead. EnterCriticalSection(&cs); /* void */ data/hoichess-0.22.0/src/util.cc:93:17: [3] (random) random: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. uint64_t tmp = random(); data/hoichess-0.22.0/src/util.cc:95:9: [3] (random) random: This function is not sufficiently random for security-related functions such as key and nonce creation (CWE-327). Use a more secure technique for acquiring random values. tmp |= random(); data/hoichess-0.22.0/src/chess/basic.h:59:14: [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 const char piece_char[6]; data/hoichess-0.22.0/src/chess/basic.h:60:14: [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 const char file_char[8]; data/hoichess-0.22.0/src/chess/basic.h:61:14: [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 const char rank_char[8]; data/hoichess-0.22.0/src/chess/basic.h:62:14: [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 const char square_str[64][3]; data/hoichess-0.22.0/src/chess/board_util.cc:196: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 ss[128]; data/hoichess-0.22.0/src/chess/board_util.cc:266: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 pos[80+1]; data/hoichess-0.22.0/src/chess/board_util.cc:268: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 flg[4+1]; data/hoichess-0.22.0/src/chess/board_util.cc:269: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 ep[2+1]; data/hoichess-0.22.0/src/chess/move.cc:98: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 ss[6]; data/hoichess-0.22.0/src/chess/move.cc:115: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 ss[16]; data/hoichess-0.22.0/src/chess/move.cc: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 ss[8]; /* longest is 7 (exd8=Q# or Qc3xc6#) */ data/hoichess-0.22.0/src/chess/move.cc:151:4: [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(s, "O-O-O"); data/hoichess-0.22.0/src/chess/move.cc:154:4: [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(s, "O-O"); data/hoichess-0.22.0/src/common/book.cc:252:7: [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(filename, "rb"); data/hoichess-0.22.0/src/common/book.cc:294:7: [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(filename, "w+b"); data/hoichess-0.22.0/src/common/book.cc:401: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). FILE * fp = fopen(pgnfile, "r"); data/hoichess-0.22.0/src/common/hash.cc:91: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(pvtable[key].moves, pvline->moves, n * sizeof(Move)); data/hoichess-0.22.0/src/common/hash.cc:123: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(pvline->moves, pvtable[key].moves, n * sizeof(Move)); data/hoichess-0.22.0/src/common/node.cc:108: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(child->pvline.moves, pvline.moves+1, data/hoichess-0.22.0/src/common/node.cc:299: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(best_line.moves+1, child->best_line.moves, n*sizeof(Move)); data/hoichess-0.22.0/src/common/pgn.cc:44: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 buf[1024]; data/hoichess-0.22.0/src/common/pgn.cc:247: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). FILE * fp = fopen(filename, "r"); data/hoichess-0.22.0/src/common/shell.cc:477: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 buf[1024]; data/hoichess-0.22.0/src/common/shell_cmd.cc:310: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). int secs = atoi(cmd_args[1].c_str()); data/hoichess-0.22.0/src/common/shell_cmd.cc:325: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). unsigned int depth = atoi(cmd_args[1].c_str()); data/hoichess-0.22.0/src/common/shell_cmd.cc:637: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). FILE * fp = fopen(filename, "r"); data/hoichess-0.22.0/src/common/shell_cmd.cc:754:8: [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(filename, "r"); data/hoichess-0.22.0/src/common/shell_cmd.cc:768: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 buf[1024]; data/hoichess-0.22.0/src/common/shell_cmd.cc:1057: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). FILE* fp = fopen(pgnfile, "r"); data/hoichess-0.22.0/src/common/shell_cmd.cc:1084: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). FILE* fp = fopen(pgnfile, "w"); data/hoichess-0.22.0/src/common/shell_util.cc:117: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 buf[128]; data/hoichess-0.22.0/src/common/shell_util.cc:248: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 buf[128]; data/hoichess-0.22.0/src/lib/snprintf.cc:111: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 buffer[4096]; data/hoichess-0.22.0/src/lib/snprintf.cc:126: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 buffer[4096]; data/hoichess-0.22.0/src/lib/snprintf.cc:142: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 buffer[4096]; data/hoichess-0.22.0/src/lib/snprintf.cc:554:15: [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. fmtstr((char *)fmtparptr[i]->value, fmtparptr[i]->leftjust, data/hoichess-0.22.0/src/lib/snprintf.cc:623: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 convert[64]; data/hoichess-0.22.0/src/lib/snprintf.cc:663: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 fmt[32]; data/hoichess-0.22.0/src/lib/snprintf.cc:664: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 convert[512]; data/hoichess-0.22.0/src/lib/snprintf.cc:669:3: [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(fmt, "%%.%d%c", precision, type); data/hoichess-0.22.0/src/lib/snprintf.cc:671:3: [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(fmt, "%%%c", type); data/hoichess-0.22.0/src/main.cc:149:15: [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). verbose = atoi(optarg); data/hoichess-0.22.0/src/main.cc:156: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). debug = atoi(optarg); data/hoichess-0.22.0/src/main.cc:271:15: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). FILE * fp = fopen(*it, "r"); data/hoichess-0.22.0/src/main.cc:319:16: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). FILE * fp = fopen(it->c_str(), "r"); data/hoichess-0.22.0/src/util.cc:102: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 buf[65536]; // should be enough data/hoichess-0.22.0/src/xiangqi/basic.h:64:14: [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 const char piece_char[7]; data/hoichess-0.22.0/src/xiangqi/basic.h:65:14: [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 const char file_char[9]; data/hoichess-0.22.0/src/xiangqi/basic.h:66:14: [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 const char rank_char[10]; data/hoichess-0.22.0/src/xiangqi/basic.h:67:14: [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 const char square_str[90][3]; data/hoichess-0.22.0/src/xiangqi/board_util.cc:185: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 ss[128]; data/hoichess-0.22.0/src/xiangqi/board_util.cc:241: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 pos[160+1]; data/hoichess-0.22.0/src/xiangqi/move.cc:47: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 ss[6]; data/hoichess-0.22.0/src/xiangqi/move.cc:60: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 ss[12]; data/hoichess-0.22.0/src/chess/board_util.cc:273:6: [1] (buffer) sscanf: It's unclear if the %s limit in the format string is small enough (CWE-120). Check that the limit is sufficiently small, or use a different input function. if (sscanf(s, "%80s %c %4s %2s %d %d", pos, &clr, flg, ep, &hmc, &fmc) data/hoichess-0.22.0/src/common/book.cc:451:6: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). read, skipped); data/hoichess-0.22.0/src/common/book.cc:460:4: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). read, skipped); data/hoichess-0.22.0/src/common/epd.cc:39: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 (s[strlen(s)-1] == '\n') data/hoichess-0.22.0/src/common/epd.cc:40:5: [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). s[strlen(s)-1] = '\0'; data/hoichess-0.22.0/src/common/pgn.cc:199:11: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int c = fgetc(fp); data/hoichess-0.22.0/src/common/shell.cc:418: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). while (line[strlen(line)-1] == '\n' || line[strlen(line)-1] == '\r') { data/hoichess-0.22.0/src/common/shell.cc:418:46: [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). while (line[strlen(line)-1] == '\n' || line[strlen(line)-1] == '\r') { data/hoichess-0.22.0/src/common/shell.cc:419: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). line[strlen(line)-1] = '\0'; data/hoichess-0.22.0/src/common/shell.cc:480:33: [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 * ret = (char *) malloc((strlen(p)+1) * sizeof(char)); data/hoichess-0.22.0/src/common/shell_cmd.cc:771: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). while (buf[strlen(buf)-1] == '\n' || buf[strlen(buf)-1] == '\r') { data/hoichess-0.22.0/src/common/shell_cmd.cc:771:44: [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). while (buf[strlen(buf)-1] == '\n' || buf[strlen(buf)-1] == '\r') { data/hoichess-0.22.0/src/common/shell_cmd.cc:772: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). buf[strlen(buf)-1] = '\0'; data/hoichess-0.22.0/src/debug.cc:57: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 (fmt[strlen(fmt)-1] != '\n') { data/hoichess-0.22.0/src/debug.cc:82: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 (fmt[strlen(fmt)-1] != '\n') { data/hoichess-0.22.0/src/debug.cc:107: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 (fmt[strlen(fmt)-1] != '\n') { data/hoichess-0.22.0/src/lib/my_getopt.cc:238: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). if ((strlen(longopts[ind].name) == (size_t) (charind - offset)) && data/hoichess-0.22.0/src/lib/snprintf.cc:91: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). return strlen(str); data/hoichess-0.22.0/src/lib/snprintf.cc:117:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(str, buffer, (len + 1 < 4096) ? len + 1 : 4096); data/hoichess-0.22.0/src/lib/snprintf.cc:602: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). vallen = strlen(value); data/hoichess-0.22.0/src/sparc32/leon/stdio.cc:14:7: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). if (read(fd, p, 1) != 1) { data/hoichess-0.22.0/src/sparc32/leon/usleep.cc:3:5: [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. int usleep(int usec) data/hoichess-0.22.0/src/sparc32/leon/usleep.h:1:12: [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. extern int usleep(int usec); data/hoichess-0.22.0/src/util.cc:125: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 (s[strlen(s)-1] == 'M' && sscanf(s, "%ldM", &tmp) == 1) { data/hoichess-0.22.0/src/util.cc:128: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). } else if (s[strlen(s)-1] == 'K' && sscanf(s, "%ldK", &tmp) == 1) { data/hoichess-0.22.0/src/xiangqi/board_util.cc:246:6: [1] (buffer) sscanf: It's unclear if the %s limit in the format string is small enough (CWE-120). Check that the limit is sufficiently small, or use a different input function. if (sscanf(s, "%160s %c %d %d", pos, &clr, &hmc, &fmc) ANALYSIS SUMMARY: Hits = 144 Lines analyzed = 23605 in approximately 0.60 seconds (39339 lines/second) Physical Source Lines of Code (SLOC) = 17029 Hits@level = [0] 366 [1] 26 [2] 54 [3] 18 [4] 46 [5] 0 Hits@level+ = [0+] 510 [1+] 144 [2+] 118 [3+] 64 [4+] 46 [5+] 0 Hits/KSLOC@level+ = [0+] 29.9489 [1+] 8.45616 [2+] 6.92936 [3+] 3.75829 [4+] 2.70127 [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.