readFile: Check against nul bytes
This commit is contained in:
parent
feca5cb67f
commit
1c88e100e7
1 changed files with 4 additions and 1 deletions
|
@ -749,7 +749,10 @@ static void prim_readFile(EvalState & state, const Pos & pos, Value * * args, Va
|
|||
throw EvalError(format("cannot read ‘%1%’, since path ‘%2%’ is not valid, at %3%")
|
||||
% path % e.path % pos);
|
||||
}
|
||||
mkString(v, readFile(state.checkSourcePath(path)).c_str());
|
||||
string s = readFile(state.checkSourcePath(path));
|
||||
if (s.find((char) 0) != string::npos)
|
||||
throw Error(format("the contents of the file ‘%1%’ cannot be represented as a Nix string") % path);
|
||||
mkString(v, s.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue