Skip to content

Commit

Permalink
proxy: don't allow mutating mutated objects
Browse files Browse the repository at this point in the history
  • Loading branch information
dormando committed Oct 30, 2024
1 parent e887658 commit 8cfaf31
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions proxy_mutator.c
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 8cfaf31

Please sign in to comment.