I posted a bug to squirrelmail-users yesterday, about SM barfing when
trying to display gif file attachments.
The problem: SM doesn't base64_decode() perfectly if the base64 lines in
an attachment are 70 characters long; however 76 bytes works fine. My
other email client (Evolution) correctly decodes either way.
I'm including a test mailbox containing two almost identical messages,
each with the same gif file attachment, but the first one can't be
viewed in SM. It appears to lose *half* a byte every 17k or so, causing
massive corruption in the attachment as nibbles slide from one byte to
In /usr/share/squirrelmail/functions/mime.php (line 528) it says:
Either $body is corrupted before this point, or base64_decode() has a
bug, in which case PHP is to blame.
Version of SM: squirrelmail-1.4.2-1.noarch.rpm
Version of PHP: php-4.3.2-8.ent.src.rpm
Penelope Fudd <kernel@...>
From: Marc Groot Koerkamp <marc@sq...> - 2004-05-02 13:49:40
Penelope Fudd said:
> I posted a bug to squirrelmail-users yesterday, about SM barfing when
> trying to display gif file attachments.
> The problem: SM doesn't base64_decode() perfectly if the base64 lines i=
> an attachment are 70 characters long; however 76 bytes works fine. My
> other email client (Evolution) correctly decodes either way.
Thnx for reporting this issue.
It's SquirrelMail who is to blame in this case.
The reason this error could happen has to do with "on the fly" decoding o=
base64 attachments to reduce memory usage. Normally a line of base64 data
contains multiples of 4 bytes of characters (line ending excluded). Base6=
encoded data exists in pairs of 4 bytes. In your case the pairs were
splitted accross 2 lines and that's where it went wrong.
I modified the on the fly decoding algoritme a bit and do not assume
anymore a line contains complete pairs of bytes. The fix is commited to
stable and devel and will be part of the 1.4.3 release.
Marc groot Koerkamp.