From 3c31499bbc3af614e7c3e701b66895b82de8a9c9 Mon Sep 17 00:00:00 2001 From: congqixia Date: Wed, 22 May 2024 19:07:40 +0800 Subject: [PATCH] enhance: [2.4]Assert insert data length not overflow int (#33248) (#33271) Cherry-pick from master pr: #33248 When InsertData is too large for cpp proto unmarshalling, the error message is confusing since the length is overflowed This PR adds assertion for insert data length. Signed-off-by: Congqi Xia --- internal/core/src/segcore/segment_c.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/core/src/segcore/segment_c.cpp b/internal/core/src/segcore/segment_c.cpp index df3b8fda7a..06643ea3f7 100644 --- a/internal/core/src/segcore/segment_c.cpp +++ b/internal/core/src/segcore/segment_c.cpp @@ -12,6 +12,7 @@ #include "segcore/segment_c.h" #include +#include #include "common/FieldData.h" #include "common/LoadInfo.h" @@ -239,6 +240,9 @@ Insert(CSegmentInterface c_segment, const uint8_t* data_info, const uint64_t data_info_len) { try { + AssertInfo(data_info_len < std::numeric_limits::max(), + "insert data length ({}) exceeds max int", + data_info_len); auto segment = static_cast(c_segment); auto insert_record_proto = std::make_unique();