]> git.proxmox.com Git - pve-http-server.git/commitdiff
limit websocket frame size
authorDietmar Maurer <dietmar@proxmox.com>
Wed, 6 Jun 2018 14:41:30 +0000 (16:41 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 6 Jun 2018 14:41:30 +0000 (16:41 +0200)
AnyEvent checks rbuf_max after calling the callback (too late), so
we can receive larger data.

PVE/APIServer/AnyEvent.pm

index eac788bc25dc36ae6d3e11fb36418a0e14efd80a..9efd662c14a41dbc52225a4f21dfe15de7773d01 100755 (executable)
@@ -374,8 +374,8 @@ sub websocket_proxy {
 
            $reqstate->{proxyhdl} = AnyEvent::Handle->new(
                fh => $fh,
-               rbuf_max => 64*1024,
-               wbuf_max => 64*10*1024,
+               rbuf_max => $max_payload_size,
+               wbuf_max => $max_payload_size*10,
                timeout => 5,
                on_eof => sub {
                    my ($hdl) = @_;
@@ -398,7 +398,7 @@ sub websocket_proxy {
                my ($hdl) = @_;
 
                my $len = length($hdl->{rbuf});
-               my $data = substr($hdl->{rbuf}, 0, $len, '');
+               my $data = substr($hdl->{rbuf}, 0, $len > $max_payload_size ? $max_payload_size : $len, '');
 
                my $string;
                my $payload;