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/gddrescue-1.23/arg_parser.cc Examining data/gddrescue-1.23/arg_parser.h Examining data/gddrescue-1.23/block.cc Examining data/gddrescue-1.23/block.h Examining data/gddrescue-1.23/ddrescuelog.cc Examining data/gddrescue-1.23/fillbook.cc Examining data/gddrescue-1.23/genbook.cc Examining data/gddrescue-1.23/io.cc Examining data/gddrescue-1.23/loggers.cc Examining data/gddrescue-1.23/loggers.h Examining data/gddrescue-1.23/main.cc Examining data/gddrescue-1.23/main_common.cc Examining data/gddrescue-1.23/mapbook.cc Examining data/gddrescue-1.23/mapbook.h Examining data/gddrescue-1.23/mapfile.cc Examining data/gddrescue-1.23/non_posix.cc Examining data/gddrescue-1.23/non_posix.h Examining data/gddrescue-1.23/rational.cc Examining data/gddrescue-1.23/rational.h Examining data/gddrescue-1.23/rescuebook.cc Examining data/gddrescue-1.23/rescuebook.h FINAL RESULTS: data/gddrescue-1.23/mapbook.cc:76:33: [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 * const p = std::getenv( "HOME" ); data/gddrescue-1.23/block.cc:106: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 buf[80]; data/gddrescue-1.23/ddrescuelog.cc:301: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 buf[80]; data/gddrescue-1.23/ddrescuelog.cc:329: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 buf[80]; data/gddrescue-1.23/ddrescuelog.cc:369: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 buf[80]; data/gddrescue-1.23/fillbook.cc:224: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. std::memcpy( iobuf() + i, iobuf(), size ); data/gddrescue-1.23/genbook.cc:38: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. static char buffer[buffers][bufsize]; // circle of static buffers for printf data/gddrescue-1.23/loggers.cc:33: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. static char buf[32]; data/gddrescue-1.23/loggers.cc:82: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). f = std::fopen( filename_, "a" ); data/gddrescue-1.23/loggers.cc:130: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). f = std::fopen( filename_, "w" ); data/gddrescue-1.23/loggers.cc:160: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). f = std::fopen( filename_, "w" ); data/gddrescue-1.23/main.cc:279:20: [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). const int ides = open( iname, O_RDONLY | O_BINARY ); data/gddrescue-1.23/main.cc:287:20: [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). const int odes = open( oname, O_CREAT | O_WRONLY | o_direct_out | O_BINARY, data/gddrescue-1.23/main.cc:325:20: [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). const int ides = open( iname, O_RDONLY | O_BINARY ); data/gddrescue-1.23/main.cc:341:20: [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). const int odes = open( oname, O_RDONLY | O_BINARY ); data/gddrescue-1.23/main.cc:372: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 buf[32]; data/gddrescue-1.23/main.cc:391:24: [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). const int odes = open( oname, O_RDONLY ); data/gddrescue-1.23/main.cc:445:20: [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). const int ides = open( iname, O_RDONLY | rb_opts.o_direct_in | O_BINARY ); data/gddrescue-1.23/main.cc:488:20: [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). const int odes = open( oname, O_CREAT | O_WRONLY | o_direct_out | data/gddrescue-1.23/main.cc:695:11: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). ides_ = open( iname_, O_RDONLY | o_direct_in | O_BINARY ); data/gddrescue-1.23/main_common.cc:119: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 buf[80]; data/gddrescue-1.23/main_common.cc:154: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. static char buf[80]; data/gddrescue-1.23/main_common.cc:194: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 buf[80]; data/gddrescue-1.23/main_common.cc:204: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 buf[80]; data/gddrescue-1.23/main_common.cc:254: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. const char * const si_prefix[8] = data/gddrescue-1.23/main_common.cc:256: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. const char * const binary_prefix[8] = data/gddrescue-1.23/main_common.cc:259: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. static char buffer[buffers][bufsize]; // circle of static buffers for printf data/gddrescue-1.23/main_common.cc:283: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. static char buf[80]; data/gddrescue-1.23/mapbook.cc:40: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 buf[128]; data/gddrescue-1.23/mapbook.cc:53:25: [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 * const f = std::fopen( name, "w" ); data/gddrescue-1.23/mapbook.cc:56: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 buf[80]; data/gddrescue-1.23/mapbook.cc:150: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 buf[80]; data/gddrescue-1.23/mapfile.cc:50: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. static char buf[maxlen+1]; data/gddrescue-1.23/mapfile.cc:73: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 buf[80]; data/gddrescue-1.23/mapfile.cc:213:31: [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). else if( ro || ( !(f = std::fopen( filename_, "r+" )) && errno != ENOENT ) ) data/gddrescue-1.23/mapfile.cc:214: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). { f = std::fopen( filename_, "r" ); read_only_ = true; } data/gddrescue-1.23/mapfile.cc:274:23: [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 ) { f = std::fopen( filename_, "w" ); if( !f ) return false; } data/gddrescue-1.23/mapfile.cc:278: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 buf[80] = { 0 }; // comment data/gddrescue-1.23/non_posix.cc:50: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 buf[256]; data/gddrescue-1.23/non_posix.cc:73: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 raw[1024]; data/gddrescue-1.23/rescuebook.cc:155:34: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. { voe_ipos = b.pos(); std::memcpy( voe_buf, iobuf(), hardbs() ); } data/gddrescue-1.23/rescuebook.cc:262: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 msgbuf[80] = "Copying non-tried blocks... Pass "; data/gddrescue-1.23/rescuebook.cc:544: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 msgbuf[80] = "Retrying bad sectors... Retry "; data/gddrescue-1.23/rescuebook.cc:915: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 buf[80]; data/gddrescue-1.23/arg_parser.cc:40: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). if( std::strlen( options[i].name ) == len ) // Exact match found data/gddrescue-1.23/fillbook.cc:143:28: [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). const int len = std::strlen( msg ); std::printf( "\r%s", msg ); data/gddrescue-1.23/genbook.cc:153:28: [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). const int len = std::strlen( msg ); std::printf( "\r%s", msg ); data/gddrescue-1.23/io.cc:62:19: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). const int n = read( fd, buf + sz, size - sz ); data/gddrescue-1.23/io.cc:84:21: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). const int n = read( fd, buf + sz, size - sz ); data/gddrescue-1.23/main.cc:414:31: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). return ( std::tolower( std::fgetc( stdin ) ) == 'y' ); data/gddrescue-1.23/main_common.cc:93:47: [1] (obsolete) ulimit: This C routine is considered obsolete (as opposed to the shell command by the same name, which is NOT obsolete) (CWE-676). Use getrlimit(2), setrlimit(2), and sysconf(3) instead. if( !errno && ( result < llimit || result > ulimit ) ) errno = ERANGE; data/gddrescue-1.23/mapbook.cc:160:40: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). const int c = std::tolower( std::fgetc( stdin ) ); data/gddrescue-1.23/mapbook.cc:162:53: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). while( tmp != '\n' && tmp != EOF ) tmp = std::fgetc( stdin ); data/gddrescue-1.23/mapfile.cc:37:17: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). int ch = std::fgetc( f ); data/gddrescue-1.23/mapfile.cc:39:20: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). { do ch = std::fgetc( f ); while( ch != '\n' && ch != EOF ); } data/gddrescue-1.23/rescuebook.cc:263:27: [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). const int msglen = std::strlen( msgbuf ); data/gddrescue-1.23/rescuebook.cc:545:27: [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). const int msglen = std::strlen( msgbuf ); data/gddrescue-1.23/rescuebook.cc:774: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). const int len = std::strlen( msg ); std::printf( "\r%s", msg ); ANALYSIS SUMMARY: Hits = 58 Lines analyzed = 6139 in approximately 0.24 seconds (26046 lines/second) Physical Source Lines of Code (SLOC) = 4961 Hits@level = [0] 135 [1] 14 [2] 43 [3] 1 [4] 0 [5] 0 Hits@level+ = [0+] 193 [1+] 58 [2+] 44 [3+] 1 [4+] 0 [5+] 0 Hits/KSLOC@level+ = [0+] 38.9034 [1+] 11.6912 [2+] 8.86918 [3+] 0.201572 [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.