Subject: pkg/18664: nmh sortm core dump
To: None <>
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
>Originator:     Robert Elz
>Release:        NetBSD 1.5ZC (current pkgsrc of 20021014)
	Prince of Songkla University
System: NetBSD 1.5ZC NetBSD 1.5ZC (DELTA) #4: Mon May 27 23:17:55 ICT 2002 i386
Architecture: i386
Machine: i386
	A bug report (from Scott Lipcon) was submitted elsewhere:
	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).

	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 ...

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

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;