This is an automated email from the ASF dual-hosted git repository. yangzhg pushed a commit to branch branch-1.2-lts in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-1.2-lts by this push: new 9b49b2e856 [chore](vulnerability) fix some high risk vulnerabilities report by bug scanner (#15621) 9b49b2e856 is described below commit 9b49b2e856a76a2b0bc637608092d7179a2980ca Author: Zhengguo Yang <yangz...@gmail.com> AuthorDate: Thu Jan 5 14:58:23 2023 +0800 [chore](vulnerability) fix some high risk vulnerabilities report by bug scanner (#15621) * [chore](vulnerability) fix some high risk vulnerabilities report by bug scanner --- be/src/exprs/aggregate_functions.cpp | 4 +++- be/src/olap/storage_policy_mgr.cpp | 9 ++++++--- be/src/olap/utils.cpp | 10 ++++++++-- be/src/runtime/plan_fragment_executor.cpp | 4 +++- be/src/vec/exec/vmysql_scan_node.cpp | 21 ++++++++++++--------- be/src/vec/exec/vrepeat_node.cpp | 6 +++--- be/src/vec/exec/vschema_scan_node.cpp | 16 ++++++++++------ .../functions/functions_multi_string_position.cpp | 12 ++++++++---- 8 files changed, 53 insertions(+), 29 deletions(-) diff --git a/be/src/exprs/aggregate_functions.cpp b/be/src/exprs/aggregate_functions.cpp index 4a3f9cd090..202dd1852b 100644 --- a/be/src/exprs/aggregate_functions.cpp +++ b/be/src/exprs/aggregate_functions.cpp @@ -824,7 +824,9 @@ void AggregateFunctions::string_concat_update(FunctionContext* ctx, const String const auto header_len = sizeof(StringConcatHeader); DCHECK(header_len == sizeof(sep->len)); *result = StringVal(ctx->allocate(header_len), header_len); - *reinterpret_cast<StringConcatHeader*>(result->ptr) = sep->len; + if (result->ptr) { + *reinterpret_cast<StringConcatHeader*>(result->ptr) = sep->len; + } } result->append(ctx, sep->ptr, sep->len, src.ptr, src.len); } diff --git a/be/src/olap/storage_policy_mgr.cpp b/be/src/olap/storage_policy_mgr.cpp index e330dc3229..ce9241c7f8 100644 --- a/be/src/olap/storage_policy_mgr.cpp +++ b/be/src/olap/storage_policy_mgr.cpp @@ -34,9 +34,12 @@ void StoragePolicyMgr::update(const std::string& name, const StoragePolicyPtr& p it->second = policy; s3_fs = std::dynamic_pointer_cast<io::S3FileSystem>( io::FileSystemMap::instance()->get(name)); - DCHECK(s3_fs); - s3_fs->set_ak(policy->s3_ak); - s3_fs->set_sk(policy->s3_sk); + if (s3_fs) { + s3_fs->set_ak(policy->s3_ak); + s3_fs->set_sk(policy->s3_sk); + } else { + DCHECK(false) << "s3_fs is null"; + } } } if (s3_fs) { diff --git a/be/src/olap/utils.cpp b/be/src/olap/utils.cpp index 367b3d6bda..175e462581 100644 --- a/be/src/olap/utils.cpp +++ b/be/src/olap/utils.cpp @@ -61,8 +61,14 @@ namespace doris { Status olap_compress(const char* src_buf, size_t src_len, char* dest_buf, size_t dest_len, size_t* written_len, OLAPCompressionType compression_type) { if (nullptr == src_buf || nullptr == dest_buf || nullptr == written_len) { - LOG(WARNING) << "input param with nullptr pointer. [src_buf=" << src_buf - << " dest_buf=" << dest_buf << " written_len=" << written_len << "]"; + LOG(WARNING) << "input param with nullptr pointer. src_buf is nullptr: " + << (src_buf == nullptr ? "true" : "false") << " src_buf=[" + << (src_buf == nullptr ? "nullptr" : src_buf) + << "], dest_buf is nullptr: " << (dest_buf == nullptr ? "true" : "false") + << " dest_buf=[" << (dest_buf == nullptr ? "nullptr" : dest_buf) + << "], written_len is nullptr: " + << (written_len == nullptr ? "true" : " false") << " written_len=[" + << (dest_buf == nullptr ? -1 : *dest_buf) << "]"; return Status::OLAPInternalError(OLAP_ERR_INPUT_PARAMETER_ERROR); } diff --git a/be/src/runtime/plan_fragment_executor.cpp b/be/src/runtime/plan_fragment_executor.cpp index bc46027bec..e901a738e1 100644 --- a/be/src/runtime/plan_fragment_executor.cpp +++ b/be/src/runtime/plan_fragment_executor.cpp @@ -95,7 +95,9 @@ Status PlanFragmentExecutor::prepare(const TExecPlanFragmentParams& request, fragments_ctx == nullptr ? request.query_globals : fragments_ctx->query_globals; _runtime_state.reset(new RuntimeState(params, request.query_options, query_globals, _exec_env)); _runtime_state->set_query_fragments_ctx(fragments_ctx); - _runtime_state->set_query_mem_tracker(fragments_ctx->query_mem_tracker); + _runtime_state->set_query_mem_tracker(fragments_ctx == nullptr + ? _exec_env->orphan_mem_tracker() + : fragments_ctx->query_mem_tracker); _runtime_state->set_tracer(std::move(tracer)); SCOPED_ATTACH_TASK(_runtime_state.get()); diff --git a/be/src/vec/exec/vmysql_scan_node.cpp b/be/src/vec/exec/vmysql_scan_node.cpp index c1c206a371..d8148d4b9d 100644 --- a/be/src/vec/exec/vmysql_scan_node.cpp +++ b/be/src/vec/exec/vmysql_scan_node.cpp @@ -98,16 +98,15 @@ Status VMysqlScanNode::prepare(RuntimeState* state) { } Status VMysqlScanNode::open(RuntimeState* state) { + if (nullptr == state) { + return Status::InternalError("input pointer is nullptr."); + } START_AND_SCOPE_SPAN(state->get_tracer(), span, "VMysqlScanNode::open"); SCOPED_TIMER(_runtime_profile->total_time_counter()); RETURN_IF_ERROR(ExecNode::open(state)); SCOPED_CONSUME_MEM_TRACKER(mem_tracker()); VLOG_CRITICAL << "MysqlScanNode::Open"; - if (nullptr == state) { - return Status::InternalError("input pointer is nullptr."); - } - if (!_is_init) { return Status::InternalError("used before initialize."); } @@ -146,11 +145,15 @@ Status VMysqlScanNode::write_text_slot(char* value, int value_length, SlotDescri } Status VMysqlScanNode::get_next(RuntimeState* state, vectorized::Block* block, bool* eos) { + if (state == nullptr || block == nullptr || eos == nullptr) { + return Status::InternalError("input is nullptr"); + } INIT_AND_SCOPE_GET_NEXT_SPAN(state->get_tracer(), _get_next_span, "VMysqlScanNode::get_next"); VLOG_CRITICAL << "VMysqlScanNode::GetNext"; - if (state == NULL || block == NULL || eos == NULL) - return Status::InternalError("input is NULL pointer"); - if (!_is_init) return Status::InternalError("used before initialize."); + + if (!_is_init) { + return Status::InternalError("used before initialize."); + } RETURN_IF_CANCELLED(state); bool mem_reuse = block->mem_reuse(); DCHECK(block->rows() == 0); @@ -173,8 +176,8 @@ Status VMysqlScanNode::get_next(RuntimeState* state, vectorized::Block* block, b break; } - char** data = NULL; - unsigned long* length = NULL; + char** data = nullptr; + unsigned long* length = nullptr; RETURN_IF_ERROR(_mysql_scanner->get_next_row(&data, &length, &mysql_eos)); if (mysql_eos) { diff --git a/be/src/vec/exec/vrepeat_node.cpp b/be/src/vec/exec/vrepeat_node.cpp index cb79fcb317..bcfab1c415 100644 --- a/be/src/vec/exec/vrepeat_node.cpp +++ b/be/src/vec/exec/vrepeat_node.cpp @@ -149,13 +149,13 @@ Status VRepeatNode::get_repeated_block(Block* child_block, int repeat_id_idx, Bl } Status VRepeatNode::get_next(RuntimeState* state, Block* block, bool* eos) { + if (state == nullptr || block == nullptr || eos == nullptr) { + return Status::InternalError("input is NULL pointer"); + } INIT_AND_SCOPE_GET_NEXT_SPAN(state->get_tracer(), _get_next_span, "VRepeatNode::get_next"); VLOG_CRITICAL << "VRepeatNode::get_next"; SCOPED_TIMER(_runtime_profile->total_time_counter()); - if (state == nullptr || block == nullptr || eos == nullptr) { - return Status::InternalError("input is NULL pointer"); - } RETURN_IF_CANCELLED(state); DCHECK(_repeat_id_idx >= 0); for (const std::vector<int64_t>& v : _grouping_list) { diff --git a/be/src/vec/exec/vschema_scan_node.cpp b/be/src/vec/exec/vschema_scan_node.cpp index 250ea9bdb3..c0b1491c50 100644 --- a/be/src/vec/exec/vschema_scan_node.cpp +++ b/be/src/vec/exec/vschema_scan_node.cpp @@ -105,7 +105,11 @@ Status VSchemaScanNode::init(const TPlanNode& tnode, RuntimeState* state) { } Status VSchemaScanNode::open(RuntimeState* state) { - START_AND_SCOPE_SPAN(state->get_tracer(), span, "AggregationNode::close"); + if (nullptr == state) { + return Status::InternalError("input pointer is nullptr."); + } + + START_AND_SCOPE_SPAN(state->get_tracer(), span, "VSchemaScanNode::open"); if (!_is_init) { span->SetStatus(opentelemetry::trace::StatusCode::kError, "Open before Init."); return Status::InternalError("Open before Init."); @@ -138,9 +142,9 @@ Status VSchemaScanNode::prepare(RuntimeState* state) { } if (nullptr == state) { - return Status::InternalError("input pointer is nullptr."); + return Status::InternalError("state pointer is nullptr."); } - + START_AND_SCOPE_SPAN(state->get_tracer(), span, "VSchemaScanNode::prepare"); RETURN_IF_ERROR(ScanNode::prepare(state)); SCOPED_CONSUME_MEM_TRACKER(mem_tracker()); @@ -244,13 +248,13 @@ Status VSchemaScanNode::prepare(RuntimeState* state) { } Status VSchemaScanNode::get_next(RuntimeState* state, vectorized::Block* block, bool* eos) { + if (state == nullptr || block == nullptr || eos == nullptr) { + return Status::InternalError("input is NULL pointer"); + } INIT_AND_SCOPE_GET_NEXT_SPAN(state->get_tracer(), _get_next_span, "VSchemaScanNode::get_next"); SCOPED_TIMER(_runtime_profile->total_time_counter()); VLOG_CRITICAL << "VSchemaScanNode::GetNext"; - if (state == nullptr || block == nullptr || eos == nullptr) { - return Status::InternalError("input is NULL pointer"); - } if (!_is_init) { return Status::InternalError("used before initialize."); } diff --git a/be/src/vec/functions/functions_multi_string_position.cpp b/be/src/vec/functions/functions_multi_string_position.cpp index c5da16d17d..756d561ee6 100644 --- a/be/src/vec/functions/functions_multi_string_position.cpp +++ b/be/src/vec/functions/functions_multi_string_position.cpp @@ -65,11 +65,12 @@ public: const ColumnConst* col_needles_const = check_and_get_column_const<ColumnArray>(needles_ptr.get()); - if (col_haystack_const && col_needles_vector) + if (col_haystack_const && col_needles_vector) { return Status::InvalidArgument( "function '{}' doesn't support search with non-constant needles " "in constant haystack", name); + } using ResultType = typename Impl::ResultType; auto col_res = ColumnVector<ResultType>::create(); @@ -79,17 +80,20 @@ public: auto& offsets_res = col_offsets->get_data(); Status status; - if (col_needles_const) + if (col_needles_const) { status = Impl::vector_constant( col_haystack_vector->get_chars(), col_haystack_vector->get_offsets(), col_needles_const->get_value<Array>(), vec_res, offsets_res); - else + } else { status = Impl::vector_vector(col_haystack_vector->get_chars(), col_haystack_vector->get_offsets(), col_needles_vector->get_data(), col_needles_vector->get_offsets(), vec_res, offsets_res); + } - if (!status.ok()) return status; + if (!status.ok()) { + return status; + } auto nullable_col = ColumnNullable::create(std::move(col_res), ColumnUInt8::create(col_res->size(), 0)); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org