Skip to content

Commit a67c2ab

Browse files
authored
fix: reject geosearch count 0 (#5734)
1 parent e1bd960 commit a67c2ab

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/server/geo_family.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,8 @@ void GeoFamily::GeoSearch(CmdArgList args, const CommandContext& cmd_cntx) {
679679
return builder->SendError(kByRadiusBoxErr);
680680
} else if (geo_ops.sorting == Sorting::kError) {
681681
return builder->SendError(kAscDescErr);
682+
} else if (geo_ops.count == 0) {
683+
return builder->SendError(kCountError);
682684
}
683685

684686
geo_ops.count = (geo_ops.count == UINT64_MAX) ? 0 : geo_ops.count;

src/server/geo_family_test.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ TEST_F(GeoFamilyTest, GeoRadiusByMember) {
240240
"ERR STORE option in GEORADIUSBYMEMBER is not compatible with WITHDIST, WITHHASH and WITHCOORDS options"sv;
241241
resp = Run("GEORADIUSBYMEMBER Sicily Agrigento 100 km WITHHASH store tmp");
242242
EXPECT_THAT(resp, ErrArg(err));
243+
244+
resp = Run("GEOADD t 13.361389 38.115556 a 13.3619 38.1159 b 13.3608 38.1152 c");
245+
resp = Run("GEOSEARCH t FROMLONLAT 13.361389 38.115556 BYRADIUS 1 KM COUNT 0");
246+
EXPECT_THAT(resp, ErrArg("ERR COUNT must be > 0"));
243247
}
244248

245249
TEST_F(GeoFamilyTest, GeoRadiusByMemberRO) {

0 commit comments

Comments
 (0)