Buffer potential problem (may close #733)

This commit is contained in:
Xavier Guimard 2016-02-15 17:31:26 +00:00
parent b78d3ae916
commit 174651d9ae
2 changed files with 9 additions and 9 deletions

View File

@ -22,6 +22,7 @@ use constant DONE => Apache2::Const::DONE;
use constant SERVER_ERROR => Apache2::Const::SERVER_ERROR;
use constant AUTH_REQUIRED => Apache2::Const::AUTH_REQUIRED;
use constant MAINTENANCE => Apache2::Const::HTTP_SERVICE_UNAVAILABLE;
use constant BUFF_LEN => 8192;
eval { require threads::shared; };
print STDERR
@ -230,16 +231,15 @@ sub addToHtmlHead {
$request->add_output_filter(
sub {
my $f = shift;
my $buffer;
my $body = $f->ctx || "";
$body .= $buffer while ( $f->read($buffer) );
unless ( $f->seen_eos ) {
$f->ctx($body);
}
else {
$body =~ s/(<\/head>)/$data$1/si
or $body =~ s/(<body>)/$1$data/si;
my $done = 0;
while ( $f->read( my $buffer, BUFF_LEN ) ) {
unless ($done) {
$done = 1
if ( $buffer =~ s/(<\/head>)/$data$1/si
or $buffer =~ s/(<body>)/$1$data/si );
}
$f->print($body);
}
return OK;

View File

@ -12,7 +12,7 @@ use Lemonldap::NG::Handler::SharedConf qw(:all);
use Lemonldap::NG::Handler::API qw(:httpCodes);
use base qw(Lemonldap::NG::Handler::SharedConf);
use Apache2::Filter ();
use constant BUFF_LEN => 1024;
use constant BUFF_LEN => 8192;
## @rmethod Apache2::Const run(Apache2::Filter f)
# Overload main run method