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/unrar-free-0.0.1+cvs20140707/src/unrar.h Examining data/unrar-free-0.0.1+cvs20140707/src/unpack29.c Examining data/unrar-free-0.0.1+cvs20140707/src/unrarlib.h Examining data/unrar-free-0.0.1+cvs20140707/src/opts.h Examining data/unrar-free-0.0.1+cvs20140707/src/unrar.c Examining data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c Examining data/unrar-free-0.0.1+cvs20140707/src/opts.c FINAL RESULTS: data/unrar-free-0.0.1+cvs20140707/src/unrar.c:316:8: [5] (race) chmod: This accepts filename arguments; if an attacker can move those files, a race condition results. (CWE-362). Use fchmod( ) instead. chmod (destination, 0777); data/unrar-free-0.0.1+cvs20140707/src/opts.c:96:20: [4] (misc) getpass: This function is obsolete and not portable. It was in SUSv2 but removed by POSIX.2. What it does exactly varies considerably between systems, particularly in where its prompt is displayed and where it gets its data (e.g., /dev/tty, stdin, stderr, etc.). In addition, some implementations overflow buffers. (CWE-676, CWE-120, CWE-20). Make the specific calls to do exactly what you want. If you continue to use it, or write your own, be sure to zero the password as soon as possible to avoid leaving the cleartext password visible in the process' address space. if ((pass = getpass ("Password:"))) data/unrar-free-0.0.1+cvs20140707/src/opts.c:300:19: [4] (misc) getpass: This function is obsolete and not portable. It was in SUSv2 but removed by POSIX.2. What it does exactly varies considerably between systems, particularly in where its prompt is displayed and where it gets its data (e.g., /dev/tty, stdin, stderr, etc.). In addition, some implementations overflow buffers. (CWE-676, CWE-120, CWE-20). Make the specific calls to do exactly what you want. If you continue to use it, or write your own, be sure to zero the password as soon as possible to avoid leaving the cleartext password visible in the process' address space. if ((pass = getpass ("Password:")) != NULL) { data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:298:3: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf (DebugMsg, "Extracting \"%s\" from \"%s\" (password is \"%s\")...", data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:331:7: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf (DebugMsg, data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:416:7: [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 (tmp_List->item.Name, ArcFileName); data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:2098: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 ((char *) Psw, Password); data/unrar-free-0.0.1+cvs20140707/src/opts.c:120:11: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. file = realpath (arguments->args[0], NULL); data/unrar-free-0.0.1+cvs20140707/src/opts.c:145:10: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. dir = realpath (arguments->args[arguments->arraylen - 1], NULL); data/unrar-free-0.0.1+cvs20140707/src/opts.c:173:30: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. unrar->destination_dir = realpath ("./", NULL); data/unrar-free-0.0.1+cvs20140707/src/opts.c:359:12: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. file = realpath (arguments1->args[0], NULL); data/unrar-free-0.0.1+cvs20140707/src/opts.c:383:11: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. dir = realpath (arguments1->args[arguments1->arraylen - 1], NULL); data/unrar-free-0.0.1+cvs20140707/src/unpack29.c:94: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 tmpfilename[100]; data/unrar-free-0.0.1+cvs20140707/src/unpack29.c:101:11: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). ofile = fopen(tmpfilename,"w+b"); data/unrar-free-0.0.1+cvs20140707/src/unpack29.c:103:11: [2] (tmpfile) tmpfile: Function tmpfile() has a security flaw on some systems (e.g., older System V systems) (CWE-377). ofile = tmpfile(); data/unrar-free-0.0.1+cvs20140707/src/unpack29.c:154: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 * unarARGV[10]; data/unrar-free-0.0.1+cvs20140707/src/unpack29.c:215: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). dataFile = fopen(dataFileName, "r"); data/unrar-free-0.0.1+cvs20140707/src/unrar.c:142: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 datetime[20]; data/unrar-free-0.0.1+cvs20140707/src/unrar.c:271: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). fd = open (filename, fcntl_flags, 0666); data/unrar-free-0.0.1+cvs20140707/src/unrar.c:274:10: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). fd = open (filename, fcntl_flags, 0666); data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:275: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 DebugMsg[500]; /* used to compose debug msg */ data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:337:7: [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 (DebugMsg, "Extracted %u Bytes.", (unsigned int) *size); data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:359: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). inputfile = fopen (rarfile, "r"); data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:551: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 tmpbuf1[8]; data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:598:12: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. unsigned char Header[64]; data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:632: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 tmpbuf1[8]; data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:697:20: [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 ((inputfile = fopen (ArcName, "r")) != NULL) data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:772:8: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char DebugMsg[64]; data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:849: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 S1[512], S2[512]; data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:950: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. unsigned char InBuf[8192]; /* input read buffer */ data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:952: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. unsigned char UnpOldTable[MC * 4]; data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:1116: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 (temp_output_buffer + *temp_output_buffer_offset, data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:1121: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 (temp_output_buffer + *temp_output_buffer_offset, data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:1139: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 (temp_output_buffer + *temp_output_buffer_offset, data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:1286:8: [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 (temp_output_buffer + *temp_output_buffer_offset, data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:1291:8: [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 (temp_output_buffer + *temp_output_buffer_offset, UnpBuf, data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:1308:8: [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 (temp_output_buffer + *temp_output_buffer_offset, data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:1374:7: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy (InBuf, &InBuf[sizeof (InBuf) - 32], 32); data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:1389:12: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. unsigned char Table[MC * 4]; data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:2085:12: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. unsigned char Psw[256]; data/unrar-free-0.0.1+cvs20140707/src/unpack29.c:124:11: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). c = fgetc(ofile); data/unrar-free-0.0.1+cvs20140707/src/unpack29.c:212:21: [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). dataFileNameLen = strlen(tempdir)+strlen(argName)+1; data/unrar-free-0.0.1+cvs20140707/src/unpack29.c:212:37: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). dataFileNameLen = strlen(tempdir)+strlen(argName)+1; data/unrar-free-0.0.1+cvs20140707/src/unpack29.c:233:11: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). c = fgetc(dataFile); data/unrar-free-0.0.1+cvs20140707/src/unrar.c:365:34: [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 (!strncmp ("../", file, strlen("../")) || strstr (file, "/../")) data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:561:19: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). sflag = fgetc(inputfile); data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:562:22: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). sflag |= ((fgetc(inputfile)<<8) & 0x0ff00); data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:577:15: [1] (buffer) fgetc: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). fgetc(inputfile); data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:852:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (S1, Str1, sizeof (S1)); data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:853:3: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy (S2, Str2, sizeof (S2)); data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:2099: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). PswLength = strlen (Password); data/unrar-free-0.0.1+cvs20140707/src/unrarlib.c:2147:56: [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). PswCRC = CalcCRC32 (0xFFFFFFFFL, (UBYTE *) Password, strlen (Password)); ANALYSIS SUMMARY: Hits = 52 Lines analyzed = 3605 in approximately 0.10 seconds (37534 lines/second) Physical Source Lines of Code (SLOC) = 2895 Hits@level = [0] 45 [1] 12 [2] 28 [3] 5 [4] 6 [5] 1 Hits@level+ = [0+] 97 [1+] 52 [2+] 40 [3+] 12 [4+] 7 [5+] 1 Hits/KSLOC@level+ = [0+] 33.506 [1+] 17.962 [2+] 13.8169 [3+] 4.14508 [4+] 2.41796 [5+] 0.345423 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.