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

yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new 1c91fbc167e [fix](multi table) do not use strlen to calculate the 
length of msg (#40367) (#40511)
1c91fbc167e is described below

commit 1c91fbc167ee25df26d829175bd1d3b1e747c66a
Author: hui lai <1353307...@qq.com>
AuthorDate: Mon Sep 9 10:35:59 2024 +0800

    [fix](multi table) do not use strlen to calculate the length of msg 
(#40367) (#40511)
    
    pick #40367
    
    Meet code dump when using single stream multi table load:
    ```
    SUMMARY: AddressSanitizer: heap-buffer-overflow 
/root/doris/be/src/io/fs/multi_table_pipe.cpp:99:22 in 
doris::io::MultiTablePipe::dispatch(std::__cxx11::basic_string<char, 
std::char_traits<char>, std::allocator<char>> const&, char const*, unsigned 
long, doris::Status (doris::io::KafkaConsumerPipe::*)(char const*, unsigned 
long))
    ```
    
    1. It is hard to guaranteed that msg is a C-style string ending in '\0'
    character. If not, it may cause the core dump to access memory out of
    bounds.
    2. It is not need to calculate the length of msg twice.
    
    Therefore, deleting the logic that using strlen to calculate the length
    of msg.
---
 be/src/io/fs/multi_table_pipe.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/be/src/io/fs/multi_table_pipe.cpp 
b/be/src/io/fs/multi_table_pipe.cpp
index 75fd05f2ef8..be77b3685fc 100644
--- a/be/src/io/fs/multi_table_pipe.cpp
+++ b/be/src/io/fs/multi_table_pipe.cpp
@@ -96,7 +96,7 @@ std::string MultiTablePipe::parse_dst_table(const char* data, 
size_t size) {
 
 Status MultiTablePipe::dispatch(const std::string& table, const char* data, 
size_t size,
                                 AppendFunc cb) {
-    if (size == 0 || strlen(data) == 0) {
+    if (size == 0) {
         LOG(WARNING) << "empty data for table: " << table << ", ctx: " << 
_ctx->brief();
         return Status::InternalError("empty data");
     }


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

Reply via email to