From 66c49d24e50e05f28ae02e1b9a2f4bc7b945e605 Mon Sep 17 00:00:00 2001 From: Silas Mariusz Date: Mon, 28 Sep 2026 10:26:57 +0000 Subject: [PATCH] Use heap allocated buffer for rpc::ExecFile::execute_object() and increase size to 128Kb. --- src/rpc/exec_file.cc | 7 +++++-- src/rpc/exec_file.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/rpc/exec_file.cc b/src/rpc/exec_file.cc index 114922de..0b45fb3d 100644 --- a/src/rpc/exec_file.cc +++ b/src/rpc/exec_file.cc @@ -1,5 +1,7 @@ #include "config.h" +#include + #include "rpc/exec_file.h" // #include @@ -81,8 +83,9 @@ ExecFile::execute_object(const torrent::Object& rawArgs, int flags) { char* argsBuffer[max_args]; char** argsCurrent = argsBuffer; - // Size of value strings are less than 24. - char valueBuffer[buffer_size+1]; + // On the heap: a buffer of buffer_size does not belong on the stack of whichever thread runs the command. + auto valueStorage = std::make_unique(buffer_size + 1); + char* valueBuffer = valueStorage.get(); char* valueCurrent = valueBuffer; if (rawArgs.is_list()) { diff --git a/src/rpc/exec_file.h b/src/rpc/exec_file.h index 2a60578d..58696c3e 100644 --- a/src/rpc/exec_file.h +++ b/src/rpc/exec_file.h @@ -10,7 +10,7 @@ namespace rpc { class ExecFile { public: static constexpr unsigned int max_args = 128; - static constexpr unsigned int buffer_size = 4096; + static constexpr unsigned int buffer_size = 128 * 1024; static constexpr int flag_expand_tilde = 0x1; static constexpr int flag_throw = 0x2;