fix: support skipping entries with NO_ENTRY (-1) flag (#3209)

This commit is contained in:
Connor Tumbleson 2023-07-24 06:06:45 -04:00 committed by GitHub
parent 79f57b070c
commit 03c198c1e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -308,7 +308,7 @@ public class ARSCDecoder {
for (int i : entryOffsetMap.keySet()) {
int offset = entryOffsetMap.get(i);
if (offset == -1) {
if (offset == NO_ENTRY) {
continue;
}
mMissingResSpecMap.put(i, false);
@ -318,12 +318,15 @@ public class ARSCDecoder {
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
@ -344,6 +347,10 @@ public class ARSCDecoder {
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;
@ -662,5 +669,7 @@ public class ARSCDecoder {
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());
}