Skip to content

Commit

Permalink
Allow invalid xml end namespace chunk size
Browse files Browse the repository at this point in the history
  • Loading branch information
REAndroid committed Mar 21, 2024
1 parent 5379cde commit 9be31b4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/com/reandroid/arsc/chunk/Chunk.java
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/reandroid/arsc/chunk/xml/ResXmlEndNamespace.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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);
}
}
}

0 comments on commit 9be31b4

Please sign in to comment.