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


##########
src/brpc/redis_reply.cpp:
##########
@@ -141,6 +141,12 @@ ParseError RedisReply::ConsumePartialIOBuf(butil::IOBuf& 
buf, int depth) {
             return PARSE_ERROR_NOT_ENOUGH_DATA;
         }
         const size_t len = str.size() - 1;
+        if (FLAGS_redis_max_allocation_size < 0 ||
+            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:
   Good point. I now enforce the cap in the waiting-for-CRLF path too, so a 
peer that never sends the terminator can't grow buf past the limit (only up to 
the 2^32 hard bound before). Kept a one-byte '\r' allowance so a boundary CRLF 
split isn't rejected, matching how RedisCommandParser handles inline commands. 
Added an over-limit-before-CRLF test and a boundary-split test alongside the 
existing ones.



-- 
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