summaryrefslogtreecommitdiffstats
path: root/graphics/java
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2011-06-02 19:36:41 -0700
committerStephen Hines <srhines@google.com>2011-06-02 19:36:41 -0700
commite27832acc083fa889e86b4c629b6aedd8855ceca (patch)
tree8a7a414bd4864c283b96e4019fc72473bd123011 /graphics/java
parentd5f89ebefe95c42466e287531a247b7f02dedd52 (diff)
downloadframeworks_base-e27832acc083fa889e86b4c629b6aedd8855ceca.zip
frameworks_base-e27832acc083fa889e86b4c629b6aedd8855ceca.tar.gz
frameworks_base-e27832acc083fa889e86b4c629b6aedd8855ceca.tar.bz2
Improve validation in RS FieldPacker.
Change-Id: I9f6a58048129db4978c893c2dc591b0ed825d05f
Diffstat (limited to 'graphics/java')
-rw-r--r--graphics/java/android/renderscript/FieldPacker.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/graphics/java/android/renderscript/FieldPacker.java b/graphics/java/android/renderscript/FieldPacker.java
index bdda830..6487623 100644
--- a/graphics/java/android/renderscript/FieldPacker.java
+++ b/graphics/java/android/renderscript/FieldPacker.java
@@ -25,10 +25,15 @@ package android.renderscript;
public class FieldPacker {
public FieldPacker(int len) {
mPos = 0;
+ mLen = len;
mData = new byte[len];
}
public void align(int v) {
+ if ((v <= 0) || ((v & (v - 1)) != 0)) {
+ throw new RSIllegalArgumentException("argument must be a non-negative non-zero power of 2: " + v);
+ }
+
while ((mPos & (v - 1)) != 0) {
mData[mPos++] = 0;
}
@@ -38,11 +43,18 @@ public class FieldPacker {
mPos = 0;
}
public void reset(int i) {
+ if ((i < 0) || (i >= mLen)) {
+ throw new RSIllegalArgumentException("out of range argument: " + i);
+ }
mPos = i;
}
public void skip(int i) {
- mPos += i;
+ int res = mPos + i;
+ if ((res < 0) || (res >= mLen)) {
+ throw new RSIllegalArgumentException("out of range argument: " + i);
+ }
+ mPos = res;
}
public void addI8(byte v) {
@@ -277,6 +289,7 @@ public class FieldPacker {
private final byte mData[];
private int mPos;
+ private int mLen;
}