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/r-cran-zip-2.1.1/src/rzip.c
Examining data/r-cran-zip-2.1.1/src/zip.c
Examining data/r-cran-zip-2.1.1/src/tools/cmdzip.c
Examining data/r-cran-zip-2.1.1/src/tools/cmdunzip.c
Examining data/r-cran-zip-2.1.1/src/winutils.c
Examining data/r-cran-zip-2.1.1/src/miniz.h
Examining data/r-cran-zip-2.1.1/src/init.c
Examining data/r-cran-zip-2.1.1/src/miniz.c
Examining data/r-cran-zip-2.1.1/src/zip.h
Examining data/r-cran-zip-2.1.1/src/unixutils.c

FINAL RESULTS:

data/r-cran-zip-2.1.1/src/zip.c:226:9:  [5] (race) chmod:
  This accepts filename arguments; if an attacker can move those files, a
  race condition results. (CWE-362). Use fchmod( ) instead.
    if (chmod(buffer, mode)) {
data/r-cran-zip-2.1.1/src/tools/cmdunzip.c:59:5:  [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, "Failed to create zip archive " CFMT, argv[1]);
data/r-cran-zip-2.1.1/src/tools/cmdzip.c:119:5:  [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, "Failed to create zip archive " CFMT, argv[1]);
data/r-cran-zip-2.1.1/src/unixutils.c:43: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(*buffer, cexdir);
data/r-cran-zip-2.1.1/src/unixutils.c:45: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(*buffer + len1 + 1, key);
data/r-cran-zip-2.1.1/src/zip.c:56:3:  [4] (format) vsnprintf:
  If format strings can be influenced by an attacker, they can be exploited,
  and note that sprintf variations do not always \0-terminate (CWE-134). Use
  a constant for the format specification.
  vsnprintf(zip_error_buffer, ZIP_ERROR_BUFFER_SIZE - 1,
data/r-cran-zip-2.1.1/src/miniz.c:29:18:  [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.
typedef unsigned char mz_validate_uint16[sizeof(mz_uint16) == 2 ? 1 : -1];
data/r-cran-zip-2.1.1/src/miniz.c:30:18:  [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.
typedef unsigned char mz_validate_uint32[sizeof(mz_uint32) == 4 ? 1 : -1];
data/r-cran-zip-2.1.1/src/miniz.c:31:18:  [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.
typedef unsigned char mz_validate_uint64[sizeof(mz_uint64) == 8 ? 1 : -1];
data/r-cran-zip-2.1.1/src/miniz.c:460: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(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n);
data/r-cran-zip-2.1.1/src/miniz.c:485: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(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n);
data/r-cran-zip-2.1.1/src/miniz.c:961: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(code_sizes_to_pack, &d->m_huff_code_sizes[0][0], num_lit_codes);
data/r-cran-zip-2.1.1/src/miniz.c:962: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(code_sizes_to_pack + num_lit_codes, &d->m_huff_code_sizes[1][0], num_dist_codes);
data/r-cran-zip-2.1.1/src/miniz.c:1324:13:  [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((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs, d->m_output_buf, bytes_to_copy);
data/r-cran-zip-2.1.1/src/miniz.c:1346:2:  [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(&ret, p, sizeof(mz_uint16));
data/r-cran-zip-2.1.1/src/miniz.c:1352:2:  [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(&ret, p, sizeof(mz_uint16));
data/r-cran-zip-2.1.1/src/miniz.c:1476:13:  [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(d->m_dict + dst_pos, d->m_pSrc, n);
data/r-cran-zip-2.1.1/src/miniz.c:1478:17:  [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(d->m_dict + TDEFL_LZ_DICT_SIZE + dst_pos, d->m_pSrc, MZ_MIN(n, (TDEFL_MAX_MATCH_LEN - 1) - dst_pos));
data/r-cran-zip-2.1.1/src/miniz.c:1826: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((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs, d->m_output_buf + d->m_output_flush_ofs, n);
data/r-cran-zip-2.1.1/src/miniz.c:1998: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((mz_uint8 *)p->m_pBuf + p->m_size, pBuf, len);
data/r-cran-zip-2.1.1/src/miniz.c:2122: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(out_buf.m_pBuf, pnghdr, 41);
data/r-cran-zip-2.1.1/src/miniz.c:2200:31:  [2] (buffer) memcpy:
  Does not check for buffer overflows when copying to destination (CWE-120).
  Make sure destination can always hold the source data.
#define TINFL_MEMCPY(d, s, l) memcpy(d, s, l)
data/r-cran-zip-2.1.1/src/miniz.c:2978: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).
#define MZ_FOPEN(f, m) fopen(f, m)
data/r-cran-zip-2.1.1/src/miniz.c:2993: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).
#define MZ_FOPEN(f, m) fopen(f, m)
data/r-cran-zip-2.1.1/src/miniz.c:3023: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).
#define MZ_FOPEN(f, m) fopen(f, m)
data/r-cran-zip-2.1.1/src/miniz.c:3040: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).
#define MZ_FOPEN(f, m) fopen(f, m)
data/r-cran-zip-2.1.1/src/miniz.c:3258:20:  [2] (buffer) memcpy:
  Does not check for buffer overflows when copying to destination (CWE-120).
  Make sure destination can always hold the source data.
    if (pElements) memcpy((mz_uint8 *)pArray->m_p + orig_size * pArray->m_element_size, pElements, n * pArray->m_element_size);
data/r-cran-zip-2.1.1/src/miniz.c:3801: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(pBuf, (const mz_uint8 *)pZip->m_pState->m_pMem + file_ofs, s);
data/r-cran-zip-2.1.1/src/miniz.c:3968: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(value, p + MZ_ZIP_CDH_VERSION_MADE_BY_OFS, sizeof(mz_uint16));
data/r-cran-zip-2.1.1/src/miniz.c:3978: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(p + MZ_ZIP_CDH_VERSION_MADE_BY_OFS, &value, sizeof(mz_uint16));
data/r-cran-zip-2.1.1/src/miniz.c:3988: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(value, p + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS, sizeof(mz_uint32));
data/r-cran-zip-2.1.1/src/miniz.c:3998: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(p + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS, &value, sizeof(mz_uint32));
data/r-cran-zip-2.1.1/src/miniz.c:4115: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(pStat->m_filename, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n);
data/r-cran-zip-2.1.1/src/miniz.c:4121: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(pStat->m_comment, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS) + MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS), n);
data/r-cran-zip-2.1.1/src/miniz.c:4925:13:  [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( pvBuf, pState->pRead_buf, copied_to_caller );
data/r-cran-zip-2.1.1/src/miniz.c:4997:17:  [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( (uint8_t*)pvBuf + copied_to_caller, pWrite_buf_cur, to_copy );
data/r-cran-zip-2.1.1/src/miniz.c:5550: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((mz_uint8 *)pState->m_pMem + file_ofs, pBuf, n);
data/r-cran-zip-2.1.1/src/miniz.c:5737: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[4096];
data/r-cran-zip-2.1.1/src/miniz.c:6042: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[4096];
data/r-cran-zip-2.1.1/src/miniz.c:7030: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(new_central_header, pSrc_central_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE);
data/r-cran-zip-2.1.1/src/miniz.c:7580: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(pFilename, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n);
data/r-cran-zip-2.1.1/src/miniz.h:960: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 m_filename[MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE];
data/r-cran-zip-2.1.1/src/miniz.h:964: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 m_comment[MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE];
data/r-cran-zip-2.1.1/src/rzip.c:37: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).
  fh = fopen(czipfile, "rb");
data/r-cran-zip-2.1.1/src/rzip.c:216: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 fd = open(cfilename, O_WRONLY | O_CREAT);
data/r-cran-zip-2.1.1/src/tools/cmdzip.c:49: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(argv[2], O_RDONLY);
data/r-cran-zip-2.1.1/src/unixutils.c:14: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).
  FILE *fh = fopen(filename, mode);
data/r-cran-zip-2.1.1/src/winutils.c:14:12:  [2] (buffer) MultiByteToWideChar:
  Requires maximum length in CHARACTERS, not bytes (CWE-120).
  ws_len = MultiByteToWideChar(
data/r-cran-zip-2.1.1/src/winutils.c:34:7:  [2] (buffer) MultiByteToWideChar:
  Requires maximum length in CHARACTERS, not bytes (CWE-120).
  r = MultiByteToWideChar(
data/r-cran-zip-2.1.1/src/winutils.c:94:10:  [2] (buffer) MultiByteToWideChar:
  Requires maximum length in CHARACTERS, not bytes (CWE-120).
  len1 = MultiByteToWideChar(
data/r-cran-zip-2.1.1/src/winutils.c:102:10:  [2] (buffer) MultiByteToWideChar:
  Requires maximum length in CHARACTERS, not bytes (CWE-120).
  len2 = MultiByteToWideChar(
data/r-cran-zip-2.1.1/src/winutils.c:126:10:  [2] (buffer) MultiByteToWideChar:
  Requires maximum length in CHARACTERS, not bytes (CWE-120).
  len1 = MultiByteToWideChar(
data/r-cran-zip-2.1.1/src/winutils.c:134:10:  [2] (buffer) MultiByteToWideChar:
  Requires maximum length in CHARACTERS, not bytes (CWE-120).
  len2 = MultiByteToWideChar(
data/r-cran-zip-2.1.1/src/zip.c:19: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.
static char zip_error_buffer[ZIP_ERROR_BUFFER_SIZE];
data/r-cran-zip-2.1.1/src/zip.c:205:12:  [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).
      fh = fopen(buffer, "wb");
data/r-cran-zip-2.1.1/src/miniz.c:4239:43:  [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 mz_uint filename_len = (mz_uint)strlen(pFilename);
data/r-cran-zip-2.1.1/src/miniz.c:4301: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).
    name_len = strlen(pName);
data/r-cran-zip-2.1.1/src/miniz.c:4305: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).
    comment_len = pComment ? strlen(pComment) : 0;
data/r-cran-zip-2.1.1/src/miniz.c:5211:38:  [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 (local_header_filename_len != strlen(file_stat.m_filename))
data/r-cran-zip-2.1.1/src/miniz.c:6145:25:  [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).
    archive_name_size = strlen(pArchive_name);
data/r-cran-zip-2.1.1/src/miniz.c:6404:25:  [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).
    archive_name_size = strlen(pArchive_name);
data/r-cran-zip-2.1.1/src/tools/cmdzip.c:54:7:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  if (read(fd, &num_files, sizeof(num_files)) != sizeof(num_files)) {
data/r-cran-zip-2.1.1/src/tools/cmdzip.c:66:7:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  if (read(fd, &ckeysbytes, sizeof(ckeysbytes)) != sizeof(ckeysbytes)) {
data/r-cran-zip-2.1.1/src/tools/cmdzip.c:71:7:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  if (read(fd, keysbuffer, ckeysbytes) != ckeysbytes) ZERROR(6);
data/r-cran-zip-2.1.1/src/tools/cmdzip.c:78:7:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  if (read(fd, &cfilesbytes, sizeof(cfilesbytes)) != sizeof(cfilesbytes)) {
data/r-cran-zip-2.1.1/src/tools/cmdzip.c:83:7:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  if (read(fd, filesbuffer, cfilesbytes) != cfilesbytes) ZERROR(8);
data/r-cran-zip-2.1.1/src/tools/cmdzip.c:90:7:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  if (read(fd, cdirs, num_files * sizeof(int)) != num_files * sizeof(int)) {
data/r-cran-zip-2.1.1/src/tools/cmdzip.c:95:7:  [1] (buffer) read:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
  if (read(fd, ctimes, num_files * sizeof(double)) !=
data/r-cran-zip-2.1.1/src/unixutils.c:23:17:  [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 len1 = strlen(cexdir);
data/r-cran-zip-2.1.1/src/unixutils.c:32:10:  [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).
  len2 = strlen(key);

ANALYSIS SUMMARY:

Hits = 70
Lines analyzed = 10187 in approximately 0.26 seconds (39290 lines/second)
Physical Source Lines of Code (SLOC) = 7839
Hits@level = [0]  10 [1]  15 [2]  49 [3]   0 [4]   5 [5]   1
Hits@level+ = [0+]  80 [1+]  70 [2+]  55 [3+]   6 [4+]   6 [5+]   1
Hits/KSLOC@level+ = [0+] 10.2054 [1+] 8.92971 [2+] 7.0162 [3+] 0.765404 [4+] 0.765404 [5+] 0.127567
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.