ASN.1 BER decode of NULL type broken

Simon Cornish zl9d97p02@REDACTED
Wed Feb 10 01:11:31 CET 2010


Hi,
The asn1rt_bin_ber:decode_null function is broken for many cases.
Example: when a NULL type element is present and not the last element
in a sequence. Attached a sample ASN.1 module, demonstration of the
fault and patch against ccase/r13b04_dev

Sorry I don't have time today to wrestle with git to get this into a
branch. Hope it's simple enough to be included directly.

Regards,
 Simon
-------------- next part --------------
liveoak:asn1dn simon$ which erl
/Users/simon/src/otp/git/r13b04_dev/bin/erl
liveoak:asn1dn simon$ erlc +bber_bin -pa . DecodeNull.asn 
Erlang ASN.1 version "1.6.12" compiling "/private/tmp/simon/asn1dn/DecodeNull.asn" 
Compiler Options: [ber,report_errors,
                   {cwd,"/private/tmp/simon/asn1dn"},
                   {outdir,"/private/tmp/simon/asn1dn"},
                   bber_bin,
                   {i,"."},
                   {i,"/private/tmp/simon/asn1dn"}]
--{generated,"/private/tmp/simon/asn1dn/DecodeNull.asn1db"}--
--{generated,"/private/tmp/simon/asn1dn/DecodeNull.hrl"}--
--{generated,"/private/tmp/simon/asn1dn/DecodeNull.erl"}--
ok
liveoak:asn1dn simon$ erl -pa .
Erlang R13B04 (erts-5.7.5) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.7.5  (abort with ^G)
1> rr('DecodeNull').
['Seq1']
2> S = #'Seq1'{opt11 = 'NULL', opt12 = 'NULL'}.
#'Seq1'{opt11 = 'NULL',opt12 = 'NULL'}
3> {ok, Enc} = asn1rt:encode('DecodeNull', 'Seq1', S).
{ok,[48,8,171,2,5,0,172,2,5,0]}
4> asn1rt:decode('DecodeNull', 'Seq1', Enc).
{error,{asn1,{unexpected,<<172,2,5,0>>}}}
5> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DecodeNull.asn
Type: application/octet-stream
Size: 176 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-patches/attachments/20100209/18d9752d/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: asn1-decode_null.patch
Type: application/octet-stream
Size: 671 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-patches/attachments/20100209/18d9752d/attachment-0001.obj>


More information about the erlang-patches mailing list