diff --git a/src/server/rds/data/cmd_sarray.c b/src/server/rds/data/cmd_sarray.c index c1ba0424f..d277a1ef7 100644 --- a/src/server/rds/data/cmd_sarray.c +++ b/src/server/rds/data/cmd_sarray.c @@ -89,7 +89,7 @@ cmd_sarray_create(struct response *rsp, const struct request *req, item_rstatus_e istatus; uint32_t ntoken; bool bounded; - int64_t esize, low, high; + uint64_t esize, low, high; ntoken = array_nelem(req->token); ASSERT(ntoken >= cmd->narg); @@ -102,7 +102,7 @@ cmd_sarray_create(struct response *rsp, const struct request *req, return; } - if (!req_get_int(&esize, req, SARRAY_ESIZE)) { + if (!req_get_uint(&esize, req, SARRAY_ESIZE)) { compose_rsp_client_err(rsp, reply, cmd, key); INCR(process_metrics, sarray_create_ex); @@ -118,8 +118,8 @@ cmd_sarray_create(struct response *rsp, const struct request *req, } /* get low & high watermarks */ - if (cmd->nopt > 0 && (!req_get_int(&low, req, SARRAY_WML) || - !req_get_int(&high, req, SARRAY_WMH))) { + if (cmd->nopt > 0 && (!req_get_uint(&low, req, SARRAY_WML) || + !req_get_uint(&high, req, SARRAY_WMH))) { compose_rsp_client_err(rsp, reply, cmd, key); INCR(process_metrics, sarray_create_ex); @@ -225,7 +225,7 @@ cmd_sarray_find(struct response *rsp, const struct request *req, const struct struct bstring *key = &null_key; struct item *it; uint32_t idx; - int64_t val; + uint64_t val; sarray_rstatus_e status; ASSERT(array_nelem(req->token) == cmd->narg); @@ -238,7 +238,7 @@ cmd_sarray_find(struct response *rsp, const struct request *req, const struct return; } - if (!req_get_int(&val, req, SARRAY_VAL)) { + if (!req_get_uint(&val, req, SARRAY_VAL)) { compose_rsp_client_err(rsp, reply, cmd, key); INCR(process_metrics, sarray_find_ex); @@ -372,7 +372,8 @@ cmd_sarray_insert(struct response *rsp, const struct request *req, const struct struct bstring *key = &null_key; struct item *it; uint32_t nval = 0, esize; - int64_t delta, val, wml, wmh, nentry, ninserted = 0; + int64_t delta, wml, wmh, nentry, ninserted = 0; + uint64_t val; sarray_p sa; sarray_rstatus_e status; @@ -397,13 +398,14 @@ cmd_sarray_insert(struct response *rsp, const struct request *req, const struct /* parse and store all values to be inserted in array vals */ for (uint32_t i = SARRAY_VAL; i < array_nelem(req->token); ++i, ++nval) { - if (!req_get_int(&val, req, i)) { + if (!req_get_uint(&val, req, i)) { + log_debug("the value at offset %"PRIu32" is invalid", i); compose_rsp_client_err(rsp, reply, cmd, key); INCR(process_metrics, sarray_insert_ex); return; } else { - vals[nval] = (uint64_t)val; + vals[nval] = val; } } @@ -442,6 +444,7 @@ cmd_sarray_insert(struct response *rsp, const struct request *req, const struct for (uint32_t i = 0; i < nval; ++i) { status = sarray_insert(sa, vals[i]); if (status == SARRAY_EINVALID) { + log_debug("value %"PRIu32" out of %"PRIu32" is invalid", i, nval); compose_rsp_client_err(rsp, reply, cmd, key); INCR(process_metrics, sarray_insert_ex); return; @@ -530,6 +533,7 @@ cmd_sarray_remove(struct response *rsp, const struct request *req, const struct break; case SARRAY_EINVALID: /* client error, bad argument */ + log_debug("value %"PRIu32" out of %"PRIu32" is invalid", i, nval); compose_rsp_client_err(rsp, reply, cmd, key); INCR(process_metrics, sarray_remove_ex); diff --git a/src/server/rds/data/shared.h b/src/server/rds/data/shared.h index 5b28ccda6..531ba0d5f 100644 --- a/src/server/rds/data/shared.h +++ b/src/server/rds/data/shared.h @@ -127,3 +127,19 @@ req_get_int(int64_t *i, const struct request *req, uint32_t offset) return true; } + +static inline bool +req_get_uint(uint64_t *u, const struct request *req, uint32_t offset) +{ + struct bstring *bstr; + + if (!req_get_bstr(&bstr, req, offset)) { + return false; + } + + if (bstring_atou64(u, bstr) != CC_OK) { + return false; + } + + return true; +}