Null terminate decoded_query_string if there are no url parameters. #12266
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.
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 onw->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.