Skip to content

Commit a738db4

Browse files
authored
chore: Strict bounds when adding uknown command for INFO ALL stats (#5735)
Currently we allow 1024 uknown command with max length of 4096 characters to be stored in temporary vector. Create more strict rule that allows only 64 entries with max length of 20 chars. Closes #5732
1 parent 188081d commit a738db4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/server/main_service.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1805,8 +1805,11 @@ void Service::DispatchMC(const MemcacheParser::Command& cmd, std::string_view va
18051805
}
18061806

18071807
ErrorReply Service::ReportUnknownCmd(string_view cmd_name) {
1808+
constexpr uint8_t kMaxUknownCommands = 64;
1809+
constexpr uint8_t kMaxUknownCommandLength = 20;
1810+
18081811
lock_guard lk(mu_);
1809-
if (unknown_cmds_.size() < 1024)
1812+
if (unknown_cmds_.size() <= kMaxUknownCommands && cmd_name.size() <= kMaxUknownCommandLength)
18101813
unknown_cmds_[cmd_name]++;
18111814

18121815
return ErrorReply{StrCat("unknown command `", cmd_name, "`"), "unknown_cmd"};

0 commit comments

Comments
 (0)