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/pbzip2-1.1.13/BZ2StreamScanner.cpp
Examining data/pbzip2-1.1.13/BZ2StreamScanner.h
Examining data/pbzip2-1.1.13/ErrorContext.cpp
Examining data/pbzip2-1.1.13/ErrorContext.h
Examining data/pbzip2-1.1.13/pbzip2.h
Examining data/pbzip2-1.1.13/pbzip2.cpp

FINAL RESULTS:

data/pbzip2-1.1.13/pbzip2.cpp:3140:8:  [5] (race) chmod:
  This accepts filename arguments; if an attacker can move those files, a
  race condition results. (CWE-362). Use fchmod( ) instead.
	ret = chmod(fileName, fileMetaData.st_mode);
data/pbzip2-1.1.13/pbzip2.cpp:3157:8:  [5] (race) chown:
  This accepts filename arguments; if an attacker can move those files, a
  race condition results. (CWE-362). Use fchown( ) instead.
	ret = chown(fileName, fileMetaData.st_uid, fileMetaData.st_gid);
data/pbzip2-1.1.13/pbzip2.cpp:637: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(stderr, fmt, args);
data/pbzip2-1.1.13/BZ2StreamScanner.cpp:148: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( newBuff, _outBuff.buf, _outBuff.bufSize );
data/pbzip2-1.1.13/BZ2StreamScanner.cpp:195: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( getOutBuffEnd(), getInBuffCurrent(), additionSize );
data/pbzip2-1.1.13/pbzip2.cpp:335: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).
	int ret = open(path, O_WRONLY | O_CREAT | O_EXCL | O_BINARY, FILE_MODE);
data/pbzip2-1.1.13/pbzip2.cpp:441: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).
	int hOutfile = open( filename, O_RDONLY | O_BINARY );
data/pbzip2-1.1.13/pbzip2.cpp:2105:11:  [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 obuf[5000];
data/pbzip2-1.1.13/pbzip2.cpp:2106:11:  [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 unused[BZ_MAX_UNUSED];
data/pbzip2-1.1.13/pbzip2.cpp:2120: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).
		zStream = fopen(InFilename, "rb");
data/pbzip2-1.1.13/pbzip2.cpp:2995:11:  [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 obuf[5000];
data/pbzip2-1.1.13/pbzip2.cpp:2996:11:  [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 unused[BZ_MAX_UNUSED];
data/pbzip2-1.1.13/pbzip2.cpp:3009: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).
		zStream = fopen(fileName, "rb");
data/pbzip2-1.1.13/pbzip2.cpp:3289: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 cmdLineTemp[2048];
data/pbzip2-1.1.13/pbzip2.cpp:3290:11:  [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 tmpBuff[50];
data/pbzip2-1.1.13/pbzip2.cpp:3291: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 stdinFile[2] = {"-"};
data/pbzip2-1.1.13/pbzip2.cpp:3385:31:  [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.
	FileList = new(std::nothrow) char *[argc];
data/pbzip2-1.1.13/pbzip2.cpp:3515: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).
					numCPU = atoi(cmdLineTemp);
data/pbzip2-1.1.13/pbzip2.cpp:3544:18:  [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).
					blockSize = atoi(cmdLineTemp)*100000;
data/pbzip2-1.1.13/pbzip2.cpp:3568:18:  [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).
					maxMemory = atoi(cmdLineTemp)*1000000;
data/pbzip2-1.1.13/pbzip2.cpp:3594:29:  [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).
					ChildThreadStackSize = atoi(cmdLineTemp)*1024;
data/pbzip2-1.1.13/pbzip2.cpp:3891:14:  [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).
			hInfile = open(InFilename, O_RDONLY | O_BINARY);
data/pbzip2-1.1.13/pbzip2.cpp:3992:14:  [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).
			hInfile = open(InFilename, O_RDONLY | O_BINARY);
data/pbzip2-1.1.13/pbzip2.cpp:315:43:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
	while ((bytesRemaining > 0) && (nbytes = read(fd, pbuf, bytesRemaining)) > 0)
data/pbzip2-1.1.13/pbzip2.cpp:2217:15:  [1] (buffer) fgetc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
						int c = fgetc(zStream);
data/pbzip2-1.1.13/pbzip2.cpp:2299:12:  [1] (buffer) fgetc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
			int c = fgetc(zStream);
data/pbzip2-1.1.13/pbzip2.cpp:2372:9:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
		ret = read(hf, buf, rsize);
data/pbzip2-1.1.13/pbzip2.cpp:3085:12:  [1] (buffer) fgetc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
			int c = fgetc(zStream);
data/pbzip2-1.1.13/pbzip2.cpp:3494:75:  [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).
			fprintf(stderr, "argv[%u]: %s   Len: %d\n", (unsigned)i, argv[i], (int)strlen(argv[i]));
data/pbzip2-1.1.13/pbzip2.cpp:3502:46:  [1] (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 character.
				case 'p': k = j+1; cmdLineTempCount = 0; strcpy(cmdLineTemp, "2");
data/pbzip2-1.1.13/pbzip2.cpp:3513:6:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
					strncpy(cmdLineTemp, argv[i]+j+1, cmdLineTempCount);
data/pbzip2-1.1.13/pbzip2.cpp:3531:46:  [1] (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 character.
				case 'b': k = j+1; cmdLineTempCount = 0; strcpy(cmdLineTemp, "9"); blockSize = 900000;
data/pbzip2-1.1.13/pbzip2.cpp:3542:6:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
					strncpy(cmdLineTemp, argv[i]+j+1, cmdLineTempCount);
data/pbzip2-1.1.13/pbzip2.cpp:3555:46:  [1] (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 character.
				case 'm': k = j+1; cmdLineTempCount = 0; strcpy(cmdLineTemp, "1"); maxMemory = 1000000;
data/pbzip2-1.1.13/pbzip2.cpp:3566:6:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
					strncpy(cmdLineTemp, argv[i]+j+1, cmdLineTempCount);
data/pbzip2-1.1.13/pbzip2.cpp:3581:46:  [1] (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 character.
				case 'S': k = j+1; cmdLineTempCount = 0; strcpy(cmdLineTemp, "0"); ChildThreadStackSize = -1;
data/pbzip2-1.1.13/pbzip2.cpp:3592:6:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
					strncpy(cmdLineTemp, argv[i]+j+1, cmdLineTempCount);
data/pbzip2-1.1.13/pbzip2.cpp:3902: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).
			size_t size = do_read(hInfile, tmpBuff, strlen(bz2Header)+1);
data/pbzip2-1.1.13/pbzip2.cpp:3904:42:  [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 ((size == (size_t)(-1)) || (size < strlen(bz2Header)+1))
data/pbzip2-1.1.13/pbzip2.cpp:3923:48:  [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 (memstr(tmpBuff+4, size-4, bz2Header+4, strlen(bz2Header)-4) == NULL)
data/pbzip2-1.1.13/pbzip2.cpp:3926:53:  [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 (memstr(tmpBuff+4, size-4, Bz2HeaderZero+4, strlen(bz2Header)-4) == NULL)
data/pbzip2-1.1.13/pbzip2.h:77:9:  [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.
#define usleep(x) Sleep(x/1000)

ANALYSIS SUMMARY:

Hits = 42
Lines analyzed = 5874 in approximately 0.15 seconds (39374 lines/second)
Physical Source Lines of Code (SLOC) = 4357
Hits@level = [0] 295 [1]  19 [2]  20 [3]   0 [4]   1 [5]   2
Hits@level+ = [0+] 337 [1+]  42 [2+]  23 [3+]   3 [4+]   3 [5+]   2
Hits/KSLOC@level+ = [0+] 77.3468 [1+] 9.63966 [2+] 5.27886 [3+] 0.688547 [4+] 0.688547 [5+] 0.459031
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.