Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make Fix use after free bug.
details: https://anonhg.NetBSD.org/src/rev/1834b47a1f96
branches: trunk
changeset: 787451:1834b47a1f96
user: sjg <sjg%NetBSD.org@localhost>
date: Tue Jun 18 19:31:27 2013 +0000
description:
Fix use after free bug.
Parse_SetInput:
curFile->fname was using the buffer passed to it - which ReadMakefile frees.
This change makes the comment in ParseEOF about leaking curFile->fname true.
diffstat:
usr.bin/make/parse.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diffs (53 lines):
diff -r e50c6f02ac70 -r 1834b47a1f96 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c Tue Jun 18 18:18:57 2013 +0000
+++ b/usr.bin/make/parse.c Tue Jun 18 19:31:27 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.188 2013/03/22 16:07:59 sjg Exp $ */
+/* $NetBSD: parse.c,v 1.189 2013/06/18 19:31:27 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.188 2013/03/22 16:07:59 sjg Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.189 2013/06/18 19:31:27 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.188 2013/03/22 16:07:59 sjg Exp $");
+__RCSID("$NetBSD: parse.c,v 1.189 2013/06/18 19:31:27 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -154,7 +154,7 @@
* Structure for a file being read ("included file")
*/
typedef struct IFile {
- const char *fname; /* name of file */
+ char *fname; /* name of file */
int lineno; /* current line number in file */
int first_lineno; /* line number of start of text */
int cond_depth; /* 'if' nesting when file opened */
@@ -2334,7 +2334,7 @@
* name of the include file so error messages refer to the right
* place.
*/
- curFile->fname = name;
+ curFile->fname = bmake_strdup(name);
curFile->lineno = line;
curFile->first_lineno = line;
curFile->nextbuf = nextbuf;
@@ -2347,6 +2347,8 @@
buf = curFile->nextbuf(curFile->nextbuf_arg, &len);
if (buf == NULL) {
/* Was all a waste of time ... */
+ if (curFile->fname)
+ free(curFile->fname);
free(curFile);
return;
}
Home |
Main Index |
Thread Index |
Old Index