content_encoding: fix non-last chunked rejection

Even when two 'chunked' are listed and neither is the last encoding the
transfer is rejected.

Verified by test 1722 and 1723

Reported-by: violet12331 on hackerone
Closes #21966
This commit is contained in:
Daniel Stenberg 2026-06-11 10:59:05 +02:00
parent b7c9229cc6
commit 2b336e6b73
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
4 changed files with 146 additions and 25 deletions

View file

@ -225,7 +225,7 @@ test1685 test1686 \
\
test1700 test1701 test1702 test1703 test1704 test1705 test1706 test1707 \
test1708 test1709 test1710 test1711 test1712 test1713 test1714 test1715 \
test1720 test1721 \
test1720 test1721 test1722 test1723 \
\
test1800 test1801 test1802 test1847 test1848 test1849 test1850 test1851 \
\

61
tests/data/test1722 Normal file
View file

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="US-ASCII"?>
<testcase>
<info>
<keywords>
HTTP
HTTP GET
chunked Transfer-Encoding
</keywords>
</info>
# Server-side
<reply>
<data>
HTTP/1.1 200 funky chunky!
Server: fakeit/0.9 fakeitbad/1.0
Transfer-Encoding: chunked, another
Connection: mooo
40%CR
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa%CR
30%CR
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb%CR
21;heresatest=moooo%CR
cccccccccccccccccccccccccccccccc
%CR
0%CR
%CR
</data>
<datacheck>
HTTP/1.1 200 funky chunky!
Server: fakeit/0.9 fakeitbad/1.0
</datacheck>
</reply>
# Client-side
<client>
<server>
http
</server>
<name>
HTTP with chunked Transfer-Encoding not listed last
</name>
<command>
http://%HOSTIP:%HTTPPORT/%TESTNUMBER
</command>
</client>
# Verify data after the test has been "shot"
<verify>
<protocol crlf="headers">
GET /%TESTNUMBER HTTP/1.1
Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
</protocol>
<errorcode>
61
</errorcode>
</verify>
</testcase>

61
tests/data/test1723 Normal file
View file

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="US-ASCII"?>
<testcase>
<info>
<keywords>
HTTP
HTTP GET
chunked Transfer-Encoding
</keywords>
</info>
# Server-side
<reply>
<data>
HTTP/1.1 200 funky chunky!
Server: fakeit/0.9 fakeitbad/1.0
Transfer-Encoding: chunked, chunked, another
Connection: mooo
40%CR
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa%CR
30%CR
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb%CR
21;heresatest=moooo%CR
cccccccccccccccccccccccccccccccc
%CR
0%CR
%CR
</data>
<datacheck>
HTTP/1.1 200 funky chunky!
Server: fakeit/0.9 fakeitbad/1.0
</datacheck>
</reply>
# Client-side
<client>
<server>
http
</server>
<name>
HTTP with two chunked Transfer-Encoding not listed last
</name>
<command>
http://%HOSTIP:%HTTPPORT/%TESTNUMBER
</command>
</client>
# Verify data after the test has been "shot"
<verify>
<protocol crlf="headers">
GET /%TESTNUMBER HTTP/1.1
Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
</protocol>
<errorcode>
61
</errorcode>
</verify>
</testcase>