Skip to content

Bug in zip encryption #83

Description

@mikecat

This part looks wrong:

zlib.js/zip.js at develop · imaya/zlib.js · GitHub

      for (j = 0; j < 12; ++j) {
        buffer[j] = this.encode(
          key,
          i === 11 ? (file.crc32 & 0xff) : (Math.random() * 256 | 0)
        );
      }

Specifically the condition i === 1 looks wrong. j is used in this loop. i is used in an outer loop and won't change in this loop.

This wrong condition will prevent it from correctiy storing CRC information and make the resulting file incompatible with commonly-used decompression tools.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions