gbarr / perl-Convert-ASN1

encode/decode data using ASN.1 description
http://search.cpan.org/dist/Convert-ASN1/
13 stars 21 forks source link

Uninitialized value with ANY DEFINED BY #27

Open tlhackque opened 8 years ago

tlhackque commented 8 years ago

Use of uninitialized value in hash element at /usr/lib/perl5/site_perl/5.8.8/Convert/ASN1/_decode.pm line 133 The asn snipped:

    Attributes ::= SET OF Attribute
    Attribute ::= SEQUENCE {
      type   OBJECT IDENTIFIER,
      values SET OF ANY DEFINED BY type}

In this case, I'd called registertype( 'type', 'an OID', 'A macro'). But I didn't register all the OIDs that can be encountered.

I expected that the known (registered) OIDs would decode, and the others would be left raw (or ignored).

This is a pretty common use case with things like X.509 certs; one knows what's in the RFCs, but someone else will always provide input with a private extension. So one can't enumerate all the possible values. Or the value for most OIDs is simple, but some need special handling.

The alternative is to leave off the DEFINED BY and manually call find and decode. This works, but is more code.

In any case, Convert::ASN1 shouldn't complain about the uninitialized value...

Convert::ASN1 => 0.27