Skip to content

Commit

Permalink
fix: support skipping entries with NO_ENTRY (-1) flag (#3209)
Browse files Browse the repository at this point in the history
  • Loading branch information
iBotPeaches authored Jul 24, 2023
1 parent 79f57b0 commit 03c198c
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ private ResType readTableType() throws IOException, AndrolibException {

for (int i : entryOffsetMap.keySet()) {
int offset = entryOffsetMap.get(i);
if (offset == -1) {
if (offset == NO_ENTRY) {
continue;
}
mMissingResSpecMap.put(i, false);
Expand All @@ -318,12 +318,15 @@ private ResType readTableType() throws IOException, AndrolibException {
if (mCountIn.getCount() == mHeader.endPosition) {
int remainingEntries = entryCount - i;
LOGGER.warning(String.format("End of chunk hit. Skipping remaining entries (%d) in type: %s",
remainingEntries, mTypeSpec.getName())
);
remainingEntries, mTypeSpec.getName()
));
break;
}

readEntry(readEntryData());
EntryData entryData = readEntryData();
if (entryData != null) {
readEntry(entryData);
}
}

// skip "TYPE 8 chunks" and/or padding data at the end of this chunk
Expand All @@ -344,6 +347,10 @@ private EntryData readEntryData() throws IOException, AndrolibException {

short flags = mIn.readShort();
int specNamesId = mIn.readInt();
if (specNamesId == NO_ENTRY) {
return null;
}

ResValue value = (flags & ENTRY_FLAG_COMPLEX) == 0 ? readValue() : readComplexEntry();
EntryData entryData = new EntryData();
entryData.mFlags = flags;
Expand Down Expand Up @@ -662,5 +669,7 @@ private void checkChunkType(int expectedType) throws AndrolibException {

private static final int KNOWN_CONFIG_BYTES = 64;

private static final int NO_ENTRY = 0xFFFFFFFF;

private static final Logger LOGGER = Logger.getLogger(ARSCDecoder.class.getName());
}

0 comments on commit 03c198c

Please sign in to comment.