File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -198,9 +198,10 @@ public long getLocalHeaderOffset() {
198198 }
199199
200200 public void setLocalHeaderOffset (long offset ) {
201- if (offset > 0xFFFFFFFFL ) {
201+ if (offset > 0xFFFFFFFFL || localHeaderOffset == 0xFFFFFFFFL ) {
202202 Zip64ExtendedInfoExtraField zip64ExtraField = (Zip64ExtendedInfoExtraField ) extraFields .get (1 );
203203 zip64ExtraField .localHeaderOffset = offset ;
204+ localHeaderOffset = 0xFFFFFFFFL ;
204205 } else {
205206 localHeaderOffset = offset ;
206207 }
Original file line number Diff line number Diff line change @@ -73,4 +73,19 @@ public void testReadWrongRecord() throws Exception {
7373 assertEquals ("message" , "Invalid Central Directory File Header signature 0x4034b50" , e .getMessage ());
7474 }
7575 }
76+
77+ @ Test
78+ public void testLocalHeaderOffsetUpdate () throws Exception {
79+ File file = new File ("target/test-classes/minimal.zip" );
80+
81+ try (SeekableByteChannel channel = Files .newByteChannel (file .toPath (), StandardOpenOption .READ )) {
82+ channel .position (0x247B );
83+
84+ CentralDirectoryFileHeader centralDirectoryFileHeader = new CentralDirectoryFileHeader ();
85+ centralDirectoryFileHeader .read (channel );
86+
87+ centralDirectoryFileHeader .setLocalHeaderOffset (centralDirectoryFileHeader .getLocalHeaderOffset ());
88+ assertEquals ("local header offset" , 0xFFFFFFFFL , centralDirectoryFileHeader .localHeaderOffset );
89+ }
90+ }
7691}
You can’t perform that action at this time.
0 commit comments