Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streaming issue #31

Open
pmqs opened this issue Mar 29, 2021 · 0 comments
Open

Streaming issue #31

pmqs opened this issue Mar 29, 2021 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@pmqs
Copy link
Owner

pmqs commented Mar 29, 2021

When writing in streaming mode, force a Zip64 extra field in the local header if the file size >0xFFFFFFFF

Summary of issue

        my $size = 0x100000000 ;
        my $zipfile = "large-streamed.zip";
        my $zip = new IO::Compress::Zip $zipfile,
                                    Name => "one",
                                    Stream => 1,
                                    Minimal => 1,
                                    Sparse => $size,
                                    Method => ZIP_CM_STORE,
                                    Zip64 => 1,
                                    ;

        # File size now >0xFFFFFFFF, but the next entry doesn't enable Zip64
        $zip->newStream(Name => "two", Zip64 => 0, Sparse => 0, Stream => 1, Method => 8);
        print $zip "12345";
        $zip->close();

This results in a file that unzip doesn't like

$ unzip -t large-streamed.zip 
Archive:  large-streamed.zip
    testing: one                      OK
    testing: two                      OK
error: invalid zip file with overlapped components (possible zip bomb)
$ zipdetails large-streamed.zip
000000000 LOCAL HEADER #1       04034B50
000000004 Extract Zip Spec      2D '4.5'
000000005 Extract OS            00 'MS-DOS'
000000006 General Purpose Flag  0008
          [Bit  3]              1 'Streamed'
000000008 Compression Method    0000 'Stored'
00000000A Last Mod Time         527D4876 'Mon Mar 29 09:03:44 2021'
00000000E CRC                   00000000
000000012 Compressed Length     FFFFFFFF
000000016 Uncompressed Length   FFFFFFFF
00000001A Filename Length       0003
00000001C Extra Length          0014
00000001E Filename              'one'
000000021 Extra ID #0001        0001 'ZIP64'
000000023   Length              0010
000000025   Uncompressed Size   0000000000000000
00000002D   Compressed Size     0000000000000000
000000035 PAYLOAD

100000035 STREAMING DATA HEADER 08074B50
100000039 CRC                   D202EF8D
10000003D Compressed Length     0000000100000000
100000045 Uncompressed Length   0000000100000000

10000004D LOCAL HEADER #2       04034B50
100000051 Extract Zip Spec      14 '2.0'
100000052 Extract OS            00 'MS-DOS'
100000053 General Purpose Flag  0008
          [Bit  3]              1 'Streamed'
100000055 Compression Method    0000 'Stored'
100000057 Last Mod Time         527D487B 'Mon Mar 29 09:03:54 2021'
10000005B CRC                   00000000
10000005F Compressed Length     00000000
100000063 Uncompressed Length   00000000
100000067 Filename Length       0003
100000069 Extra Length          0000
10000006B Filename              'two'
10000006E PAYLOAD               12345

100000073 STREAMING DATA HEADER 08074B50
100000077 CRC                   CBF53A1C
10000007B Compressed Length     00000005
10000007F Uncompressed Length   00000005

100000083 CENTRAL HEADER #1     02014B50
100000087 Created Zip Spec      2D '4.5'
100000088 Created OS            03 'Unix'
100000089 Extract Zip Spec      2D '4.5'
10000008A Extract OS            00 'MS-DOS'
10000008B General Purpose Flag  0008
          [Bit  3]              1 'Streamed'
10000008D Compression Method    0000 'Stored'
10000008F Last Mod Time         527D4876 'Mon Mar 29 09:03:44 2021'
100000093 CRC                   D202EF8D
100000097 Compressed Length     FFFFFFFF
10000009B Uncompressed Length   FFFFFFFF
10000009F Filename Length       0003
1000000A1 Extra Length          0014
1000000A3 Comment Length        0000
1000000A5 Disk Start            0000
1000000A7 Int File Attributes   0000
          [Bit 0]               0 'Binary Data'
1000000A9 Ext File Attributes   81A40000
1000000AD Local Header Offset   00000000
1000000B1 Filename              'one'
1000000B4 Extra ID #0001        0001 'ZIP64'
1000000B6   Length              0010
1000000B8   Uncompressed Size   0000000100000000
1000000C0   Compressed Size     0000000100000000

1000000C8 CENTRAL HEADER #2     02014B50
1000000CC Created Zip Spec      14 '2.0'
1000000CD Created OS            03 'Unix'
1000000CE Extract Zip Spec      14 '2.0'
1000000CF Extract OS            00 'MS-DOS'
1000000D0 General Purpose Flag  0008
          [Bit  3]              1 'Streamed'
1000000D2 Compression Method    0000 'Stored'
1000000D4 Last Mod Time         527D487B 'Mon Mar 29 09:03:54 2021'
1000000D8 CRC                   CBF53A1C
1000000DC Compressed Length     00000005
1000000E0 Uncompressed Length   00000005
1000000E4 Filename Length       0003
1000000E6 Extra Length          000C
1000000E8 Comment Length        0000
1000000EA Disk Start            0000
1000000EC Int File Attributes   0000
          [Bit 0]               0 'Binary Data'
1000000EE Ext File Attributes   81A40000
1000000F2 Local Header Offset   FFFFFFFF
1000000F6 Filename              'two'
1000000F9 Extra ID #0001        0001 'ZIP64'
1000000FB   Length              0008
1000000FD   Offset to Local Dir 000000010000004D

100000105 ZIP64 END CENTRAL DIR 06064B50
          RECORD
100000109 Size of record        000000000000002C
100000111 Created Zip Spec      14 '2.0'
100000112 Created OS            03 'Unix'
100000113 Extract Zip Spec      14 '2.0'
100000114 Extract OS            00 'MS-DOS'
100000115 Number of this disk   00000000
100000119 Central Dir Disk no   00000000
10000011D Entries in this disk  0000000000000002
100000125 Total Entries         0000000000000002
10000012D Size of Central Dir   0000000000000082
100000135 Offset to Central dir 0000000100000083

10000013D ZIP64 END CENTRAL DIR 07064B50
          LOCATOR
100000141 Central Dir Disk no   00000000
100000145 Offset to Central dir 0000000100000105
10000014D Total no of Disks     00000001

100000151 END CENTRAL HEADER    06054B50
100000155 Number of this disk   0000
100000157 Central Dir Disk no   0000
100000159 Entries in this disk  0002
10000015B Total Entries         0002
10000015D Size of Central Dir   00000082
100000161 Offset to Central Dir FFFFFFFF
100000165 Comment Length        0000
Done
@pmqs pmqs self-assigned this Mar 29, 2021
@pmqs pmqs added the bug Something isn't working label Apr 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant