Subject: pkg/25130: elm hang on invalid inbox
To: None <>
From: None <>
List: pkgsrc-bugs
Date: 04/10/2004 14:56:20
>Number:         25130
>Category:       pkg
>Synopsis:       elm hangs on inboxes with certain invalid from lines
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Apr 10 18:57:00 UTC 2004
>Originator:     David A. Holland <>
>Release:        NetBSD 1.6ZG
   - David A. Holland /
System: NetBSD alicante 1.6ZG NetBSD 1.6ZG (ALICANTE) #8: Wed Mar 17 18:47:39 EST 2004 dholland@alicante:/usr/src/sys/arch/i386/compile/ALICANTE i386
Architecture: i386
Machine: i386

	Elm 2.5pl5 hangs trying to open a mailbox where the character
	0x80 appears on the From: line.

	The problem is that one of the internal address-parsing
	routines truncates characters to 7-bit when tokenizing; the
	result is that when 0x80 comes along, it thinks it's at the
	end of the string but its caller disagrees and loops forever
	trying to continue tokenization.


	Create a simple test message, save it to a file, edit the file
	so the From: line has the form "From: User Name ? <user@host>"
	(substitute the 0x80 for the ?), then do "elm -f file".


	The following patch is not a real fix (just a patch) and for
	various reasons I haven't actually tested it, but it ought to
	do the trick.

	(A somewhat more detailed version of this report, including
	the patch, has been sent to the upstream maintainer.)

--- elm2.5.5/lib/rfc822tlen.c.orig	2004-04-10 14:37:03.000000000 -0400
+++ elm2.5.5/lib/rfc822tlen.c	2004-04-10 14:38:15.000000000 -0400
@@ -180,10 +180,12 @@
 			; /* ERROR - unterminated domain literal */
 		return (str-str0);
 	case CH_EOS:
+		if (*str != '\0')
+			return 1; /* 0x80 and not really end of string */
 		return 0; /* ERROR - we should not see this */
 	/* case CH_SPECIAL: */
 	/* case CH_CTL: */

 	Applies to elm 2.5pl5 and pkgsrc as of today (20040410).