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

Increase buffer token size as needed #1230

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

denisonbarbosa
Copy link
Member

Some users had issues with GPOs with large entries overflowing the buffer and causing the update to fail. This fixes that by progressively increasing the expected readable token size until the maximum we can (the bufio package limits this).

UDENG-6434
Closes #1191

Verified

This commit was signed with the committer’s verified signature.
denisonbarbosa Denison Barbosa

Verified

This commit was signed with the committer’s verified signature.
denisonbarbosa Denison Barbosa
In order to be able to resize the buffer later, we need to have control
over the file cursor otherwise it would move forward and we would not be
able to retry reading the large entry.

Sadly, this implies on removing the fuzz test as we can't use os.File as
argument.

Verified

This commit was signed with the committer’s verified signature.
denisonbarbosa Denison Barbosa
Although the token size is already quite large by default, we might
end up in a situation where it's still not big enough, so we need to
address this by increasing its size if we find one that's too large.
@denisonbarbosa denisonbarbosa marked this pull request as ready for review March 21, 2025 10:42
@denisonbarbosa denisonbarbosa requested a review from a team as a code owner March 21, 2025 10:42
@@ -51,10 +52,10 @@ type meta struct {
}

// DecodePolicy parses a policy stream in registry file format and returns a slice of entries.
func DecodePolicy(r io.Reader) (entries []entry.Entry, err error) {
func DecodePolicy(f *os.File) (entries []entry.Entry, err error) {

Choose a reason for hiding this comment

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

In order to be able to resize the buffer later, we need to have control
over the file cursor otherwise it would move forward and we would not be
able to retry reading the large entry.

Sadly, this implies on removing the fuzz test as we can't use os.File as
argument.

Could we do the f.Seek(0, 0) conditionally if the r io.Reader is of type *os.File, so that we're able to keep the fuzz test?

Choose a reason for hiding this comment

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

alternatively, the fuzz test could write the fuzz data to a file (which should be in-memory for performance) and pass that to DecodePolicy

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.

Issue: go bufio.scanner GPO size too large
2 participants