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/bzip2-1.0.8/blocksort.c
Examining data/bzip2-1.0.8/huffman.c
Examining data/bzip2-1.0.8/crctable.c
Examining data/bzip2-1.0.8/randtable.c
Examining data/bzip2-1.0.8/compress.c
Examining data/bzip2-1.0.8/decompress.c
Examining data/bzip2-1.0.8/bzlib.c
Examining data/bzip2-1.0.8/bzlib.h
Examining data/bzip2-1.0.8/bzlib_private.h
Examining data/bzip2-1.0.8/dlltest.c
Examining data/bzip2-1.0.8/unzcrash.c
Examining data/bzip2-1.0.8/spewG.c
Examining data/bzip2-1.0.8/mk251.c
Examining data/bzip2-1.0.8/bzip2.c
Examining data/bzip2-1.0.8/bzip2recover.c

FINAL RESULTS:

data/bzip2-1.0.8/bzip2.c:1126:4:  [4] (buffer) strcat:
  Does not check for buffer overflows when concatenating to destination
  [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or
  snprintf (warning: strncat is easily misused).
   strcat ( name, newSuffix );
data/bzip2-1.0.8/bzip2.c:1628:4:  [4] (format) fprintf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
   fprintf (
data/bzip2-1.0.8/bzip2.c:1734: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->name, name );
data/bzip2-1.0.8/bzip2recover.c:365:4:  [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 ( inFileName, argv[1] );
data/bzip2-1.0.8/bzip2recover.c:488:10:  [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 (outFileName, inFileName);
data/bzip2-1.0.8/bzip2recover.c:499:10:  [4] (buffer) strcat:
  Does not check for buffer overflows when concatenating to destination
  [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or
  snprintf (warning: strncat is easily misused).
         strcat (outFileName, inFileName + ofs);
data/bzip2-1.0.8/bzlib.c:1417:4:  [4] (buffer) strcat:
  Does not check for buffer overflows when concatenating to destination
  [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or
  snprintf (warning: strncat is easily misused).
   strcat(mode2, writing ? "w" : "r" );
data/bzip2-1.0.8/bzlib_private.h:65:7:  [4] (format) fprintf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
      fprintf ( stderr,   \
data/bzip2-1.0.8/bzlib_private.h:74:4:  [4] (format) fprintf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
   fprintf(stderr,zf)
data/bzip2-1.0.8/bzlib_private.h:76:4:  [4] (format) fprintf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
   fprintf(stderr,zf,za1)
data/bzip2-1.0.8/bzlib_private.h:78:4:  [4] (format) fprintf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
   fprintf(stderr,zf,za1,za2)
data/bzip2-1.0.8/bzlib_private.h:80:4:  [4] (format) fprintf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
   fprintf(stderr,zf,za1,za2,za3)
data/bzip2-1.0.8/bzlib_private.h:82:4:  [4] (format) fprintf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
   fprintf(stderr,zf,za1,za2,za3,za4)
data/bzip2-1.0.8/bzlib_private.h:84:4:  [4] (format) fprintf:
  If format strings can be influenced by an attacker, they can be exploited
  (CWE-134). Use a constant for the format specification.
   fprintf(stderr,zf,za1,za2,za3,za4,za5)
data/bzip2-1.0.8/bzip2.c:1752:14:  [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.
   envbase = getenv(varName);
data/bzip2-1.0.8/dlltest.c:31:9:  [3] (misc) LoadLibrary:
  Ensure that the full path to the library is specified, or current directory
  may be used (CWE-829, CWE-20). Use registry entry or GetWindowsDirectory to
  find library path, if you aren't already.
   hLib=LoadLibrary(BZ2_LIBNAME);
data/bzip2-1.0.8/spewG.c:41:4:  [3] (random) srandom:
  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.
   srandom(1);
data/bzip2-1.0.8/spewG.c:44:14:  [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 = 25+random()%50;
data/bzip2-1.0.8/bzip2.c:942:18:  [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 *tmp   = fopen ( name, "rb" );
data/bzip2-1.0.8/bzip2.c:965: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).
   fh = open(name, O_WRONLY|O_CREAT|O_EXCL, S_IWUSR|S_IRUSR);
data/bzip2-1.0.8/bzip2.c:971: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).
   return fopen(name, mode);
data/bzip2-1.0.8/bzip2.c:1153:10:  [2] (buffer) strcat:
  Does not check for buffer overflows when concatenating to destination
  [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or
  snprintf (warning: strncat is easily misused). Risk is low because the
  source is a constant string.
         strcat ( outName, ".bz2" ); 
data/bzip2-1.0.8/bzip2.c:1242:18:  [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).
         inStr = fopen ( inName, "rb" );
data/bzip2-1.0.8/bzip2.c:1263:18:  [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).
         inStr = fopen ( inName, "rb" );
data/bzip2-1.0.8/bzip2.c:1341:10:  [2] (buffer) strcat:
  Does not check for buffer overflows when concatenating to destination
  [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or
  snprintf (warning: strncat is easily misused). Risk is low because the
  source is a constant string.
         strcat ( outName, ".out" );
data/bzip2-1.0.8/bzip2.c:1428:18:  [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).
         inStr = fopen ( inName, "rb" );
data/bzip2-1.0.8/bzip2.c:1440:18:  [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).
         inStr = fopen ( inName, "rb" );
data/bzip2-1.0.8/bzip2.c:1570:18:  [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).
         inStr = fopen ( inName, "rb" );
data/bzip2-1.0.8/bzip2recover.c:281: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).
  fh = open(name, O_WRONLY|O_CREAT|O_EXCL, 0600);
data/bzip2-1.0.8/bzip2recover.c:367: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).
   inFile = fopen ( inFileName, "rb" );
data/bzip2-1.0.8/bzip2recover.c:441: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).
   inFile = fopen ( inFileName, "rb" );
data/bzip2-1.0.8/bzip2recover.c:497:10:  [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 (split, "rec%5d", wrBlock+1);
data/bzip2-1.0.8/bzip2recover.c:501:40:  [2] (buffer) strcat:
  Does not check for buffer overflows when concatenating to destination
  [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or
  snprintf (warning: strncat is easily misused). Risk is low because the
  source is a constant string.
         if ( !endsInBz2(outFileName)) strcat ( outFileName, ".bz2" );
data/bzip2-1.0.8/bzlib.c:1390: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   unused[BZ_MAX_UNUSED];
data/bzip2-1.0.8/bzlib.c:1393: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   mode2[10]     = "";
data/bzip2-1.0.8/bzlib.c:1425: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).
        fp = fopen(path,mode2);
data/bzip2-1.0.8/dlltest.c:116:7:  [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[0x1000];
data/bzip2-1.0.8/dlltest.c:117:7:  [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 mode[10];
data/bzip2-1.0.8/dlltest.c:124:24:  [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((fp_w = fopen(fn_w,"wb"))==NULL){
data/bzip2-1.0.8/dlltest.c:147:24:  [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((fp_r = fopen(fn_r,"rb"))==NULL){
data/bzip2-1.0.8/spewG.c:36:1:  [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[N_BUF];
data/bzip2-1.0.8/unzcrash.c:86:8:  [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 = fopen ( argv[1], "r" );
data/bzip2-1.0.8/bzip2.c:320:14:  [1] (buffer) fgetc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
   Int32 c = fgetc ( f );
data/bzip2-1.0.8/bzip2.c:911: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 ( (Int32)strlen(s) >= longestFileName ) return;
data/bzip2-1.0.8/bzip2.c:912:46:  [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).
   for (i = 1; i <= longestFileName - (Int32)strlen(s); i++)
data/bzip2-1.0.8/bzip2.c:921:9:  [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 ( strlen(from) > FILE_NAME_LEN-10 )  {
data/bzip2-1.0.8/bzip2.c:933:3:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
  strncpy(to,from,FILE_NAME_LEN-10);
data/bzip2-1.0.8/bzip2.c:1112: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).
   Int32 ns = strlen(s);
data/bzip2-1.0.8/bzip2.c:1113: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).
   Int32 nx = strlen(suffix);
data/bzip2-1.0.8/bzip2.c:1125:9:  [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).
   name[strlen(name)-strlen(oldSuffix)] = 0;
data/bzip2-1.0.8/bzip2.c:1125:22:  [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).
   name[strlen(name)-strlen(oldSuffix)] = 0;
data/bzip2-1.0.8/bzip2.c:1733: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).
      tmp->name = (Char*) myMalloc ( 5 + strlen(name) );
data/bzip2-1.0.8/bzip2.c:1842:36:  [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 (longestFileName < (Int32)strlen(aa->name) )
data/bzip2-1.0.8/bzip2.c:1843:35:  [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).
         longestFileName = (Int32)strlen(aa->name);
data/bzip2-1.0.8/bzip2recover.c:207:22:  [1] (buffer) getc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
      Int32 retVal = getc ( bs->handle );
data/bzip2-1.0.8/bzip2recover.c:265:14:  [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).
   Int32 n = strlen ( name );
data/bzip2-1.0.8/bzip2recover.c:327:4:  [1] (buffer) strncpy:
  Easily used incorrectly; doesn't always \0-terminate or check for invalid
  pointers [MS-banned] (CWE-120).
   strncpy ( progName, argv[0], BZ_MAX_FILENAME-1);
data/bzip2-1.0.8/bzip2recover.c:358:8:  [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 (strlen(argv[1]) >= BZ_MAX_FILENAME-20) {
data/bzip2-1.0.8/bzip2recover.c:361:32:  [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).
                progName, (int)strlen(argv[1]) );
data/bzip2-1.0.8/bzlib.c:908:14:  [1] (buffer) fgetc:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
   Int32 c = fgetc ( f );
data/bzip2-1.0.8/bzlib.c:1418:4:  [1] (buffer) strcat:
  Does not check for buffer overflows when concatenating to destination
  [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or
  snprintf (warning: strncat is easily misused). Risk is low because the
  source is a constant character.
   strcat(mode2,"b");   /* binary mode */

ANALYSIS SUMMARY:

Hits = 61
Lines analyzed = 8144 in approximately 0.26 seconds (31673 lines/second)
Physical Source Lines of Code (SLOC) = 5841
Hits@level = [0] 132 [1]  19 [2]  24 [3]   4 [4]  14 [5]   0
Hits@level+ = [0+] 193 [1+]  61 [2+]  42 [3+]  18 [4+]  14 [5+]   0
Hits/KSLOC@level+ = [0+] 33.0423 [1+] 10.4434 [2+] 7.19055 [3+] 3.08166 [4+] 2.39685 [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.