From e887658d74d0a21eb038ff0d38e8aa8250365a4e Mon Sep 17 00:00:00 2001 From: dormando Date: Wed, 30 Oct 2024 13:31:44 -0700 Subject: [PATCH] proxy: fix for result value buffers wasn't malloc'ing space for a value to copy into a result object. we still can't copy a value from a result object, which prevents us from creating new requests from a response or a response from a response, but that will happen after upstream mcmc fixes. --- proxy_mutator.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/proxy_mutator.c b/proxy_mutator.c index ab4a2ef2e..e3ffe3dc4 100644 --- a/proxy_mutator.c +++ b/proxy_mutator.c @@ -947,6 +947,10 @@ static int mcp_mut_run(struct mcp_mut_run *run) { struct mcp_mut_part parts[mut->scount]; // first accumulate the length tally + // FIXME: noticed off-by-one's sometimes. + // maybe add a debug assert to verify the written total (d_pos - etc) + // matches total? + // This isn't critical so long as total is > actual, which it has been int total = _mcp_mut_run_total(run, parts); if (total < 0) { lua_pushboolean(run->L, 0); @@ -986,7 +990,9 @@ static int mcp_mut_run(struct mcp_mut_run *run) { } else { mcp_resp_t *rs = run->arg; - rs->buf = malloc(total); + // value is inlined in result buffers. future intention to allow more + // complex objects so we can refcount values. + rs->buf = malloc(total + run->vlen); if (rs->buf == NULL) { proxy_lua_error(run->L, "mutator: failed to allocate result buffer"); return 0;