changeset 16524:a3f48d8fc56a

8168705: Better ObjectIdentifier validation Reviewed-by: mullan, asmotrak, ahgross
author ascarpino
date Thu, 17 Nov 2016 09:51:10 -0800
parents 105b6e394d28
children cd7eaa7bf282
files src/java.base/share/classes/sun/security/util/ObjectIdentifier.java
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/sun/security/util/ObjectIdentifier.java	Thu Nov 17 16:59:18 2016 +0000
+++ b/src/java.base/share/classes/sun/security/util/ObjectIdentifier.java	Thu Nov 17 09:51:10 2016 -0800
@@ -255,7 +255,13 @@
                 + " (tag = " +  type_id + ")"
                 );
 
-        encoding = new byte[in.getDefiniteLength()];
+        int len = in.getDefiniteLength();
+        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);
     }