summaryrefslogtreecommitdiff
path: root/bcprov/src/main/java/org/bouncycastle/asn1/ASN1Primitive.java
diff options
context:
space:
mode:
Diffstat (limited to 'bcprov/src/main/java/org/bouncycastle/asn1/ASN1Primitive.java')
-rw-r--r--bcprov/src/main/java/org/bouncycastle/asn1/ASN1Primitive.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/bcprov/src/main/java/org/bouncycastle/asn1/ASN1Primitive.java b/bcprov/src/main/java/org/bouncycastle/asn1/ASN1Primitive.java
index 3c887e55..db72d6ad 100644
--- a/bcprov/src/main/java/org/bouncycastle/asn1/ASN1Primitive.java
+++ b/bcprov/src/main/java/org/bouncycastle/asn1/ASN1Primitive.java
@@ -18,7 +18,7 @@ public abstract class ASN1Primitive
*
* @param data the byte stream to parse.
* @return the base ASN.1 object represented by the byte stream.
- * @exception IOException if there is a problem parsing the data.
+ * @exception IOException if there is a problem parsing the data, or parsing the stream did not exhaust the available data.
*/
public static ASN1Primitive fromByteArray(byte[] data)
throws IOException
@@ -27,7 +27,14 @@ public abstract class ASN1Primitive
try
{
- return aIn.readObject();
+ ASN1Primitive o = aIn.readObject();
+
+ if (aIn.available() != 0)
+ {
+ throw new IOException("Extra data detected in stream");
+ }
+
+ return o;
}
catch (ClassCastException e)
{