Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make After each strsep(&p) check that p is valid.
details: https://anonhg.NetBSD.org/src/rev/82c7b58b9453
branches: trunk
changeset: 766447:82c7b58b9453
user: sjg <sjg%NetBSD.org@localhost>
date: Wed Jun 22 21:13:12 2011 +0000
description:
After each strsep(&p) check that p is valid.
If not the .meta file is corrupted (build interrupted?)
issue a warning and declare target oodate.
diffstat:
usr.bin/make/meta.c | 23 ++++++++++++++++++++---
1 files changed, 20 insertions(+), 3 deletions(-)
diffs (66 lines):
diff -r 0a5d50f56c8e -r 82c7b58b9453 usr.bin/make/meta.c
--- a/usr.bin/make/meta.c Wed Jun 22 20:29:38 2011 +0000
+++ b/usr.bin/make/meta.c Wed Jun 22 21:13:12 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: meta.c,v 1.19 2011/06/11 02:10:48 sjg Exp $ */
+/* $NetBSD: meta.c,v 1.20 2011/06/22 21:13:12 sjg Exp $ */
/*
* Implement 'meta' mode.
@@ -809,6 +809,17 @@
*/
#define LDIR_VNAME_FMT ".meta.%d.ldir"
+/*
+ * It is possible that a .meta file is corrupted,
+ * if we detect this we want to reproduce it.
+ * Setting oodate TRUE will have that effect.
+ */
+#define CHECK_VALID_META(p) if (!(p && *p)) { \
+ warnx("%s: %d: malformed", fname, lineno); \
+ oodate = TRUE; \
+ continue; \
+ }
+
Boolean
meta_oodate(GNode *gn, Boolean oodate)
{
@@ -882,9 +893,11 @@
lineno++;
if (buf[x - 1] == '\n')
buf[x - 1] = '\0';
- else
+ else {
warnx("%s: %d: line truncated at %u", fname, lineno, x);
-
+ oodate = TRUE;
+ break;
+ }
/* Find the start of the build monitor section. */
if (!f) {
if (strncmp(buf, "-- filemon", 10) == 0) {
@@ -940,6 +953,7 @@
* re-initialize 'latestdir' to any pre-saved
* value for the current 'pid' and 'CWD' if none.
*/
+ CHECK_VALID_META(p);
pid = atoi(p);
if (pid > 0 && pid != lastpid) {
char *ldir;
@@ -969,6 +983,8 @@
break;
}
+ CHECK_VALID_META(p);
+
/* Process according to record type. */
switch (buf[0]) {
case 'X': /* eXit */
@@ -1020,6 +1036,7 @@
/* we want the target */
if (strsep(&p, " ") == NULL)
continue;
+ CHECK_VALID_META(p);
/* 'L' and 'M' put single quotes around the args */
if (*p == '\'') {
char *ep;
Home |
Main Index |
Thread Index |
Old Index