From 8cfaf3107c55625f7517818eb491b1d3bfd38b32 Mon Sep 17 00:00:00 2001 From: dormando Date: Wed, 30 Oct 2024 13:38:19 -0700 Subject: [PATCH] proxy: don't allow mutating mutated objects --- proxy_mutator.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/proxy_mutator.c b/proxy_mutator.c index e3ffe3dc4..cd1220d8a 100644 --- a/proxy_mutator.c +++ b/proxy_mutator.c @@ -960,6 +960,12 @@ static int mcp_mut_run(struct mcp_mut_run *run) { // ensure space and/or allocate memory then seed our destination pointer. if (mut->type == MUT_REQ) { mcp_request_t *rq = run->arg; + if (rq->pr.vbuf) { + // FIXME: maybe NULL rq->pr.request in cleanup phase and test that + // instead? this check will only fire if req had a vbuf. + proxy_lua_error(run->L, "mutator: request has already been rendered"); + return 0; + } // future.. should be able to dynamically assign request buffer. if (total > MCP_REQUEST_MAXLEN) { proxy_lua_error(run->L, "mutator: new request is too long"); @@ -989,6 +995,10 @@ static int mcp_mut_run(struct mcp_mut_run *run) { } } else { mcp_resp_t *rs = run->arg; + if (rs->buf) { + proxy_lua_error(run->L, "mutator: result has already been rendered"); + return 0; + } // value is inlined in result buffers. future intention to allow more // complex objects so we can refcount values.