Offer option to disable traversalLimitInWords

Use case: large trusted input data file, mapped in memory by
MappedByteBuffer, which is often re-queried so a sensible
limit cannot be set.
This commit is contained in:
Wim Dumon 2021-04-28 17:47:58 +02:00
parent cf62cd4a58
commit cc4fa2bbc8
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.");
}