aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/hash.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2018-03-22 13:19:25 +0100
committerEelco Dolstra <edolstra@gmail.com>2018-03-22 13:19:25 +0100
commitf87e286e82f37c3746ba62ba5503db90277eeb6e (patch)
tree627a0914bf495a43969a3448d0a05049a5b078ea /src/libutil/hash.cc
parent92aee1b7d69adc9552dc0efae9d030e02aa2f353 (diff)
parent6b9a03f5d878ae434b54bb883b51e28082dc30b3 (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.cc6
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);