Subject: pkg/18664: nmh sortm core dump
To: None <gnats-bugs@gnats.netbsd.org>
From: None <kre@munnari.OZ.AU>
List: netbsd-bugs
Date: 10/15/2002 15:41:37
>Number:         18664
>Category:       pkg
>Synopsis:       nmh sortm core dump
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Oct 15 01:44:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Robert Elz
>Release:        NetBSD 1.5ZC (current pkgsrc of 20021014)
>Organization:
	Prince of Songkla University
>Environment:
	
	
System: NetBSD delta.cs.mu.OZ.AU 1.5ZC NetBSD 1.5ZC (DELTA) #4: Mon May 27 23:17:55 ICT 2002 kre@delta.cs.mu.OZ.AU:/usr/src/sys.X/arch/i386/compile/DELTA i386
Architecture: i386
Machine: i386
>Description:
	A bug report (from Scott Lipcon) was submitted elsewhere:
http://savannah.nongnu.org/bugs/?func=detailbug&bug_id=1393&group_id=2166
	and then today copied to the nmh-workers list.

	Basically, using "sortm -textfield subject" where a message
	in the folder contains "Subject:N" where "N" is alphanumeric
	will cause sortm to dump core (the "korean spam" aspect of the
	mail that caused the original bug report is irrelevant).

>How-To-Repeat:
	Use nmh.   Put a message in a folder that contains "Subject:1234"
	and then run
		sortm +whatever-folder -textfield subject
	and watch for the core dump.

	Or, examine the code and be amazed ...
>Fix:

Here's a patch, I stuck it in patches/patch-ce (though the naming
convention for patches is beyond my comprehension).   And yes, this
really does add a preprocessor conditional that makes either one of
two original statements get compiled, and the other omitted (ie: the
patch is correct, though just deleting a line would work as well).
The "#if 0" could become "#if 1" and the core dump would also be gone,
though the results of the sort would then sometimes be rather hard to
explain...

If we're quick, NetBSD can be the first OS to include a patch for
this (I did already send the same patch to nmh-workers, though I have
no reason to believe it will achieve a lot there).

--- uip/sortm.c.WAS	Tue Oct 15 15:18:47 2002
+++ uip/sortm.c	Tue Oct 15 15:20:11 2002
@@ -439,9 +439,12 @@
 			if(uprf(cp, "re:"))
 			    cp += 2;
 			else {
+#if 0
 			    if (isalnum(c))
 				*cp2++ = isupper(c) ? tolower(c) : c;
+#else
 			    break;
+#endif
 			}
 		    }
 		    cp++;
>Release-Note:
>Audit-Trail:
>Unformatted: