Copilot commented on code in PR #3404:
URL: https://github.com/apache/brpc/pull/3404#discussion_r3637656996


##########
src/brpc/redis_reply.cpp:
##########
@@ -141,6 +141,11 @@ ParseError RedisReply::ConsumePartialIOBuf(butil::IOBuf& 
buf, int depth) {
             return PARSE_ERROR_NOT_ENOUGH_DATA;
         }
         const size_t len = str.size() - 1;
+        if (len > (size_t)FLAGS_redis_max_allocation_size) {
+            LOG(ERROR) << "simple string exceeds max allocation size! max="
+                       << FLAGS_redis_max_allocation_size << ", actually=" << 
len;
+            return PARSE_ERROR_ABSOLUTELY_WRONG;
+        }

Review Comment:
   The new max-allocation check casts FLAGS_redis_max_allocation_size (int32) 
to size_t. If the flag is ever set to a negative value, the cast becomes a huge 
size_t and effectively disables the cap for simple/error strings, which is 
inconsistent with the bulk-string branch (where a negative flag would reject 
all lengths). Add an explicit negative check before the cast to keep behavior 
consistent and avoid accidental cap bypass.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to