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: support decoding application with duplicate res entries #3252

Merged
merged 1 commit into from
Aug 5, 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 @@ -328,7 +328,6 @@ private ResType readTableType() throws IOException, AndrolibException {
return mType;
}


private EntryData readEntryData() throws IOException, AndrolibException {
short size = mIn.readShort();
if (size < 0) {
Expand All @@ -342,6 +341,12 @@ private EntryData readEntryData() throws IOException, AndrolibException {
}

ResValue value = (flags & ENTRY_FLAG_COMPLEX) == 0 ? readValue() : readComplexEntry();
// #2824 - In some applications the res entries are duplicated with the 2nd being malformed.
// AOSP skips this, so we will do the same.
if (value == null) {
return null;
}

EntryData entryData = new EntryData();
entryData.mFlags = flags;
entryData.mSpecNamesId = specNamesId;
Expand Down Expand Up @@ -416,7 +421,11 @@ private ResBagValue readComplexEntry() throws IOException, AndrolibException {
}

private ResIntBasedValue readValue() throws IOException, AndrolibException {
mIn.skipCheckShort((short) 8); // size
int size = mIn.readShort();
if (size < 8) {
return null;
}

mIn.skipCheckByte((byte) 0); // zero
byte type = mIn.readByte();
int data = mIn.readInt();
Expand Down