| Index: mojo/public/java/bindings/src/org/chromium/mojo/bindings/Decoder.java
|
| diff --git a/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Decoder.java b/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Decoder.java
|
| index 755fb019aca0f621d1c767b6705dfb6d5dbe8280..6898f93e099826c1e50e814233b7406b49f2279a 100644
|
| --- a/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Decoder.java
|
| +++ b/mojo/public/java/bindings/src/org/chromium/mojo/bindings/Decoder.java
|
| @@ -34,6 +34,10 @@ public class Decoder {
|
| * Minimal value of the start of the next memory to claim.
|
| */
|
| private long mMinNextMemory = 0;
|
| + /**
|
| + * The current nesting level when decoding.
|
| + */
|
| + private long mStackDepth;
|
|
|
| /**
|
| * The maximal memory accessible.
|
| @@ -46,11 +50,17 @@ public class Decoder {
|
| private final long mNumberOfHandles;
|
|
|
| /**
|
| + * The maximum nesting level when decoding.
|
| + */
|
| + private static final int MAX_RECURSION_DEPTH = 100;
|
| +
|
| + /**
|
| * Constructor.
|
| */
|
| Validator(long maxMemory, int numberOfHandles) {
|
| mMaxMemory = maxMemory;
|
| mNumberOfHandles = numberOfHandles;
|
| + mStackDepth = 0;
|
| }
|
|
|
| public void claimHandle(int handle) {
|
| @@ -79,6 +89,17 @@ public class Decoder {
|
| }
|
| mMinNextMemory = BindingsHelper.align(end);
|
| }
|
| +
|
| + public void increaseStackDepth() {
|
| + ++mStackDepth;
|
| + if (mStackDepth >= MAX_RECURSION_DEPTH) {
|
| + throw new DeserializationException("Recursion depth limit exceeded.");
|
| + }
|
| + }
|
| +
|
| + public void decreaseStackDepth() {
|
| + --mStackDepth;
|
| + }
|
| }
|
|
|
| /**
|
| @@ -744,4 +765,12 @@ public class Decoder {
|
| throw new DeserializationException("Buffer is smaller than expected.");
|
| }
|
| }
|
| +
|
| + public void increaseStackDepth() {
|
| + mValidator.increaseStackDepth();
|
| + }
|
| +
|
| + public void decreaseStackDepth() {
|
| + mValidator.decreaseStackDepth();
|
| + }
|
| }
|
|
|