NetBSD Problem Report #52638

From mrg@eterna.com.au  Sun Oct 22 19:46:28 2017
Return-Path: <mrg@eterna.com.au>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-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 C7A577A182
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 22 Oct 2017 19:46:27 +0000 (UTC)
Message-Id: <20171022194623.474241590B6@splode.eterna.com.au>
Date: Mon, 23 Oct 2017 06:46:23 +1100 (AEDT)
From: mrg@eterna.com.au
Reply-To: mrg@eterna.com.au
To: gnats-bugs@gnats.NetBSD.org
Subject: m4 dumps core in ifelse()
X-Send-Pr-Version: 3.95

>Number:         52638
>Category:       bin
>Synopsis:       m4 dumps core in ifelse()
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Oct 22 19:50:00 +0000 2017
>Closed-Date:    Mon Oct 23 23:16:28 +0000 2017
>Last-Modified:  Wed Apr 11 14:30:01 +0000 2018
>Originator:     matthew green
>Release:        NetBSD 6, 7, 8, -current
>Organization:
people's front against (bozotic) www (softwar foundation)
>Environment:
Architecture: x86
Machine: x86
>Description:

	given a potentially illegal ifelse() sequence m4 dumps core.

>How-To-Repeat:

	i reduced the case to this:

		ifelse(A, "s", define(X, `Y'), define(X, `Z'),)

	just passing this file to m4 triggers the bug.  the problem is related
	to the quoting as this version does not core dump:

		ifelse(A, "s", `define(X, Y)', `define(X, Z)',)

	on my netbsd-8 system gdb on the m4.core shows:

	Program terminated with signal SIGSEGV, Segmentation fault.
	#0  0x000072c07aef0da1 in strlen () from /usr/lib/libc.so.12
	(gdb) bt
	#0  0x000072c07aef0da1 in strlen () from /usr/lib/libc.so.12
	#1  0x000000011ec076ca in pbstr (s=0x402 <error: Cannot access memory at address 0x402>) at /usr/8/src/usr.bin/m4/misc.c:105
	#2  0x000000011ec04d93 in expand_builtin (td=<optimized out>, argc=4, argv=0x72c07ad08038) at /usr/8/src/usr.bin/m4/eval.c:219
	#3  eval (argv=<optimized out>, argc=<optimized out>, td=<optimized out>, is_traced=<optimized out>) at /usr/8/src/usr.bin/m4/eval.c:118
	#4  0x000000011ec06c53 in macro () at /usr/8/src/usr.bin/m4/main.c:594
	#5  0x000000011ec099cc in main (argc=0, argv=0x7f7fff7b8548) at /usr/8/src/usr.bin/m4/main.c:368

>Fix:

>Release-Note:

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/52638 CVS commit: src/usr.bin/m4
Date: Sun, 22 Oct 2017 19:01:34 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Sun Oct 22 23:01:34 UTC 2017

 Modified Files:
 	src/usr.bin/m4: eval.c

 Log Message:
 PR/52638: matthew green: missing argument check causes m4 to core in ifelse()


 To generate a diff of this commit:
 cvs rdiff -u -r1.24 -r1.25 src/usr.bin/m4/eval.c

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

State-Changed-From-To: open->feedback
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Mon, 23 Oct 2017 00:11:49 +0000
State-Changed-Why:
christos committed a fix, is it sufficient?


State-Changed-From-To: feedback->closed
State-Changed-By: mrg@NetBSD.org
State-Changed-When: Mon, 23 Oct 2017 23:16:28 +0000
State-Changed-Why:
works now, thanks!


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/52638 CVS commit: [netbsd-7] src/usr.bin/m4
Date: Wed, 21 Mar 2018 12:08:43 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Wed Mar 21 12:08:43 UTC 2018

 Modified Files:
 	src/usr.bin/m4 [netbsd-7]: eval.c

 Log Message:
 Pull up following revision(s) (requested by mrg in ticket #1587):
 	usr.bin/m4/eval.c: revision 1.25
 	usr.bin/m4/eval.c: revision 1.26
 PR/52638: matthew green: missing argument check causes m4 to core in ifelse()

 remove the braces I accidentally added.


 To generate a diff of this commit:
 cvs rdiff -u -r1.22 -r1.22.20.1 src/usr.bin/m4/eval.c

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

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/52638 CVS commit: [netbsd-8] src/usr.bin/m4
Date: Wed, 11 Apr 2018 14:27:51 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Wed Apr 11 14:27:51 UTC 2018

 Modified Files:
 	src/usr.bin/m4 [netbsd-8]: eval.c

 Log Message:
 Pull up following revision(s) (requested by mrg in ticket #732):

 	usr.bin/m4/eval.c: revision 1.25
 	usr.bin/m4/eval.c: revision 1.26

 PR/52638: matthew green: missing argument check causes m4 to core in ifelse()

 remove the braces I accidentally added.


 To generate a diff of this commit:
 cvs rdiff -u -r1.24 -r1.24.8.1 src/usr.bin/m4/eval.c

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

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.