unrar-5 patch
amavis17 at iotti.biz
amavis17 at iotti.biz
Wed Jun 18 12:29:18 CEST 2014
Hi all
I would like to contribute a patch to correctly parse the output of unrar
v5. Without this, mail with rar attachments arrive as ***UNCHECKED*** and
in the logs are found lines like this:
amavis[18309]: (18309-18) (!)do_unrar: can't parse info line for "
..A.... 467449 410604 87% 03-03-14 15:51 F6FEDE10
Verifica.pdf\n" ..A.... 17960 15137 84% 17-06-14 16:43
D8D5EB73 Verifica.docx\n
The output of unrar v changed in v5 from something like:
Pathname/Comment
Size Packed Ratio Date Time Attr CRC
Meth Ver
--------------------------------------------------------------------------
-----
Contenuti/Contenuti.docx
33299 29956 89% 16-06-14 19:35 .....A. D487AD2D
m3b 2.9
--------------------------------------------------------------------------
-----
To something like:
Attributes Size Packed Ratio Date Time Checksum Name
----------- --------- -------- ----- -------- ----- -------- ----
..A.... 33299 29956 89% 16-06-14 19:35 D487AD2D
Contenuti/Contenuti.docx
----------- --------- -------- ----- -------- ----- -------- ----
The patch:
--- amavisd.orig 2012-06-30 15:43:31.000000000 +0200
+++ amavisd 2014-06-18 11:47:19.960683716 +0200
@@ -28131,6 +28131,7 @@
my $lcnt = 0; my $member_name; my $bytes = 0; my $last_line;
my $item_num = 0; my $parent_placement = $part->mime_placement;
my $retval = 1; my $fn = $part->full_name; my($proc_fh,$pid);
+ my $unrarvers = 5;
my(@common_rar_switches) = qw(-c- -p- -idcdp); # -av-
prolong_timer('do_unrar_pre'); # restart timer
@@ -28151,7 +28152,33 @@
} elsif ($hypcount < 1 && $ln =~ /^Encrypted file:/) {
do_log(4,"do_unrar: %s", $ln);
$part->attributes_add('U','C');
+ } elsif ($hypcount < 1 && $ln =~ /^\s+Size\s+Packed
Ratio\s+Date\s+Time\s+Attr\s+CRC/) {
+ do_log(5,"do_unrar: found unrar version < 5");
+ $unrarvers = 4;
} elsif ($hypcount == 1) {
+ if ($unrarvers >= 5) {
+ local($1,$2,$3,$4,$5);
+ if ($ln !~ /^([*
])\s+(?:\S+)\s+(\d+)\s+(\d+)\s+(\d+%|-->|<--|<->)\s+(?:\S+)\s+(?:\S+)\s+(?
:\S+)\s+(.*)/) {
+ do_log($testing_for_sfx ? 4 : -1,
+ "do_unrar: can't parse info line for \"%s\" %s",
+ $member_name,$ln);
+ } else {
+ $member_name = $5;
+ if ($1 eq '*') { # member is encrypted
+ $encryptedcount++; $item_num++;
+ # make a phantom entry - carrying only name and attributes
+ my $newpart_obj =
+ Amavis::Unpackers::Part->new("$tempdir/parts",$part);
+ $newpart_obj->mime_placement("$parent_placement/$item_num");
+ $newpart_obj->name_declared($member_name);
+ $newpart_obj->attributes_add('U','C');
+ } else { # makes no sense extracting encrypted files
+ do_log(5,'do_unrar: member: "%s", size: %s',
$member_name,$2);
+ if ($2 > 0) { $bytes += $2; push(@list, $member_name) }
+ }
+ undef $member_name;
+ }
+ } else {
$lcnt++; local($1,$2,$3);
if ($lcnt % 2 == 0) { # information line (every other line)
if ($entries_cnt++, $MAXFILES && $entries_cnt > $MAXFILES)
@@ -28178,6 +28205,7 @@
undef $member_name; # makes no sense extracting encrypted
files
}
}
+ }
}
}
defined $ln || $! == 0 || $! == EAGAIN or die "Error reading (1):
$!";
Thank you
More information about the amavis-users
mailing list