Removed
Link Here
|
1 |
--- ../MailScanner-install-4.60.8.orig/lib/MailScanner/Message.pm Mon Jun 4 21:52:14 2007 |
2 |
+++ lib/MailScanner/Message.pm Mon Jun 4 21:52:31 2007 |
3 |
@@ -2,7 +2,7 @@ |
4 |
# MailScanner - SMTP E-Mail Virus Scanner |
5 |
# Copyright (C) 2002 Julian Field |
6 |
# |
7 |
-# $Id: Message.pm 3920 2007-05-28 17:20:11Z sysjkf $ |
8 |
+# $Id: Message.pm 3948 2007-06-04 18:25:09Z sysjkf $ |
9 |
# |
10 |
# This program is free software; you can redistribute it and/or modify |
11 |
# it under the terms of the GNU General Public License as published by |
12 |
@@ -57,7 +57,7 @@ |
13 |
use vars qw($VERSION); |
14 |
|
15 |
### The package version, both in 1.23 style *and* usable by MakeMaker: |
16 |
-$VERSION = substr q$Revision: 3920 $, 10; |
17 |
+$VERSION = substr q$Revision: 3948 $, 10; |
18 |
|
19 |
# Attributes are |
20 |
# |
21 |
@@ -126,6 +126,7 @@ |
22 |
# %alltypes set by CombineReports |
23 |
# %entity2parent set by CreateEntitiesHelpers |
24 |
# %entity2file set by CreateEntitiesHelpers |
25 |
+# %entity2safefile set by CreateEntitiesHelpers |
26 |
# %file2entity set by CreateEntitiesHelpers (maps original evil names) |
27 |
# %file2safefile set by CreateEntitiesHelpers (evil==>safe) |
28 |
# %safefile2file set by CreateEntitiesHelpers (safe==>evil) |
29 |
@@ -1528,14 +1529,17 @@ |
30 |
$regexp = join('|', @escaped); |
31 |
print STDERR "Regexp is \"$regexp\"\n"; |
32 |
|
33 |
- # Build a list of attachment filenames |
34 |
- my($file,@files,$entity); |
35 |
+ # Build a list of attachment entities |
36 |
+ my($file,@files,$entity,@entitylist); |
37 |
+ $this->ListLeafEntities($this->{entity}, \@entitylist); |
38 |
+ |
39 |
my $totalsize = 0; # Track total size of all attachments added to zip |
40 |
- while (defined($file = $dir->read)) { |
41 |
- next if $file =~ /^\.+$/; |
42 |
+ foreach $entity (@entitylist) { |
43 |
+ $file = $this->{entity2safefile}{$entity}; |
44 |
next unless -f "$explodeinto/$file"; |
45 |
print STDERR "Possibly adding file $file\n"; |
46 |
- $entity = $this->{file2entity}{$this->{safefile2file}{$file}}; |
47 |
+ print STDERR "Nasty filename is " . $this->{entity2file}{$entity} . "\n"; |
48 |
+ #$entity = $this->{file2entity}{$this->{safefile2file}{$file}}; |
49 |
print STDERR "Entity is $entity\n"; |
50 |
next unless $entity; |
51 |
# Don't add the file if it's the winmail.dat file |
52 |
@@ -1589,6 +1593,7 @@ |
53 |
|
54 |
# Create all the Helpers for the new attachment |
55 |
$this->{entity2file}{$newentity} = $newzipname; |
56 |
+ $this->{entity2safefile}{$newentity} = $safezipname; |
57 |
$this->{entity2parent}{$newentity} = 0; |
58 |
$this->{file2entity}{$newzipname} = $newentity; |
59 |
$this->{name2entity}{scalar($newentity)} = $newentity; |
60 |
@@ -1597,12 +1602,12 @@ |
61 |
|
62 |
# Delete the old attachments' entities |
63 |
my($attachfile, $attachentity); |
64 |
- foreach $file (@files) { |
65 |
- $attachfile = $this->{safefile2file}{$file}; |
66 |
- $attachentity = $this->{file2entity}{$attachfile}; |
67 |
- $this->DeleteEntity($entity, $attachentity); |
68 |
+ foreach $entity (@entitylist) { |
69 |
+ $attachfile = $this->{entity2safefile}{$entity}; |
70 |
+ #$attachentity = $this->{file2entity}{$attachfile}; |
71 |
+ $this->DeleteEntity($this->{entity}, $entity); |
72 |
# And the files themselves |
73 |
- unlink("$explodeinto/$file"); |
74 |
+ unlink("$explodeinto/$attachfile"); |
75 |
} |
76 |
|
77 |
} |
78 |
@@ -1890,6 +1895,27 @@ |
79 |
if $workarea->{changeowner}; |
80 |
} |
81 |
|
82 |
+sub ListLeafEntities { |
83 |
+ my($message, $entity, $entitylist) = @_; |
84 |
+ |
85 |
+ my(@parts, $part); |
86 |
+ |
87 |
+ # Fallen off the tree? |
88 |
+ return unless $entity && defined($entity->head); |
89 |
+ |
90 |
+ # Found a leaf node |
91 |
+ if ($entity && !$entity->parts) { |
92 |
+ push @$entitylist, $entity; |
93 |
+ return; |
94 |
+ } |
95 |
+ |
96 |
+ # Walk down each sub-tree |
97 |
+ @parts = $entity->parts; |
98 |
+ foreach $part (@parts) { |
99 |
+ ListLeafEntities($message, $part, $entitylist); |
100 |
+ } |
101 |
+} |
102 |
+ |
103 |
# Delete a given entity from the MIME entity tree. |
104 |
# Have to walk the entire tree to do this. |
105 |
# Bail out as soon as we've found it. |
106 |
@@ -2860,6 +2886,7 @@ |
107 |
|
108 |
# Put something useless in the 2 hashes so that they exist. |
109 |
$this->{entity2file}{""} = 0; |
110 |
+ $this->{entity2safefile}{""} = 0; |
111 |
$this->{entity2parent}{""} = 0; |
112 |
$this->{file2entity}{""} = $this->{entity}; # Root of this message |
113 |
$this->{name2entity}{""} = 0; |
114 |
@@ -2870,6 +2897,7 @@ |
115 |
$this->{file2safefile}, |
116 |
$this->{safefile2file}, |
117 |
$this->{entity2file}, |
118 |
+ $this->{entity2safefile}, |
119 |
$this->{name2entity}); |
120 |
#print STDERR "In CreateEntitiesHelpers, this = $this\n"; |
121 |
#print STDERR "In CreateEntitiesHelpers, this entity = " . |
122 |
@@ -2903,7 +2931,7 @@ |
123 |
# This is recursive. This is a class function, not a normal method. |
124 |
sub BuildFile2EntityAndEntity2File { |
125 |
my($entity, $file2entity, $file2safefile, $safefile2file, $entity2file, |
126 |
- $name2entity) = @_; |
127 |
+ $entity2safefile, $name2entity) = @_; |
128 |
|
129 |
# Build the conversion hash from scalar(entity) --> real entity object |
130 |
# Need to do this as objects cannot be hash keys. |
131 |
@@ -2929,6 +2957,7 @@ |
132 |
if ($headfile) { |
133 |
$file2entity->{$headfile} = $entity if !$file2entity->{$headfile}; |
134 |
$file2safefile->{$headfile} = $path; |
135 |
+ $entity2safefile->{$entity} = $path; |
136 |
$safefile2file->{$path} = $headfile; |
137 |
#print STDERR "File2SafeFile (\"$headfile\") = \"$path\"\n"; |
138 |
} |
139 |
@@ -2937,7 +2966,8 @@ |
140 |
@parts = $entity->parts; |
141 |
foreach $part (@parts) { |
142 |
BuildFile2EntityAndEntity2File($part, $file2entity, $file2safefile, |
143 |
- $safefile2file, $entity2file, $name2entity); |
144 |
+ $safefile2file, $entity2file, |
145 |
+ $entity2safefile, $name2entity); |
146 |
} |
147 |
} |
148 |
|