Skip to content

Commit

Permalink
bugfix the integer overflow in RedisAppendLen() (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
Axlgrep authored Jul 30, 2018
1 parent 1daa06d commit dab37ba
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions include/pika_command.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ class CmdInfo {
};

void inline RedisAppendContent(std::string& str, const std::string& value);
void inline RedisAppendLen(std::string& str, int ori, const std::string &prefix);
void inline RedisAppendLen(std::string& str, int64_t ori, const std::string &prefix);

const std::string kNewLine = "\r\n";

Expand Down Expand Up @@ -381,13 +381,13 @@ class CmdRes {
}

// Inline functions for Create Redis protocol
void AppendStringLen(int ori) {
void AppendStringLen(int64_t ori) {
RedisAppendLen(message_, ori, "$");
}
void AppendArrayLen(int ori) {
void AppendArrayLen(int64_t ori) {
RedisAppendLen(message_, ori, "*");
}
void AppendInteger(int ori) {
void AppendInteger(int64_t ori) {
RedisAppendLen(message_, ori, ":");
}
void AppendContent(const std::string &value) {
Expand Down Expand Up @@ -482,7 +482,7 @@ void RedisAppendContent(std::string& str, const std::string& value) {
str.append(kNewLine);
}

void RedisAppendLen(std::string& str, int ori, const std::string &prefix) {
void RedisAppendLen(std::string& str, int64_t ori, const std::string &prefix) {
char buf[32];
slash::ll2string(buf, 32, static_cast<long long>(ori));
str.append(prefix);
Expand Down
2 changes: 1 addition & 1 deletion src/pika_admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,7 @@ void DbsizeCmd::Do() {
res_.SetRes(CmdRes::kErrOther, "keyspace error");
return;
}
int32_t dbsize = key_nums_v[0] + key_nums_v[1] + key_nums_v[2] + key_nums_v[3] + key_nums_v[4];
int64_t dbsize = key_nums_v[0] + key_nums_v[1] + key_nums_v[2] + key_nums_v[3] + key_nums_v[4];
res_.AppendInteger(dbsize);
}

Expand Down
2 changes: 1 addition & 1 deletion third/blackwidow

0 comments on commit dab37ba

Please sign in to comment.