Skip to content

Commit 03c198c

Browse files
authored
fix: support skipping entries with NO_ENTRY (-1) flag (#3209)
1 parent 79f57b0 commit 03c198c

File tree

1 file changed

+13
-4
lines changed
  • brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder

1 file changed

+13
-4
lines changed

brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ARSCDecoder.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ private ResType readTableType() throws IOException, AndrolibException {
308308

309309
for (int i : entryOffsetMap.keySet()) {
310310
int offset = entryOffsetMap.get(i);
311-
if (offset == -1) {
311+
if (offset == NO_ENTRY) {
312312
continue;
313313
}
314314
mMissingResSpecMap.put(i, false);
@@ -318,12 +318,15 @@ private ResType readTableType() throws IOException, AndrolibException {
318318
if (mCountIn.getCount() == mHeader.endPosition) {
319319
int remainingEntries = entryCount - i;
320320
LOGGER.warning(String.format("End of chunk hit. Skipping remaining entries (%d) in type: %s",
321-
remainingEntries, mTypeSpec.getName())
322-
);
321+
remainingEntries, mTypeSpec.getName()
322+
));
323323
break;
324324
}
325325

326-
readEntry(readEntryData());
326+
EntryData entryData = readEntryData();
327+
if (entryData != null) {
328+
readEntry(entryData);
329+
}
327330
}
328331

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

345348
short flags = mIn.readShort();
346349
int specNamesId = mIn.readInt();
350+
if (specNamesId == NO_ENTRY) {
351+
return null;
352+
}
353+
347354
ResValue value = (flags & ENTRY_FLAG_COMPLEX) == 0 ? readValue() : readComplexEntry();
348355
EntryData entryData = new EntryData();
349356
entryData.mFlags = flags;
@@ -662,5 +669,7 @@ private void checkChunkType(int expectedType) throws AndrolibException {
662669

663670
private static final int KNOWN_CONFIG_BYTES = 64;
664671

672+
private static final int NO_ENTRY = 0xFFFFFFFF;
673+
665674
private static final Logger LOGGER = Logger.getLogger(ARSCDecoder.class.getName());
666675
}

0 commit comments

Comments
 (0)