<feed xmlns='http://www.w3.org/2005/Atom'>
<title>uhttpd/tests/chunked_body.py, branch master</title>
<subtitle>Tiny HTTP server</subtitle>
<id>https://git.openwrt.org/project/uhttpd/atom?h=master</id>
<link rel='self' href='https://git.openwrt.org/project/uhttpd/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/uhttpd/'/>
<updated>2026-11-05T21:36:33Z</updated>
<entry>
<title>client: keep request parsing inside the bytes that are actually buffered</title>
<updated>2026-11-05T21:36:33Z</updated>
<author>
<name>Jo-Philipp Wich</name>
</author>
<published>2026-11-01T22:03:59Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/uhttpd/commit/?id=b0aaa81a166ed7f8ed7264726e4af3994b6d0ae3'/>
<id>urn:sha1:b0aaa81a166ed7f8ed7264726e4af3994b6d0ae3</id>
<content type='text'>
The chunked request body parser located line ends with strstr(), which
scans the whole read buffer instead of only the bytes the ustream
currently holds. When the CRLF terminating a chunk arrived split over two
packets, the parser skipped two bytes that were not buffered yet and then
matched a CRLF left over from earlier data past the tail of the buffer.
Consuming up to that match made ustream_consume() abort the server, so an
unauthenticated remote client could kill uhttpd with a crafted chunked
request body.

Add find_crlf(), which searches for a CR/LF pair within the valid buffer
length only, and use it for the request line, the header lines, the chunk
size lines and the trailer lines. Also wait for a complete chunk size line
before parsing it, and skip chunk extensions as defined by RFC 9112 7.1.1
(BWS, token or quoted-string values) so that valid size lines are not
mistaken for malformed framing.

Add tests/chunked_body.py, which covers the request shapes from the
report, size lines and chunk terminators split across packets, chunk
extensions, trailer sections, malformed framing and randomized
fragmentation, asserting the received body length and that the server is
still alive.

Reported-by: Guy Godfroy &lt;guy.godfroy@gugod.fr&gt;
Signed-off-by: Jo-Philipp Wich &lt;jo@mein.io&gt;
</content>
</entry>
</feed>
