progress: count amount of data "delivered" to application

... and apply the CURLOPT_MAXFILESIZE limit (if set) on that as well.
This effectively protects the user against "zip bombs".

Test case 1618 verifies using a 14 byte brotli payload that otherwise
explodes to 102400 zero bytes.
This commit is contained in:
Daniel Stenberg 2026-03-02 11:02:03 +01:00
parent 7fe5b933d8
commit f6fce4f5ab
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
6 changed files with 90 additions and 6 deletions

View file

@ -213,7 +213,7 @@ test1580 test1581 test1582 test1583 test1584 test1585 \
test1590 test1591 test1592 test1593 test1594 test1595 test1596 test1597 \
test1598 test1599 test1600 test1601 test1602 test1603 test1604 test1605 \
test1606 test1607 test1608 test1609 test1610 test1611 test1612 test1613 \
test1614 test1615 test1616 test1617 \
test1614 test1615 test1616 test1617 test1618 \
test1620 test1621 test1622 test1623 \
\
test1630 test1631 test1632 test1633 test1634 test1635 test1636 test1637 \

68
tests/data/test1618 Normal file
View file

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="US-ASCII"?>
<testcase>
<info>
<keywords>
HTTP
HTTP GET
compressed
brotli
</keywords>
</info>
<reply>
<data crlf="headers" nonewline="yes">
HTTP/1.1 200 OK
Date: Mon, 29 Nov 2004 21:56:53 GMT
Vary: Accept-Encoding
Content-Encoding: br
Content-Length: 14
%hex[%81%fa%7f%0c%fc%13%00%f1%58%20%90%7b%18%00]hex%
</data>
<datacheck crlf="headers">
HTTP/1.1 200 OK
Date: Mon, 29 Nov 2004 21:56:53 GMT
Vary: Accept-Encoding
Content-Encoding: br
Content-Length: 14
</datacheck>
</reply>
# Client-side
<client>
<features>
brotli
</features>
<server>
http
</server>
<name>
HTTP GET brotli compression bomb
</name>
<command>
http://%HOSTIP:%HTTPPORT/%TESTNUMBER --compressed --max-filesize=1000
</command>
</client>
# Verify data after the test has been "shot"
<verify>
<strippart>
s/^Accept-Encoding: [a-zA-Z, ]*/Accept-Encoding: xxx/
</strippart>
<protocol crlf="headers">
GET /%TESTNUMBER HTTP/1.1
Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
Accept-Encoding: xxx
</protocol>
<errorcode>
63
</errorcode>
</verify>
</testcase>