1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-29 02:11:15 +02:00

Merge branch 'fix/avoid-large-stack-buffers' of https://github.com/dtzWill/nix

This commit is contained in:
Eelco Dolstra 2018-03-22 13:19:25 +01:00
commit f87e286e82
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
5 changed files with 27 additions and 26 deletions

View file

@ -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);