#296959 courier-imap: bug in BODYSTRUCTURE for messages with malformed Content-Type inbox which contains the following header:

Package:
courier-imap
Source:
courier
Description:
Courier mail server - IMAP server
Submitter:
Mike O'Connor
Date:
2026-07-01 21:23:05 UTC
Severity:
normal
Tags:
#296959#5
Date:
2005-02-26 00:03:52 UTC
From:
To:
Content-type: text; charset=iso-8859-1

Here's what happens when i try to fetch the BODYSTRUCTURE:

On page 61 of RFC 2060, it says:

"A body type of type TEXT contains, immediately after the basic fields, the size of the body in text lines. Note that this size is the size in its content transfer encoding and not the resulting size after any decoding."

But here, courier failed to returned the size of the body in text lines.  The field immediately following the basic fields (which ends with the size in octets, 1270 in this case), is NIL.

I agree that the message was malformed, it should have had the Content-Type: as text/plain or something, but in the handling of this malformed message it seems that courier didn't correctly follow the RFC by specifying the mime type as text and not supplying # lines.

I created the following patch which has fixed the problem for me.  It was created against the courier sources in debian version 0.47-3, but it sould apply cleanly to the current courier-imap sources.
--------

diff -ru courier-0.47/imap/msgbodystructure.c courier-0.47-fixbodystructure/imap/msgbodystructure.c
--- courier-0.47/imap/msgbodystructure.c	2002-09-20 08:22:48.000000000 -0400
+++ courier-0.47-fixbodystructure/imap/msgbodystructure.c	2005-02-25 17:51:26.000000000 -0500
@@ -206,7 +206,7 @@
 		(content_type_s[1] == 'e' || content_type_s[1] == 'E') &&
 		(content_type_s[2] == 'x' || content_type_s[2] == 'X') &&
 		(content_type_s[3] == 't' || content_type_s[3] == 'T') &&
-			content_type_s[4] == '/')
+            !isalnum( content_type_s[4] ) )
 		{
 			(*writefunc)(" ", 1);
 			sprintf(buf, "%lu", (unsigned long)nbodylines);

#296959#12
Date:
2026-07-01 21:03:48 UTC
From:
To:
I have recently taken over maintenance of the courier packages.  I apologize
that nobody responded to your bug report in a timely manner.  Can you confirm
if this is still an issue with the current version of courier-imap
(5.3.1-1.5.1-4)?

#296959#15
Date:
2026-07-01 21:04:04 UTC
From:
To:
I have recently taken over maintenance of the courier packages.  I apologize
that nobody responded to your bug report in a timely manner.  Can you confirm
if this is still an issue with the current version of courier-imap
(5.3.1-1.5.1-4)?