Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asn1 application: problem decoding REAL 0 values #9096

Open
BigChungusDaddy opened this issue Nov 20, 2024 · 0 comments
Open

asn1 application: problem decoding REAL 0 values #9096

BigChungusDaddy opened this issue Nov 20, 2024 · 0 comments
Assignees
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM

Comments

@BigChungusDaddy
Copy link

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};
@BigChungusDaddy BigChungusDaddy added the bug Issue is reported as a bug label Nov 20, 2024
@bjorng bjorng self-assigned this Nov 21, 2024
@bjorng bjorng added the team:VM Assigned to OTP team VM label Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM
Projects
None yet
Development

No branches or pull requests

2 participants