ZipArchive: UnzipFile API crashes on free(ioposix->filename);

We were using ziparchive framework code from many years for unzipping operation in our iOS code. I tried to upgrade to SSZiparchive, and my unzipping code started crashing. Its crashing in fclose_file_func where it tries to close the file fclose(ioposix->file). The same piece of code is working fine with ziparchive, then I found fclose_file_func has just one line int ret; ret = fclose((FILE *)stream); return ret; compared to SSZiparchive . In my case while unzipping it fails somewhere in unzOpen2 and trying to call fclose_file_func twice and complains for SIG ABRT. Check the screenshot below for the issue. image

image I wanted to migrate to SSZiparchive to consume [zipperdown fix]

My zippath and destination paths are as below

/Users/sandhya/Library/Developer/CoreSimulator/Devices/1D841CCD-A36F-49AF-848A-33CE0512774B/data/Containers/Data/Application/414C18C7-DAD8-48AC-99C9-65179B7B54AF/tmp/resources.zip Printing description of tempWWWDirectory: /Users/sandhya/Library/Developer/CoreSimulator/Devices/1D841CCD-A36F-49AF-848A-33CE0512774B/data/Containers/Data/Application/414C18C7-DAD8-48AC-99C9-65179B7B54AF/tmp/wwwtemp

I want to migrate to SSZiparchive to consume zipperdown fix. (https://github.com/ZipArchive/ZipArchive/pull/456) which is not available to older ziparchive.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (7 by maintainers)

Commits related to this issue

Most upvoted comments

I have the same issue. The reason is that SSZiparchive uses the MiniZip, and a third party lib (MailCore2 lib in my project) uses the MiniZip too. My solution is to modify methods (unzOpenCurrentFilePassword 、 unzOpenCurrentFile3 ------> prefix_unzOpenCurrentFilePassword、 prefix_unzOpenCurrentFile3).

@Coeur - Only other thing that might cause this is if fopen_file_func fails, but fclose_file_func is stilled called but I don’t see that happening in the code either.

It may be that he is using an older version of minizip because unzlocal_getByte in his callstack is not part of my minizip fork. @sandsuma mentioned he tried upgrading so I think this is a case of some files not being upgraded properly.

@nmoinvaz

You’re correct on the possibility of a double call. You’re incorrect on the fix: even like that, free(ioposix); two lines below would get called twice, and that can’t be prevented.