2 ms·
The distinction between file formats and programs is mostly convention rather than semantic. The logical structure of a file parser is almost indistinguishable
by barrkel 11y ago
The distinction between file formats and programs is mostly convention rather than semantic.
The logical structure of a file parser is almost indistinguishable from that of a language parser, and most file parsers include what is effectively an interpreter to massage the low-level file instructions into something more meaningful in the loading program's domain model.
A file format is a program that, when evaluated, constructs an in-memory data structure.
The degree to which this is a problem depends on the side effects (if any) of data structure construction, and the set of data structures available to be constructed. And of course how the data structure is used later; if the data structure represents instructions (this is perfectly possible even in pure languages like Haskell) or may behave other than expected with inheritance, more problems ensue.
That's all independent of simple bugs in the parser, such as buffer overflows when trusting lengths and offsets embedded in the file, or infinite loops with naive offset chasing.