Module Name:    src
Committed By:   sjg
Date:           Thu Sep 26 21:09:55 UTC 2019

Modified Files:
        src/usr.bin/make: parse.c

Log Message:
Do not assume safe to pass NULL to realpath(3).

PR: 54574
Reviewed by: buhrow


To generate a diff of this commit:
cvs rdiff -u -r1.232 -r1.233 src/usr.bin/make/parse.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/parse.c
diff -u src/usr.bin/make/parse.c:1.232 src/usr.bin/make/parse.c:1.233
--- src/usr.bin/make/parse.c:1.232	Tue Apr  9 18:28:10 2019
+++ src/usr.bin/make/parse.c	Thu Sep 26 21:09:55 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.232 2019/04/09 18:28:10 sjg Exp $	*/
+/*	$NetBSD: parse.c,v 1.233 2019/09/26 21:09:55 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.232 2019/04/09 18:28:10 sjg Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.233 2019/09/26 21:09:55 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)parse.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: parse.c,v 1.232 2019/04/09 18:28:10 sjg Exp $");
+__RCSID("$NetBSD: parse.c,v 1.233 2019/09/26 21:09:55 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -670,6 +670,7 @@ ParseVErrorInternal(FILE *f, const char 
     const char *fmt, va_list ap)
 {
 	static Boolean fatal_warning_error_printed = FALSE;
+	char dirbuf[MAXPATHLEN+1];
 
 	(void)fprintf(f, "%s: ", progname);
 
@@ -688,9 +689,7 @@ ParseVErrorInternal(FILE *f, const char 
 			if (dir == NULL)
 				dir = ".";
 			if (*dir != '/') {
-				dir = cp2 = realpath(dir, NULL);
-				free(cp);
-				cp = cp2; /* cp2 set to NULL by Var_Value */
+				dir = realpath(dir, dirbuf);
 			}
 			fname = Var_Value(".PARSEFILE", VAR_GLOBAL, &cp2);
 			if (fname == NULL) {

Reply via email to