NetBSD Problem Report #53712

From www@NetBSD.org  Thu Nov  8 22:05:46 2018
Return-Path: <www@NetBSD.org>
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 CD3497A1A9
	for <gnats-bugs@gnats.NetBSD.org>; Thu,  8 Nov 2018 22:05:45 +0000 (UTC)
Message-Id: <20181108220544.D30A87A1F8@mollari.NetBSD.org>
Date: Thu,  8 Nov 2018 22:05:44 +0000 (UTC)
From: roland.illig@gmx.de
Reply-To: roland.illig@gmx.de
To: gnats-bugs@NetBSD.org
Subject: /bin/sh crashes on syntax error
X-Send-Pr-Version: www-1.0

>Number:         53712
>Category:       bin
>Synopsis:       /bin/sh crashes on syntax error
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kre
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Nov 08 22:10:00 +0000 2018
>Closed-Date:    Fri Nov 09 05:33:15 +0000 2018
>Last-Modified:  Mon Dec 10 17:25:00 +0000 2018
>Originator:     Roland Illig
>Release:        7.0.2, also current as of 2018-11-08
>Organization:
>Environment:
NetBSD nb7.fritz.box 7.0.2 NetBSD 7.0.2 (GENERIC.201610210724Z) amd64
>Description:
$ sh -c '{ } > out'
Segmentation fault (core dumped)

$ bash -c '{ } > out'
bash: -c: line 0: syntax error near unexpected token `}'
bash: -c: line 0: `{ } > out'

$ pkglint -Wall -s pkglint-test.mk
>               { } > out
WARN: pkglint-test.mk:2: Pkglint ShellLine.CheckShellCommand: parse error at []string{"}", ">", "out"}

>How-To-Repeat:

>Fix:
in bin/sh/parser.c, the crash happens in this line:

if (n1->type != NSUBSHELL) {

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: bin-bug-people->kre
Responsible-Changed-By: kre@NetBSD.org
Responsible-Changed-When: Fri, 09 Nov 2018 01:34:20 +0000
Responsible-Changed-Why:
I am (for now) handling this PR


State-Changed-From-To: open->analyzed
State-Changed-By: kre@NetBSD.org
State-Changed-When: Fri, 09 Nov 2018 01:34:20 +0000
State-Changed-Why:
Problem understood, (trivial) fix in progress.


From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/53712: /bin/sh crashes on syntax error
Date: Fri, 09 Nov 2018 08:33:06 +0700

 Actually, it is because (in sh) we do not treat  { } as a syntax error 
 (unless -o posix is set) that there ios a problem.

 That is, "./sh -o posix -c '{ } > out' gives a syntax error, and no crash.

 Fix is currently being tested.

 kre

State-Changed-From-To: analyzed->feedback
State-Changed-By: kre@NetBSD.org
State-Changed-When: Fri, 09 Nov 2018 02:13:50 +0000
State-Changed-Why:
Is the fix OK?


From: "Robert Elz" <kre@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53712 CVS commit: src/bin/sh
Date: Fri, 9 Nov 2018 02:11:05 +0000

 Module Name:	src
 Committed By:	kre
 Date:		Fri Nov  9 02:11:05 UTC 2018

 Modified Files:
 	src/bin/sh: parser.c

 Log Message:
 PR bin/53712

 Avoid crash from redirect on null compound command.


 To generate a diff of this commit:
 cvs rdiff -u -r1.151 -r1.152 src/bin/sh/parser.c

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

State-Changed-From-To: feedback->closed
State-Changed-By: rillig@NetBSD.org
State-Changed-When: Fri, 09 Nov 2018 05:33:15 +0000
State-Changed-Why:
Works fine, thanks for the quick fix.


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53712 CVS commit: [netbsd-8] src/bin/sh
Date: Mon, 12 Nov 2018 08:46:54 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Mon Nov 12 08:46:54 UTC 2018

 Modified Files:
 	src/bin/sh [netbsd-8]: parser.c

 Log Message:
 Pull up following revision(s) (requested by kre in ticket #1086):

 	bin/sh/parser.c: revision 1.152

 PR bin/53712

 Avoid crash from redirect on null compound command.


 To generate a diff of this commit:
 cvs rdiff -u -r1.132.2.6 -r1.132.2.7 src/bin/sh/parser.c

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

From: "Robert Elz" <kre@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53712 CVS commit: src/tests/bin/sh
Date: Wed, 14 Nov 2018 02:37:51 +0000

 Module Name:	src
 Committed By:	kre
 Date:		Wed Nov 14 02:37:51 UTC 2018

 Modified Files:
 	src/tests/bin/sh: t_syntax.sh

 Log Message:
 Add a test for the bug in PR bin/53712   ( " { } > out " core dump )
 Tested with both fixed, and unfixed, versions of /bin/sh (and in
 posix mode, where that is a syntax error).


 To generate a diff of this commit:
 cvs rdiff -u -r1.9 -r1.10 src/tests/bin/sh/t_syntax.sh

 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/53712 CVS commit: [netbsd-7] src/bin/sh
Date: Mon, 10 Dec 2018 17:20:03 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Mon Dec 10 17:20:03 UTC 2018

 Modified Files:
 	src/bin/sh [netbsd-7]: parser.c

 Log Message:
 Pull up following revision(s) (requested by kre in ticket #1663):

 	bin/sh/parser.c: revision 1.152 (via patch)

 PR bin/53712

 Avoid crash from redirect on null compound command.


 To generate a diff of this commit:
 cvs rdiff -u -r1.90.4.1 -r1.90.4.2 src/bin/sh/parser.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.