Subject: bin/25050: a bug in nvi option handling
To: None <gnats-bugs@gnats.netbsd.org>
From: None <yamt@mwd.biglobe.ne.jp>
List: netbsd-bugs
Date: 04/04/2004 17:47:59
>Number:         25050
>Category:       bin
>Synopsis:       a bug in nvi option handling
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Apr 04 08:49:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
>Release:        NetBSD 2.0B
>Organization:

>Environment:
	
	
System: NetBSD kaeru 2.0B NetBSD 2.0B (build.kaeru) #1168: Sat Apr 3 16:24:03 JST 2004 takashi@kaeru:/home/takashi/work/kernel/build.kaeru i386
Architecture: i386
Machine: i386
>Description:
	there's a bug in nvi option handling.  see below.
>How-To-Repeat:
	IIRC, the plain nvi is not actually affected by this bug. (luckily?)
	if you're using nvi-m17n patches, you can easily reproduce a crash
	with the following sequence.
		% vi
		:N b
		:q
		:q
>Fix:
	apply the following patch.
	(the same as pkgsrc/editors/nvi-m17n/patches/patch-ae.)
	i sent the same one to bostic@bostic.com in July 2001.

--- common/options.c.orig	Tue Jul  3 22:53:06 2001
+++ common/options.c	Tue Jul  3 22:48:27 2001
@@ -1088,7 +1088,7 @@
 	/* Copy the string edit options. */
 	for (cnt = rval = 0; cnt < O_OPTIONCOUNT; ++cnt) {
 		if (optlist[cnt].type != OPT_STR ||
-		    F_ISSET(&optlist[cnt], OPT_GLOBAL))
+		    F_ISSET(&sp->opts[cnt], OPT_GLOBAL))
 			continue;
 		/*
 		 * If never set, or already failed, NULL out the entries --
@@ -1131,7 +1131,7 @@
 
 	for (cnt = 0; cnt < O_OPTIONCOUNT; ++cnt) {
 		if (optlist[cnt].type != OPT_STR ||
-		    F_ISSET(&optlist[cnt], OPT_GLOBAL))
+		    F_ISSET(&sp->opts[cnt], OPT_GLOBAL))
 			continue;
 		if (O_STR(sp, cnt) != NULL)
 			free(O_STR(sp, cnt));
>Release-Note:
>Audit-Trail:
>Unformatted: