From c3f433b86bb0a90e96a1f50d356e3e77c2e26f3b Mon Sep 17 00:00:00 2001 From: kukey Date: Sun, 26 Sep 2021 23:44:56 +0800 Subject: [PATCH] fix parse eval on SW_ARG2 calculate r->rlen error (#654) Update src/proto/nc_redis.c Co-authored-by: Tyson Andre --- src/proto/nc_redis.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/proto/nc_redis.c b/src/proto/nc_redis.c index a5ea210..a80f84a 100644 --- a/src/proto/nc_redis.c +++ b/src/proto/nc_redis.c @@ -1633,7 +1633,19 @@ redis_parse_req(struct msg *r) m = p + r->rlen; if (m >= b->last) { - r->rlen -= (uint32_t)(b->last - p); + /* + * For EVAL/EVALHASH, the r->token has been assigned a value. When + * m >= b->last happens will need to repair mbuf. + * + * At the end of redis_parse_req, r->token will be used to choose + * the start (p) for the next call to redis_parse_req and clear + * r->token when repairing this and adding more data. + * + * So, only when r->token == NULL we need to calculate r->rlen again. + */ + if (r->token == NULL) { + r->rlen -= (uint32_t)(b->last - p); + } m = b->last - 1; p = m; break; -- GitLab