-
Notifications
You must be signed in to change notification settings - Fork 498
feat(client): set client buffer size to avoid buffer overflow #323
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
Open
GoldenSheep402
wants to merge
1
commit into
hashicorp:main
Choose a base branch
from
GoldenSheep402:feat/set-client-buffer
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -227,6 +227,10 @@ type ClientConfig struct { | |
| // If this is 0, then the default of 64KB is used. | ||
| PluginLogBufferSize int | ||
|
|
||
| // ClientScanerBufferSize is the buffer size(bytes) to read from stderr for plugin log lines. | ||
| // If this is 0, then the default of 64KB is used. | ||
| ClientScanerBufferSize int | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo for Scanner |
||
|
|
||
| // AutoMTLS has the client and server automatically negotiate mTLS for | ||
| // transport authentication. This ensures that only the original client will | ||
| // be allowed to connect to the server, and all other connections will be | ||
|
|
@@ -427,6 +431,10 @@ func NewClient(config *ClientConfig) (c *Client) { | |
| config.PluginLogBufferSize = defaultPluginLogBufferSize | ||
| } | ||
|
|
||
| if config.ClientScanerBufferSize == 0 { | ||
| config.ClientScanerBufferSize = bufio.MaxScanTokenSize | ||
| } | ||
|
|
||
| c = &Client{ | ||
| config: config, | ||
| logger: config.Logger, | ||
|
|
@@ -799,6 +807,9 @@ func (c *Client) Start() (addr net.Addr, err error) { | |
| defer close(linesCh) | ||
|
|
||
| scanner := bufio.NewScanner(runner.Stdout()) | ||
| buf := make([]byte, c.config.ClientScanerBufferSize) | ||
| scanner.Buffer(buf, c.config.ClientScanerBufferSize) | ||
|
|
||
| for scanner.Scan() { | ||
| linesCh <- scanner.Text() | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ require ( | |
| github.com/hashicorp/go-hclog v0.14.1 // indirect | ||
| github.com/hashicorp/yamux v0.1.1 // indirect | ||
| github.com/mattn/go-colorable v0.1.4 // indirect | ||
| github.com/mattn/go-isatty v0.0.10 // indirect | ||
| github.com/mattn/go-isatty v0.0.17 // indirect | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What caused this change ? |
||
| github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 // indirect | ||
| github.com/oklog/run v1.0.0 // indirect | ||
| golang.org/x/net v0.17.0 // indirect | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its more related to stdout than stderr