diff options
author | eldritch horrors <pennae@lix.systems> | 2024-03-04 05:51:23 +0100 |
---|---|---|
committer | eldritch horrors <pennae@lix.systems> | 2024-03-04 05:51:23 +0100 |
commit | 5e182235cb7e7b601c5e010c298bf17415113ce0 (patch) | |
tree | d7dcfb54efbb5277184e0fcda9aa169b75e771ea /src/libstore/gc.cc | |
parent | 30f3298e9dafa3bc4422c29dad972e320ad70e01 (diff) |
Merge pull request #7348 from thufschmitt/dont-use-vlas
Remove the usage of VLAs in the code
(cherry picked from commit ac4431e9d016e62fb5dc9ae36833bd0c6cdadeec)
Change-Id: Ifbf5fbfc2e27122362a2aaea4b62c7cf3ca46b1a
Diffstat (limited to 'src/libstore/gc.cc')
-rw-r--r-- | src/libstore/gc.cc | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc index 516cbef83..7c7273012 100644 --- a/src/libstore/gc.cc +++ b/src/libstore/gc.cc @@ -323,9 +323,7 @@ typedef std::unordered_map<Path, std::unordered_set<std::string>> UncheckedRoots static void readProcLink(const std::string & file, UncheckedRoots & roots) { - /* 64 is the starting buffer size gnu readlink uses... */ - auto bufsiz = ssize_t{64}; -try_again: + constexpr auto bufsiz = PATH_MAX; char buf[bufsiz]; auto res = readlink(file.c_str(), buf, bufsiz); if (res == -1) { @@ -334,10 +332,7 @@ try_again: throw SysError("reading symlink"); } if (res == bufsiz) { - if (SSIZE_MAX / 2 < bufsiz) - throw Error("stupidly long symlink"); - bufsiz *= 2; - goto try_again; + throw Error("overly long symlink starting with '%1%'", std::string_view(buf, bufsiz)); } if (res > 0 && buf[0] == '/') roots[std::string(static_cast<char *>(buf), res)] |