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

Configure protobuf decoding limits #3739

Open
pepone opened this issue Oct 23, 2023 · 3 comments
Open

Configure protobuf decoding limits #3739

pepone opened this issue Oct 23, 2023 · 3 comments

Comments

@pepone
Copy link
Member

pepone commented Oct 23, 2023

See:

https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.CodedInputStream#Google_Protobuf_CodedInputStream_RecursionLimit

Seems this limits are not exposed with the ReadOnlySequence API we are using

@pepone pepone added this to the 0.2.0 milestone Oct 23, 2023
@pepone
Copy link
Member Author

pepone commented Oct 26, 2023

Looking at the C# protobuf API and sources, the decoding limits can only be set with the CodecInputStream API, the ParseContext used by other overloads always uses the default limits.

If we want to use the CodecInputStream API, we need to wrap the ReadOnlySequence in a Stream and then create the CodecInputStream with the desired limits using CreateWithLimits https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.CodedInputStream#Google_Protobuf_CodedInputStream_CreateWithLimits_System_IO_Stream_System_Int32_System_Int32_

This means an additional allocation for the stream wrapping the read-only sequence.

@pepone
Copy link
Member Author

pepone commented Nov 8, 2023

See a related issue in the grpc-dotnet repository:

@pepone pepone modified the milestones: 0.2.0, Future Nov 13, 2023
@bernardnormier
Copy link
Member

I'd rather not wrap CodecInputStream.

Since this is a Protobuf C# issue, should we open an issue in https://github.com/protocolbuffers/protobuf/issues?q=is%3Aopen+is%3Aissue+label%3Ac%23?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants