flatbuffers icon indicating copy to clipboard operation
flatbuffers copied to clipboard

[CPP] Unable to pass SIzeVerifier to root verifier

Open jtdavis777 opened this issue 9 months ago • 1 comments

It looks like FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE was deprecated, the ability to call either of the following was broken:

flatbuffers::SizeVerifier verifier{ data, len };

verifier.VerifyBuffer<my_root_type>(); // compiler error

auto my_buffer = Getmy_root_type(data);

my_buffer->Verify(verifier); // compiler error

jtdavis777 avatar Apr 14 '25 16:04 jtdavis777

these both fail with some flavor of

verifier.h:216:64: error: cannot convert 'flatbuffers::VerifierTemplate<true>' to 'flatbuffers::Verifier&' {aka 'flatbuffers::VerifierTemplate<false>&'}

jtdavis777 avatar Apr 14 '25 16:04 jtdavis777

This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale, or this will be closed in 14 days.

github-actions[bot] avatar Oct 13 '25 20:10 github-actions[bot]

I just encountered this as well.

sketch34 avatar Oct 15 '25 01:10 sketch34

Thanks for reporting this.

And thanks to sketch34 for connecting this with issue #8274, which is how this hit my inbox. Sorry for the slow response, but until yesterday I wasn't aware of the issue.

A likely work-around is to continue to build with FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE defined, and either be careful to avoid using SizeVerifier in header files, or be careful to ensure that all source files using flatbuffers get compiled with FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE.

I have also uploaded a tentative fix to https://github.com/google/flatbuffers/commit/0af519ec861654cc1bccb27c67f08275a9dd72a6 but I haven't tested it much yet.

thejtshow and sketch34: perhaps you can try patching it in and seeing if it works for you?

fergushenderson avatar Oct 16 '25 17:10 fergushenderson

Sure, I can certainly take a look.

jtdavis777 avatar Oct 17 '25 11:10 jtdavis777

I have now tested the patch that I posted earlier (0af519e), and it seems to work correctly for my use case, at least. So I have sent a pull request.

@dbaileychess

fergushenderson avatar Oct 27 '25 19:10 fergushenderson