Repository navigation
Closed
Labels
compatibilityBackwards compatibilityBackwards compatibilityfixedIssue or bug has been fixedIssue or bug has been fixedrawRaw file storageRaw file storage
Description
Both output .zip extracts fine with 2.3.9. With 2.4.0 testcopy.zip fails with ERROR: CRC Failed : test.txt (using 7za to uncompress):
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "mz.h"
#include "mz_zip.h"
#include "mz_compat.h"
int main(void)
{
int iResult;
zip_fileinfo zfi;
const unsigned char content[] = "abcdefghijklmnopqrstuvvvwwwxxx";
zipFile hZip;
unzFile hUnzip;
unz_file_info64 ufi;
void * buffer;
int iRead;
// 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,
NULL /* "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));
// create another .zip by using raw data of the above
// (= without recompressing)
printf("zcreat: %p\n", (void *)(hZip = zipOpen2_64("testcopy.zip", APPEND_STATUS_CREATE, NULL, NULL)));
printf("uopen : %p\n", (void *)(hUnzip = unzOpen2_64("test.zip", NULL)));
printf("ufinfo: %d\n", unzGetCurrentFileInfo64(hUnzip, &ufi, NULL, 0, NULL, 0, NULL, 0));
printf("ufopen: %d\n", unzOpenCurrentFile3(hUnzip, NULL, NULL, 1 /* raw! */, NULL));
memset(&zfi, 0, sizeof(zfi));
zfi.dosDate = ufi.dosDate;
zfi.internal_fa = ufi.internal_fa;
zfi.external_fa = ufi.external_fa;
printf("zaddfi: %d\n", zipOpenNewFileInZip4_64(hZip, "test.txt", &zfi, NULL, 0, NULL, 0, NULL,
ufi.compression_method, 6, 1 /* raw! */,
-MAX_WBITS, DEF_MEM_LEVEL, 0,
NULL, 0,
0, ( 0 << 0 ) /* encrypted */, 0));
buffer = malloc(1024);
printf("uread : %d\n", iRead = unzReadCurrentFile( hUnzip, buffer, 1024));
printf("zwrite: %d\n", zipWriteInFileInZip(hZip, buffer, iRead));
free(buffer);
printf("zfclos: %d\n", zipCloseFileInZipRaw(hZip, ufi.uncompressed_size, ufi.crc));
printf("ufclos: %d\n", unzCloseCurrentFile(hUnzip));
printf("uclose: %d\n", unzClose(hUnzip));
printf("zclose: %d\n", zipClose(hZip, NULL));
return 0;
}Metadata
Metadata
Assignees
Labels
compatibilityBackwards compatibilityBackwards compatibilityfixedIssue or bug has been fixedIssue or bug has been fixedrawRaw file storageRaw file storage
Activity
vszakats commentedon Aug 7, 2018
More precisely it worked till commit 7f6f08a. The likely commit causing this regression is the one following it: 298126a.
Fixed closing entry with raw mode. #293
nmoinvaz commentedon Aug 9, 2018
Let me know if that changes fixed it.
vszakats commentedon Aug 9, 2018
@nmoinvaz: The reported issues all seem to be fixed with your updates — thank you so much! (I'm going to roll live tests later today to double-check it.)