libexpr: fix stack overflow in checkMeta on deeply nested structures
This commit is contained in:
@@ -213,6 +213,8 @@ StringSet PackageInfo::queryMetaNames()
|
||||
|
||||
bool PackageInfo::checkMeta(Value & v)
|
||||
{
|
||||
auto _level = state->addCallDepth(v.determinePos(noPos));
|
||||
|
||||
state->forceValue(v, v.determinePos(noPos));
|
||||
if (v.type() == nList) {
|
||||
for (auto elem : v.listView())
|
||||
|
||||
@@ -40,3 +40,9 @@ fi
|
||||
# produces a controlled stack overflow error rather than a segfault.
|
||||
expectStderr 1 nix-instantiate --expr 'let x = { recurseForDerivations = true; more = x; }; in x' \
|
||||
| grepQuiet "stack overflow; max-call-depth exceeded"
|
||||
|
||||
# Test that nix-env -qa --meta on deeply nested meta attributes produces a
|
||||
# controlled stack overflow error rather than a segfault.
|
||||
echo 'let f = n: { type = "derivation"; name = "test"; system = "x86_64-linux"; meta.nested = f (n + 1); }; in { pkg = f 0; }' > "$TEST_ROOT/deep-meta.nix"
|
||||
expectStderr 1 nix-env -qa -f "$TEST_ROOT/deep-meta.nix" --json --meta \
|
||||
| grepQuiet "stack overflow; max-call-depth exceeded"
|
||||
|
||||
Reference in New Issue
Block a user