Merge pull request #96 from wdu/master

Offer option to disable traversalLimitInWords
This commit is contained in:
David Renshaw 2021-05-09 14:47:02 -04:00 committed by GitHub
commit 854997703d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View file

@ -45,11 +45,13 @@ public final class ReaderArena implements Arena {
}
@Override
public final void checkReadLimit(int numBytes) {
if (numBytes > limit) {
public final void checkReadLimit(int numWords) {
if (limit == -1) {
return;
} else if (numWords > limit) {
throw new DecodeException("Read limit exceeded.");
} else {
limit -= numBytes;
limit -= numWords;
}
}
}

View file

@ -145,7 +145,7 @@ public final class Serialize {
}
bb.position(segmentBase + totalWords * Constants.BYTES_PER_WORD);
if (totalWords > options.traversalLimitInWords) {
if (options.traversalLimitInWords != -1 && totalWords > options.traversalLimitInWords) {
throw new DecodeException("Message size exceeds traversal limit.");
}