This is an automated email from the ASF dual-hosted git repository.

gavinchou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new a1910e45de2 [fix](be) Validate stream load content length before group 
commit (#62110)
a1910e45de2 is described below

commit a1910e45de2dde9ce8979edaab56569a4dff913e
Author: Xin Liao <[email protected]>
AuthorDate: Fri Apr 17 18:02:27 2026 +0800

    [fix](be) Validate stream load content length before group commit (#62110)
    
    Group commit pre-check parsed Content-Length before the normal request 
validation path, so malformed values could escape the expected InvalidArgument 
handling.
    
    - Add try/catch around Content-Length parsing in _can_group_commit() to 
return Status::InvalidArgument on malformed values.
    - Preserve existing negative-length handling while preventing std::stoll 
exceptions from escaping.
    - Cache the Content-Length header while validating group commit requests to 
avoid repeated lookups.
---
 be/src/service/http/action/stream_load.cpp | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/be/src/service/http/action/stream_load.cpp 
b/be/src/service/http/action/stream_load.cpp
index 5570c53c6b1..5d9cf40aea7 100644
--- a/be/src/service/http/action/stream_load.cpp
+++ b/be/src/service/http/action/stream_load.cpp
@@ -915,9 +915,16 @@ Status StreamLoadAction::_check_wal_space(const 
std::string& group_commit_mode,
 Status StreamLoadAction::_can_group_commit(HttpRequest* req, 
std::shared_ptr<StreamLoadContext> ctx,
                                            std::string& group_commit_header,
                                            bool& can_group_commit) {
-    int64_t content_length = req->header(HttpHeaders::CONTENT_LENGTH).empty()
-                                     ? 0
-                                     : 
std::stoll(req->header(HttpHeaders::CONTENT_LENGTH));
+    int64_t content_length = 0;
+    const auto& content_length_str = req->header(HttpHeaders::CONTENT_LENGTH);
+    if (!content_length_str.empty()) {
+        try {
+            content_length = std::stoll(content_length_str);
+        } catch (const std::exception& e) {
+            return Status::InvalidArgument("invalid HTTP header 
CONTENT_LENGTH={}: {}",
+                                           content_length_str, e.what());
+        }
+    }
     if (content_length < 0) {
         std::stringstream ss;
         ss << "This stream load content length <0 (" << content_length


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

Reply via email to