Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: Some unfin conditions are not properly handled #151

Merged
merged 3 commits into from
Apr 14, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/protocol/data/redis/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,26 @@ parse_req(struct request *req, struct buf *buf)
}
status = token_array_nelem(&nelem, buf);
if (status != PARSE_OK) {
log_verb("getting array size returns status %d", status);
buf->rpos = old_rpos;
return status;
} else {
log_verb("array size is %"PRId64, nelem);
}

if (nelem < 1 || nelem > req->token->nalloc) {
log_debug("parse req: invalid array size, %d not in [1, %"PRIu32"]",
nelem, req->token->nalloc);
return PARSE_EINVALID;
}


/* parse elements */
while (nelem > 0) {
if (buf_rsize(buf) == 0) {
buf->rpos = old_rpos;
return PARSE_EUNFIN;
}
el = array_push(req->token);
status = parse_element(el, buf);
if (status != PARSE_OK) {
Expand Down
2 changes: 1 addition & 1 deletion src/protocol/data/redis/response.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ typedef struct {
* - a dummy entry RSP_UNKNOWN so we can use it as the initial type value;
* - a RSP_NUMERIC type that doesn't have a corresponding message body.
*/
#define RSP_STR_OK "+OK\r\n"
#define RSP_STR_OK "OK"

/*
* NOTE(yao): we store fields as location in rbuf, this assumes the data will
Expand Down