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

Enforce discard limits #606

Closed
wants to merge 1 commit into from
Closed

Enforce discard limits #606

wants to merge 1 commit into from

Conversation

emcfarlane
Copy link
Contributor

I'm not sure if this is the correct solution but raising as a PR to get feedback. Currently enveloped messages can cause a large discard call as if the size is above the message size, which is above the the discard limit, then we always discard the next N bytes which could be 4Gb (max uint32).

Connect clients will discard when they've read as much input as the max message size, plus the discard limit.

Should the discard size be greater than the message size? For enveloped payloads should we discard the message limit? And for connect payloads should we count the message size read into the discard limit?

Another option could be to move the discard calls to occur after the error return, try discard for TCP reuse as a cleanup routine.

return errorf(CodeUnknown, "read enveloped message: %w", err)
}
return errorf(CodeResourceExhausted, "message size %d is larger than configured max %d", size, r.readMaxBytes)
src := io.LimitReader(r.reader, int64(size))
Copy link
Contributor Author

@emcfarlane emcfarlane Oct 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For grpc-web tests I've limited this to the message payload. We discard the message but not the body trailers. Otherwise the count is incorrect. But maybe this defeats the purpose of the discard?

@emcfarlane emcfarlane closed this Nov 20, 2023
@emcfarlane emcfarlane deleted the ed/discard branch February 16, 2024 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant