From 3cdd8243c7fe0adae70e5901d1d897f636e71c14 Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Sun, 22 Mar 2015 07:09:00 -0500 Subject: [PATCH] Read res header completely --- .../java/brut/androlib/res/decoder/ARSCDecoder.java | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 78512e2c..1ca53d35 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 @@ -248,6 +248,8 @@ public class ARSCDecoder { private ResConfigFlags readConfigFlags() throws IOException, AndrolibException { int size = mIn.readInt(); + int read = 0; + if (size < 28) { throw new AndrolibException("Config size < 28"); } @@ -283,6 +285,7 @@ public class ARSCDecoder { screenLayout = mIn.readByte(); uiMode = mIn.readByte(); smallestScreenWidthDp = mIn.readShort(); + read = 32; } short screenWidthDp = 0; @@ -290,6 +293,7 @@ public class ARSCDecoder { if (size >= 36) { screenWidthDp = mIn.readShort(); screenHeightDp = mIn.readShort(); + read = 36; } char[] localeScript = null; @@ -297,6 +301,7 @@ public class ARSCDecoder { if (size >= 48) { localeScript = readScriptOrVariantChar(4).toCharArray(); localeVariant = readScriptOrVariantChar(8).toCharArray(); + read = 48; } int exceedingSize = size - KNOWN_CONFIG_BYTES; @@ -316,6 +321,11 @@ public class ARSCDecoder { } } + int remainingSize = size - read; + if (remainingSize > 0) { + mIn.skipBytes(remainingSize); + } + return new ResConfigFlags(mcc, mnc, language, country, orientation, touchscreen, density, keyboard, navigation, inputFlags, screenWidth, screenHeight, sdkVersion,