INN commit: trunk/control (controlchan.in)
INN Commit
Russ_Allbery at isc.org
Sun Jan 11 09:16:41 UTC 2009
Date: Sunday, January 11, 2009 @ 01:16:40
Author: iulius
Revision: 8283
Do not output temp to core because it can lead to memory issues
(or attacks/starvation). Instead, use temporary files, which
is incidentally the default for MIME::Parser.
controlchan is spawn during a long time, so it is necessary.
We purge the temporary files once used.
see #122
Modified:
trunk/control/controlchan.in
----------------+
controlchan.in | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
Modified: controlchan.in
===================================================================
--- controlchan.in 2009-01-10 13:36:38 UTC (rev 8282)
+++ controlchan.in 2009-01-11 09:16:40 UTC (rev 8283)
@@ -92,14 +92,18 @@
my %hdr;
my $parser = new MIME::Parser;
- $parser->output_to_core(1);
+ $parser->output_dir("$INN::Config::pathtmp");
my $article = $parser->parse_data($article_string);
if (not parse_article($article, \%hdr)) {
+ $parser->filer->purge;
next;
}
- next if not $hdr{'control'};
+ if (not $hdr{'control'}) {
+ $parser->filer->purge;
+ next;
+ }
$curmsgid = $hdr{'message-id'};
my $sender = cleanaddr($hdr{'sender'} || $hdr{'from'});
@@ -114,10 +118,14 @@
$progname = lc $hdr{'control'};
}
- next if $progname eq 'cancel';
+ if ($progname eq 'cancel') {
+ $parser->filer->purge;
+ next;
+ }
if ($progname !~ /^([a-z]+)$/) {
logmsg("Naughty control in article $curmsgid ($progname)");
+ $parser->filer->purge;
next;
}
$progname = $1;
@@ -127,7 +135,10 @@
ctlperm($progname, $sender, $progparams[0],
$token, $article);
- next if $action eq 'drop';
+ if ($action eq 'drop') {
+ $parser->filer->purge;
+ next;
+ }
if ($action eq '_pgpfail') {
my $type = '';
@@ -140,6 +151,7 @@
}
logmsg("skipping $progname $type$sender"
. "(pgpverify failed) in $curmsgid");
+ $parser->filer->purge;
next;
}
@@ -163,6 +175,7 @@
} else {
logmsg("Unknown \"$progname\" control by $sender");
}
+ $parser->filer->purge;
next;
}
@@ -173,6 +186,8 @@
&$subfind(\@progparams, $sender, $replyto, $sitepath,
$action, $logname, $approved, $article);
+
+ $parser->filer->purge;
}
closelog() if $use_syslog;
More information about the inn-committers
mailing list