From 9be31b4a52839ed78d2a872d3b121a6e69cf5f81 Mon Sep 17 00:00:00 2001 From: REAndroid Date: Thu, 21 Mar 2024 17:18:52 +0100 Subject: [PATCH] Allow invalid xml end namespace chunk size --- src/main/java/com/reandroid/arsc/chunk/Chunk.java | 5 ++++- .../arsc/chunk/xml/ResXmlEndNamespace.java | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/reandroid/arsc/chunk/Chunk.java b/src/main/java/com/reandroid/arsc/chunk/Chunk.java index c31124ed1..949a9e152 100755 --- a/src/main/java/com/reandroid/arsc/chunk/Chunk.java +++ b/src/main/java/com/reandroid/arsc/chunk/Chunk.java @@ -56,11 +56,14 @@ public void onReadBytes(BlockReader reader) throws IOException { HeaderBlock headerBlock=reader.readHeaderBlock(); checkInvalidChunk(headerBlock); BlockReader chunkReader = reader.create(headerBlock.getChunkSize()); - super.onReadBytes(chunkReader); + onReadChildes(chunkReader); reader.offset(headerBlock.getChunkSize()); chunkReader.close(); onChunkLoaded(); } + protected void onReadChildes(BlockReader reader) throws IOException{ + super.onReadBytes(reader); + } void checkInvalidChunk(HeaderBlock headerBlock) throws IOException { ChunkType chunkType = headerBlock.getChunkType(); if(chunkType==null || chunkType==ChunkType.NULL){ diff --git a/src/main/java/com/reandroid/arsc/chunk/xml/ResXmlEndNamespace.java b/src/main/java/com/reandroid/arsc/chunk/xml/ResXmlEndNamespace.java index 8ff388b1a..601e01874 100755 --- a/src/main/java/com/reandroid/arsc/chunk/xml/ResXmlEndNamespace.java +++ b/src/main/java/com/reandroid/arsc/chunk/xml/ResXmlEndNamespace.java @@ -16,6 +16,10 @@ package com.reandroid.arsc.chunk.xml; import com.reandroid.arsc.chunk.ChunkType; +import com.reandroid.arsc.header.HeaderBlock; +import com.reandroid.arsc.io.BlockReader; + +import java.io.IOException; public class ResXmlEndNamespace extends ResXmlNamespaceChunk { public ResXmlEndNamespace() { @@ -27,4 +31,14 @@ public ResXmlStartNamespace getStart(){ public void setStart(ResXmlStartNamespace namespace){ setPair(namespace); } + + @Override + public void onReadBytes(BlockReader reader) throws IOException { + HeaderBlock headerBlock = reader.readHeaderBlock(); + if(headerBlock.getChunkSize() < 8){ + super.onReadChildes(reader); + }else { + super.onReadBytes(reader); + } + } }