summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2022-01-31 23:41:26 -0800
committerdormando <dormando@rydia.net>2022-02-04 13:56:25 -0800
commitf352f0e062abb2ac957829352a429076d6e30d2d (patch)
treeb5eb6fd29989112c5941fdc93f52302ac8044a9d
parentef7541abd519cc1b8a7adbea41a642832636c6f3 (diff)
downloadmemcached-f352f0e062abb2ac957829352a429076d6e30d2d.tar.gz
proxy: fix re-assembly bug if \r missing
proxy does actually accept requests with "\n" and not "\r\n", so this parser could've read past the end of the input buffer. adding the end token to the parser would fix this better though.
-rw-r--r--proto_proxy.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/proto_proxy.c b/proto_proxy.c
index ccd90f4..67901d0 100644
--- a/proto_proxy.c
+++ b/proto_proxy.c
@@ -988,8 +988,8 @@ void proxy_worker_reload(void *arg, LIBEVENT_THREAD *thr) {
pthread_mutex_unlock(&ctx->worker_lock);
}
-// FIXME: need to test how to recover from an actual error here. stuff gets
-// left on the stack?
+// FIXME (v2): need to test how to recover from an actual error here. error message
+// needs to go somewhere useful, counters added, etc.
static int proxy_thread_loadconf(LIBEVENT_THREAD *thr) {
lua_State *L = thr->L;
// load the precompiled config function.
@@ -1004,7 +1004,7 @@ static int proxy_thread_loadconf(LIBEVENT_THREAD *thr) {
// - pcall the func (which should load it)
int res = lua_pcall(L, 0, LUA_MULTRET, 0);
if (res != LUA_OK) {
- // FIXME: don't exit here!
+ // FIXME (v2): don't exit here!
fprintf(stderr, "Failed to load data into worker thread\n");
return -1;
}
@@ -1259,12 +1259,6 @@ int try_read_command_proxy(conn *c) {
return 0;
}
cont = el + 1;
- // TODO: we don't want to cut the \r\n here. lets see how lua handles
- // non-terminated strings?
- /*if ((el - c->rcurr) > 1 && *(el - 1) == '\r') {
- el--;
- }
- *el = '\0';*/
assert(cont <= (c->rcurr + c->rbytes));
@@ -3600,7 +3594,7 @@ static void mcp_request_attach(lua_State *L, mcp_request_t *rq, io_pending_proxy
or = rq->request + pr->tokens[x];
// will walk past the end without the \r test.
// if we add the end token trick this can be changed.
- while (*or != ' ' && *or != '\r') {
+ while (*or != ' ' && *or != '\r' && *or != '\n') {
*nr = *or;
nr++;
or++;
@@ -3855,7 +3849,6 @@ static int mcplib_jump_hash_new(lua_State *L) {
}
mcplib_jump_hash_t *jh = lua_newuserdatauv(L, sizeof(mcplib_jump_hash_t), 0);
- // TODO: check jh.
// don't need to loop through the table at all, just need its length.
// could optimize startup time by adding hints to the module for how to