chenBright commented on code in PR #3035:
URL: https://github.com/apache/brpc/pull/3035#discussion_r2222773676


##########
src/brpc/redis_reply.cpp:
##########
@@ -229,9 +233,10 @@ ParseError RedisReply::ConsumePartialIOBuf(butil::IOBuf& 
buf) {
                 _data.array.replies = NULL;
                 return PARSE_OK;
             }
-            if (count > (int64_t)std::numeric_limits<uint32_t>::max()) {
-                LOG(ERROR) << "Too many sub replies! max count=2^32-1,"
-                    " actually=" << count;
+            int64_t array_size = sizeof(RedisReply) * count;

Review Comment:
   Use `array_size` instead of `sizeof(RedisReply) * count` in line 243.



##########
src/brpc/redis_reply.cpp:
##########
@@ -175,9 +179,9 @@ ParseError RedisReply::ConsumePartialIOBuf(butil::IOBuf& 
buf) {
                 _data.integer = 0;
                 return PARSE_OK;
             }
-            if (len > (int64_t)std::numeric_limits<uint32_t>::max()) {
-                LOG(ERROR) << "bulk string is too long! max length=2^32-1,"
-                    " actually=" << len;
+            if (len > FLAGS_redis_max_allocation_size) {
+                LOG(ERROR) << "bulk string exceeds max allocation size! max=" 
+                          << FLAGS_redis_max_allocation_size << ", actually=" 
<< len;

Review Comment:
   Format



##########
src/brpc/redis_command.cpp:
##########
@@ -403,6 +406,12 @@ ParseError RedisCommandParser::Consume(butil::IOBuf& buf,
         return PARSE_ERROR_ABSOLUTELY_WRONG;
     }
     if (!_parsing_array) {
+        if (value > (int64_t)(FLAGS_redis_max_allocation_size / 
sizeof(butil::StringPiece))) {
+            LOG(ERROR) << "command array size exceeds limit! max=" 
+                      << (FLAGS_redis_max_allocation_size / 
sizeof(butil::StringPiece)) 
+                      << ", actually=" << value;

Review Comment:
   Format.



##########
src/brpc/redis_command.cpp:
##########
@@ -417,9 +426,9 @@ ParseError RedisCommandParser::Consume(butil::IOBuf& buf,
         LOG(ERROR) << "string in command is nil!";
         return PARSE_ERROR_ABSOLUTELY_WRONG;
     }
-    if (len > (int64_t)std::numeric_limits<uint32_t>::max()) {
-        LOG(ERROR) << "string in command is too long! max length=2^32-1,"
-            " actually=" << len;
+    if (len > FLAGS_redis_max_allocation_size) {
+        LOG(ERROR) << "command string exceeds max allocation size! max=" 
+                  << FLAGS_redis_max_allocation_size << ", actually=" << len;

Review Comment:
   Format



##########
src/brpc/redis_reply.cpp:
##########
@@ -229,9 +233,10 @@ ParseError RedisReply::ConsumePartialIOBuf(butil::IOBuf& 
buf) {
                 _data.array.replies = NULL;
                 return PARSE_OK;
             }
-            if (count > (int64_t)std::numeric_limits<uint32_t>::max()) {
-                LOG(ERROR) << "Too many sub replies! max count=2^32-1,"
-                    " actually=" << count;
+            int64_t array_size = sizeof(RedisReply) * count;
+            if (array_size > FLAGS_redis_max_allocation_size) {
+                LOG(ERROR) << "array allocation exceeds max allocation size! 
max=" 
+                          << FLAGS_redis_max_allocation_size << ", actually=" 
<< array_size;

Review Comment:
   Format



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org

Reply via email to