File tree Expand file tree Collapse file tree
main/java/org/apache/commons/compress/archivers/lha
test/java/org/apache/commons/compress/archivers/lha Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -166,6 +166,7 @@ Builder setFileSeparatorChar(final char fileSeparatorChar) {
166166 private static final int HEADER_LEVEL_1_OFFSET_FILENAME = 22 ;
167167
168168 // Header Level 2
169+ private static final int HEADER_LEVEL_2_MINIMUM_HEADER_LENGTH = 26 ;
169170 private static final int HEADER_LEVEL_2_OFFSET_HEADER_SIZE = 0 ;
170171 private static final int HEADER_LEVEL_2_OFFSET_COMPRESSED_SIZE = 7 ;
171172 private static final int HEADER_LEVEL_2_OFFSET_ORIGINAL_SIZE = 11 ;
@@ -473,7 +474,7 @@ LhaArchiveEntry readHeaderLevel1(ByteBuffer buffer) throws IOException {
473474 */
474475 LhaArchiveEntry readHeaderLevel2 (ByteBuffer buffer ) throws IOException {
475476 final int headerSize = Short .toUnsignedInt (buffer .getShort (HEADER_LEVEL_2_OFFSET_HEADER_SIZE ));
476- if (headerSize < HEADER_GENERIC_MINIMUM_HEADER_LENGTH ) {
477+ if (headerSize < HEADER_LEVEL_2_MINIMUM_HEADER_LENGTH ) {
477478 throw new ArchiveException ("Invalid header level 2 length: %d" , headerSize );
478479 }
479480
Original file line number Diff line number Diff line change @@ -904,13 +904,13 @@ void testParseHeaderLevel2File() throws IOException {
904904 void testInvalidHeaderLevel2Length () throws IOException {
905905 final byte [] data = toByteArray (VALID_HEADER_LEVEL_2_FILE );
906906
907- data [0 ] = 0x10 ; // Change the first byte to an invalid length
907+ data [0 ] = 25 ; // Change the first byte to an invalid length
908908
909909 try (LhaArchiveInputStream archive = LhaArchiveInputStream .builder ().setInputStream (new ByteArrayInputStream (data )).get ()) {
910910 archive .getNextEntry ();
911911 fail ("Expected ArchiveException for invalid header length" );
912912 } catch (ArchiveException e ) {
913- assertEquals ("Invalid header level 2 length: 16 " , e .getMessage ());
913+ assertEquals ("Invalid header level 2 length: 25 " , e .getMessage ());
914914 }
915915 }
916916
You can’t perform that action at this time.
0 commit comments