Signature: Check off, len & input early.
Change-Id: Ic4e80065a258bffe4c2e5a4a8258138597ad9e7f
diff --git a/ojluni/src/main/java/java/security/Signature.java b/ojluni/src/main/java/java/security/Signature.java
index aa1574d..7d12852 100755
--- a/ojluni/src/main/java/java/security/Signature.java
+++ b/ojluni/src/main/java/java/security/Signature.java
@@ -711,6 +711,16 @@
*/
public final void update(byte[] data, int off, int len)
throws SignatureException {
+ // Android-changed: Check data, off & len early and throw an exception
+ // as soon as possible.
+ if (data == null) {
+ throw new IllegalArgumentException("data == null");
+ }
+
+ if (off < 0 || len < 0 || off + len > data.length) {
+ throw new IllegalArgumentException();
+ }
+
if (state == SIGN || state == VERIFY) {
engineUpdate(data, off, len);
} else {