summaryrefslogtreecommitdiff
path: root/fml
diff options
context:
space:
mode:
authortmu <tmu>2002-05-18 02:22:42 +0000
committertmu <tmu>2002-05-18 02:22:42 +0000
commit7879d3a3f105ff949f183bc46a25c47ba6ef4033 (patch)
treea2a0fcad7e7ee7912381658c80a5400cf1b1238e /fml
parentaddd11840a0dd696b47ac93c8ff9df71a507f499 (diff)
downloadfml8-7879d3a3f105ff949f183bc46a25c47ba6ef4033.tar.gz
fml8-7879d3a3f105ff949f183bc46a25c47ba6ef4033.tar.bz2
fml8-7879d3a3f105ff949f183bc46a25c47ba6ef4033.zip
add reject_uuencode()
Diffstat (limited to 'fml')
-rw-r--r--fml/lib/FML/Filter/BodyCheck.pm52
1 files changed, 51 insertions, 1 deletions
diff --git a/fml/lib/FML/Filter/BodyCheck.pm b/fml/lib/FML/Filter/BodyCheck.pm
index 6e048b3a..665745b3 100644
--- a/fml/lib/FML/Filter/BodyCheck.pm
+++ b/fml/lib/FML/Filter/BodyCheck.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: BodyCheck.pm,v 1.17 2002/04/10 03:20:52 fukachan Exp $
+# $FML: BodyCheck.pm,v 1.18 2002/04/20 11:21:25 fukachan Exp $
#
package FML::Filter::BodyCheck;
@@ -483,6 +483,56 @@ sub clean_up_buffer
$xbuf;
}
+# Descriptions: virus check against uuencode
+# Even if Multipart, evaluate all blocks agasint virus checks.
+# Arguments: OBJ($self) OBJ($msg) HASH_REF($args) OBJ($first_msg)
+# Side Effects: croak if error
+# Return Value: none
+sub reject_uuencode
+{
+ my ($self, $msg, $args, $first_msg) = @_;
+
+ for (my $mp = $msg->{ next }; $mp ; $mp = $mp->{ next } ) {
+ $self->_probe_uuencode($mp);
+ }
+}
+
+
+# Descriptions: check $msg contains uuencode or not.
+# Arguments: OBJ($self) OBJ($msg)
+# Side Effects: croak() if error
+# Return Value: none
+sub _probe_uuencode
+{
+ my ($self, $msg) = @_;
+ my ($xbuf, $pbuf, $buf, $found, @id);
+
+ # cheap diagnostic check
+ return unless defined $msg->{ data };
+
+ my $uuencode_pat = '^begin\s+\d{3}\s+\S+|\nbegin\s+\d{3}\s+\S+';
+
+ my $window_size = 1024; # at lease 32*2
+ my ($pb, $pe) = $msg->offset_pair();
+ my $dataref = $msg->{ data };
+ my $encoding = $msg->encoding_mechanism();
+
+ # get $window_size bytes window and decode it
+ $buf = substr($$dataref, $pb, $pe - $pb);
+
+ if ($encoding) {
+ $buf = $self->_decode_mime_buffer($buf, $encoding);
+ }
+
+ # check current window
+ if ($buf =~ /($uuencode_pat)/m) {
+ croak "uuencode($1) found, may be a virus";
+ }
+ else {
+ return undef;
+ }
+}
+
=head1 AUTHOR