提交 7ea651ba 编写于 作者: K KernelMaker

select: restrict dbnum in [0, 15]

上级 477e9b5f
......@@ -271,6 +271,7 @@ public:
kPurgeExist,
kInvalidParameter,
kWrongNum,
kInvalidIndex,
kErrOther,
};
......@@ -332,6 +333,9 @@ public:
result.append(message_);
result.append("' command\r\n");
break;
case kInvalidIndex:
result = "-ERR invalid DB index\r\n";
break;
case kErrOther:
result = "-ERR ";
result.append(message_);
......
......@@ -268,8 +268,9 @@ void SelectCmd::DoInitial(PikaCmdArgsType &argv, const CmdInfo* const ptr_info)
}
int64_t db_id;
if (!slash::string2l(argv[1].data(), argv[1].size(), &db_id)) {
res_.SetRes(CmdRes::kInvalidInt);
if (!slash::string2l(argv[1].data(), argv[1].size(), &db_id) ||
db_id < 0 || db_id > 15) {
res_.SetRes(CmdRes::kInvalidIndex);
}
}
void SelectCmd::Do() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册