You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes an issue where running flatc --size-prefixed --annotated <schema>.fbs -- <binary> would generate an almost empty annotated file.
Ensures that the reflection schema used by BinaryAnnotator is always validated as a normal (non–size-prefixed) schema, independent of whether the input binary is size-prefixed.
Keeps is_size_prefixed_ scoped correctly to parsing the data buffer header only.
Description
Previously, BinaryAnnotator::Annotate validated the schema buffer like this:
If is_size_prefixed_ was true (because the input binary was size-prefixed), it attempted reflection::VerifySizePrefixedSchemaBuffer.
If that failed, or if reflection::VerifySchemaBuffer failed, it returned an empty section map.
In the --annotated flow, the schema (.bfbs) is not size-prefixed, even when the binary data is. This caused schema verification to fail when --size-prefixed was used, leading to an empty annotation result and an almost empty .afb file.
This PR changes BinaryAnnotator::Annotate to always validate the schema using:
if (!reflection::VerifySchemaBuffer(verifier)) {
return {};
}
making sure I understand this right -- the binary file passed into this command would influence how the bfbs file was verified? and that is the gist of the bug? So now we verify the bfbs unconditionally, and only return an empty file if the bfbs is invalid?
Hi, @jtdavis777 thanks for your review.
Yes, exactly right. The is_size_prefixed_ flag was derived from the data binary (prefixed_sample.dat), but was then mistakenly applied to verify the schema (.bfbs).
So passing a size-prefixed data binary would cause the schema verification to fail — the schema had nothing to do with the data binary being size-prefixed.
The fix verifies the .bfbs unconditionally as a plain schema, and only returns empty if the schema itself is genuinely invalid.
Thanks again
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c++codegenInvolving generating code from schemawaiting-for-updateThis PR is waiting for a change from the author or contributors before it is ready for merge
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes: #8953
Summary
flatc --size-prefixed --annotated <schema>.fbs -- <binary>would generate an almost empty annotated file.BinaryAnnotatoris always validated as a normal (non–size-prefixed) schema, independent of whether the input binary is size-prefixed.is_size_prefixed_scoped correctly to parsing the data buffer header only.Description
Previously,
BinaryAnnotator::Annotatevalidated the schema buffer like this:is_size_prefixed_was true (because the input binary was size-prefixed), it attemptedreflection::VerifySizePrefixedSchemaBuffer.reflection::VerifySchemaBufferfailed, it returned an empty section map.In the
--annotatedflow, the schema (.bfbs) is not size-prefixed, even when the binary data is. This caused schema verification to fail when--size-prefixedwas used, leading to an empty annotation result and an almost empty.afbfile.This PR changes
BinaryAnnotator::Annotateto always validate the schema using: