diff options
author | Will Dietz <w@wdtz.org> | 2018-03-01T21·00-0600 |
---|---|---|
committer | Will Dietz <w@wdtz.org> | 2018-03-02T16·52-0600 |
commit | c89a3d536891da84403b025c70f1ae225faa0eb2 (patch) | |
tree | c019b3b8ead8a0c609d9a54db70e27904811863e /src/nix-daemon/nix-daemon.cc | |
parent | 3748a0ca1e9406ff4a701b4f0e1f506c008c4137 (diff) |
don't allocate large buffers on the stack
Diffstat (limited to 'src/nix-daemon/nix-daemon.cc')
-rw-r--r-- | src/nix-daemon/nix-daemon.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/nix-daemon/nix-daemon.cc b/src/nix-daemon/nix-daemon.cc index 890bffa19aa5..c3b94614a879 100644 --- a/src/nix-daemon/nix-daemon.cc +++ b/src/nix-daemon/nix-daemon.cc @@ -37,13 +37,13 @@ using namespace nix; static ssize_t splice(int fd_in, void *off_in, int fd_out, void *off_out, size_t len, unsigned int flags) { /* We ignore most parameters, we just have them for conformance with the linux syscall */ - char buf[8192]; - auto read_count = read(fd_in, buf, sizeof(buf)); + std::vector<char> buf(8192); + auto read_count = read(fd_in, buf.data(), buf.size()); if (read_count == -1) return read_count; auto write_count = decltype(read_count)(0); while (write_count < read_count) { - auto res = write(fd_out, buf + write_count, read_count - write_count); + auto res = write(fd_out, buf.data() + write_count, read_count - write_count); if (res == -1) return res; write_count += res; |