Skip to content

Commit

Permalink
[fix](multi table) do not use strlen to calculate the length of msg (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
sollhui authored Sep 5, 2024
1 parent 34f04ee commit ed37c81
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion be/src/io/fs/multi_table_pipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down

0 comments on commit ed37c81

Please sign in to comment.