- match_var: do not address memory at invalid address (`len' can be greater

than strlen(var) + 1)
- ReadMakeFile: prevent `fname' memory leak
- ReadMakeFile: prevent double free (caused by double fclose) --
ParsePopInput() closes input file

Reviewed by:	harti
This commit is contained in:
Max Khon 2005-11-30 20:38:03 +00:00
parent f219c9d3d3
commit 7d81571413
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=152969
2 changed files with 5 additions and 3 deletions

View File

@ -298,8 +298,10 @@ ReadMakefile(const char p[])
name = Path_FindFile(fname, &parseIncPath);
if (!name)
name = Path_FindFile(fname, &sysIncPath);
if (!name || !(stream = fopen(name, "r")))
if (!name || !(stream = fopen(name, "r"))) {
free(fname);
return (FALSE);
}
MAKEFILE = fname = name;
/*
* set the MAKEFILE variable desired by System V fans -- the
@ -310,8 +312,8 @@ ReadMakefile(const char p[])
if (setMAKEFILE)
Var_SetGlobal("MAKEFILE", MAKEFILE);
Parse_File(fname, stream);
fclose(stream);
}
free(fname);
return (TRUE);
}

View File

@ -2246,7 +2246,7 @@ match_var(const char str[], const char var[])
str[0] == CLOSE_BRACE) {
len = str - (start + 2);
if (var[len] == '\0' && strncmp(var, start + 2, len) == 0) {
if (strncmp(var, start + 2, len) == 0 && var[len] == '\0') {
return (0); /* match */
} else {
/*