File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
core/src/main/java/org/bouncycastle/asn1 Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -540,7 +540,10 @@ static ASN1Primitive createPrimitiveDERObject(
540540 case INTEGER :
541541 return ASN1Integer .createPrimitive (defIn .toByteArray ());
542542 case NULL :
543- return ASN1Null .createPrimitive (defIn .toByteArray ());
543+ {
544+ ASN1Null .checkContentsLength (defIn .getRemaining ());
545+ return ASN1Null .createPrimitive ();
546+ }
544547 case NUMERIC_STRING :
545548 return ASN1NumericString .createPrimitive (defIn .toByteArray ());
546549 case OBJECT_DESCRIPTOR :
Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ public abstract class ASN1Null
1212 {
1313 ASN1Primitive fromImplicitPrimitive (DEROctetString octetString )
1414 {
15- return createPrimitive (octetString .getOctets ());
15+ checkContentsLength (octetString .getOctetsLength ());
16+ return createPrimitive ();
1617 }
1718 };
1819
@@ -88,12 +89,16 @@ public String toString()
8889 return "NULL" ;
8990 }
9091
91- static ASN1Null createPrimitive ( byte [] contents )
92+ static void checkContentsLength ( int contentsLength )
9293 {
93- if (0 != contents . length )
94+ if (0 != contentsLength )
9495 {
9596 throw new IllegalStateException ("malformed NULL encoding encountered" );
9697 }
98+ }
99+
100+ static ASN1Null createPrimitive ()
101+ {
97102 return DERNull .INSTANCE ;
98103 }
99104}
You can’t perform that action at this time.
0 commit comments