Don't read more data than entryChunk has

- fixes #1534
This commit is contained in:
Connor Tumbleson 2017-07-26 16:21:59 -04:00
parent e93ae011a8
commit eda95b3da2

View File

@ -156,7 +156,7 @@ public class ARSCDecoder {
readTableType();
// skip "TYPE 8 chunks" and/or padding data at the end of this chunk
if(mCountIn.getCount() < mHeader.endPosition) {
if (mCountIn.getCount() < mHeader.endPosition) {
mCountIn.skip(mHeader.endPosition - mCountIn.getCount());
}
@ -238,6 +238,12 @@ public class ARSCDecoder {
short flags = mIn.readShort();
int specNamesId = mIn.readInt();
// If we are here, we probably already inserted any remaining dummy resources. No need to parse
// any resources that doesn't have type information
if (mCountIn.getCount() == mHeader.endPosition) {
return;
}
ResValue value = (flags & ENTRY_FLAG_COMPLEX) == 0 ? readValue() : readComplexEntry();
if (mTypeSpec.isString() && value instanceof ResFileValue) {
@ -519,6 +525,8 @@ public class ARSCDecoder {
private HashMap<Integer, ResTypeSpec> mResTypeSpecs = new HashMap<>();
private final static short ENTRY_FLAG_COMPLEX = 0x0001;
private final static short ENTRY_FLAG_PUBLIC = 0x0002;
private final static short ENTRY_FLAG_WEAK = 0x0004;
public static class Header {
public final short type;