10000 Fix host parsing bug by grcevski · Pull Request #486 · grafana/beyla · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix host parsing bug #486

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

Merged
merged 1 commit into from
Dec 7, 2023

Conversation

grcevski
Copy link
Contributor
@grcevski grcevski commented Dec 5, 2023

This PR fixes a bug in the host parsing fallback path for the HTTP request parser. In SSL mode we sometimes can't find the connection information, because of internal process threading models, so we have a fallback path to look for "Host: " in the headers. However, the code didn't anticipate our limited buffer size of 160 characters, so the '\r' may not be in the string.

@grcevski grcevski requested a review from mariomac as a code owner December 5, 2023 21:17
@@ -435,7 +435,7 @@ func (event *BPFHTTPInfo) method() string {
}

func (event *BPFHTTPInfo) hostFromBuf() (string, int) {
buf := string(event.Buf[:])
buf := cstr(event.Buf[:])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Use cstr here to remove any trailing null characters.

@@ -446,6 +446,10 @@ func (event *BPFHTTPInfo) hostFromBuf() (string, int) {

rIdx := strings.Index(buf, "\r")

if rIdx < 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the actual bug fix.

@codecov-commenter
Copy link
codecov-commenter commented Dec 5, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (741b435) 78.21% compared to head (c8224f0) 78.47%.

Additional details and impacted files
@@               Coverage Diff               @@
##           release-1.0     #486      +/-   ##
===============================================
+ Coverage        78.21%   78.47%   +0.25%     
===============================================
  Files               61       61              
  Lines             5032     5035       +3     
===============================================
+ Hits              3936     3951      +15     
+ Misses             883      875       -8     
+ Partials           213      209       -4     
Flag Coverage Δ
integration-test 65.91% <25.00%> (+0.20%) ⬆️
unittests 43.94% <100.00%> (+0.21%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mariomac
Copy link
Contributor
mariomac commented Dec 7, 2023

Amazing! We can cut a 1.0.2 release after merging this.

@grcevski grcevski merged commit 21bcc01 into grafana:release-1.0 Dec 7, 2023
@grcevski grcevski deleted the release-1.0-fix-len-bug branch December 7, 2023 12:12
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.

3 participants
0