Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle larger axml namespace headers than known #3210

Merged
merged 2 commits into from
Jul 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -676,12 +676,13 @@ private void doNext() throws IOException {
}

int chunkType;
int headerSize = 0;
if (event == START_DOCUMENT) {
// Fake event, see CHUNK_XML_START_TAG handler.
chunkType = ARSCHeader.RES_XML_START_ELEMENT_TYPE;
} else {
chunkType = mIn.readShort();
mIn.skipShort(); // headerSize
headerSize = mIn.readShort();
}

if (chunkType == ARSCHeader.RES_XML_RESOURCE_MAP_TYPE) {
Expand Down Expand Up @@ -718,6 +719,14 @@ private void doNext() throws IOException {
mIn.skipInt(); // uri
mNamespaces.pop();
}

// Check for larger header than we read. We know the current header is 0x10 bytes, but some apps
// are packed with a larger header of unknown data.
if (headerSize > 0x10) {
int bytesToSkip = headerSize - 0x10;
LOGGER.warning(String.format("AXML header larger than 0x10 bytes, skipping %d bytes.", bytesToSkip));
mIn.skipBytes(bytesToSkip);
}
continue;
}

Expand Down