[Mimedefang] Limiting email size to scan for viruses?

Kevin A. McGrail kmcgrail at pccc.com
Thu Oct 14 08:44:59 EDT 2004


Mike,

I assumed that the size of the email would be negligible as I've rarely seen
a legitimate mail with a body of over a few k, but moving past that, messing
with entity without checking if it's defined can cause lots of issues.  I
found this out when I was working on implementing Joseph Brennan's
iframe/script/object code.

Anyway, this code isn't correct, it just shows the extra code I had to add
to really make things stable:

     my ($sizelimit, $bh, $path);
     $sizelimit = 1048576; #1MB #max size of an email you want to check in
bytes
     $bh = $entity->bodyhandle();
      if (defined($bh)) {
        $path = $bh->path();
      }
      if (defined($path)) {
        if (-s $path <= $sizelimit) {

      }

So I think I would stay with my original recommendation for simplicity, and
"close-enough" reasons.

Regards,
KAM

----- Original Message ----- 
From: <eqx at gmx.net>

> The following should work too:
>
> $size = (stat($entity->bodyhandle->path))[7];
> if ($size < 2097152) {
>     # Scan for viruses if any virus-scanners are installed
>     my($code, $category, $action) = message_contains_virus();
> }
>
> I think INPUTMSG is the whole message, $size is the attachement size only.




More information about the MIMEDefang mailing list