svn commit: r317232 - in vendor/NetBSD/bmake/dist: . mk
Simon J. Gerraty
sjg at FreeBSD.org
Thu Apr 20 23:12:40 UTC 2017
Author: sjg
Date: Thu Apr 20 23:12:37 2017
New Revision: 317232
URL: https://svnweb.freebsd.org/changeset/base/317232
Log:
Import bmake-20170420
Only use -C arg "as is" if it contains no relative component.
Fix Main_SetObjdir() for relative paths (eg obj).
Fix a number of coverity complaints.
Modified:
vendor/NetBSD/bmake/dist/ChangeLog
vendor/NetBSD/bmake/dist/Makefile
vendor/NetBSD/bmake/dist/arch.c
vendor/NetBSD/bmake/dist/cond.c
vendor/NetBSD/bmake/dist/dir.c
vendor/NetBSD/bmake/dist/for.c
vendor/NetBSD/bmake/dist/job.c
vendor/NetBSD/bmake/dist/main.c
vendor/NetBSD/bmake/dist/make_malloc.c
vendor/NetBSD/bmake/dist/mk/ChangeLog
vendor/NetBSD/bmake/dist/mk/auto.obj.mk
vendor/NetBSD/bmake/dist/mk/install-mk
vendor/NetBSD/bmake/dist/parse.c
vendor/NetBSD/bmake/dist/suff.c
vendor/NetBSD/bmake/dist/targ.c
vendor/NetBSD/bmake/dist/var.c
Modified: vendor/NetBSD/bmake/dist/ChangeLog
==============================================================================
--- vendor/NetBSD/bmake/dist/ChangeLog Thu Apr 20 22:30:39 2017 (r317231)
+++ vendor/NetBSD/bmake/dist/ChangeLog Thu Apr 20 23:12:37 2017 (r317232)
@@ -1,3 +1,29 @@
+2017-04-20 Simon J. Gerraty <sjg at bad.crufty.net>
+
+ * Makefile (_MAKE_VERSION): 20170420
+ Merge with NetBSD make, pick up
+ o main.c: only use -C arg "as is" if it contains no
+ relative component.
+
+2017-04-18 Simon J. Gerraty <sjg at bad.crufty.net>
+
+ * Makefile (_MAKE_VERSION): 20170418
+ Merge with NetBSD make, pick up
+ o main.c: fix Main_SetObjdir() for relative paths (eg obj).
+
+2017-04-17 Simon J. Gerraty <sjg at bad.crufty.net>
+
+ * Makefile (_MAKE_VERSION): 20170417
+ Merge with NetBSD make, pick up
+ o fixes a number of coverity complaints
+ - check return value of fseek, fcntl
+ - plug memory leak in Dir_FindFile, Var_LoopExpand,
+ JobPrintCommand, ParseTraditionalInclude
+ - use bmake_malloc() where NULL is not tollerated
+ - use MAKE_ATTR_UNUSED rather that kludges like
+ return(unused ? 0 : 0)
+ - use purge_cached_realpaths() rather than abuse cached_realpath()
+
2017-04-13 Simon J. Gerraty <sjg at bad.crufty.net>
* Makefile (_MAKE_VERSION): 20170413
Modified: vendor/NetBSD/bmake/dist/Makefile
==============================================================================
--- vendor/NetBSD/bmake/dist/Makefile Thu Apr 20 22:30:39 2017 (r317231)
+++ vendor/NetBSD/bmake/dist/Makefile Thu Apr 20 23:12:37 2017 (r317232)
@@ -1,7 +1,7 @@
-# $Id: Makefile,v 1.85 2017/04/13 16:29:40 sjg Exp $
+# $Id: Makefile,v 1.88 2017/04/20 14:51:14 sjg Exp $
# Base version on src date
-_MAKE_VERSION= 20170413
+_MAKE_VERSION= 20170420
PROG= bmake
Modified: vendor/NetBSD/bmake/dist/arch.c
==============================================================================
--- vendor/NetBSD/bmake/dist/arch.c Thu Apr 20 22:30:39 2017 (r317231)
+++ vendor/NetBSD/bmake/dist/arch.c Thu Apr 20 23:12:37 2017 (r317232)
@@ -1,4 +1,4 @@
-/* $NetBSD: arch.c,v 1.69 2016/04/06 09:57:00 gson Exp $ */
+/* $NetBSD: arch.c,v 1.70 2017/04/16 20:49:09 riastradh Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.69 2016/04/06 09:57:00 gson Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.70 2017/04/16 20:49:09 riastradh Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94";
#else
-__RCSID("$NetBSD: arch.c,v 1.69 2016/04/06 09:57:00 gson Exp $");
+__RCSID("$NetBSD: arch.c,v 1.70 2017/04/16 20:49:09 riastradh Exp $");
#endif
#endif /* not lint */
#endif
@@ -726,7 +726,8 @@ ArchStatMember(char *archive, char *memb
if (fread(memName, elen, 1, arch) != 1)
goto badarch;
memName[elen] = '\0';
- fseek(arch, -elen, SEEK_CUR);
+ if (fseek(arch, -elen, SEEK_CUR) != 0)
+ goto badarch;
if (DEBUG(ARCH) || DEBUG(MAKE)) {
fprintf(debug_file, "ArchStat: Extended format entry for %s\n", memName);
}
@@ -737,7 +738,8 @@ ArchStatMember(char *archive, char *memb
Hash_SetValue(he, bmake_malloc(sizeof(struct ar_hdr)));
memcpy(Hash_GetValue(he), &arh, sizeof(struct ar_hdr));
}
- fseek(arch, (size + 1) & ~1, SEEK_CUR);
+ if (fseek(arch, (size + 1) & ~1, SEEK_CUR) != 0)
+ goto badarch;
}
fclose(arch);
@@ -956,7 +958,10 @@ ArchFindMember(char *archive, char *memb
* the file at the actual member, rather than its header, but
* not here...
*/
- fseek(arch, -sizeof(struct ar_hdr), SEEK_CUR);
+ if (fseek(arch, -sizeof(struct ar_hdr), SEEK_CUR) != 0) {
+ fclose(arch);
+ return NULL;
+ }
return (arch);
}
} else
@@ -986,10 +991,17 @@ ArchFindMember(char *archive, char *memb
}
if (strncmp(ename, member, len) == 0) {
/* Found as extended name */
- fseek(arch, -sizeof(struct ar_hdr) - elen, SEEK_CUR);
+ if (fseek(arch, -sizeof(struct ar_hdr) - elen,
+ SEEK_CUR) != 0) {
+ fclose(arch);
+ return NULL;
+ }
return (arch);
}
- fseek(arch, -elen, SEEK_CUR);
+ if (fseek(arch, -elen, SEEK_CUR) != 0) {
+ fclose(arch);
+ return NULL;
+ }
goto skip;
} else
#endif
@@ -1002,9 +1014,12 @@ skip:
* extract the size of the file from the 'size' field of the
* header and round it up during the seek.
*/
- arhPtr->ar_size[sizeof(arhPtr->AR_SIZE)-1] = '\0';
+ arhPtr->AR_SIZE[sizeof(arhPtr->AR_SIZE)-1] = '\0';
size = (int)strtol(arhPtr->AR_SIZE, NULL, 10);
- fseek(arch, (size + 1) & ~1, SEEK_CUR);
+ if (fseek(arch, (size + 1) & ~1, SEEK_CUR) != 0) {
+ fclose(arch);
+ return NULL;
+ }
}
}
Modified: vendor/NetBSD/bmake/dist/cond.c
==============================================================================
--- vendor/NetBSD/bmake/dist/cond.c Thu Apr 20 22:30:39 2017 (r317231)
+++ vendor/NetBSD/bmake/dist/cond.c Thu Apr 20 23:12:37 2017 (r317232)
@@ -1,4 +1,4 @@
-/* $NetBSD: cond.c,v 1.74 2016/02/18 18:29:14 christos Exp $ */
+/* $NetBSD: cond.c,v 1.75 2017/04/16 20:59:04 riastradh Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: cond.c,v 1.74 2016/02/18 18:29:14 christos Exp $";
+static char rcsid[] = "$NetBSD: cond.c,v 1.75 2017/04/16 20:59:04 riastradh Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94";
#else
-__RCSID("$NetBSD: cond.c,v 1.74 2016/02/18 18:29:14 christos Exp $");
+__RCSID("$NetBSD: cond.c,v 1.75 2017/04/16 20:59:04 riastradh Exp $");
#endif
#endif /* not lint */
#endif
@@ -91,6 +91,7 @@ __RCSID("$NetBSD: cond.c,v 1.74 2016/02/
*
*/
+#include <assert.h>
#include <ctype.h>
#include <errno.h> /* For strtoul() error checking */
@@ -1174,8 +1175,9 @@ Cond_EvalExpression(const struct If *inf
break;
dflt_info = info;
}
+ assert(info != NULL);
- if_info = info != NULL ? info : ifs + 4;
+ if_info = info;
condExpr = line;
condPushBack = TOK_NONE;
Modified: vendor/NetBSD/bmake/dist/dir.c
==============================================================================
--- vendor/NetBSD/bmake/dist/dir.c Thu Apr 20 22:30:39 2017 (r317231)
+++ vendor/NetBSD/bmake/dist/dir.c Thu Apr 20 23:12:37 2017 (r317232)
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.69 2017/01/31 06:54:23 sjg Exp $ */
+/* $NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: dir.c,v 1.69 2017/01/31 06:54:23 sjg Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94";
#else
-__RCSID("$NetBSD: dir.c,v 1.69 2017/01/31 06:54:23 sjg Exp $");
+__RCSID("$NetBSD: dir.c,v 1.71 2017/04/16 21:14:47 riastradh Exp $");
#endif
#endif /* not lint */
#endif
@@ -803,11 +803,11 @@ DirExpandInt(const char *word, Lst path,
*-----------------------------------------------------------------------
*/
static int
-DirPrintWord(void *word, void *dummy)
+DirPrintWord(void *word, void *dummy MAKE_ATTR_UNUSED)
{
fprintf(debug_file, "%s ", (char *)word);
- return(dummy ? 0 : 0);
+ return 0;
}
/*-
@@ -1315,8 +1315,14 @@ Dir_FindFile(const char *name, Lst path)
fprintf(debug_file, " Trying exact path matches...\n");
}
- if (!hasLastDot && cur && (file = DirLookupAbs(cur, name, cp)) != NULL)
- return *file?file:NULL;
+ if (!hasLastDot && cur && ((file = DirLookupAbs(cur, name, cp))
+ != NULL)) {
+ if (file[0] == '\0') {
+ free(file);
+ return NULL;
+ }
+ return file;
+ }
(void)Lst_Open(path);
while ((ln = Lst_Next(path)) != NULL) {
@@ -1325,13 +1331,23 @@ Dir_FindFile(const char *name, Lst path)
continue;
if ((file = DirLookupAbs(p, name, cp)) != NULL) {
Lst_Close(path);
- return *file?file:NULL;
+ if (file[0] == '\0') {
+ free(file);
+ return NULL;
+ }
+ return file;
}
}
Lst_Close(path);
- if (hasLastDot && cur && (file = DirLookupAbs(cur, name, cp)) != NULL)
- return *file?file:NULL;
+ if (hasLastDot && cur && ((file = DirLookupAbs(cur, name, cp))
+ != NULL)) {
+ if (file[0] == '\0') {
+ free(file);
+ return NULL;
+ }
+ return file;
+ }
}
/*
@@ -1851,10 +1867,10 @@ Dir_PrintDirectories(void)
}
static int
-DirPrintDir(void *p, void *dummy)
+DirPrintDir(void *p, void *dummy MAKE_ATTR_UNUSED)
{
fprintf(debug_file, "%s ", ((Path *)p)->name);
- return (dummy ? 0 : 0);
+ return 0;
}
void
Modified: vendor/NetBSD/bmake/dist/for.c
==============================================================================
--- vendor/NetBSD/bmake/dist/for.c Thu Apr 20 22:30:39 2017 (r317231)
+++ vendor/NetBSD/bmake/dist/for.c Thu Apr 20 23:12:37 2017 (r317232)
@@ -1,4 +1,4 @@
-/* $NetBSD: for.c,v 1.52 2016/02/18 18:29:14 christos Exp $ */
+/* $NetBSD: for.c,v 1.53 2017/04/16 21:04:44 riastradh Exp $ */
/*
* Copyright (c) 1992, The Regents of the University of California.
@@ -30,14 +30,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: for.c,v 1.52 2016/02/18 18:29:14 christos Exp $";
+static char rcsid[] = "$NetBSD: for.c,v 1.53 2017/04/16 21:04:44 riastradh Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)for.c 8.1 (Berkeley) 6/6/93";
#else
-__RCSID("$NetBSD: for.c,v 1.52 2016/02/18 18:29:14 christos Exp $");
+__RCSID("$NetBSD: for.c,v 1.53 2017/04/16 21:04:44 riastradh Exp $");
#endif
#endif /* not lint */
#endif
@@ -427,7 +427,7 @@ For_Iterate(void *v_arg, size_t *ret_len
for (cp = cmd_cp; (cp = strchr(cp, '$')) != NULL;) {
char ech;
ch = *++cp;
- if ((ch == '(' && (ech = ')')) || (ch == '{' && (ech = '}'))) {
+ if ((ch == '(' && (ech = ')', 1)) || (ch == '{' && (ech = '}', 1))) {
cp++;
/* Check variable name against the .for loop variables */
STRLIST_FOREACH(var, &arg->vars, i) {
Modified: vendor/NetBSD/bmake/dist/job.c
==============================================================================
--- vendor/NetBSD/bmake/dist/job.c Thu Apr 20 22:30:39 2017 (r317231)
+++ vendor/NetBSD/bmake/dist/job.c Thu Apr 20 23:12:37 2017 (r317232)
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.188 2016/08/26 23:28:39 dholland Exp $ */
+/* $NetBSD: job.c,v 1.190 2017/04/16 21:23:43 riastradh Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: job.c,v 1.188 2016/08/26 23:28:39 dholland Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.190 2017/04/16 21:23:43 riastradh Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: job.c,v 1.188 2016/08/26 23:28:39 dholland Exp $");
+__RCSID("$NetBSD: job.c,v 1.190 2017/04/16 21:23:43 riastradh Exp $");
#endif
#endif /* not lint */
#endif
@@ -427,7 +427,7 @@ static void JobSigUnlock(sigset_t *omask
static void
JobCreatePipe(Job *job, int minfd)
{
- int i, fd;
+ int i, fd, flags;
if (pipe(job->jobPipe) == -1)
Punt("Cannot create pipe: %s", strerror(errno));
@@ -442,8 +442,10 @@ JobCreatePipe(Job *job, int minfd)
}
/* Set close-on-exec flag for both */
- (void)fcntl(job->jobPipe[0], F_SETFD, FD_CLOEXEC);
- (void)fcntl(job->jobPipe[1], F_SETFD, FD_CLOEXEC);
+ if (fcntl(job->jobPipe[0], F_SETFD, FD_CLOEXEC) == -1)
+ Punt("Cannot set close-on-exec: %s", strerror(errno));
+ if (fcntl(job->jobPipe[1], F_SETFD, FD_CLOEXEC) == -1)
+ Punt("Cannot set close-on-exec: %s", strerror(errno));
/*
* We mark the input side of the pipe non-blocking; we poll(2) the
@@ -451,8 +453,12 @@ JobCreatePipe(Job *job, int minfd)
* race for the token when a new one becomes available, so the read
* from the pipe should not block.
*/
- fcntl(job->jobPipe[0], F_SETFL,
- fcntl(job->jobPipe[0], F_GETFL, 0) | O_NONBLOCK);
+ flags = fcntl(job->jobPipe[0], F_GETFL, 0);
+ if (flags == -1)
+ Punt("Cannot get flags: %s", strerror(errno));
+ flags |= O_NONBLOCK;
+ if (fcntl(job->jobPipe[0], F_SETFL, flags) == -1)
+ Punt("Cannot set flags: %s", strerror(errno));
}
/*-
@@ -754,6 +760,7 @@ JobPrintCommand(void *cmdp, void *jobp)
* but this one needs to be - use compat mode just for it.
*/
CompatRunCommand(cmdp, job->node);
+ free(cmdStart);
return 0;
}
break;
@@ -1382,15 +1389,27 @@ JobExec(Job *job, char **argv)
execError("dup2", "job->cmdFILE");
_exit(1);
}
- (void)fcntl(0, F_SETFD, 0);
- (void)lseek(0, (off_t)0, SEEK_SET);
+ if (fcntl(0, F_SETFD, 0) == -1) {
+ execError("fcntl clear close-on-exec", "stdin");
+ _exit(1);
+ }
+ if (lseek(0, (off_t)0, SEEK_SET) == -1) {
+ execError("lseek to 0", "stdin");
+ _exit(1);
+ }
if (job->node->type & (OP_MAKE | OP_SUBMAKE)) {
/*
* Pass job token pipe to submakes.
*/
- fcntl(tokenWaitJob.inPipe, F_SETFD, 0);
- fcntl(tokenWaitJob.outPipe, F_SETFD, 0);
+ if (fcntl(tokenWaitJob.inPipe, F_SETFD, 0) == -1) {
+ execError("clear close-on-exec", "tokenWaitJob.inPipe");
+ _exit(1);
+ }
+ if (fcntl(tokenWaitJob.outPipe, F_SETFD, 0) == -1) {
+ execError("clear close-on-exec", "tokenWaitJob.outPipe");
+ _exit(1);
+ }
}
/*
@@ -1407,7 +1426,10 @@ JobExec(Job *job, char **argv)
* it before routing the shell's error output to the same place as
* its standard output.
*/
- (void)fcntl(1, F_SETFD, 0);
+ if (fcntl(1, F_SETFD, 0) == -1) {
+ execError("clear close-on-exec", "stdout");
+ _exit(1);
+ }
if (dup2(1, 2) == -1) {
execError("dup2", "1, 2");
_exit(1);
Modified: vendor/NetBSD/bmake/dist/main.c
==============================================================================
--- vendor/NetBSD/bmake/dist/main.c Thu Apr 20 22:30:39 2017 (r317231)
+++ vendor/NetBSD/bmake/dist/main.c Thu Apr 20 23:12:37 2017 (r317232)
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.260 2017/04/13 13:55:23 christos Exp $ */
+/* $NetBSD: main.c,v 1.264 2017/04/20 03:57:27 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.260 2017/04/13 13:55:23 christos Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.264 2017/04/20 03:57:27 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: main.c,v 1.260 2017/04/13 13:55:23 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.264 2017/04/20 03:57:27 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -187,6 +187,7 @@ static const char * tracefile;
static void MainParseArgs(int, char **);
static int ReadMakefile(const void *, const void *);
static void usage(void) MAKE_ATTR_DEAD;
+static void purge_cached_realpaths(void);
static Boolean ignorePWD; /* if we use -C, PWD is meaningless */
static char objdir[MAXPATHLEN + 1]; /* where we chdir'ed to */
@@ -336,7 +337,7 @@ parse_debug_options(const char *argvalue
goto debug_setbuf;
}
len = strlen(modules);
- fname = malloc(len + 20);
+ fname = bmake_malloc(len + 20);
memcpy(fname, modules, len + 1);
/* Let the filename be modified by the pid */
if (strcmp(fname + len - 3, ".%d") == 0)
@@ -367,6 +368,32 @@ debug_setbuf:
}
}
+/*
+ * does path contain any relative components
+ */
+static int
+is_relpath(const char *path)
+{
+ const char *cp;
+
+ if (path[0] != '/')
+ return TRUE;
+ cp = path;
+ do {
+ cp = strstr(cp, "/.");
+ if (!cp)
+ break;
+ cp += 2;
+ if (cp[0] == '/' || cp[0] == '\0')
+ return TRUE;
+ else if (cp[0] == '.') {
+ if (cp[1] == '/' || cp[1] == '\0')
+ return TRUE;
+ }
+ } while (cp);
+ return FALSE;
+}
+
/*-
* MainParseArgs --
* Parse a given argument vector. Called from main() and from
@@ -458,7 +485,7 @@ rearg:
(void)fprintf(stderr, "%s: %s.\n", progname, strerror(errno));
exit(2);
}
- if (argvalue[0] == '/' &&
+ if (!is_relpath(argvalue) &&
stat(argvalue, &sa) != -1 &&
stat(curdir, &sb) != -1 &&
sa.st_ino == sb.st_ino &&
@@ -732,8 +759,10 @@ Main_SetObjdir(const char *fmt, ...)
va_end(ap);
if (path[0] != '/') {
- snprintf(buf, MAXPATHLEN, "%s/%s", curdir, path);
- path = buf;
+ char buf2[MAXPATHLEN + 1];
+
+ snprintf(buf2, MAXPATHLEN, "%s/%s", curdir, path);
+ path = buf2;
}
/* look for the directory and try to chdir there */
@@ -746,7 +775,7 @@ Main_SetObjdir(const char *fmt, ...)
Var_Set(".OBJDIR", objdir, VAR_GLOBAL, 0);
setenv("PWD", objdir, 1);
Dir_InitDot();
- cached_realpath(".OBJDIR", NULL); /* purge */
+ purge_cached_realpaths();
rc = TRUE;
if (enterFlag && strcmp(objdir, curdir) != 0)
enterFlagObj = TRUE;
@@ -1907,42 +1936,56 @@ usage(void)
exit(2);
}
-
/*
* realpath(3) can get expensive, cache results...
*/
+static GNode *cached_realpaths = NULL;
+
+static GNode *
+get_cached_realpaths(void)
+{
+
+ if (!cached_realpaths) {
+ cached_realpaths = Targ_NewGN("Realpath");
+#ifndef DEBUG_REALPATH_CACHE
+ cached_realpaths->flags = INTERNAL;
+#endif
+ }
+
+ return cached_realpaths;
+}
+
+/* purge any relative paths */
+static void
+purge_cached_realpaths(void)
+{
+ GNode *cache = get_cached_realpaths();
+ Hash_Entry *he, *nhe;
+ Hash_Search hs;
+
+ he = Hash_EnumFirst(&cache->context, &hs);
+ while (he) {
+ nhe = Hash_EnumNext(&hs);
+ if (he->name[0] != '/') {
+ if (DEBUG(DIR))
+ fprintf(stderr, "cached_realpath: purging %s\n", he->name);
+ Hash_DeleteEntry(&cache->context, he);
+ }
+ he = nhe;
+ }
+}
+
char *
cached_realpath(const char *pathname, char *resolved)
{
- static GNode *cache;
+ GNode *cache;
char *rp, *cp;
if (!pathname || !pathname[0])
return NULL;
- if (!cache) {
- cache = Targ_NewGN("Realpath");
-#ifndef DEBUG_REALPATH_CACHE
- cache->flags = INTERNAL;
-#endif
- }
- if (resolved == NULL && strcmp(pathname, ".OBJDIR") == 0) {
- /* purge any relative paths */
- Hash_Entry *he, *nhe;
- Hash_Search hs;
-
- he = Hash_EnumFirst(&cache->context, &hs);
- while (he) {
- nhe = Hash_EnumNext(&hs);
- if (he->name[0] != '/') {
- if (DEBUG(DIR))
- fprintf(stderr, "cached_realpath: purging %s\n", he->name);
- Hash_DeleteEntry(&cache->context, he);
- }
- he = nhe;
- }
- return NULL;
- }
+ cache = get_cached_realpaths();
+
if ((rp = Var_Value(pathname, cache, &cp)) != NULL) {
/* a hit */
strlcpy(resolved, rp, MAXPATHLEN);
Modified: vendor/NetBSD/bmake/dist/make_malloc.c
==============================================================================
--- vendor/NetBSD/bmake/dist/make_malloc.c Thu Apr 20 22:30:39 2017 (r317231)
+++ vendor/NetBSD/bmake/dist/make_malloc.c Thu Apr 20 23:12:37 2017 (r317232)
@@ -1,4 +1,4 @@
-/* $NetBSD: make_malloc.c,v 1.10 2012/06/20 17:46:28 sjg Exp $ */
+/* $NetBSD: make_malloc.c,v 1.11 2017/04/16 20:20:24 dholland Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
#ifdef MAKE_NATIVE
#include <sys/cdefs.h>
-__RCSID("$NetBSD: make_malloc.c,v 1.10 2012/06/20 17:46:28 sjg Exp $");
+__RCSID("$NetBSD: make_malloc.c,v 1.11 2017/04/16 20:20:24 dholland Exp $");
#endif
#include <stdio.h>
@@ -39,13 +39,13 @@ __RCSID("$NetBSD: make_malloc.c,v 1.10 2
#include "make.h"
#ifndef USE_EMALLOC
-static void enomem(void) MAKE_ATTR_DEAD;
+static MAKE_ATTR_DEAD void enomem(void);
/*
* enomem --
* die when out of memory.
*/
-static void
+static MAKE_ATTR_DEAD void
enomem(void)
{
(void)fprintf(stderr, "%s: %s.\n", progname, strerror(ENOMEM));
Modified: vendor/NetBSD/bmake/dist/mk/ChangeLog
==============================================================================
--- vendor/NetBSD/bmake/dist/mk/ChangeLog Thu Apr 20 22:30:39 2017 (r317231)
+++ vendor/NetBSD/bmake/dist/mk/ChangeLog Thu Apr 20 23:12:37 2017 (r317232)
@@ -1,3 +1,10 @@
+2017-04-18 Simon J. Gerraty <sjg at bad.crufty.net>
+
+ * install-mk (MK_VERSION): 20170418
+
+ * auto.obj.mk: if using MAKEOBJDIRPREFIX check if it is a
+ prefix match for .CURDIR - in which case .CURDIR *is* __objdir.
+
2017-04-01 Simon J. Gerraty <sjg at bad.crufty.net>
* install-mk (MK_VERSION): 20170401
Modified: vendor/NetBSD/bmake/dist/mk/auto.obj.mk
==============================================================================
--- vendor/NetBSD/bmake/dist/mk/auto.obj.mk Thu Apr 20 22:30:39 2017 (r317231)
+++ vendor/NetBSD/bmake/dist/mk/auto.obj.mk Thu Apr 20 23:12:37 2017 (r317232)
@@ -1,4 +1,4 @@
-# $Id: auto.obj.mk,v 1.13 2017/03/24 20:53:22 sjg Exp $
+# $Id: auto.obj.mk,v 1.14 2017/04/18 23:53:18 sjg Exp $
#
# @(#) Copyright (c) 2004, Simon J. Gerraty
#
@@ -41,6 +41,10 @@ MKOBJDIRS= auto
# Use __objdir here so it is easier to tweak without impacting
# the logic.
.if !empty(MAKEOBJDIRPREFIX)
+.if ${.CURDIR:M${MAKEOBJDIRPREFIX}/*} != ""
+# we are already in obj tree!
+__objdir?= ${.CURDIR}
+.endif
__objdir?= ${MAKEOBJDIRPREFIX}${.CURDIR}
.endif
__objdir?= ${MAKEOBJDIR:Uobj}
Modified: vendor/NetBSD/bmake/dist/mk/install-mk
==============================================================================
--- vendor/NetBSD/bmake/dist/mk/install-mk Thu Apr 20 22:30:39 2017 (r317231)
+++ vendor/NetBSD/bmake/dist/mk/install-mk Thu Apr 20 23:12:37 2017 (r317232)
@@ -55,7 +55,7 @@
# Simon J. Gerraty <sjg at crufty.net>
# RCSid:
-# $Id: install-mk,v 1.140 2017/04/03 21:04:09 sjg Exp $
+# $Id: install-mk,v 1.141 2017/04/18 23:53:18 sjg Exp $
#
# @(#) Copyright (c) 1994 Simon J. Gerraty
#
@@ -70,7 +70,7 @@
# sjg at crufty.net
#
-MK_VERSION=20170401
+MK_VERSION=20170418
OWNER=
GROUP=
MODE=444
Modified: vendor/NetBSD/bmake/dist/parse.c
==============================================================================
--- vendor/NetBSD/bmake/dist/parse.c Thu Apr 20 22:30:39 2017 (r317231)
+++ vendor/NetBSD/bmake/dist/parse.c Thu Apr 20 23:12:37 2017 (r317232)
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.218 2017/03/01 16:39:49 sjg Exp $ */
+/* $NetBSD: parse.c,v 1.225 2017/04/17 13:29:07 maya Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.218 2017/03/01 16:39:49 sjg Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.225 2017/04/17 13:29:07 maya 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.218 2017/03/01 16:39:49 sjg Exp $");
+__RCSID("$NetBSD: parse.c,v 1.225 2017/04/17 13:29:07 maya Exp $");
#endif
#endif /* not lint */
#endif
@@ -130,6 +130,7 @@ __RCSID("$NetBSD: parse.c,v 1.218 2017/0
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
+#include <stdint.h>
#include "make.h"
#include "hash.h"
@@ -539,7 +540,7 @@ loadfile(const char *path, int fd)
if (lf->buf != MAP_FAILED) {
/* succeeded */
if (lf->len == lf->maplen && lf->buf[lf->len - 1] != '\n') {
- char *b = malloc(lf->len + 1);
+ char *b = bmake_malloc(lf->len + 1);
b[lf->len] = '\n';
memcpy(b, lf->buf, lf->len++);
munmap(lf->buf, lf->maplen);
@@ -560,9 +561,15 @@ loadfile(const char *path, int fd)
while (1) {
assert(bufpos <= lf->len);
if (bufpos == lf->len) {
+ if (lf->len > SIZE_MAX/2) {
+ errno = EFBIG;
+ Error("%s: file too large", path);
+ exit(1);
+ }
lf->len *= 2;
lf->buf = bmake_realloc(lf->buf, lf->len);
}
+ assert(bufpos < lf->len);
result = read(fd, lf->buf + bufpos, lf->len - bufpos);
if (result < 0) {
Error("%s: read error: %s", path, strerror(errno));
@@ -1099,15 +1106,15 @@ ParseDoSrc(int tOp, const char *src)
*-----------------------------------------------------------------------
*/
static int
-ParseFindMain(void *gnp, void *dummy)
+ParseFindMain(void *gnp, void *dummy MAKE_ATTR_UNUSED)
{
GNode *gn = (GNode *)gnp;
if ((gn->type & OP_NOTARGET) == 0) {
mainNode = gn;
Targ_SetMain(gn);
- return (dummy ? 1 : 1);
+ return 1;
} else {
- return (dummy ? 0 : 0);
+ return 0;
}
}
@@ -1145,10 +1152,10 @@ ParseAddDir(void *path, void *name)
*-----------------------------------------------------------------------
*/
static int
-ParseClearPath(void *path, void *dummy)
+ParseClearPath(void *path, void *dummy MAKE_ATTR_UNUSED)
{
Dir_ClearPath((Lst) path);
- return(dummy ? 0 : 0);
+ return 0;
}
/*-
@@ -1685,10 +1692,12 @@ ParseDoDependency(char *line)
}
if (paths) {
Lst_Destroy(paths, NULL);
+ paths = NULL;
}
if (specType == ExPath)
Dir_SetPATH();
} else {
+ assert(paths == NULL);
while (*line) {
/*
* The targets take real sources, so we must beware of archive
@@ -1747,6 +1756,7 @@ ParseDoDependency(char *line)
}
out:
+ assert(paths == NULL);
if (curTargs)
Lst_Destroy(curTargs, NULL);
}
@@ -2550,7 +2560,7 @@ ParseTraditionalInclude(char *line)
if (*file == '\0') {
Parse_Error(PARSE_FATAL,
"Filename missing from \"include\"");
- return;
+ goto out;
}
for (file = all_files; !done; file = cp + 1) {
@@ -2565,6 +2575,7 @@ ParseTraditionalInclude(char *line)
Parse_include_file(file, FALSE, FALSE, silent);
}
+out:
free(all_files);
}
#endif
@@ -2615,6 +2626,7 @@ ParseGmakeExport(char *line)
*/
value = Var_Subst(NULL, value, VAR_CMD, VARF_WANTRES);
setenv(variable, value, 1);
+ free(value);
}
#endif
Modified: vendor/NetBSD/bmake/dist/suff.c
==============================================================================
--- vendor/NetBSD/bmake/dist/suff.c Thu Apr 20 22:30:39 2017 (r317231)
+++ vendor/NetBSD/bmake/dist/suff.c Thu Apr 20 23:12:37 2017 (r317232)
@@ -1,4 +1,4 @@
-/* $NetBSD: suff.c,v 1.84 2016/06/30 05:34:04 dholland Exp $ */
+/* $NetBSD: suff.c,v 1.86 2017/04/16 20:38:18 riastradh Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: suff.c,v 1.84 2016/06/30 05:34:04 dholland Exp $";
+static char rcsid[] = "$NetBSD: suff.c,v 1.86 2017/04/16 20:38:18 riastradh Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94";
#else
-__RCSID("$NetBSD: suff.c,v 1.84 2016/06/30 05:34:04 dholland Exp $");
+__RCSID("$NetBSD: suff.c,v 1.86 2017/04/16 20:38:18 riastradh Exp $");
#endif
#endif /* not lint */
#endif
@@ -135,6 +135,7 @@ __RCSID("$NetBSD: suff.c,v 1.84 2016/06/
* order to find the node.
*/
+#include <assert.h>
#include <stdio.h>
#include "make.h"
#include "hash.h"
@@ -762,12 +763,10 @@ Suff_AddTransform(char *line)
*-----------------------------------------------------------------------
*/
int
-Suff_EndTransform(void *gnp, void *dummy)
+Suff_EndTransform(void *gnp, void *dummy MAKE_ATTR_UNUSED)
{
GNode *gn = (GNode *)gnp;
- (void)dummy;
-
if ((gn->type & OP_DOUBLEDEP) && !Lst_IsEmpty (gn->cohorts))
gn = (GNode *)Lst_Datum(Lst_Last(gn->cohorts));
if ((gn->type & OP_TRANSFORM) && Lst_IsEmpty(gn->commands) &&
@@ -1908,6 +1907,13 @@ SuffFindArchiveDeps(GNode *gn, Lst slst)
eoarch = strchr(gn->name, '(');
eoname = strchr(eoarch, ')');
+ /*
+ * Caller guarantees the format `libname(member)', via
+ * Arch_ParseArchive.
+ */
+ assert(eoarch != NULL);
+ assert(eoname != NULL);
+
*eoname = '\0'; /* Nuke parentheses during suffix search */
*eoarch = '\0'; /* So a suffix can be found */
@@ -2597,23 +2603,20 @@ Suff_End(void)
/********************* DEBUGGING FUNCTIONS **********************/
-static int SuffPrintName(void *s, void *dummy)
+static int SuffPrintName(void *s, void *dummy MAKE_ATTR_UNUSED)
{
- (void)dummy;
fprintf(debug_file, "%s ", ((Suff *)s)->name);
return 0;
}
static int
-SuffPrintSuff(void *sp, void *dummy)
+SuffPrintSuff(void *sp, void *dummy MAKE_ATTR_UNUSED)
{
Suff *s = (Suff *)sp;
int flags;
int flag;
- (void)dummy;
-
fprintf(debug_file, "# `%s' [%d] ", s->name, s->refCount);
flags = s->flags;
@@ -2650,12 +2653,10 @@ SuffPrintSuff(void *sp, void *dummy)
}
static int
-SuffPrintTrans(void *tp, void *dummy)
+SuffPrintTrans(void *tp, void *dummy MAKE_ATTR_UNUSED)
{
GNode *t = (GNode *)tp;
- (void)dummy;
-
fprintf(debug_file, "%-16s: ", t->name);
Targ_PrintType(t->type);
fputc('\n', debug_file);
Modified: vendor/NetBSD/bmake/dist/targ.c
==============================================================================
--- vendor/NetBSD/bmake/dist/targ.c Thu Apr 20 22:30:39 2017 (r317231)
+++ vendor/NetBSD/bmake/dist/targ.c Thu Apr 20 23:12:37 2017 (r317232)
@@ -1,4 +1,4 @@
-/* $NetBSD: targ.c,v 1.61 2016/01/17 17:45:21 christos Exp $ */
+/* $NetBSD: targ.c,v 1.62 2017/04/16 19:53:58 riastradh Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: targ.c,v 1.61 2016/01/17 17:45:21 christos Exp $";
+static char rcsid[] = "$NetBSD: targ.c,v 1.62 2017/04/16 19:53:58 riastradh Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)targ.c 8.2 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: targ.c,v 1.61 2016/01/17 17:45:21 christos Exp $");
+__RCSID("$NetBSD: targ.c,v 1.62 2017/04/16 19:53:58 riastradh Exp $");
#endif
#endif /* not lint */
#endif
@@ -521,10 +521,10 @@ TargPrintName(void *gnp, void *pflags MA
int
-Targ_PrintCmd(void *cmd, void *dummy)
+Targ_PrintCmd(void *cmd, void *dummy MAKE_ATTR_UNUSED)
{
fprintf(debug_file, "\t%s\n", (char *)cmd);
- return (dummy ? 0 : 0);
+ return 0;
}
/*-
Modified: vendor/NetBSD/bmake/dist/var.c
==============================================================================
--- vendor/NetBSD/bmake/dist/var.c Thu Apr 20 22:30:39 2017 (r317231)
+++ vendor/NetBSD/bmake/dist/var.c Thu Apr 20 23:12:37 2017 (r317232)
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.213 2017/02/01 18:39:27 sjg Exp $ */
+/* $NetBSD: var.c,v 1.215 2017/04/16 21:39:49 riastradh Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.213 2017/02/01 18:39:27 sjg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.215 2017/04/16 21:39:49 riastradh 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.213 2017/02/01 18:39:27 sjg Exp $");
+__RCSID("$NetBSD: var.c,v 1.215 2017/04/16 21:39:49 riastradh Exp $");
#endif
#endif /* not lint */
#endif
@@ -1181,7 +1181,7 @@ Var_Value(const char *name, GNode *ctxt,
static Boolean
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-src-all
mailing list