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

Opaque field with zero length serialized as one byte #533

Closed
senier opened this issue Dec 30, 2020 · 0 comments
Closed

Opaque field with zero length serialized as one byte #533

senier opened this issue Dec 30, 2020 · 0 comments
Assignees
Labels
bug pyrflx Related to pyrflx package (Legacy Python API)

Comments

@senier
Copy link
Member

senier commented Dec 30, 2020

The following message has an opaque field which may have a size of zero:

package Test is
   type Length is mod 2**8;
   type M is
      message
         Length : Length
            then Data
               with Size => 8 * Length;
         Data : Opaque;
      end message;
end Test;

When serializing a message where Length is zero, the Data field is serialized as a single byte with value 0:

data = b"\x00"

msg = PyRFLX.from_specs (["test.rflx"], skip_model_verification=True)["Test"]["M"]
msg.parse (data)                                                                                                    

if data != msg.bytestring:
    print(f"Serialization mismatch:\ngot:      {msg.bytestring.hex()}\nexpected: {data.hex()}")
$ ./parse.py                                       
Serialization mismatch:
got:      0000
expected: 00
@senier senier created this issue from a note in RecordFlux 0.5 (To do) Dec 30, 2020
@senier senier added bug pyrflx Related to pyrflx package (Legacy Python API) labels Dec 30, 2020
@jklmnn jklmnn self-assigned this Jan 4, 2021
jklmnn added a commit that referenced this issue Jan 4, 2021
jklmnn added a commit that referenced this issue Jan 4, 2021
@jklmnn jklmnn moved this from To do to Done in RecordFlux 0.5 Jan 4, 2021
jklmnn added a commit that referenced this issue Jan 4, 2021
jklmnn added a commit that referenced this issue Jan 5, 2021
@jklmnn jklmnn closed this as completed Jan 5, 2021
RecordFlux 0.5 automation moved this from Done to Merged Jan 5, 2021
@treiher treiher mentioned this issue Aug 4, 2021
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug pyrflx Related to pyrflx package (Legacy Python API)
Projects
No open projects
RecordFlux 0.5
  
Merged
Development

No branches or pull requests

2 participants