Skip to content

flatc segmentation fault when converting malformed flatbuffer to JSON #8630

Open
@SamuelTheCamel

Description

@SamuelTheCamel

I'm not sure if this is intended behavior or not, but it seems that flatc can seg fault when converting a flatbuffer binary to JSON if the flatbuffer is malformed. This could be caused by a flatbuffer being from a different schema or accidentally using an unrelated file.

Steps to reproduce

  1. Modify a FlatBuffer binary file to change an offset to be well out of bounds, or use some random unrelated binary file (I used the annotated binary feature to identify the location of an offset to modify)
  2. Use flatc --json to convert the file to JSON (I specifically used flatc --json --strict-json --defaults-json -o temp schema.fbs -- --raw-binary flatbuf_binary.bin)
  3. flatc will either parse the invalid flatbuffer anyways or seg fault. I got the standard Segmentation fault (core dumped) message on Linux.

Why this might be an issue

I understand that using flatc on invalid flatbuffers is not the way it was intended to be used, but I expected some sort of error handling. I'm making this issue in case this is unintended behavior and should be fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions