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 skipping entries with NO_ENTRY (-1) flag #3209

Merged
merged 1 commit 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 @@ -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());
}