[core] fix POST with chunked request body (fixes #2854)

(thx the_jk)

x-ref:
  "chunked transfer encoding in request body only works for tiny chunks"
  https://redmine.lighttpd.net/issues/2854
personal/stbuehler/fix-fdevent
Glenn Strauss 5 years ago
parent cb371557e5
commit dc1675ea32

@ -132,7 +132,7 @@ static handler_t connection_handle_read_post_chunked(server *srv, connection *co
off_t hsz = p + 1 - (c->mem->ptr+c->offset);
unsigned char *s = (unsigned char *)c->mem->ptr+c->offset;
for (unsigned char u;(u=(unsigned char)hex2int(*s))!=0xFF;++s) {
if (te_chunked > (~((off_t)-1) >> 4)) {
if (te_chunked > (off_t)(1uL<<(8*sizeof(off_t)-5))-1) {
log_error_write(srv, __FILE__, __LINE__, "s",
"chunked data size too large -> 400");
/* 400 Bad Request */

@ -8,7 +8,7 @@ BEGIN {
use strict;
use IO::Socket;
use Test::More tests => 59;
use Test::More tests => 60;
use LightyTest;
my $tf = LightyTest->new();
@ -167,6 +167,22 @@ Connection: close
Content-Type: application/x-www-form-urlencoded
Transfer-Encoding: chunked
10
0123456789abcdef
0
EOF
);
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200 } ];
ok($tf->handle_http($t) == 0, 'POST via Transfer-Encoding: chunked, two hex');
$t->{REQUEST} = ( <<EOF
POST /get-post-len.pl HTTP/1.1
Host: www.example.org
Connection: close
Content-Type: application/x-www-form-urlencoded
Transfer-Encoding: chunked
a
0123456789
0

Loading…
Cancel
Save