Skip to content

Assertion violation when unzipping #1416

@bizerba-christoph-ehinger

Description

I'm getting the following assertion exception when trying to unzip the attached file:
Assertion violation: std::memcmp(_rawInfo, HEADER, ZipCommon::HEADER_SIZE) == 0 [in file "src\ZipDataInfo.cpp", line 47]

I've used the following Java code to Zip the attached file:

public static void zipDir2( String directory, String zipName, final List<String> excludedFiles) throws IOException 
    {
        final File zipDir = new File( directory );
        ZipOutputStream zos = null;
        FileOutputStream fos = null; 
        FileInputStream fis = null;
        File zipOutFile = new File(zipName);
        try {
            fos = new FileOutputStream( zipOutFile );
            zos = new ZipOutputStream( fos, Charset.forName("UTF-8") );         
            zos.setLevel(9);
            final ArrayList<String> list = new ArrayList<String>();
            Files.walkFileTree(
                    zipDir.toPath(),
                    new SimpleFileVisitor<Path>()   {
                         public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException   {
                             if( excludedFiles == null || excludedFiles.contains(FilenameUtils.getName(file.toFile().getName())) == false ) {                                
                                 Path p = zipDir.toPath().relativize(file);
                                 list.add(p.toString().replace("\\", "/"));
                             }
                             return FileVisitResult.CONTINUE;
                         }
                    }
            );          
            String[] dirList = list.toArray(new String[]{});        
            byte[] readBuffer = new byte[1024];         
            for( int i = 0; i < dirList.length; i++ )   {
                File f = new File( zipDir, dirList[i] );                
                fis = new FileInputStream( f.getAbsolutePath() );               
                ZipEntry anEntry = new ZipEntry( dirList[i] );                  
                zos.putNextEntry( anEntry );
                int bytesIn = fis.read( readBuffer );
                while( bytesIn != -1 ) {   // -1 == eof 
                    zos.write( readBuffer, 0, bytesIn );
                    bytesIn = fis.read( readBuffer );
                }
                zos.closeEntry();
                fis.close();
            }
        } 
        finally {
            if(zos != null) {
                zos.flush(); zos.finish(); zos.close();
            }
            if ( fos != null )  {
                fos.flush(); fos.close();
            }
        }
    }

and the following code to unzip:

int main()
{
    try {
        std::ifstream coFileIn("C:\\temp\\file.zip", ios_base::in | ios_base::binary );
        Poco::Path coExtractPath("C:\\temp\\");
        Poco::Zip::Decompress coDecompressJob(coFileIn, coExtractPath);
        coDecompressJob.decompressAllFiles();
        coFileIn.close();
    } catch( Poco::Exception& fe ) {
        cout << fe.message() << endl;
    }
    return 0;
}

which looks inocently enough.
My environment:

  • Win7 x64
  • Java 1.80_60
  • Visual Studio 2012 - Windows XP (v110_xp) Platform Toolset, 32bit
  • Poco 1.7.5 (Static link, debug)

The strange thing is that 7zip/Windows Explorer/DirectoryOpus unzipper do not complain about this file. Furthermore the error seems to depend on the input data and/or the "zip level". The "unzip" sample which is distributed with Poco also fails.
I'm all out of ideas :(

file.zip

Note that this issue might be related to #1298

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions