From 394a8d5eb08c713dda10b3421549b1b8de3b3a56 Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Sun, 10 Sep 2023 06:27:41 -0400 Subject: [PATCH] fix: load type spec if no TYPE_SPEC chunks --- .../main/java/brut/androlib/res/decoder/ARSCDecoder.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ARSCDecoder.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ARSCDecoder.java index 17e15b5155..90bc296ca0 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ARSCDecoder.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ARSCDecoder.java @@ -260,10 +260,16 @@ private ResTypeSpec readTableSpecType() throws AndrolibException, IOException { private ResType readTableType() throws IOException, AndrolibException { checkChunkType(ARSCHeader.XML_TYPE_TYPE); int typeId = mIn.readUnsignedByte() - mTypeIdOffset; + + // #3311 - Some older applications have no TYPE_SPEC chunks, but still define TYPE chunks. if (mResTypeSpecs.containsKey(typeId)) { - mResId = (0xff000000 & mResId) | mResTypeSpecs.get(typeId).getId() << 16; mTypeSpec = mResTypeSpecs.get(typeId); + } else { + mTypeSpec = new ResTypeSpec(mTypeNames.getString(typeId - 1), typeId); + addTypeSpec(mTypeSpec); + mPkg.addType(mTypeSpec); } + mResId = (0xff000000 & mResId) | mTypeSpec.getId() << 16; int typeFlags = mIn.readByte(); mIn.skipBytes(2); // reserved