diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2019-12-15 00:22:35 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2019-12-15 00:22:35 +0100 |
commit | 2b0365753a3a0340554f1d722e80693220e892c4 (patch) | |
tree | 07297f5a3b2498d17ef125c0ad5d38fa44d76e1b /src/libexpr/parser.y | |
parent | 8656a2de56e53a1fd8f2548a7520248ce254ad42 (diff) | |
parent | d89d9958a771fb6299eae084c1b52d0ecf95901b (diff) |
Merge branch 'limit_depth_resolveExprPath' of https://github.com/d-goldin/nix
Diffstat (limited to 'src/libexpr/parser.y')
-rw-r--r-- | src/libexpr/parser.y | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index 10a057062..df55986f6 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -576,10 +576,15 @@ Path resolveExprPath(Path path) { assert(path[0] == '/'); + unsigned int followCount = 0, maxFollow = 1024; + /* If `path' is a symlink, follow it. This is so that relative path references work. */ struct stat st; while (true) { + // Basic cycle/depth limit to avoid infinite loops. + if (++followCount >= maxFollow) + throw Error(format("can't resolve expression. infinite symlink recursion in path '%1%'") % path); if (lstat(path.c_str(), &st)) throw SysError(format("getting status of '%1%'") % path); if (!S_ISLNK(st.st_mode)) break; |