Ralf, Jason,

> Problem with DKIM signing a particular mail
> dkim: signing (author), From: ..., a=>rsa-sha256, c=>relaxed/simple, ...
> and after that top says:
>  1072 amavis 20 0 135m 121m 4212 R 99 6.0 10:07.20 amavisd 99% CPU
> amavisd-nanny says:
>   PID 01072: 01072-13    terminated   0:11:07

> perl                         5.10.0-22
> libmail-dkim-perl               0.33-1

So the process which tries to sign this message crashes after
11 minutes, running out of memory. It happens while Perl is
evaluating the following regexp:

  s/((?:\015\012){2,})\z/\015\012/


> Message available at request.
> attached. It's REALLY small.

Thanks! It turns out there is a runaway regexp in Mail::DKIM
(in several of the more recent version), which your message manages
to trigger. When perl runs out of memory the process crashes.
I'll notify the author of the module.

Here is a patch to Mail::DKIM 0.33, but it should apply
to older versions too:

--- Mail/DKIM/Canonicalization/simple.pm~       2008-08-12 18:03:41.000000000 
+0200
+++ Mail/DKIM/Canonicalization/simple.pm        2009-05-22 19:07:45.000000000 
+0200
@@ -69,7 +69,8 @@
        }
 
-       if ($multiline =~ s/((?:\015\012){2,})\z/\015\012/)
+       while ($multiline =~ /\015\012\015\012\z/)
        {       # count & strip trailing empty lines
-               $empty_lines += length($1)/2 - 1;
+               chop $multiline; chop $multiline;
+               $empty_lines++;
        }
 
--- Mail/DKIM/Canonicalization/relaxed.pm~      2008-08-12 18:03:41.000000000 
+0200
+++ Mail/DKIM/Canonicalization/relaxed.pm       2009-05-22 19:07:51.000000000 
+0200
@@ -103,7 +103,8 @@
        }
  
-       if ($multiline =~ s/((?:\015\012){2,})\z/\015\012/)
+       while ($multiline =~ /\015\012\015\012\z/)
        {       # count & strip trailing empty lines
-               $empty_lines += length($1)/2 - 1;
+               chop $multiline; chop $multiline;
+               $empty_lines++;
        }
 
--- Mail/DKIM/Canonicalization/dk_simple.pm~    2008-08-12 18:03:41.000000000 
+0200
+++ Mail/DKIM/Canonicalization/dk_simple.pm     2009-05-22 19:07:38.000000000 
+0200
@@ -54,7 +54,8 @@
        }
 
-       if ($multiline =~ s/((?:\015\012){2,})\z/\015\012/)
+       while ($multiline =~ /\015\012\015\012\z/)
        {       # count & strip trailing empty lines
-               $empty_lines += length($1)/2 - 1;
+               chop $multiline; chop $multiline;
+               $empty_lines++;
        }
 




Mark


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
_______________________________________________
AMaViS-user mailing list
AMaViS-user@lists.sourceforge.net 
https://lists.sourceforge.net/lists/listinfo/amavis-user 
 AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3 
 AMaViS-HowTos:http://www.amavis.org/howto/ 

Reply via email to