Merge pull request #1977 from sebras/master

Adapt AXMLResourceParser to handle broken headers.
This commit is contained in:
Connor Tumbleson 2019-01-09 17:40:01 -05:00 committed by GitHub
commit d7f9be9200
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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));
}
}