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

Always use buf in CopyBuffer #144

Merged
merged 1 commit into from
Jan 5, 2023
Merged

Conversation

jedevc
Copy link
Collaborator

@jedevc jedevc commented Jan 4, 2023

CopyBuffer may not always use the provided buffer, in the case that the src implements WriterTo. So, in the case that the io.ReadCloser returned by fs.Open implements this method, the packet size limit will not be enforced, creating an oversized packet that results in an error on the receiver.

To avoid this, we can create an anonymous structure to wrap the src, which prevents the shortcut taken by the standard library.

I'm not 100% sure of the approach for this, maybe we should write our own Copy method to circumvent this issue instead?

cc @crazy-max

CopyBuffer may not always use the provided buffer, in the case that the
src implements WriterTo. So, in the case that the io.ReadCloser returned
by fs.Open implements this method, the packet size limit will not be
enforced, creating an oversized packet that results in an error on the
receiver.

To avoid this, we can create an anonymous structure to wrap the src,
which prevents the shortcut taken by the standard library.

Signed-off-by: Justin Chadwell <[email protected]>
@jedevc
Copy link
Collaborator Author

jedevc commented Jan 5, 2023

@tonistiigi suggested adding a for loop with an io.LimitReader instead of the hacky workaround here.

@tonistiigi tonistiigi merged commit fb43384 into tonistiigi:master Jan 5, 2023
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.

2 participants