From d0a7e917ea9bd476a84fef300ea1a209445af367 Mon Sep 17 00:00:00 2001 From: rillig Date: Mon, 2 Nov 2020 20:48:36 +0000 Subject: [PATCH] make(1): error out on unclosed expressions after the colon --- usr.bin/make/unit-tests/cmd-errors-lint.exp | 1 + usr.bin/make/unit-tests/cmd-errors.exp | 1 + usr.bin/make/var.c | 11 +++++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/usr.bin/make/unit-tests/cmd-errors-lint.exp b/usr.bin/make/unit-tests/cmd-errors-lint.exp index fadc324aae6f..09924c538de0 100644 --- a/usr.bin/make/unit-tests/cmd-errors-lint.exp +++ b/usr.bin/make/unit-tests/cmd-errors-lint.exp @@ -1,6 +1,7 @@ : undefined make: Unclosed variable "UNCLOSED" : unclosed-variable +make: Unclosed variable expression (expecting '}') for "UNCLOSED" : unclosed-modifier make: Unknown modifier 'Z' : unknown-modifier diff --git a/usr.bin/make/unit-tests/cmd-errors.exp b/usr.bin/make/unit-tests/cmd-errors.exp index 504b6122c744..da18ba54749b 100644 --- a/usr.bin/make/unit-tests/cmd-errors.exp +++ b/usr.bin/make/unit-tests/cmd-errors.exp @@ -1,6 +1,7 @@ : undefined make: Unclosed variable "UNCLOSED" : unclosed-variable +make: Unclosed variable expression (expecting '}') for "UNCLOSED" : unclosed-modifier make: Unknown modifier 'Z' : unknown-modifier diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index 9e366f52c4ee..447cba85de51 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.648 2020/11/02 19:07:09 rillig Exp $ */ +/* $NetBSD: var.c,v 1.649 2020/11/02 20:48:36 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -130,7 +130,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.648 2020/11/02 19:07:09 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.649 2020/11/02 20:48:36 rillig Exp $"); #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1) #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2) @@ -3357,6 +3357,13 @@ ApplyModifiers( assert(val != NULL); p = *pp; + + if (*p == '\0' && endc != '\0') { + Error("Unclosed variable expression (expecting '%c') for \"%s\"", + st.endc, st.v->name); + goto cleanup; + } + while (*p != '\0' && *p != endc) { if (*p == '$') {