ASN.1 BER decode of NULL type broken

Simon Cornish <>
Wed Feb 10 01:11:31 CET 2010

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.

-------------- next part --------------
liveoak:asn1dn simon$ which 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,
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').
2> S = #'Seq1'{opt11 = 'NULL', opt12 = 'NULL'}.
#'Seq1'{opt11 = 'NULL',opt12 = 'NULL'}
3> {ok, Enc} = asn1rt:encode('DecodeNull', 'Seq1', S).
4> asn1rt:decode('DecodeNull', 'Seq1', Enc).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DecodeNull.asn
Type: application/octet-stream
Size: 175 bytes
Desc: not available
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: asn1-decode_null.patch
Type: application/octet-stream
Size: 670 bytes
Desc: not available
URL: <>

More information about the erlang-patches mailing list