From nobody@FreeBSD.org  Thu May 22 10:01:54 2014
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTPS id DECEBC6F
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 22 May 2014 10:01:54 +0000 (UTC)
Received: from cgiserv.freebsd.org (cgiserv.freebsd.org [IPv6:2001:1900:2254:206a::50:4])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client did not present a certificate)
	by mx1.freebsd.org (Postfix) with ESMTPS id B285D2018
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 22 May 2014 10:01:54 +0000 (UTC)
Received: from cgiserv.freebsd.org ([127.0.1.6])
	by cgiserv.freebsd.org (8.14.8/8.14.8) with ESMTP id s4MA1sG2051677
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 22 May 2014 10:01:54 GMT
	(envelope-from nobody@cgiserv.freebsd.org)
Received: (from nobody@localhost)
	by cgiserv.freebsd.org (8.14.8/8.14.8/Submit) id s4MA1sE5051676;
	Thu, 22 May 2014 10:01:54 GMT
	(envelope-from nobody)
Message-Id: <201405221001.s4MA1sE5051676@cgiserv.freebsd.org>
Date: Thu, 22 May 2014 10:01:54 GMT
From: Petr Lampa <lampa@fit.vutbr.cz>
To: freebsd-gnats-submit@FreeBSD.org
Subject: make core dump at syntax error
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         190100
>Category:       bin
>Synopsis:       [patch] make(1): fix core dumps at syntax error
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu May 22 10:10:00 UTC 2014
>Closed-Date:    
>Last-Modified:  Thu May 22 21:26:13 UTC 2014
>Originator:     Petr Lampa
>Release:        9.2-STABLE
>Organization:
BUT FIT
>Environment:
FreeBSD xxx 9.3-PRERELEASE FreeBSD 9.3-PRERELEASE #1 r266496: Wed May 21 17:47:04 CEST 2014     xxxx:/usr/obj/usr/src/sys/xxx amd64

>Description:
make core dumps with this invalid Makefile (notice two && operators):

OSVERSION=901500
. if ${OSVERSION} >= 901500 && && (${ARCH} == i386 || ${ARCH} == amd64)
. endif

(gdb) where
#0  0x0000000000448d8c in kill ()
#1  0x0000000000447bd8 in abort ()
#2  0x0000000000403197 in Cond_If (
    line=0x80085de05 "${OSVERSION} >= 901500 && && (${ARCH} == i386 || ${ARCH} == amd64)", code=<value optimized out>, lineno=2)
    at /usr/src/usr.bin/make/cond.c:1079
#3  0x000000000040d64c in Parse_File (name=<value optimized out>,
    stream=<value optimized out>) at /usr/src/usr.bin/make/parse.c:2366
#4  0x000000000040a274 in ReadMakefile (p=<value optimized out>)
    at /usr/src/usr.bin/make/main.c:323
#5  0x000000000040a328 in TryReadMakefile (p=0x80081a1b0 "Makefile")
    at /usr/src/usr.bin/make/main.c:342
#6  0x000000000040a879 in main (argc=3, argv=0x7fffffffea90)
    at /usr/src/usr.bin/make/main.c:1185

It seems that current token from CondE(TRUE) is And and this is not handled correctly in switch() at line 1061. Perhaps any unexpected token can be here?
>How-To-Repeat:

>Fix:
remove default: block and change case Err: to default:

      switch (CondE(TRUE)) {
          case True:
                if (CondToken(TRUE) != EndOfFile)
                        goto err;
                value = TRUE;
                break;

          case False:
                if (CondToken(TRUE) != EndOfFile)
                        goto err;
                value = FALSE;
                break;

          default:
  err:          Parse_Error(PARSE_FATAL, "Malformed conditional (%s)", line);
                return;

        }

With this change it correctly reports:

"Makefile", line 2: Malformed conditional ...



>Release-Note:
>Audit-Trail:
>Unformatted:
