Skip to content

LZMA encryption fails with 2.7.0 #334

@vszakats

Description

@vszakats
$ curl -LO https://github.com/nmoinvaz/minizip/archive/2.7.0.tar.gz
$ tar -xvf 2.7.0.tar.gz
$ cd minizip-2.7.0
$ cmake .
$ make
$ clang test-crypt.c  -I. -L. -lminizip -lbz2 -lz

test-crypt.c:

#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#include "mz.h"
#include "mz_zip.h"
#include "mz_compat.h"

int main(void)
{
    zip_fileinfo zfi;
    const unsigned char content[] = "abcdefghijklmnopqrstuvvvwwwxxx";
    zipFile hZip;

    // create .zip
    printf("zcreat: %p\n", (void *)(hZip = zipOpen2_64("test.zip", APPEND_STATUS_CREATE, NULL, NULL)));
    memset(&zfi, 0, sizeof(zfi));
    printf("zaddfi: %d\n", zipOpenNewFileInZip4_64(hZip, "test.txt", &zfi, NULL, 0, NULL, 0, NULL,
                                                   MZ_COMPRESS_METHOD_LZMA, 6, 0,
                                                   -MAX_WBITS, DEF_MEM_LEVEL, 0,
                                                   "password", 0x4c72ad0a /* crc of 'content' */,
                                                   0, 0, 0));
    printf("zwrite: %d\n", zipWriteInFileInZip(hZip, content, sizeof(content)));
    printf("zfclos: %d\n", zipCloseFileInZip(hZip));
    printf("zclose: %d\n", zipClose(hZip, NULL));

    return 0;
}

actual output:

zcreat: 0x7fbdf2c02cc0
zaddfi: -102
zwrite: -1
zfclos: -102
zclose: 0

expected (and actual result with 2.6.0):

zcreat: 0x7fd15ac02cc0
zaddfi: 0
zwrite: 0
zfclos: 0
zclose: 0

(Tested on macOS 10.14)

Metadata

Metadata

Assignees

No one assigned

    Labels

    encryptionEncryption/decryption issuefixedIssue or bug has been fixedlzmaXZ compression format

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions