diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2018-03-22 13:19:25 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2018-03-22 13:19:25 +0100 |
commit | f87e286e82f37c3746ba62ba5503db90277eeb6e (patch) | |
tree | 627a0914bf495a43969a3448d0a05049a5b078ea /src/libutil/hash.cc | |
parent | 92aee1b7d69adc9552dc0efae9d030e02aa2f353 (diff) | |
parent | 6b9a03f5d878ae434b54bb883b51e28082dc30b3 (diff) |
Merge branch 'fix/avoid-large-stack-buffers' of https://github.com/dtzWill/nix
Diffstat (limited to 'src/libutil/hash.cc')
-rw-r--r-- | src/libutil/hash.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libutil/hash.cc b/src/libutil/hash.cc index 150995f55..a01d651e1 100644 --- a/src/libutil/hash.cc +++ b/src/libutil/hash.cc @@ -257,12 +257,12 @@ Hash hashFile(HashType ht, const Path & path) AutoCloseFD fd = open(path.c_str(), O_RDONLY | O_CLOEXEC); if (!fd) throw SysError(format("opening file '%1%'") % path); - unsigned char buf[8192]; + std::vector<unsigned char> buf(8192); ssize_t n; - while ((n = read(fd.get(), buf, sizeof(buf)))) { + while ((n = read(fd.get(), buf.data(), buf.size()))) { checkInterrupt(); if (n == -1) throw SysError(format("reading file '%1%'") % path); - update(ht, ctx, buf, n); + update(ht, ctx, buf.data(), n); } finish(ht, ctx, hash.hash); |