Skip to content

asn1 application: problem decoding REAL 0 values #9096

Closed
@BigChungusDaddy

Description

Describe the bug
The Erlang ASN.1 compiler generates code that crashes when it is invoked to decode REAL 0 values.

To Reproduce
Use file RealTest.asn1 containing the following ASN.1 encoding:

RealTest DEFINITIONS ::= BEGIN
    Real ::= REAL
END

Compile the .asn1 file using the asn1ct module and use the decode function in the generated Erlang stub.

% erl
Erlang/OTP 27 [erts-15.1.2] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit] [dtrace]

Eshell V15.1.2 (press Ctrl+G to abort, type help(). for help)
1> asn1ct:compile('RealTest', []).
ok
2> 'RealTest':decode('Real',[9,0]).
{error,{asn1,{{badmatch,{0,<<>>}},
              [{'RealTest',decode_real,1,
                           [{file,"RealTest.erl"},{line,139}]},
               {'RealTest',decode,2,[{file,"RealTest.erl"},{line,53}]},
               {erl_eval,do_apply,7,[{file,"erl_eval.erl"},{line,904}]},
               {shell,exprs,7,[{file,"shell.erl"},{line,893}]},
               {shell,eval_exprs,7,[{file,"shell.erl"},{line,849}]},
               {shell,eval_loop,4,[{file,"shell.erl"},{line,834}]}]}}}

Expected behavior

'RealTest':decode('Real',[9,0]). should return {ok,0}

Affected versions
OTP 27

Additional context
Lev Walkin @vlm, the author of asn1c, reported a similar issue.

This bug is caused by line 218 in asn1rtt_real_common.erl. I suggest a possible fix to change line 218 from

{0,Buffer};

to

{0,<<>>,0};

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

bugIssue is reported as a bugteam:VMAssigned to OTP team VM

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions