Skip to content

Commit

Permalink
Don't read more data than entryChunk has
Browse files Browse the repository at this point in the history
 - fixes #1534
  • Loading branch information
iBotPeaches committed Jul 26, 2017
1 parent e93ae01 commit eda95b3
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private ResTypeSpec readTableTypeSpec() throws AndrolibException, IOException {
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());
}

Expand Down Expand Up @@ -238,6 +238,12 @@ private void readEntry() throws IOException, AndrolibException {
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) {
Expand Down Expand Up @@ -519,6 +525,8 @@ private void nextChunkCheckType(int expectedType) throws IOException, AndrolibEx
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;
Expand Down

0 comments on commit eda95b3

Please sign in to comment.