Adapt AXMLResourceParser to handle broken headers.

Fixes #1976.
This commit is contained in:
Sebastian Rasmussen 2019-01-08 21:16:46 +01:00
parent 261e163bc9
commit b01dce7f3a
2 changed files with 5 additions and 5 deletions

View File

@ -852,7 +852,7 @@ public class AXmlResourceParser implements XmlResourceParser {
private final void doNext() throws IOException {
// Delayed initialization.
if (m_strings == null) {
m_reader.skipCheckInt(CHUNK_AXML_FILE);
m_reader.skipCheckInt(CHUNK_AXML_FILE, CHUNK_AXML_FILE_BROKEN);
/*
* chunkSize
@ -1004,7 +1004,7 @@ public class AXmlResourceParser implements XmlResourceParser {
ATTRIBUTE_IX_VALUE_TYPE = 3, ATTRIBUTE_IX_VALUE_DATA = 4,
ATTRIBUTE_LENGTH = 5;
private static final int CHUNK_AXML_FILE = 0x00080003,
private static final int CHUNK_AXML_FILE = 0x00080003, CHUNK_AXML_FILE_BROKEN = 0x00080001,
CHUNK_RESOURCEIDS = 0x00080180, CHUNK_XML_FIRST = 0x00100100,
CHUNK_XML_START_NAMESPACE = 0x00100100,
CHUNK_XML_END_NAMESPACE = 0x00100101,

View File

@ -42,11 +42,11 @@ public class ExtDataInput extends DataInputDelegate {
skipBytes(4);
}
public void skipCheckInt(int expected) throws IOException {
public void skipCheckInt(int expected1, int expected2) throws IOException {
int got = readInt();
if (got != expected) {
if (got != expected1 && got != expected2) {
throw new IOException(String.format(
"Expected: 0x%08x, got: 0x%08x", expected, got));
"Expected: 0x%08x or 0x%08x, got: 0x%08x", expected1, expected2, got));
}
}