Use heap allocated buffer for rpc::ExecFile::execute_object() and increase size to 128Kb.

This commit is contained in:
Silas Mariusz
2026-09-28 10:26:57 +00:00
committed by Jari Sundell
parent 3af0410a6e
commit 66c49d24e5
2 changed files with 6 additions and 3 deletions
+5 -2
View File
@@ -1,5 +1,7 @@
#include "config.h" #include "config.h"
#include <memory>
#include "rpc/exec_file.h" #include "rpc/exec_file.h"
// #include <cassert> // #include <cassert>
@@ -81,8 +83,9 @@ ExecFile::execute_object(const torrent::Object& rawArgs, int flags) {
char* argsBuffer[max_args]; char* argsBuffer[max_args];
char** argsCurrent = argsBuffer; char** argsCurrent = argsBuffer;
// Size of value strings are less than 24. // On the heap: a buffer of buffer_size does not belong on the stack of whichever thread runs the command.
char valueBuffer[buffer_size+1]; auto valueStorage = std::make_unique<char[]>(buffer_size + 1);
char* valueBuffer = valueStorage.get();
char* valueCurrent = valueBuffer; char* valueCurrent = valueBuffer;
if (rawArgs.is_list()) { if (rawArgs.is_list()) {
+1 -1
View File
@@ -10,7 +10,7 @@ namespace rpc {
class ExecFile { class ExecFile {
public: public:
static constexpr unsigned int max_args = 128; 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_expand_tilde = 0x1;
static constexpr int flag_throw = 0x2; static constexpr int flag_throw = 0x2;