Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/proxy/http/HttpTunnel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ ChunkedHandler::read_size()
done = true;
break;
} else {
if ((prev_is_cr = ParseRules::is_cr(*tmp)) == true) {
if (ParseRules::is_cr(*tmp)) {
++num_cr;
}
state = CHUNK_READ_SIZE_CRLF; // now look for CRLF
Expand All @@ -213,7 +213,7 @@ ChunkedHandler::read_size()
done = true;
num_cr = 0;
break;
} else if ((prev_is_cr = ParseRules::is_cr(*tmp)) == true) {
} else if (ParseRules::is_cr(*tmp)) {
if (num_cr != 0) {
state = CHUNK_READ_ERROR;
done = true;
Expand All @@ -236,7 +236,7 @@ ChunkedHandler::read_size()
num_digits = 0;
num_cr = 0;
state = CHUNK_READ_SIZE;
} else if ((prev_is_cr = ParseRules::is_cr(*tmp)) == true) {
} else if (ParseRules::is_cr(*tmp)) {
if (num_cr != 0) {
Dbg(dbg_ctl_http_chunk, "Found multiple CRs before chunk size");
state = CHUNK_READ_ERROR;
Expand All @@ -249,9 +249,15 @@ ChunkedHandler::read_size()
done = true;
}
}
prev_is_cr = ParseRules::is_cr(*tmp);
tmp++;
data_size--;
}

if (data_size > 0) {
prev_is_cr = ParseRules::is_cr(*tmp);
}

if (drop_chunked_trailers) {
chunked_buffer->write(chunked_reader, bytes_used);
chunked_size += bytes_used;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ def setupOriginServer(self):
"chunked body of 3 bytes for key 2 with chunk stream", "Verify that writing the second response failed.")
self.server.Streams.stdout += Testers.ContainsExpression(
"Unexpected chunked content for key 3: too small", "Verify that writing the third response failed.")
self.server.Streams.stdout += Testers.ContainsExpression(
"Unexpected chunked content for key 8: too small", "Verify that writing the sixth response failed.")

# ATS should close the connection before any body gets through. "abcwxyz"
# is the body sent by the client for each of these chunked cases.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,26 @@ sessions:
server-response:
status: 200

- transactions:
- client-request:
method: "POST"
version: "1.1"
url: /malformed/chunk/header3
headers:
fields:
- [ Host, example.com ]
- [ Transfer-Encoding, chunked ]
- [ uuid, 8 ]
content:
transfer: plain
encoding: uri
# chunk-size is set to 1, but no chunk-data is present.
data: 1%0D%0A%0D%0A0%0D%0A%0D%0A

# The connection will be dropped and this response will not go out.
server-response:
status: 200

#
# Now repeat the above two malformed chunk header tests, but on the server
# side.
Expand Down