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

Null terminate decoded_query_string if there are no url parameters. #12266

Merged
merged 1 commit into from
Feb 28, 2022

Conversation

MrZammler
Copy link
Contributor

Summary

When doing an api request through a client that does not close the connection, it is possible to keep the url parameters stored, even when a next request (over the same connection) does not contain them.

As a small test, try from a web browser to request /api/v1/alarms, then /api/v1/alarms?all and then again /api/v1/alarms.

If those calls are made before the connection is closed, then it is possible to receive the output of ?all when doing the request /api/v1/alarms.

The problem is that w->decoded_query_string is not cleared between requests. It is only calculated when the agent detects that there is a separator (?) in the url requested. If there's not, then nothing is done on w->decoded_query_string potentially leaving there the parameters from a previous request.

This PR just null terminates the string if we don't have any url parameters.

Test Plan

Perform the above scenario to check results with and without this PR. Curl will close the connection on every try, so a web browser should be a better check.

@MrZammler
Copy link
Contributor Author

Thanks!

@MrZammler MrZammler merged commit ddd57cd into netdata:master Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants