diff options
| author | sjg <sjg@NetBSD.org> | 2018-02-18 00:52:42 +0000 |
|---|---|---|
| committer | sjg <sjg@NetBSD.org> | 2018-02-18 00:52:42 +0000 |
| commit | 937ebca5cb2cd29133407b7216cc7baaa2ad2ac0 (patch) | |
| tree | 3f9e403177b4264b6b4e7f825b1792725c585d03 /usr.bin/make | |
| parent | b4ed6f80088f4f88b4e57de0b669c26f0504fa91 (diff) | |
Var_Set: avoid SIGSEGV if val is NULL
A NULL val is handled gracefully (by VarAdd) when
var is not previously set, so we ought not crash
the second time.
PR: 53034
Diffstat (limited to 'usr.bin/make')
| -rw-r--r-- | usr.bin/make/var.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index 7416b7d7058..46db87be216 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.217 2017/12/08 03:36:42 sjg Exp $ */ +/* $NetBSD: var.c,v 1.218 2018/02/18 00:52:42 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: var.c,v 1.217 2017/12/08 03:36:42 sjg Exp $"; +static char rcsid[] = "$NetBSD: var.c,v 1.218 2018/02/18 00:52:42 sjg Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: var.c,v 1.217 2017/12/08 03:36:42 sjg Exp $"); +__RCSID("$NetBSD: var.c,v 1.218 2018/02/18 00:52:42 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -971,7 +971,8 @@ Var_Set(const char *name, const char *val, GNode *ctxt, int flags) VarAdd(name, val, ctxt); } else { Buf_Empty(&v->val); - Buf_AddBytes(&v->val, strlen(val), val); + if (val) + Buf_AddBytes(&v->val, strlen(val), val); if (DEBUG(VAR)) { fprintf(debug_file, "%s:%s = %s\n", ctxt->name, name, val); @@ -998,7 +999,7 @@ Var_Set(const char *name, const char *val, GNode *ctxt, int flags) * Makefile settings. */ if (varNoExportEnv != TRUE) - setenv(name, val, 1); + setenv(name, val ? val : "", 1); Var_Append(MAKEOVERRIDES, name, VAR_GLOBAL); } |
