if (c->multibulklen <= 0) {
c->querybuf = sdsrange(c->querybuf,pos,-1);
return REDIS_OK;
+ } else if (c->multibulklen > 1024*1024) {
+ addReplyError(c,"Protocol error: invalid multibulk length");
+ setProtocolError(c,pos);
+ return REDIS_ERR;
}
/* Setup argv array on client structure */
}
/* Multibulk processing could see a <= 0 length. */
- if (c->argc > 0)
- processCommand(c);
- resetClient(c);
+ if (c->argc == 0) {
+ resetClient(c);
+ } else {
+ /* Only reset the client when the command was executed. */
+ if (processCommand(c) == REDIS_OK)
+ resetClient(c);
+ }
}
}