Skip to content

Commit 9ff098a

Browse files
committed
For RedisClient exists, make sure no space or tab in key
Signed-off-by: Jipan Yang <jipan.yang@alibaba-inc.com>
1 parent 1fae511 commit 9ff098a

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

common/redisclient.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ int64_t RedisClient::del(const string &key)
2323
bool RedisClient::exists(const string &key)
2424
{
2525
RedisCommand rexists;
26+
if (key.find_first_of(" \t") != string::npos)
27+
{
28+
SWSS_LOG_ERROR("EXISTS failed, invalid space or tab in single key: %s", key.c_str());
29+
throw runtime_error("EXISTS failed, invalid space or tab in single key");
30+
}
2631
rexists.format("EXISTS %s", key.c_str());
2732
RedisReply r(m_db, rexists, REDIS_REPLY_INTEGER);
2833
return (r.getContext()->integer > 0);

0 commit comments

Comments
 (0)