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/leela-zero-0.17/autogtp/Console.h Examining data/leela-zero-0.17/autogtp/Game.cpp Examining data/leela-zero-0.17/autogtp/Job.cpp Examining data/leela-zero-0.17/autogtp/Job.h Examining data/leela-zero-0.17/autogtp/Management.h Examining data/leela-zero-0.17/autogtp/Order.cpp Examining data/leela-zero-0.17/autogtp/Order.h Examining data/leela-zero-0.17/autogtp/Result.h Examining data/leela-zero-0.17/autogtp/Worker.cpp Examining data/leela-zero-0.17/autogtp/Worker.h Examining data/leela-zero-0.17/autogtp/main.cpp Examining data/leela-zero-0.17/autogtp/Game.h Examining data/leela-zero-0.17/autogtp/Management.cpp Examining data/leela-zero-0.17/src/CL/cl2.hpp Examining data/leela-zero-0.17/src/CPUPipe.cpp Examining data/leela-zero-0.17/src/CPUPipe.h Examining data/leela-zero-0.17/src/FastBoard.cpp Examining data/leela-zero-0.17/src/FastBoard.h Examining data/leela-zero-0.17/src/FastState.cpp Examining data/leela-zero-0.17/src/FastState.h Examining data/leela-zero-0.17/src/ForwardPipe.h Examining data/leela-zero-0.17/src/FullBoard.cpp Examining data/leela-zero-0.17/src/FullBoard.h Examining data/leela-zero-0.17/src/GTP.cpp Examining data/leela-zero-0.17/src/GTP.h Examining data/leela-zero-0.17/src/GameState.cpp Examining data/leela-zero-0.17/src/GameState.h Examining data/leela-zero-0.17/src/Im2Col.h Examining data/leela-zero-0.17/src/KoState.cpp Examining data/leela-zero-0.17/src/KoState.h Examining data/leela-zero-0.17/src/Leela.cpp Examining data/leela-zero-0.17/src/NNCache.cpp Examining data/leela-zero-0.17/src/NNCache.h Examining data/leela-zero-0.17/src/Network.cpp Examining data/leela-zero-0.17/src/Network.h Examining data/leela-zero-0.17/src/OpenCL.cpp Examining data/leela-zero-0.17/src/OpenCL.h Examining data/leela-zero-0.17/src/OpenCLScheduler.cpp Examining data/leela-zero-0.17/src/OpenCLScheduler.h Examining data/leela-zero-0.17/src/Random.cpp Examining data/leela-zero-0.17/src/Random.h Examining data/leela-zero-0.17/src/SGFParser.cpp Examining data/leela-zero-0.17/src/SGFParser.h Examining data/leela-zero-0.17/src/SGFTree.cpp Examining data/leela-zero-0.17/src/SGFTree.h Examining data/leela-zero-0.17/src/SMP.cpp Examining data/leela-zero-0.17/src/SMP.h Examining data/leela-zero-0.17/src/ThreadPool.h Examining data/leela-zero-0.17/src/TimeControl.cpp Examining data/leela-zero-0.17/src/TimeControl.h Examining data/leela-zero-0.17/src/Timing.cpp Examining data/leela-zero-0.17/src/Timing.h Examining data/leela-zero-0.17/src/Training.cpp Examining data/leela-zero-0.17/src/Training.h Examining data/leela-zero-0.17/src/Tuner.cpp Examining data/leela-zero-0.17/src/Tuner.h Examining data/leela-zero-0.17/src/UCTNode.cpp Examining data/leela-zero-0.17/src/UCTNode.h Examining data/leela-zero-0.17/src/UCTNodePointer.cpp Examining data/leela-zero-0.17/src/UCTNodePointer.h Examining data/leela-zero-0.17/src/UCTNodeRoot.cpp Examining data/leela-zero-0.17/src/UCTSearch.cpp Examining data/leela-zero-0.17/src/UCTSearch.h Examining data/leela-zero-0.17/src/Utils.cpp Examining data/leela-zero-0.17/src/Utils.h Examining data/leela-zero-0.17/src/Zobrist.cpp Examining data/leela-zero-0.17/src/Zobrist.h Examining data/leela-zero-0.17/src/config.h Examining data/leela-zero-0.17/src/half/half.hpp Examining data/leela-zero-0.17/src/tests/gtests.cpp Examining data/leela-zero-0.17/src/tests/utils_unittest.cpp Examining data/leela-zero-0.17/validation/Results.cpp Examining data/leela-zero-0.17/validation/Results.h Examining data/leela-zero-0.17/validation/SPRT.cpp Examining data/leela-zero-0.17/validation/SPRT.h Examining data/leela-zero-0.17/validation/Validation.cpp Examining data/leela-zero-0.17/validation/Validation.h Examining data/leela-zero-0.17/validation/main.cpp FINAL RESULTS: data/leela-zero-0.17/src/Utils.cpp:125:5: [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/leela-zero-0.17/src/Utils.cpp:129:9: [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(cfg_logfile_handle, fmt, ap2); data/leela-zero-0.17/src/Utils.cpp:155:5: [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(file, fmt, ap); data/leela-zero-0.17/src/Utils.cpp:181:5: [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(stdout, fmt, ap); data/leela-zero-0.17/src/Utils.cpp:187:9: [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(cfg_logfile_handle, fmt, ap); data/leela-zero-0.17/src/Utils.cpp:221:20: [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")) == nullptr) { data/leela-zero-0.17/autogtp/Game.cpp:72:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char readBuffer[256]; data/leela-zero-0.17/autogtp/Game.cpp:93:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char readBuffer[256]; data/leela-zero-0.17/autogtp/Game.cpp:114:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char readBuffer[256]; data/leela-zero-0.17/autogtp/Game.cpp:188:17: [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). sgfFile.open(QIODevice::Text | QIODevice::ReadOnly); data/leela-zero-0.17/autogtp/Game.cpp:257:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char readBuffer[256]; data/leela-zero-0.17/autogtp/Game.cpp:339: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. char readBuffer[256]; data/leela-zero-0.17/autogtp/Game.cpp:451:18: [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 (!sgfFile.open(QIODevice::Text | QIODevice::ReadOnly)) { data/leela-zero-0.17/autogtp/Game.cpp:459:17: [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 (sgfFile.open(QFile::WriteOnly | QFile::Truncate)) { data/leela-zero-0.17/autogtp/Management.cpp:543:15: [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 (f.open(QFile::ReadOnly)) { data/leela-zero-0.17/autogtp/Management.cpp:673:12: [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 (!f.open(QIODevice::WriteOnly | QIODevice::Text)) { data/leela-zero-0.17/autogtp/Management.cpp:701:19: [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 (!file.open(QFile::ReadOnly)) { data/leela-zero-0.17/autogtp/Order.cpp:25:12: [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 (!f.open(QIODevice::WriteOnly | QIODevice::Text)) { data/leela-zero-0.17/autogtp/Order.cpp:41:12: [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 (!f.open(QIODevice::ReadOnly | QIODevice::Text)) { data/leela-zero-0.17/src/FastBoard.cpp:267:17: [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). open.push(vertex); data/leela-zero-0.17/src/FastBoard.cpp:271:13: [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). while (!open.empty()) { data/leela-zero-0.17/src/FastBoard.cpp:273:23: [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). auto vertex = open.front(); data/leela-zero-0.17/src/FastBoard.cpp:274: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). open.pop(); data/leela-zero-0.17/src/FastBoard.cpp:281:17: [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). open.push(neighbor); data/leela-zero-0.17/src/Leela.cpp:295:30: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). cfg_logfile_handle = fopen(cfg_logfile.c_str(), "a"); data/leela-zero-0.17/src/Leela.cpp:574:34: [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). cfg_logfile_handle = fopen(cfg_logfile.c_str(), "a"); data/leela-zero-0.17/src/SGFTree.cpp:444:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char timestr[sizeof "2017-10-16"]; data/leela-zero-0.17/src/Training.cpp:128: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(in_buff.get(), m_buffer.data(), in_buff_size); data/leela-zero-0.17/src/half/half.hpp:458: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. std::memcpy(&bits, &value, sizeof(float)); data/leela-zero-0.17/src/half/half.hpp:535: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. static const unsigned char shift_table[512] = { data/leela-zero-0.17/src/half/half.hpp:579: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. std::memcpy(&bits, &value, sizeof(double)); data/leela-zero-0.17/src/half/half.hpp:897: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. std::memcpy(&out, &bits, sizeof(float)); data/leela-zero-0.17/src/half/half.hpp:919: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. std::memcpy(&out, &bits, sizeof(double)); data/leela-zero-0.17/validation/Validation.cpp:175:12: [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 (!f.open(QIODevice::WriteOnly | QIODevice::Text)) { data/leela-zero-0.17/validation/Validation.cpp:197:12: [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 (!f.open(QIODevice::ReadOnly | QIODevice::Text)) { data/leela-zero-0.17/src/half/half.hpp:1242:86: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). template<typename charT,typename traits> static std::basic_istream<charT,traits>& read(std::basic_istream<charT,traits> &in, half &arg) data/leela-zero-0.17/src/half/half.hpp:2209:84: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). operator>>(std::basic_istream<charT,traits> &in, half &arg) { return functions::read(in, arg); } ANALYSIS SUMMARY: Hits = 37 Lines analyzed = 30679 in approximately 1.53 seconds (20009 lines/second) Physical Source Lines of Code (SLOC) = 20980 Hits@level = [0] 14 [1] 2 [2] 29 [3] 1 [4] 5 [5] 0 Hits@level+ = [0+] 51 [1+] 37 [2+] 35 [3+] 6 [4+] 5 [5+] 0 Hits/KSLOC@level+ = [0+] 2.43089 [1+] 1.76358 [2+] 1.66826 [3+] 0.285987 [4+] 0.238322 [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.