aboutsummaryrefslogtreecommitdiff
path: root/src/libstore
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2022-01-24 12:05:30 +0100
committerGitHub <noreply@github.com>2022-01-24 12:05:30 +0100
commit076945c80815323658f02ef5e04a9c0e9f638d1c (patch)
treecd9e33783e1e8745d522e25309457cdbb6f6cd1f /src/libstore
parentc9a4ddb9c0a7d15c29d904a017d4d5d58492fdfd (diff)
parent0407436b0f15900399d11da43178cd09fddba0af (diff)
Merge pull request #5875 from hercules-ci/fix-large-drv-field-stack-overflow
Fix segfault or stack overflow caused by large derivation fields
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/derivations.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc
index b926bb711..3e3d50144 100644
--- a/src/libstore/derivations.cc
+++ b/src/libstore/derivations.cc
@@ -4,6 +4,7 @@
#include "util.hh"
#include "worker-protocol.hh"
#include "fs-accessor.hh"
+#include <boost/container/small_vector.hpp>
namespace nix {
@@ -272,7 +273,9 @@ Derivation parseDerivation(const Store & store, std::string && s, std::string_vi
static void printString(string & res, std::string_view s)
{
- char buf[s.size() * 2 + 2];
+ boost::container::small_vector<char, 64 * 1024> buffer;
+ buffer.reserve(s.size() * 2 + 2);
+ char * buf = buffer.data();
char * p = buf;
*p++ = '"';
for (auto c : s)