diff --git a/lib/modules/Standards.pmod/ASN1.pmod/Decode.pmod b/lib/modules/Standards.pmod/ASN1.pmod/Decode.pmod index b51e3c91e9500368e35d14b1deca646ac00aad6b..1c5bd61c560580af99e25a0e9f412baae5069722 100644 --- a/lib/modules/Standards.pmod/ASN1.pmod/Decode.pmod +++ b/lib/modules/Standards.pmod/ASN1.pmod/Decode.pmod @@ -110,6 +110,7 @@ protected array(int) read_identifier(Stdio.Buffer data) constructed, tag, len); data = [object(Stdio.Buffer)]data->read_buffer(len); + data->set_error_mode(1); program(.Types.Object) p = types[ .Types.make_combined_tag(cls, tag) ]; @@ -234,7 +235,7 @@ mapping(int:program(.Types.Object)) universal_types = mapping(int:program(.Types.Object))|void types) { types = types ? universal_types+types : universal_types; - Stdio.Buffer buf = Stdio.Buffer(data); + Stdio.Buffer buf = Stdio.Buffer(data)->set_error_mode(1); .Types.Object ret = der_decode(buf, types); if( sizeof(buf) ) return 0; return ret; diff --git a/lib/modules/Standards.pmod/ASN1.pmod/testsuite.in b/lib/modules/Standards.pmod/ASN1.pmod/testsuite.in index b07972ebf1a7f7dcb20b72c9ad8fa28f93a1364c..dc5a132e5c6cbda123e10cb70ffc188622c44690 100644 --- a/lib/modules/Standards.pmod/ASN1.pmod/testsuite.in +++ b/lib/modules/Standards.pmod/ASN1.pmod/testsuite.in @@ -20,6 +20,12 @@ test_do( add_constant("P", lambda(object o) test_eval_error(Standards.ASN1.Decode.simple_der_decode("")) +test_eval_error(Standards.ASN1.Decode.simple_der_decode("")) +test_eval_error(Standards.ASN1.Decode.secure_der_decode("")) + +test_eval_error(Standards.ASN1.Decode.simple_der_decode(String.hex2string("a2184515521e4c5d26f05590543c696ca2bd04b7754a18107d7f62744fbcb3a52ee80de3dca53339c3f6b2196afe3c540adfeb92686029f2"))) +test_eval_error(Standards.ASN1.Decode.secure_der_decode(String.hex2string("a2184515521e4c5d26f05590543c696ca2bd04b7754a18107d7f62744fbcb3a52ee80de3dca53339c3f6b2196afe3c540adfeb92686029f2"))) + define(test_decode,[[ test_eq(P(Standards.ASN1.Decode.simple_der_decode(String.hex2string($1-" "))),$2) test_eq(Standards.ASN1.Decode.simple_der_decode(String.hex2string($1-" "))->get_der(),