Mailing List Archive

[bug] ripmime troubles with incorrect base64
Software Used:

qmail
Clam-0.70
qscanq-0.42
ripmime-1.3.1.2

For the most part, this setup works nicely. Periodically, I get messages
bouncing with the error:

451 qq read error (#4.3.0)

After some serious hair-pulling, I discovered the problem. The cause of
the "451 qq read error (#4.3.0)" is that ripmime cannot extract messages
like the one I've attached, because they aren't valid base64 encoded
email (even though the headers say they should be). This is why the error
happens only occasionally. The chain fails with an error status that is
interpreted by qmail as a temporary failure, causing the message to be
re-sent later.

Below is a dump of a message that causes ripmime-1.3.1.2 (and 1.3.1.1,
1.3.1.0, etc.) to barf. For privacy, I've mangled the email addresses,
but I changed nothing else.

Any ideas on how to fix this?

/----------- begin email example -----------/
Return-Path: <XXX@sau.edu>
Received: from frontend2.messagingengine.com (frontend2.internal
[10.202.2.151])
by server2.fastmail.fm (Cyrus v2.2.3) with LMTP; Tue, 18 May 2004
17:35:19 -0400
X-Sieve: CMU Sieve 2.2
X-Resolved-to: zanekierkegaard@allmail.net
X-Delivered-to: zanekierkegaard@allmail.net
X-Mail-from: XXX@sau.edu
Received: from sauexchange.ambrose.sau.edu (sauexchange.sau.edu
[64.22.217.14])
by smtp.us.messagingengine.com (Postfix) with ESMTP id
E909A4E589D
for <zanekierkegaard@allmail.net>; Tue, 18 May 2004 17:35:17
-0400 (EDT)
X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0
content-class: urn:content-classes:message
MIME-Version: 1.0
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: base64
Subject:
Date: Tue, 18 May 2004 16:35:16 -0500
Message-ID:
<943A094F376EC94EBD24724C218FB50D065CB019@sauexchange.ambrose.sau.edu>
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
Thread-Index: AcQ9IAJ9e2f6Iq/PS+WZ+m2RPH64uw==
From: "Sender Name" <XXX@sau.edu>
To: <XXX@foobar.com>
Cc: <zanekierkegaard@allmail.net>

IA0K
/----------- end email example -----------/

--
http://www.fastmail.fm - Choose from over 50 domains or use your own
RE: [bug] ripmime troubles with incorrect base64 [ In reply to ]
> Software Used:
>
> qmail
> Clam-0.70
> qscanq-0.42
> ripmime-1.3.1.2
>
> For the most part, this setup works nicely. Periodically, I
> get messages
> bouncing with the error:
>
> 451 qq read error (#4.3.0)
>
> After some serious hair-pulling, I discovered the problem.
> The cause of
> the "451 qq read error (#4.3.0)" is that ripmime cannot
> extract messages
> like the one I've attached, because they aren't valid base64 encoded
> email (even though the headers say they should be). This is
> why the error
> happens only occasionally. The chain fails with an error
> status that is
> interpreted by qmail as a temporary failure, causing the message to be
> re-sent later.
>
> Below is a dump of a message that causes ripmime-1.3.1.2 (and 1.3.1.1,
> 1.3.1.0, etc.) to barf. For privacy, I've mangled the email addresses,
> but I changed nothing else.
>
> Any ideas on how to fix this?

I had a similar problem with qmail-scanner. I traced the problem back to
the exit code from ripmime, which changed with ripmime 1.3.1.0. The
newer versions return code 242, previous versions return 0.
I am using the following patch (I've included the patch inline as well
as attaching it) which reverts ripmime back to pre-1.3.1.0
behaviour. I've been using this for about 2 months with no problems.

I haven't posted the patch before, as I'm sure this is the wrong way to
fix the problem, but I don't know what the correct way is.

Hope this helps,
Chris Hine

--- mime.c~ Wed Mar 17 14:55:26 2004
+++ mime.c Fri Mar 19 18:06:11 2004
@@ -1703,7 +1703,9 @@
{
if (MIME_DNORMAL)
LOGGER_log("%s:%d:MIME_decode_64:DEBUG: input stream broken for base64
decoding for file %s. %ld bytes of data in buffer to be written
out\n",FL,hinfo->filename,wbcount);

- status = MIME_ERROR_B64_INPUT_STREAM_EOF;
+ // Temporary kludge to hopefully resolve
error
+ // status = MIME_ERROR_B64_INPUT_STREAM_EOF;
+ status = MIME_BASE64_STATUS_OK;
fwrite(writebuffer, 1, wbcount, of);
fclose(of);
if (writebuffer) free(writebuffer);
Re: [bug] ripmime troubles with incorrect base64 [ In reply to ]
Hey everyone;

Chris, thanks again for the kludge/patch :-D

It's a bit of a dicky situation I'm faced with - and of course this means it's going to result in yet more
options/paramters for ripMIME (going to get more parameters than 'ls' soon!).

Essentially, for qmail situations, anything less than a total failure should (it seems) return a 0. On the other side
of the camp, I have people asking for more /verbose/ return codes indicating partial failures (ie, stream ran out
prematurely or invalid base-64).

Looks like I'll need something like --extended-returncodes :-)

Paul.

--
Paul L Daniels - PLD Software - Xamime
Unix systems Internet Development A.B.N. 19 500 721 806
ICQ#103642862,AOL:pldsoftware,Yahoo:pldaniels73
PGP Public Key at http://www.pldaniels.com/gpg-keys.pld
RE: [bug] ripmime troubles with incorrect base64 [ In reply to ]
> Chris, thanks again for the kludge/patch :-D

No problem. Thanks for great software. :-)

That reminds me, I found a few cases where qmail-scanner was
barfing on output from ripmime to stdout, when it should have
been logging to syslog. I traced it to some printf's in ole.c.
You should find a patch attached.

> Essentially, for qmail situations, anything less than a
> total failure should (it seems) return a 0. On the other side
> of the camp, I have people asking for more /verbose/ return
> codes indicating partial failures (ie, stream ran out
> prematurely or invalid base-64).
>
> Looks like I'll need something like
> --extended-returncodes :-)

How about --basic-returncodes instead, this problem does only
seem to affect the minority of users.
You already reset some return codes on exit from mime.c,
shouldn't be too difficult to do some more.

Chris