Correctly handle ResTable_typeSpec by using unsigned bytes to prevent overflow

- fixes #1185
 - allows applications that have large typeSpec indexes to work
This commit is contained in:
Connor Tumbleson 2016-08-01 23:26:00 -04:00
parent 3a982948ea
commit e6faa56c96
No known key found for this signature in database
GPG Key ID: C3CC0A201EC7DA75
2 changed files with 6 additions and 6 deletions

View File

@ -30,10 +30,10 @@ public final class ResTypeSpec {
private final ResTable mResTable; private final ResTable mResTable;
private final ResPackage mPackage; private final ResPackage mPackage;
private final byte mId; private final int mId;
private final int mEntryCount; private final int mEntryCount;
public ResTypeSpec(String name, ResTable resTable, ResPackage package_, byte id, int entryCount) { public ResTypeSpec(String name, ResTable resTable, ResPackage package_, int id, int entryCount) {
this.mName = name; this.mName = name;
this.mResTable = resTable; this.mResTable = resTable;
this.mPackage = package_; this.mPackage = package_;
@ -45,7 +45,7 @@ public final class ResTypeSpec {
return mName; return mName;
} }
public byte getId() { public int getId() {
return mId; return mId;
} }

View File

@ -161,7 +161,7 @@ public class ARSCDecoder {
private ResTypeSpec readSingleTableTypeSpec() throws AndrolibException, IOException { private ResTypeSpec readSingleTableTypeSpec() throws AndrolibException, IOException {
checkChunkType(Header.TYPE_SPEC_TYPE); checkChunkType(Header.TYPE_SPEC_TYPE);
byte id = mIn.readByte(); int id = mIn.readUnsignedByte();
mIn.skipBytes(3); mIn.skipBytes(3);
int entryCount = mIn.readInt(); int entryCount = mIn.readInt();
@ -177,7 +177,7 @@ public class ARSCDecoder {
private ResType readTableType() throws IOException, AndrolibException { private ResType readTableType() throws IOException, AndrolibException {
checkChunkType(Header.TYPE_TYPE); checkChunkType(Header.TYPE_TYPE);
byte typeId = mIn.readByte(); int typeId = mIn.readUnsignedByte();
if (mResTypeSpecs.containsKey(typeId)) { if (mResTypeSpecs.containsKey(typeId)) {
mResId = (0xff000000 & mResId) | mResTypeSpecs.get(typeId).getId() << 16; mResId = (0xff000000 & mResId) | mResTypeSpecs.get(typeId).getId() << 16;
mTypeSpec = mResTypeSpecs.get(typeId); mTypeSpec = mResTypeSpecs.get(typeId);
@ -502,7 +502,7 @@ public class ARSCDecoder {
private ResType mType; private ResType mType;
private int mResId; private int mResId;
private boolean[] mMissingResSpecs; private boolean[] mMissingResSpecs;
private HashMap<Byte, ResTypeSpec> mResTypeSpecs = new HashMap<>(); private HashMap<Integer, ResTypeSpec> mResTypeSpecs = new HashMap<>();
private final static short ENTRY_FLAG_COMPLEX = 0x0001; private final static short ENTRY_FLAG_COMPLEX = 0x0001;