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/pipewalker-0.9.4/src/button.cpp Examining data/pipewalker-0.9.4/src/button.h Examining data/pipewalker-0.9.4/src/cell.cpp Examining data/pipewalker-0.9.4/src/cell.h Examining data/pipewalker-0.9.4/src/common.h Examining data/pipewalker-0.9.4/src/explosion.cpp Examining data/pipewalker-0.9.4/src/explosion.h Examining data/pipewalker-0.9.4/src/game.cpp Examining data/pipewalker-0.9.4/src/game.h Examining data/pipewalker-0.9.4/src/image.cpp Examining data/pipewalker-0.9.4/src/image.h Examining data/pipewalker-0.9.4/src/level.cpp Examining data/pipewalker-0.9.4/src/level.h Examining data/pipewalker-0.9.4/src/loading_xpm.h Examining data/pipewalker-0.9.4/src/mode.h Examining data/pipewalker-0.9.4/src/mode_puzzle.cpp Examining data/pipewalker-0.9.4/src/mode_puzzle.h Examining data/pipewalker-0.9.4/src/mode_settings.cpp Examining data/pipewalker-0.9.4/src/mode_settings.h Examining data/pipewalker-0.9.4/src/mtrandom.cpp Examining data/pipewalker-0.9.4/src/mtrandom.h Examining data/pipewalker-0.9.4/src/render.cpp Examining data/pipewalker-0.9.4/src/render.h Examining data/pipewalker-0.9.4/src/settings.cpp Examining data/pipewalker-0.9.4/src/settings.h Examining data/pipewalker-0.9.4/src/sound.cpp Examining data/pipewalker-0.9.4/src/sound.h Examining data/pipewalker-0.9.4/src/main.cpp FINAL RESULTS: data/pipewalker-0.9.4/src/explosion.cpp:37:54: [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. const size_t num = static_cast<size_t>(mtrandom::random(2, 5)); data/pipewalker-0.9.4/src/explosion.cpp:51:22: [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. p.speed = mtrandom::random(-0.05f, 0.05f); data/pipewalker-0.9.4/src/explosion.cpp:52:48: [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. p.life = static_cast<unsigned long>(mtrandom::random(500, 3000)); data/pipewalker-0.9.4/src/level.cpp:72:54: [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. if (it->cell_type() != cell::ct_free && mtrandom::random(0, 5) != 0) { data/pipewalker-0.9.4/src/level.cpp:73:32: [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. it->rotate_still(mtrandom::random(0, 2) != 0, mtrandom::random(0, 2) != 0); data/pipewalker-0.9.4/src/level.cpp:73:61: [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. it->rotate_still(mtrandom::random(0, 2) != 0, mtrandom::random(0, 2) != 0); data/pipewalker-0.9.4/src/level.cpp:147:70: [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. if (it->cell_type() != cell::ct_free && !it->locked() && mtrandom::random(0, 5) != 0) { data/pipewalker-0.9.4/src/level.cpp:148:25: [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. it->rotate(mtrandom::random(0, 2) != 0); data/pipewalker-0.9.4/src/level.cpp:149:18: [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. if (mtrandom::random(0, 2) != 0) //Twice rotation data/pipewalker-0.9.4/src/level.cpp:160:52: [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. _senderX = static_cast<unsigned short>(mtrandom::random(0, static_cast<int>(_size_cell))); data/pipewalker-0.9.4/src/level.cpp:161:52: [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. _senderY = static_cast<unsigned short>(mtrandom::random(0, static_cast<int>(_size_cell))); data/pipewalker-0.9.4/src/level.cpp:172:20: [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. switch (mtrandom::random(0, 4)) { data/pipewalker-0.9.4/src/level.cpp:230:39: [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. const int free_cell_ind = mtrandom::random(0, static_cast<int>(free_cells.size())); data/pipewalker-0.9.4/src/level.cpp:256:50: [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. i = 1 - static_cast<unsigned short>(mtrandom::random(0, 3)); data/pipewalker-0.9.4/src/level.cpp:257:50: [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. j = 1 - static_cast<unsigned short>(mtrandom::random(0, 3)); data/pipewalker-0.9.4/src/mode_puzzle.cpp:143:56: [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. new_map_id = static_cast<unsigned long>(mtrandom::random(1, PW_MAX_LEVEL_NUMBER)); data/pipewalker-0.9.4/src/mtrandom.cpp:51: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. float mtrandom::random(const float min_val, const float max_val) data/pipewalker-0.9.4/src/mtrandom.cpp:53:58: [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. const float r = min_val + static_cast<float>(instance().random() % static_cast<unsigned long>(((max_val - min_val) * 1000.f))) / 1000.0f; data/pipewalker-0.9.4/src/mtrandom.cpp:60:15: [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. int mtrandom::random(const int min_val, const int max_val) data/pipewalker-0.9.4/src/mtrandom.cpp:62:38: [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. const int r = min_val + (instance().random() % (max_val - min_val)); data/pipewalker-0.9.4/src/mtrandom.cpp:80:25: [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. unsigned long mtrandom::random() data/pipewalker-0.9.4/src/mtrandom.h:50:15: [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. static float random(const float min_val, const float max_val); data/pipewalker-0.9.4/src/mtrandom.h:58:13: [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. static int random(const int min_val, const int max_val); data/pipewalker-0.9.4/src/mtrandom.h:70:16: [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. unsigned long random(); data/pipewalker-0.9.4/src/settings.cpp:185:19: [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. settings_file = getenv("USERPROFILE"); data/pipewalker-0.9.4/src/settings.cpp:188:19: [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. settings_file = getenv("HOME"); data/pipewalker-0.9.4/src/image.cpp:60:3: [2] (buffer) MultiByteToWideChar: Requires maximum length in CHARACTERS, not bytes (CWE-120). MultiByteToWideChar(CP_ACP, 0, file_name, -1, &wide_file_name[0], static_cast<int>(wide_file_name.size())); data/pipewalker-0.9.4/src/image.cpp:111: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). img_file = fopen(file_name, "rb"); data/pipewalker-0.9.4/src/image.cpp:282: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( data/pipewalker-0.9.4/src/image.cpp:351: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( data/pipewalker-0.9.4/src/image.cpp:363: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( data/pipewalker-0.9.4/src/image.cpp:378: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(&img._data[row_src + (img._width - x - 1) * BPP], src_data, BPP); data/pipewalker-0.9.4/src/image.cpp:398:6: [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(&img._data[y * img._width * BPP + x * BPP], &_data[ys * _width * BPP + xs * BPP], BPP); data/pipewalker-0.9.4/src/image.cpp:418: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(swap_buff, src, ln_size); data/pipewalker-0.9.4/src/image.cpp:419: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(src, dst, ln_size); data/pipewalker-0.9.4/src/image.cpp:420: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(dst, swap_buff, ln_size); data/pipewalker-0.9.4/src/level.cpp:42:2: [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(_id_text, "%08u", static_cast<unsigned int>(_id)); data/pipewalker-0.9.4/src/level.cpp:87:2: [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(_id_text, "%08u", static_cast<unsigned int>(_id)); data/pipewalker-0.9.4/src/level.cpp:134: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 buf[3]; data/pipewalker-0.9.4/src/level.cpp:135:4: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(buf, "%02x", cell_state); data/pipewalker-0.9.4/src/level.h:194: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 _id_text[9]; ///< Map ID (as text) data/pipewalker-0.9.4/src/main.cpp:256:40: [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). lvl_id = static_cast<unsigned long>(atoi(param_val + sizeof("id=") - 1)); data/pipewalker-0.9.4/src/main.cpp:261:51: [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). lvl_wrap = *(param_val + sizeof("id=") - 1) && atoi(param_val + sizeof("id=") - 1) != 0; data/pipewalker-0.9.4/src/settings.cpp:181: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). fstr.open(settings_file.c_str(), ifstream::in); data/pipewalker-0.9.4/src/settings.cpp:193: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). fstr.open(settings_file.c_str(), ifstream::in); data/pipewalker-0.9.4/src/settings.cpp:238: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). fstr.open(settings_file.c_str(), ofstream::out); data/pipewalker-0.9.4/src/settings.cpp:266:39: [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). return val.empty() ? default_value : atoi(val.c_str()); data/pipewalker-0.9.4/src/settings.cpp:284: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 buff[16]; data/pipewalker-0.9.4/src/settings.cpp:285:2: [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(buff, "%i", val); data/pipewalker-0.9.4/src/image.cpp:59:26: [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). wstring wide_file_name(strlen(file_name) + 1, 0); data/pipewalker-0.9.4/src/mode_settings.cpp:66:49: [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). renderer.draw_text(0.0f - ((static_cast<float>(strlen(theme_name)) / 2.0f) * 0.55f), -4.0f, 0.7f, alpha, theme_name); ANALYSIS SUMMARY: Hits = 51 Lines analyzed = 5260 in approximately 0.15 seconds (34698 lines/second) Physical Source Lines of Code (SLOC) = 3159 Hits@level = [0] 26 [1] 2 [2] 23 [3] 26 [4] 0 [5] 0 Hits@level+ = [0+] 77 [1+] 51 [2+] 49 [3+] 26 [4+] 0 [5+] 0 Hits/KSLOC@level+ = [0+] 24.3748 [1+] 16.1443 [2+] 15.5112 [3+] 8.23045 [4+] 0 [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.