procmail
[Top] [All Lists]

Re: why is this failing?

1997-07-14 07:26:00
On Mon, 14 Jul 1997 08:11:15 -0500,
wwgrol(_at_)sparc01(_dot_)fw(_dot_)hac(_dot_)com (W. Wesley Groleau x4923) 
wrote:
LINEBUF=16384          # Needed to keep Procmail from choking on large
Any notion of how long the list would have to be before it chokes
otherwise?
I don't know.  And anyway I guessed wrong.  The original poster fixed it
by removing a space.  And according to the man page, there is a diagnostic
"Exceeded LINEBUF" issued when appropriate.  So ends that display of
ignorance.

It's quite simple. No line in the .rc file can be longer than LINEBUF,
+after+ expansion. So this would permit any single line to be a
maximum of 16384 characters; assuming an average of, say, sixteen
characters per e-mail address, and sixteen more for general overhead,
this would permit 1023 addresses. (Simple division. Backslash plus
newline counts as gluing together the current line and the next line
as part of the expansion [I imagine].)
  I've found that Procmail will actually dump core if you exceed
LINEBUF with a very long line. I haven't tested this very rigorously,
but I had Procmail 3.11pre4 crash on me when I received spams with
huge To: headers and a recipe that grabbed the To: field into MATCH
and then tried to do things on it. (That's what the "expanded" part
means. You should be safe even if MATCH contained a megabyte-long
string, but as soon as you say $MATCH, boom.)

BTW, this simple awk script is now part of my spam filters, on the
theory that anyone who loads too much into the To: field is doing
something more or less malicious: 

    # Safety net against core dumps:
    #
    # Any one line should not be longer than LINEBUF.
    # If LINEBUF is not set, it defaults to 2048

    BUFLIM=${LINEBUF:-2048}
    MAXLEN=`formail -c | \
        awk '{len=length;max=(max>len?max:len)}END{print max}'`

    :0
    * $ -$BUFLIM^0
    * $ $MAXLEN^0
    {
        LOG="spamreject: $MAXLEN-character header line (> LINEBUF [$BUFLIM])
 "
        :0
        $SPAMFOLDER
    }

As you can see, I'm saving the malignant mail to SPAMFOLDER for manual
inspection, so it wouldn't really hurt that match if this accidentally
caught mail from, say, a clueless relative ... :-)
  To be really proper, I should add a bit of overhead to the scoring
recipe; I might add 80 characters to cover the overhead of setting up
any one recipe (the leading * and the names of the headers I want to
search, etcetera).
  The be +really+ proper, I should guard myself against the
possibility that MAXLEN or the LOG line might be in excess of LINEBUF
characters :-)

Hope this helps,

/* era */

-- 
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r.  <http://www.iki.fi/~era/>
 * Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>

<Prev in Thread] Current Thread [Next in Thread>