possible bug in Empty() method of MessageBatch.pm
Timofey Kutergin
tkutergin at googlemail.com
Tue Jul 20 05:54:11 IST 2010
Hi all,
here is possible bug in Empty() method:
# Return true if all the messages in the batch are deleted!
# Return false otherwise.
sub Empty {
my $this = shift;
my($id, $message);
while(($id,$message) = each %{$this->{messages}}) {
return 0 unless $message->{deleted};
}
return 1;
}
Problem is that if this function does return 0, it does not reset "each"
iterator so next loop around $this->{messages} will continue with the same
position.
This may manifest itself in phishing not always detected since loop in
ScanBatch() in SweepContent.pm exits due to not resetting iterator.
>From my point of view, more proper code would be:
# Return true if all the messages in the batch are deleted!
# Return false otherwise.
sub Empty {
my $this = shift;
my $res = 1;
my($id, $message);
while(($id,$message) = each %{$this->{messages}}) {
$res = 0 unless $message->{deleted};
}
return $res;
}
So iterator resets itself after completing cycle
Am I terribly wrong?
Regards
Timofey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.mailscanner.info/pipermail/mailscanner/attachments/20100720/53d4d178/attachment.html
More information about the MailScanner
mailing list