Subject: rfc822_parse_content() hang

From: "Sebastian Voges" <[email-masked]>
Date: Mon, 17 Nov 2003 15:05:08 -0500

Hello,

I am experiencing problems downloading an email from a POP server using
imap2002e library.

As far as I can tell now the code is looping in rfc822.c
rfc822_parse_content() using up 50% of my cpu

To prevent the hang we  are detecting this loop in
rfc822_parse_content()  and forcing the code to exit() out:

case TYPETEXT:		/* text content */
    if (!body->parameter) {	/* default parameters */
      body->parameter = mail_newbody_parameter ();
      body->parameter->attribute = cpystr ("CHARSET");
      body->parameter->value = cpystr ("US-ASCII");
    }
				/* count number of lines */
    while (i--) {
		if ((SNX (bs)) == '\n') body->size.lines++;
		if ( i > bs->size ) {
			// this should not happen...
			// GOAL: Here, some users force the c-client lib
			//       to hang forever (but the process gets
killed
			//       by apache).
			// NOTE: I used exit() to flush the log buffers.
			mm_fatal("Content length broken");
			exit(1);
		}
	}
    break;

The problem is that in the lines before
 body->size.bytes = body->contents.text.size = i = SIZE (bs);

SIZE(bs) returned 0xfffffffd. 

Exit() was a first shot to detect this problem, as a first workaround I
could probably just break out of the while loop, and continue. Is this
safe to do?
Right now I am debugging the code to see what caused the offsets to be
incorrect.
Any input on this or if this even is a known issue  will be appreciated
:-) 

Best regards,

Sebastian Voges
-- 
------------------------------------------------------------------
 For information about this mailing list, and its archives, see: 
 http://www.washington.edu/imap/c-client-list.html
------------------------------------------------------------------

---

From: Mark Crispin <[email-masked]>
Date: Mon, 17 Nov 2003 16:20:26 -0800 (Pacific Standard Time)

If you would send me a mailbox with the offending message, I will take a
look at it.  Basically, you are telling me that the body part being parsed
is 2 bytes beyond the end of the message.

How are you using c-client?  Are you calling the rfc822 routines directly,
or are you using mail_fetch_structure(), etc.?

-- Mark --

http://staff.washington.edu/mrc
Science does not emerge from voting, party politics, or public debate.
Si vis pacem, para bellum.