Skip to content

Commit f265847

Browse files
committed
fix(messenger): increase http request limit from 2048 to 4096
1 parent 2db37fe commit f265847

File tree

1 file changed

+40
-11
lines changed

1 file changed

+40
-11
lines changed

src/ConfigServer/Messenger.pm

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -331,33 +331,41 @@ sub messenger {
331331
logfile("lfd $oldtype messenger using $vmsize kB of VIRT memory at startup, adding up to $config{MESSENGER_CHILDREN} children = ".(($config{MESSENGER_CHILDREN} + 1) * $vmsize)." kB");
332332
}
333333

334-
if ($user ne "") {
334+
if ($user ne "")
335+
{
335336
my (undef,undef,$uid,$gid,undef,undef,undef,$homedir) = getpwnam($user);
336337
if (($uid > 0) and ($gid > 0)) {
337338
local $( = $gid;
338339
local $) = "$gid $gid";
339340
local $> = local $< = $uid;
340-
if (($) != $gid) or ($> != $uid) or ($( != $gid) or ($< != $uid)) {
341+
if (($) != $gid) or ($> != $uid) or ($( != $gid) or ($< != $uid))
342+
{
341343
logfile("MESSENGER_USER unable to drop privileges - stopping $oldtype Messenger");
342344
exit;
343345
}
346+
344347
my %children;
345-
while (1) {
346-
while (my $client = $server->accept()) {
347-
while (scalar (keys %children) >= $chldallow) {
348+
while (1)
349+
{
350+
while (my $client = $server->accept())
351+
{
352+
while (scalar (keys %children) >= $chldallow)
353+
{
348354
sleep 1;
349355
foreach my $pid (keys %children) {
350356
unless (kill(0,$pid)) {delete $children{$pid}}
351357
}
352358
$0 = "lfd $oldtype messenger (busy)";
353359
}
360+
354361
$0 = "lfd $oldtype messenger";
355-
356362
$SIG{CHLD} = 'IGNORE';
357363
my $pid = fork;
358364
$children{$pid} = 1;
359-
if ($pid == 0) {
360-
eval {
365+
if ($pid == 0)
366+
{
367+
eval
368+
{
361369
local $SIG{__DIE__} = undef;
362370
local $SIG{'ALRM'} = sub {die};
363371
alarm(10);
@@ -374,14 +382,35 @@ sub messenger {
374382
$peeraddress =~ s/^::ffff://;
375383
$hostaddress =~ s/^::ffff://;
376384

377-
if ($type eq "HTML") {
378-
while ($firstline !~ /\n$/) {
385+
if ($type eq "HTML")
386+
{
387+
while ($firstline !~ /\n$/)
388+
{
379389
my $char;
380390
$client->read($char,1);
381391
$firstline .= $char;
382392
if ($char eq "") {exit}
383-
if (length $firstline > 2048) {last}
393+
394+
# #
395+
# RFC 7230, Sec 3.1.1: recommends supporting at least 8000 octets.
396+
# Prefix: GET /unblk?g-recaptcha-response= = 32 bytes
397+
# Suffix: HTTP/1.1\r\n = 11 bytes (\r\n = 2 bytes) (carriage return (0x0D)/line feed (0x0A))
398+
# 32 + 11 = 43 bytes
399+
#
400+
# Remaining for Recaptcha token 4053 bytes
401+
# Acceptable Limit 4096 bytes
402+
#
403+
# @since v15.10
404+
# @reference https://datatracker.ietf.org/doc/html/rfc7230#autoid-17
405+
# https://mothereff.in/byte-counter
406+
# #
407+
408+
if ( length $firstline > 4096 )
409+
{
410+
last
411+
}
384412
}
413+
385414
chomp $firstline;
386415
if ($firstline =~ /\r$/) {chop $firstline}
387416
}

0 commit comments

Comments
 (0)