Skip to content

Commit

Permalink
fix: read correct buffer size for string pool parsing (#712)
Browse files Browse the repository at this point in the history
  • Loading branch information
skylot committed Jul 15, 2019
1 parent d89ec67 commit 15d56ab
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions jadx-core/src/main/java/jadx/core/xmlgen/CommonBinaryParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,22 @@ protected String[] parseStringPoolNoType() throws IOException {
int[] stylesOffset = is.readInt32Array(styleCount);

is.checkPos(start + stringsStart, "Expected strings start");
long stringsEnd = stylesStart == 0 ? chunkEnd : start + stylesStart;
String[] strings = new String[stringCount];
byte[] strArray = is.readInt8Array((int) (stringsEnd - is.getPos()));
byte[] strData = is.readInt8Array((int) (chunkEnd - is.getPos()));
if ((flags & UTF8_FLAG) != 0) {
// UTF-8
for (int i = 0; i < stringCount; i++) {
strings[i] = extractString8(strArray, stringsOffset[i]);
strings[i] = extractString8(strData, stringsOffset[i]);
}
} else {
// UTF-16
for (int i = 0; i < stringCount; i++) {
// don't trust specified string length, read until \0
// stringsOffset can be same for different indexes
strings[i] = extractString16(strArray, stringsOffset[i]);
strings[i] = extractString16(strData, stringsOffset[i]);
}
}
if (stylesStart != 0) {
is.checkPos(start + stylesStart, "Expected styles start");
if (styleCount != 0) {
// TODO: implement styles parsing
}
}
// skip padding zeroes
is.skipToPos(chunkEnd, "Skip string pool padding");
is.checkPos(chunkEnd, "Expected strings pool end");
return strings;
}

Expand Down

0 comments on commit 15d56ab

Please sign in to comment.