changeset 12062:683c9263a5b1

8168705: Better ObjectIdentifier validation Reviewed-by: ascarpino
author robm
date Fri, 18 Nov 2016 14:52:52 +0000
parents 41594ac7ca27
children cd0585378c46
files src/share/classes/sun/security/util/ObjectIdentifier.java
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/security/util/ObjectIdentifier.java	Wed Nov 16 15:49:39 2016 +0000
+++ b/src/share/classes/sun/security/util/ObjectIdentifier.java	Fri Nov 18 14:52:52 2016 +0000
@@ -255,7 +255,13 @@
                 + " (tag = " +  type_id + ")"
                 );
 
-        encoding = new byte[in.getLength()];
+        int len = in.getLength();
+        if (len > in.available()) {
+            throw new IOException("ObjectIdentifier() -- length exceeds" +
+                    "data available.  Length: " + len + ", Available: " +
+                    in.available());
+        }
+        encoding = new byte[len];
         in.getBytes(encoding);
         check(encoding);
     }