Module Name: src
Committed By: rillig
Date: Sat Jun 1 12:17:41 UTC 2024
Modified Files:
src/usr.bin/make: main.c
Log Message:
make: fix variable lifetime when initializing MAKE and .MAKE
The pathbuf buffer is aliased by abspath, which later escapes the block
where the buffer is declared.
To generate a diff of this commit:
cvs rdiff -u -r1.620 -r1.621 src/usr.bin/make/main.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.620 src/usr.bin/make/main.c:1.621
--- src/usr.bin/make/main.c:1.620 Sat Jun 1 07:37:19 2024
+++ src/usr.bin/make/main.c Sat Jun 1 12:17:41 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.620 2024/06/01 07:37:19 sjg Exp $ */
+/* $NetBSD: main.c,v 1.621 2024/06/01 12:17:41 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -111,7 +111,7 @@
#include "trace.h"
/* "@(#)main.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.620 2024/06/01 07:37:19 sjg Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.621 2024/06/01 12:17:41 rillig Exp $");
#if defined(MAKE_NATIVE)
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
"The Regents of the University of California. "
@@ -1126,9 +1126,9 @@ static void
InitVarMake(const char *argv0)
{
const char *make = argv0;
+ char pathbuf[MAXPATHLEN];
if (argv0[0] != '/' && strchr(argv0, '/') != NULL) {
- char pathbuf[MAXPATHLEN];
const char *abspath = cached_realpath(argv0, pathbuf);
struct stat st;
if (abspath != NULL && abspath[0] == '/' &&