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

Improve Tunnel Server RESPONSE dumps #279

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

eduard-bagdasaryan
Copy link

@eduard-bagdasaryan eduard-bagdasaryan commented Dec 26, 2024

Level-2 "Tunnel Server RESPONSE:..." debugs() incorrectly assumed that
its readBuf parameter contained hdr_sz header bytes. In reality, by the
time code reached that debugs(), readBuf no longer had any header bytes
(and often had no bytes at all). Besides broken header dumps, this bug
could lead to problems that Valgrind reports as "Conditional jump or
move depends on uninitialised value" in DebugChannel::writeToStream().

This fix mimics HttpStateData::processReplyHeader() reporting code,
including its known problems. Future changes should address those
problems and reduce code duplication across at least ten functions
containing similar "decorated" level-2 message dumps.

"Tunnel Server RESPONSE" debugs() in Http::Tunneler::handleResponse()
incorrectly assumed that readBuf contained hdr_sz bytes, but in reality
it contains no header bytes and usually is empty. To avoid such problems
we must pair rawContent() with the SBuf's length().
src/clients/HttpTunneler.cc Outdated Show resolved Hide resolved
Adjusted Http::Tunneler::handleResponse() in line with a similar
HttpStateData::processReplyHeader().
@rousskov rousskov changed the title Fix Tunnel Server RESPONSE dumps Improve Tunnel Server RESPONSE dumps Dec 28, 2024
Copy link

@rousskov rousskov left a comment

Choose a reason for hiding this comment

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

Thank you for fixing this. I think we must disclose the known problems associated with this duplicated code. I adjusted PR description accordingly and posted a suggestion. I also reduce PR title claim from "fix" to "improve" because this change can be viewed as a partial fix, and I do not want to overpromise and underdeliver.

@@ -296,15 +296,23 @@ Http::Tunneler::handleResponse(const bool eof)
}

if (!parsedOk) {
debugs(11, 3, "Non-HTTP-compliant header:\n---------\n" << readBuf << "\n----------");

Choose a reason for hiding this comment

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

This code suffers from the same two problems that equivalent HttpStateData::processReplyHeader() code suffers from. We can propose to duplicate those problems (for now), but (if we do) we should be explicit about it (so that it does not look as if we are unknowingly adding bugs):

Suggested change
debugs(11, 3, "Non-HTTP-compliant header:\n---------\n" << readBuf << "\n----------");
// XXX: This code and Server RESPONSE reporting code below duplicate
// HttpStateData::processReplyHeader() reporting code, including its problems.
debugs(11, 3, "Non-HTTP-compliant header:\n---------\n" << readBuf << "\n----------");

The above suggestion also documents code duplication itself.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

eduard-bagdasaryan and others added 4 commits December 30, 2024 01:28
…cache#1977)

To avoid documentation duplication, current https_port and ftp_port
directive descriptions reference http_port directive instead of
detailing their own supported parameters. For https_port, this solution
creates a false impression that the directive supports all http_port
options. Our ftp_port documentation is better but still leaves the
reader guessing which options are actually supported.

This change starts enumerating http_port configuration parameters that
ftp_port and https_port directives do _not_ support. Eventually, Squid
should reject configurations with unsupported listening port options.
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