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

Fix for AMI NVAR parser based on kaitai struct #373

Merged
merged 2 commits into from
Aug 4, 2023

Conversation

chunqing286
Copy link
Contributor

modify 1 line in ami_nvar.ksy (line 128).

Bug scenario:
nvar_entry.attributes.valid = 0
nvar_entry.attributes.extended_header = 1

Now, extended_header_size_field 's value is undefined, as defined in ami_nvar.ksy

extended_header_size_field:
     pos: _io.pos - sizeof<u2>
     type: u2
     if: _parent.attributes.valid
      and _parent.attributes.extended_header
      and _parent.size > sizeof<u4> + sizeof<u2> + sizeof<u4> + sizeof<u2>

but this value would be used by other instances, e.g. extended_header_size, as defined in ami_nvar.ksy

extended_header_size:
     value: '_parent.attributes.extended_header ? (extended_header_size_field >= sizeof<nvar_extended_attributes> + sizeof<u2> ? extended_header_size_field : 0) : 0'

finally leads to parse error/exception or program crash.

@NikolajSchlej
Copy link
Collaborator

Thanks for the fix, makes sense. Need to regenerate the files by calling the most recent kaitai_regenerate.sh, because the current ones seem to be generated without C++11 additions (kaitai-struct-compiler --target cpp_stl --cpp-standard 11).

@chunqing286
Copy link
Contributor Author

Hi, thanks for your instructions about C++ 11 standard.

I have regenerate the C++ header and source file by kaitai-struct-compiler --target cpp_stl --cpp-standard 11.

By the way , I use the lastest Kaitai Struct release version 0.10.

@NikolajSchlej NikolajSchlej merged commit 4a41c33 into LongSoft:new_engine Aug 4, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants