add some documentation about the new 'no limit' option
This commit is contained in:
parent
854997703d
commit
07e47d4104
3 changed files with 14 additions and 2 deletions
|
@ -23,5 +23,5 @@ package org.capnproto;
|
|||
|
||||
public interface Arena {
|
||||
public SegmentReader tryGetSegment(int id);
|
||||
public void checkReadLimit(int numBytes);
|
||||
public void checkReadLimit(int numWords);
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ import java.nio.ByteBuffer;
|
|||
|
||||
public final class ReaderArena implements Arena {
|
||||
|
||||
// Current limit. -1 means no limit.
|
||||
public long limit;
|
||||
// current limit
|
||||
|
||||
public final ArrayList<SegmentReader> segments;
|
||||
|
||||
|
@ -47,6 +47,7 @@ public final class ReaderArena implements Arena {
|
|||
@Override
|
||||
public final void checkReadLimit(int numWords) {
|
||||
if (limit == -1) {
|
||||
// No limit.
|
||||
return;
|
||||
} else if (numWords > limit) {
|
||||
throw new DecodeException("Read limit exceeded.");
|
||||
|
|
|
@ -22,7 +22,18 @@
|
|||
package org.capnproto;
|
||||
|
||||
public final class ReaderOptions {
|
||||
/**
|
||||
How many words are allowed to be read before an exception is thrown,
|
||||
to protect against denial of service attacks.
|
||||
|
||||
-1 means "no limit".
|
||||
*/
|
||||
public final long traversalLimitInWords;
|
||||
|
||||
/**
|
||||
How many pointer indirections deep a message may be before an exception
|
||||
is thrown.
|
||||
*/
|
||||
public final int nestingLimit;
|
||||
|
||||
public ReaderOptions(long traversalLimitInWords, int nestingLimit) {
|
||||
|
|
Loading…
Reference in a new issue