NetBSD Problem Report #56548

From www@netbsd.org  Tue Dec 14 06:00:30 2021
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id C42621A923A
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 14 Dec 2021 06:00:30 +0000 (UTC)
Message-Id: <20211214060029.3F3B41A923B@mollari.NetBSD.org>
Date: Tue, 14 Dec 2021 06:00:29 +0000 (UTC)
From: rvp@SDF.ORG
Reply-To: rvp@SDF.ORG
To: gnats-bugs@NetBSD.org
Subject: mail(1) segfaults if thread commands are used in ~/.mailrc
X-Send-Pr-Version: www-1.0

>Number:         56548
>Category:       bin
>Synopsis:       mail(1) segfaults if thread commands are used in ~/.mailrc
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Dec 14 06:05:00 +0000 2021
>Last-Modified:  Tue Dec 14 15:15:01 +0000 2021
>Originator:     RVP
>Release:        NetBSD/amd64 9.99.92
>Organization:
>Environment:
NetBSD x202e.localdomain 9.99.92 NetBSD 9.99.92 (MYKERNEL) #0: Mon Dec 13 03:43:43 UTC 2021  bld@x202e.localdomain:/usr/obj/usr/src/sys/arch/amd64/compile/MYKERNEL amd64
>Description:
Most of the thread-related commands (thread, sort, reverse, ...) cause a
segfault if they're included in ~/.mailrc:

$ echo "sort rdate" > newmailrc
$ mail -r newmailrc
Segmentation fault (core dumped)
$ 
>How-To-Repeat:
As above.
>Fix:
Make the `thread' commands interactive-only (however, commands like `sort'
or `reverse' seem useful if included in ~/.mailrc).

---START PATCH---
diff -urN a/src/usr.bin/mail/cmdtab.c b/src/usr.bin/mail/cmdtab.c
--- a/src/usr.bin/mail/cmdtab.c	2009-04-10 13:08:24.000000000 +0000
+++ b/src/usr.bin/mail/cmdtab.c	2021-12-13 22:10:21.827573957 +0000
@@ -152,32 +152,32 @@
 /* R */	{ "Detach",	Detach,		S, CMP(F)	STRLIST,	0,		0 },
 #endif
 #ifdef THREAD_SUPPORT
-	{ "flatten",	flattencmd,	0, CMP(n)	T|NDMLIST,	0,		MMNDEL },
-	{ "reverse",	reversecmd,	0, CMP(n)	T|STRLIST,	0,		0 },
-	{ "sort",	sortcmd,	0, CMP(T)	T|STRLIST,	0,		0 },
-	{ "thread",	threadcmd,	0, CMP(T)	T|STRLIST,	0,		0 },
-	{ "unthread",	unthreadcmd,	0, CMP(n)	T|STRLIST,	0,		0 },
+	{ "flatten",	flattencmd,	0, CMP(n)	I|T|NDMLIST,	0,		MMNDEL },
+	{ "reverse",	reversecmd,	0, CMP(n)	I|T|STRLIST,	0,		0 },
+	{ "sort",	sortcmd,	0, CMP(T)	I|T|STRLIST,	0,		0 },
+	{ "thread",	threadcmd,	0, CMP(T)	I|T|STRLIST,	0,		0 },
+	{ "unthread",	unthreadcmd,	0, CMP(n)	I|T|STRLIST,	0,		0 },

-	{ "down",	downcmd,	0, CMP(n)	T|MSGLIST,	0,		MMNDEL },
-	{ "tset",	tsetcmd,	0, CMP(n)	T|MSGLIST,	0,		MMNDEL },
-	{ "up",		upcmd,		0, CMP(n)	T|STRLIST,	0,		0 },
+	{ "down",	downcmd,	0, CMP(n)	I|T|MSGLIST,	0,		MMNDEL },
+	{ "tset",	tsetcmd,	0, CMP(n)	I|T|MSGLIST,	0,		MMNDEL },
+	{ "up",		upcmd,		0, CMP(n)	I|T|STRLIST,	0,		0 },

-	{ "expose",	exposecmd,	0, CMP(n)	T|STRLIST,	0,		0 },
-	{ "hide",	hidecmd,	0, CMP(n)	T|STRLIST,	0,		0 },
-	{ "showthreads",exposecmd,	0, CMP(n)	T|STRLIST,	0,		0 },
-	{ "hidethreads",hidecmd,	0, CMP(n)	T|STRLIST,	0,		0 },
+	{ "expose",	exposecmd,	0, CMP(n)	I|T|STRLIST,	0,		0 },
+	{ "hide",	hidecmd,	0, CMP(n)	I|T|STRLIST,	0,		0 },
+	{ "showthreads",exposecmd,	0, CMP(n)	I|T|STRLIST,	0,		0 },
+	{ "hidethreads",hidecmd,	0, CMP(n)	I|T|STRLIST,	0,		0 },
 #ifdef THREAD_DEBUG
-	{ "debug_links",thread_showcmd,	S, CMP(n)	T|MSGLIST,	0,		MMNDEL },
+	{ "debug_links",thread_showcmd,	S, CMP(n)	I|T|MSGLIST,	0,		MMNDEL },
 #endif
-/* R */	{ "tag",	tagcmd,		0, CMP(n)	T|MSGLIST,	0,		MMNDEL },
-/* R */	{ "untag",	untagcmd,	0, CMP(n)	T|MSGLIST,	0,		MMNDEL },
-/* R */	{ "invtags",	invtagscmd,	0, CMP(n)	T|MSGLIST,	0,	 	MMNDEL },
-	{ "tagbelow",	tagbelowcmd,	0, CMP(n)	T|MSGLIST,	0,		MMNDEL },
+/* R */	{ "tag",	tagcmd,		0, CMP(n)	I|T|MSGLIST,	0,		MMNDEL },
+/* R */	{ "untag",	untagcmd,	0, CMP(n)	I|T|MSGLIST,	0,		MMNDEL },
+/* R */	{ "invtags",	invtagscmd,	0, CMP(n)	I|T|MSGLIST,	0,	 	MMNDEL },
+	{ "tagbelow",	tagbelowcmd,	0, CMP(n)	I|T|MSGLIST,	0,		MMNDEL },

-	{ "hidetags",	hidetagscmd,	0, CMP(n)	T|STRLIST,	0,		0 },
-	{ "showtags",	showtagscmd,	0, CMP(n)	T|STRLIST,	0,		0 },
+	{ "hidetags",	hidetagscmd,	0, CMP(n)	I|T|STRLIST,	0,		0 },
+	{ "showtags",	showtagscmd,	0, CMP(n)	I|T|STRLIST,	0,		0 },

-	{ "deldups",	deldupscmd,	0, CMP(n)	T|STRLIST,	0,		0 },
+	{ "deldups",	deldupscmd,	0, CMP(n)	I|T|STRLIST,	0,		0 },
 #endif /* THREAD_SUPPORT */
 	{ 0,		0,		0, CMP0		0,		0,		0 }
 };
---END PATCH---

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/56548 CVS commit: src/usr.bin/mail
Date: Tue, 14 Dec 2021 10:13:42 -0500

 Module Name:	src
 Committed By:	christos
 Date:		Tue Dec 14 15:13:42 UTC 2021

 Modified Files:
 	src/usr.bin/mail: cmdtab.c

 Log Message:
 PR/56548: RVP: mail(1) segfaults if thread commands are used in ~/.mailrc


 To generate a diff of this commit:
 cvs rdiff -u -r1.21 -r1.22 src/usr.bin/mail/cmdtab.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.