1
0
Fork 0
mirror of https://github.com/dragonflydb/dragonfly.git synced 2024-12-14 11:58:02 +00:00

fix(cluster): Fix crash when getting DFLYCLUSTER GETSLOTINFO with no other args. (#1351)

This commit is contained in:
Chaka 2023-06-05 06:42:00 +03:00 committed by GitHub
parent 9ab70e4f15
commit 7dcdeee1bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -434,7 +434,7 @@ void ClusterFamily::DflyClusterConfig(CmdArgList args, ConnectionContext* cntx)
}
void ClusterFamily::DflyClusterGetSlotInfo(CmdArgList args, ConnectionContext* cntx) {
if (args.size() == 2) {
if (args.size() <= 2) {
return (*cntx)->SendError(facade::WrongNumArgsError("DFLYCLUSTER GETSLOTINFO"), kSyntaxErrType);
}
ToUpper(&args[1]);

View file

@ -430,6 +430,14 @@ TEST_F(ClusterFamilyTest, ClusterConfigFullMultipleInstances) {
}
}
TEST_F(ClusterFamilyTest, ClusterGetSlotInfoInvalid) {
constexpr string_view kTooFewArgs =
"ERR wrong number of arguments for 'dflycluster getslotinfo' command";
EXPECT_THAT(RunAdmin({"dflycluster", "getslotinfo"}), ErrArg(kTooFewArgs));
EXPECT_THAT(RunAdmin({"dflycluster", "getslotinfo", "s"}), ErrArg(kTooFewArgs));
EXPECT_THAT(RunAdmin({"dflycluster", "getslotinfo", "slots"}), ErrArg(kTooFewArgs));
}
TEST_F(ClusterFamilyTest, ClusterGetSlotInfo) {
string config_template = R"json(
[