diff --git a/cloud/src/meta-service/meta_service.cpp b/cloud/src/meta-service/meta_service.cpp index 4f374832925dd75..70a6237c76f6725 100644 --- a/cloud/src/meta-service/meta_service.cpp +++ b/cloud/src/meta-service/meta_service.cpp @@ -1310,7 +1310,14 @@ void internal_get_rowset(Transaction* txn, int64_t start, int64_t end, while (it->has_next()) { auto [k, v] = it->next(); - auto rs = response->add_rowset_meta(); + auto* rs = response->add_rowset_meta(); + auto byte_size = rs->ByteSizeLong(); + if (byte_size + v.size() > std::numeric_limits::max()) { + code = MetaServiceCode::PROTOBUF_PARSE_ERR; + msg = "rowset meta exceeded 2G, unable to deserialize"; + LOG(WARNING) << msg << " key=" << hex(k); + return; + } if (!rs->ParseFromArray(v.data(), v.size())) { code = MetaServiceCode::PROTOBUF_PARSE_ERR; msg = "malformed rowset meta, unable to deserialize"; @@ -1318,7 +1325,9 @@ void internal_get_rowset(Transaction* txn, int64_t start, int64_t end, return; } ++num_rowsets; - if (!it->has_next()) key0 = k; + if (!it->has_next()) { + key0 = k; + } } key0.push_back('\x00'); // Update to next smallest key for iteration } while (it->more());