!88 update to v3.19.6
From: @taotao-sauce Reviewed-by: @duguhaotian Signed-off-by: @duguhaotian
This commit is contained in:
commit
6b52811f58
@ -1,12 +1,24 @@
|
|||||||
|
From 03ce780382f83b0921a55f9e06bb59c6ce7b03f1 Mon Sep 17 00:00:00 2001
|
||||||
|
From: zhongtao <zhongtao17@huawei.com>
|
||||||
|
Date: Fri, 21 Jul 2023 17:30:51 +0800
|
||||||
|
Subject: [PATCH] add secure compile option in Makefile
|
||||||
|
|
||||||
|
---
|
||||||
|
src/Makefile.am | 1 +
|
||||||
|
1 file changed, 1 insertion(+)
|
||||||
|
|
||||||
diff --git a/src/Makefile.am b/src/Makefile.am
|
diff --git a/src/Makefile.am b/src/Makefile.am
|
||||||
index f1099d9..9b7053b 100644
|
index 1d9cd6fb4..cd9f7cff5 100644
|
||||||
--- a/src/Makefile.am
|
--- a/src/Makefile.am
|
||||||
+++ b/src/Makefile.am
|
+++ b/src/Makefile.am
|
||||||
@@ -19,6 +19,7 @@ PTHREAD_DEF =
|
@@ -19,6 +19,7 @@ PTHREAD_DEF =
|
||||||
endif
|
endif
|
||||||
|
|
||||||
PROTOBUF_VERSION = 25:0:0
|
PROTOBUF_VERSION = 30:6:0
|
||||||
+PROTOBUF_OPT_FLAG += -Wl,-z,now
|
+PROTOBUF_OPT_FLAG += -Wl,-z,now
|
||||||
|
|
||||||
if GCC
|
if GCC
|
||||||
# Turn on all warnings except for sign comparison (we ignore sign comparison
|
# Turn on all warnings except for sign comparison (we ignore sign comparison
|
||||||
|
--
|
||||||
|
2.25.1
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
From dddceb14106499f9fca17e75cdce458a205b102c Mon Sep 17 00:00:00 2001
|
From 3908a54725aae8ed549ba527306c9b4a5551bf88 Mon Sep 17 00:00:00 2001
|
||||||
From: haozi007 <liuhao27@huawei.com>
|
From: zhongtao <zhongtao17@huawei.com>
|
||||||
Date: Sat, 20 Feb 2021 16:52:15 +0800
|
Date: Fri, 21 Jul 2023 17:32:52 +0800
|
||||||
Subject: [PATCH] add secure compile fs check in Makefile
|
Subject: [PATCH] add secure compile fs check in Makefile
|
||||||
|
|
||||||
Signed-off-by: haozi007 <liuhao27@huawei.com>
|
Signed-off-by: haozi007 <liuhao27@huawei.com>
|
||||||
@ -9,13 +9,13 @@ Signed-off-by: haozi007 <liuhao27@huawei.com>
|
|||||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
diff --git a/src/Makefile.am b/src/Makefile.am
|
diff --git a/src/Makefile.am b/src/Makefile.am
|
||||||
index 9b7053b..e447b05 100644
|
index cd9f7cff5..df9d134ed 100644
|
||||||
--- a/src/Makefile.am
|
--- a/src/Makefile.am
|
||||||
+++ b/src/Makefile.am
|
+++ b/src/Makefile.am
|
||||||
@@ -19,7 +19,7 @@ PTHREAD_DEF =
|
@@ -19,7 +19,7 @@ PTHREAD_DEF =
|
||||||
endif
|
endif
|
||||||
|
|
||||||
PROTOBUF_VERSION = 25:0:0
|
PROTOBUF_VERSION = 30:6:0
|
||||||
-PROTOBUF_OPT_FLAG += -Wl,-z,now
|
-PROTOBUF_OPT_FLAG += -Wl,-z,now
|
||||||
+PROTOBUF_OPT_FLAG += -Wl,-z,now -fstack-check
|
+PROTOBUF_OPT_FLAG += -Wl,-z,now -fstack-check
|
||||||
|
|
||||||
|
|||||||
@ -1,73 +0,0 @@
|
|||||||
From 5afdc4d13ac997204873e734b20c30b6efc253d1 Mon Sep 17 00:00:00 2001
|
|
||||||
From: wangxiaochao <wangxiaochao2@huawei.com>
|
|
||||||
Date: Fri, 18 Mar 2022 14:46:35 +0800
|
|
||||||
Subject: [PATCH] fix CVE-2021-22570
|
|
||||||
|
|
||||||
Signed-off-by: wangxiaochao <wangxiaochao2@huawei.com>
|
|
||||||
|
|
||||||
---
|
|
||||||
src/google/protobuf/descriptor.cc | 20 ++++++++++++++++++++
|
|
||||||
1 file changed, 20 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc
|
|
||||||
index 8998e1b..e6f7ec2 100644
|
|
||||||
--- a/src/google/protobuf/descriptor.cc
|
|
||||||
+++ b/src/google/protobuf/descriptor.cc
|
|
||||||
@@ -2626,6 +2626,8 @@ void Descriptor::DebugString(int depth, std::string* contents,
|
|
||||||
const Descriptor::ReservedRange* range = reserved_range(i);
|
|
||||||
if (range->end == range->start + 1) {
|
|
||||||
strings::SubstituteAndAppend(contents, "$0, ", range->start);
|
|
||||||
+ } else if (range->end > FieldDescriptor::kMaxNumber) {
|
|
||||||
+ strings::SubstituteAndAppend(contents, "$0 to max, ", range->start);
|
|
||||||
} else {
|
|
||||||
strings::SubstituteAndAppend(contents, "$0 to $1, ", range->start,
|
|
||||||
range->end - 1);
|
|
||||||
@@ -2829,6 +2831,8 @@ void EnumDescriptor::DebugString(
|
|
||||||
const EnumDescriptor::ReservedRange* range = reserved_range(i);
|
|
||||||
if (range->end == range->start) {
|
|
||||||
strings::SubstituteAndAppend(contents, "$0, ", range->start);
|
|
||||||
+ } else if (range->end == INT_MAX) {
|
|
||||||
+ strings::SubstituteAndAppend(contents, "$0 to max, ", range->start);
|
|
||||||
} else {
|
|
||||||
strings::SubstituteAndAppend(contents, "$0 to $1, ", range->start,
|
|
||||||
range->end);
|
|
||||||
@@ -4019,6 +4023,11 @@ bool DescriptorBuilder::AddSymbol(const std::string& full_name,
|
|
||||||
// Use its file as the parent instead.
|
|
||||||
if (parent == nullptr) parent = file_;
|
|
||||||
|
|
||||||
+ if (full_name.find('\0') != std::string::npos) {
|
|
||||||
+ AddError(full_name, proto, DescriptorPool::ErrorCollector::NAME,
|
|
||||||
+ "\"" + full_name + "\" contains null character.");
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
if (tables_->AddSymbol(full_name, symbol)) {
|
|
||||||
if (!file_tables_->AddAliasUnderParent(parent, name, symbol)) {
|
|
||||||
// This is only possible if there was already an error adding something of
|
|
||||||
@@ -4059,6 +4068,11 @@ bool DescriptorBuilder::AddSymbol(const std::string& full_name,
|
|
||||||
void DescriptorBuilder::AddPackage(const std::string& name,
|
|
||||||
const Message& proto,
|
|
||||||
const FileDescriptor* file) {
|
|
||||||
+ if (name.find('\0') != std::string::npos) {
|
|
||||||
+ AddError(name, proto, DescriptorPool::ErrorCollector::NAME,
|
|
||||||
+ "\"" + name + "\" contains null character.");
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
if (tables_->AddSymbol(name, Symbol(file))) {
|
|
||||||
// Success. Also add parent package, if any.
|
|
||||||
std::string::size_type dot_pos = name.find_last_of('.');
|
|
||||||
@@ -4372,6 +4386,12 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl(
|
|
||||||
}
|
|
||||||
result->pool_ = pool_;
|
|
||||||
|
|
||||||
+ if (result->name().find('\0') != std::string::npos) {
|
|
||||||
+ AddError(result->name(), proto, DescriptorPool::ErrorCollector::NAME,
|
|
||||||
+ "\"" + result->name() + "\" contains null character.");
|
|
||||||
+ return nullptr;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
// Add to tables.
|
|
||||||
if (!tables_->AddFile(result)) {
|
|
||||||
AddError(proto.name(), proto, DescriptorPool::ErrorCollector::OTHER,
|
|
||||||
--
|
|
||||||
2.25.1
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@ -1,368 +0,0 @@
|
|||||||
From 55815e423bb82cc828836bbd60c79c1f9a195763 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Deanna Garcia <deannagarcia@google.com>
|
|
||||||
Date: Tue, 13 Sep 2022 17:20:00 +0000
|
|
||||||
Subject: [PATCH] Apply patch
|
|
||||||
|
|
||||||
---
|
|
||||||
src/google/protobuf/extension_set_inl.h | 27 +++--
|
|
||||||
src/google/protobuf/wire_format.cc | 26 +++--
|
|
||||||
src/google/protobuf/wire_format_lite.h | 27 +++--
|
|
||||||
src/google/protobuf/wire_format_unittest.cc | 109 ++++++++++++++++++--
|
|
||||||
4 files changed, 152 insertions(+), 37 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/src/google/protobuf/extension_set_inl.h b/src/google/protobuf/extension_set_inl.h
|
|
||||||
index 074784b96..77f95f62f 100644
|
|
||||||
--- a/src/google/protobuf/extension_set_inl.h
|
|
||||||
+++ b/src/google/protobuf/extension_set_inl.h
|
|
||||||
@@ -206,16 +206,21 @@ const char* ExtensionSet::ParseMessageSetItemTmpl(
|
|
||||||
const char* ptr, const Msg* containing_type,
|
|
||||||
internal::InternalMetadata* metadata, internal::ParseContext* ctx) {
|
|
||||||
std::string payload;
|
|
||||||
- uint32 type_id = 0;
|
|
||||||
- bool payload_read = false;
|
|
||||||
+ uint32 type_id;
|
|
||||||
+ enum class State { kNoTag, kHasType, kHasPayload, kDone };
|
|
||||||
+ State state = State::kNoTag;
|
|
||||||
+
|
|
||||||
while (!ctx->Done(&ptr)) {
|
|
||||||
uint32 tag = static_cast<uint8>(*ptr++);
|
|
||||||
if (tag == WireFormatLite::kMessageSetTypeIdTag) {
|
|
||||||
uint64 tmp;
|
|
||||||
ptr = ParseBigVarint(ptr, &tmp);
|
|
||||||
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
|
|
||||||
- type_id = tmp;
|
|
||||||
- if (payload_read) {
|
|
||||||
+ if (state == State::kNoTag) {
|
|
||||||
+ type_id = tmp;
|
|
||||||
+ state = State::kHasType;
|
|
||||||
+ } else if (state == State::kHasPayload) {
|
|
||||||
+ type_id = tmp;
|
|
||||||
ExtensionInfo extension;
|
|
||||||
bool was_packed_on_wire;
|
|
||||||
if (!FindExtension(2, type_id, containing_type, ctx, &extension,
|
|
||||||
@@ -241,20 +246,24 @@ const char* ExtensionSet::ParseMessageSetItemTmpl(
|
|
||||||
GOOGLE_PROTOBUF_PARSER_ASSERT(value->_InternalParse(p, &tmp_ctx) &&
|
|
||||||
tmp_ctx.EndedAtLimit());
|
|
||||||
}
|
|
||||||
- type_id = 0;
|
|
||||||
+ state = State::kDone;
|
|
||||||
}
|
|
||||||
} else if (tag == WireFormatLite::kMessageSetMessageTag) {
|
|
||||||
- if (type_id != 0) {
|
|
||||||
+ if (state == State::kHasType) {
|
|
||||||
ptr = ParseFieldMaybeLazily(static_cast<uint64>(type_id) * 8 + 2, ptr,
|
|
||||||
containing_type, metadata, ctx);
|
|
||||||
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr != nullptr);
|
|
||||||
- type_id = 0;
|
|
||||||
+ state = State::kDone;
|
|
||||||
} else {
|
|
||||||
+ std::string tmp;
|
|
||||||
int32 size = ReadSize(&ptr);
|
|
||||||
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
|
|
||||||
- ptr = ctx->ReadString(ptr, size, &payload);
|
|
||||||
+ ptr = ctx->ReadString(ptr, size, &tmp);
|
|
||||||
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
|
|
||||||
- payload_read = true;
|
|
||||||
+ if (state == State::kNoTag) {
|
|
||||||
+ payload = std::move(tmp);
|
|
||||||
+ state = State::kHasPayload;
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ptr = ReadTag(ptr - 1, &tag);
|
|
||||||
diff --git a/src/google/protobuf/wire_format.cc b/src/google/protobuf/wire_format.cc
|
|
||||||
index c30b7abff..382d01ea0 100644
|
|
||||||
--- a/src/google/protobuf/wire_format.cc
|
|
||||||
+++ b/src/google/protobuf/wire_format.cc
|
|
||||||
@@ -657,9 +657,11 @@ struct WireFormat::MessageSetParser {
|
|
||||||
const char* _InternalParse(const char* ptr, internal::ParseContext* ctx) {
|
|
||||||
// Parse a MessageSetItem
|
|
||||||
auto metadata = reflection->MutableInternalMetadata(msg);
|
|
||||||
+ enum class State { kNoTag, kHasType, kHasPayload, kDone };
|
|
||||||
+ State state = State::kNoTag;
|
|
||||||
+
|
|
||||||
std::string payload;
|
|
||||||
uint32 type_id = 0;
|
|
||||||
- bool payload_read = false;
|
|
||||||
while (!ctx->Done(&ptr)) {
|
|
||||||
// We use 64 bit tags in order to allow typeid's that span the whole
|
|
||||||
// range of 32 bit numbers.
|
|
||||||
@@ -668,8 +670,11 @@ struct WireFormat::MessageSetParser {
|
|
||||||
uint64 tmp;
|
|
||||||
ptr = ParseBigVarint(ptr, &tmp);
|
|
||||||
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
|
|
||||||
- type_id = tmp;
|
|
||||||
- if (payload_read) {
|
|
||||||
+ if (state == State::kNoTag) {
|
|
||||||
+ type_id = tmp;
|
|
||||||
+ state = State::kHasType;
|
|
||||||
+ } else if (state == State::kHasPayload) {
|
|
||||||
+ type_id = tmp;
|
|
||||||
const FieldDescriptor* field;
|
|
||||||
if (ctx->data().pool == nullptr) {
|
|
||||||
field = reflection->FindKnownExtensionByNumber(type_id);
|
|
||||||
@@ -696,17 +701,17 @@ struct WireFormat::MessageSetParser {
|
|
||||||
GOOGLE_PROTOBUF_PARSER_ASSERT(value->_InternalParse(p, &tmp_ctx) &&
|
|
||||||
tmp_ctx.EndedAtLimit());
|
|
||||||
}
|
|
||||||
- type_id = 0;
|
|
||||||
+ state = State::kDone;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
} else if (tag == WireFormatLite::kMessageSetMessageTag) {
|
|
||||||
- if (type_id == 0) {
|
|
||||||
+ if (state == State::kNoTag) {
|
|
||||||
int32 size = ReadSize(&ptr);
|
|
||||||
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
|
|
||||||
ptr = ctx->ReadString(ptr, size, &payload);
|
|
||||||
GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
|
|
||||||
- payload_read = true;
|
|
||||||
- } else {
|
|
||||||
+ state = State::kHasPayload;
|
|
||||||
+ } else if (state == State::kHasType) {
|
|
||||||
// We're now parsing the payload
|
|
||||||
const FieldDescriptor* field = nullptr;
|
|
||||||
if (descriptor->IsExtensionNumber(type_id)) {
|
|
||||||
@@ -720,7 +725,12 @@ struct WireFormat::MessageSetParser {
|
|
||||||
ptr = WireFormat::_InternalParseAndMergeField(
|
|
||||||
msg, ptr, ctx, static_cast<uint64>(type_id) * 8 + 2, reflection,
|
|
||||||
field);
|
|
||||||
- type_id = 0;
|
|
||||||
+ state = State::kDone;
|
|
||||||
+ } else {
|
|
||||||
+ int32 size = ReadSize(&ptr);
|
|
||||||
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
|
|
||||||
+ ptr = ctx->Skip(ptr, size);
|
|
||||||
+ GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// An unknown field in MessageSetItem.
|
|
||||||
diff --git a/src/google/protobuf/wire_format_lite.h b/src/google/protobuf/wire_format_lite.h
|
|
||||||
index f2a3cad82..0b13096cc 100644
|
|
||||||
--- a/src/google/protobuf/wire_format_lite.h
|
|
||||||
+++ b/src/google/protobuf/wire_format_lite.h
|
|
||||||
@@ -1798,6 +1798,9 @@ bool ParseMessageSetItemImpl(io::CodedInputStream* input, MS ms) {
|
|
||||||
// we can parse it later.
|
|
||||||
std::string message_data;
|
|
||||||
|
|
||||||
+ enum class State { kNoTag, kHasType, kHasPayload, kDone };
|
|
||||||
+ State state = State::kNoTag;
|
|
||||||
+
|
|
||||||
while (true) {
|
|
||||||
const uint32 tag = input->ReadTagNoLastTag();
|
|
||||||
if (tag == 0) return false;
|
|
||||||
@@ -1806,26 +1809,34 @@ bool ParseMessageSetItemImpl(io::CodedInputStream* input, MS ms) {
|
|
||||||
case WireFormatLite::kMessageSetTypeIdTag: {
|
|
||||||
uint32 type_id;
|
|
||||||
if (!input->ReadVarint32(&type_id)) return false;
|
|
||||||
- last_type_id = type_id;
|
|
||||||
-
|
|
||||||
- if (!message_data.empty()) {
|
|
||||||
+ if (state == State::kNoTag) {
|
|
||||||
+ last_type_id = type_id;
|
|
||||||
+ state = State::kHasType;
|
|
||||||
+ } else if (state == State::kHasPayload) {
|
|
||||||
// We saw some message data before the type_id. Have to parse it
|
|
||||||
// now.
|
|
||||||
io::CodedInputStream sub_input(
|
|
||||||
reinterpret_cast<const uint8*>(message_data.data()),
|
|
||||||
static_cast<int>(message_data.size()));
|
|
||||||
sub_input.SetRecursionLimit(input->RecursionBudget());
|
|
||||||
- if (!ms.ParseField(last_type_id, &sub_input)) {
|
|
||||||
+ if (!ms.ParseField(type_id, &sub_input)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
message_data.clear();
|
|
||||||
+ state = State::kDone;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case WireFormatLite::kMessageSetMessageTag: {
|
|
||||||
- if (last_type_id == 0) {
|
|
||||||
+ if (state == State::kHasType) {
|
|
||||||
+ // Already saw type_id, so we can parse this directly.
|
|
||||||
+ if (!ms.ParseField(last_type_id, input)) {
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+ state = State::kDone;
|
|
||||||
+ } else if (state == State::kNoTag) {
|
|
||||||
// We haven't seen a type_id yet. Append this data to message_data.
|
|
||||||
uint32 length;
|
|
||||||
if (!input->ReadVarint32(&length)) return false;
|
|
||||||
@@ -1836,11 +1847,9 @@ bool ParseMessageSetItemImpl(io::CodedInputStream* input, MS ms) {
|
|
||||||
auto ptr = reinterpret_cast<uint8*>(&message_data[0]);
|
|
||||||
ptr = io::CodedOutputStream::WriteVarint32ToArray(length, ptr);
|
|
||||||
if (!input->ReadRaw(ptr, length)) return false;
|
|
||||||
+ state = State::kHasPayload;
|
|
||||||
} else {
|
|
||||||
- // Already saw type_id, so we can parse this directly.
|
|
||||||
- if (!ms.ParseField(last_type_id, input)) {
|
|
||||||
- return false;
|
|
||||||
- }
|
|
||||||
+ if (!ms.SkipField(tag, input)) return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
diff --git a/src/google/protobuf/wire_format_unittest.cc b/src/google/protobuf/wire_format_unittest.cc
|
|
||||||
index e75fc316f..8d767b283 100644
|
|
||||||
--- a/src/google/protobuf/wire_format_unittest.cc
|
|
||||||
+++ b/src/google/protobuf/wire_format_unittest.cc
|
|
||||||
@@ -46,6 +46,7 @@
|
|
||||||
#include <google/protobuf/io/zero_copy_stream_impl.h>
|
|
||||||
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
|
|
||||||
#include <google/protobuf/descriptor.h>
|
|
||||||
+#include <google/protobuf/dynamic_message.h>
|
|
||||||
#include <google/protobuf/wire_format_lite.h>
|
|
||||||
#include <google/protobuf/testing/googletest.h>
|
|
||||||
#include <google/protobuf/stubs/logging.h>
|
|
||||||
@@ -585,30 +586,56 @@ TEST(WireFormatTest, ParseMessageSet) {
|
|
||||||
EXPECT_EQ(message_set.DebugString(), dynamic_message_set.DebugString());
|
|
||||||
}
|
|
||||||
|
|
||||||
-TEST(WireFormatTest, ParseMessageSetWithReverseTagOrder) {
|
|
||||||
+namespace {
|
|
||||||
+std::string BuildMessageSetItemStart() {
|
|
||||||
std::string data;
|
|
||||||
{
|
|
||||||
- unittest::TestMessageSetExtension1 message;
|
|
||||||
- message.set_i(123);
|
|
||||||
- // Build a MessageSet manually with its message content put before its
|
|
||||||
- // type_id.
|
|
||||||
io::StringOutputStream output_stream(&data);
|
|
||||||
io::CodedOutputStream coded_output(&output_stream);
|
|
||||||
coded_output.WriteTag(WireFormatLite::kMessageSetItemStartTag);
|
|
||||||
+ }
|
|
||||||
+ return data;
|
|
||||||
+}
|
|
||||||
+std::string BuildMessageSetItemEnd() {
|
|
||||||
+ std::string data;
|
|
||||||
+ {
|
|
||||||
+ io::StringOutputStream output_stream(&data);
|
|
||||||
+ io::CodedOutputStream coded_output(&output_stream);
|
|
||||||
+ coded_output.WriteTag(WireFormatLite::kMessageSetItemEndTag);
|
|
||||||
+ }
|
|
||||||
+ return data;
|
|
||||||
+}
|
|
||||||
+std::string BuildMessageSetTestExtension1(int value = 123) {
|
|
||||||
+ std::string data;
|
|
||||||
+ {
|
|
||||||
+ unittest::TestMessageSetExtension1 message;
|
|
||||||
+ message.set_i(value);
|
|
||||||
+ io::StringOutputStream output_stream(&data);
|
|
||||||
+ io::CodedOutputStream coded_output(&output_stream);
|
|
||||||
// Write the message content first.
|
|
||||||
WireFormatLite::WriteTag(WireFormatLite::kMessageSetMessageNumber,
|
|
||||||
WireFormatLite::WIRETYPE_LENGTH_DELIMITED,
|
|
||||||
&coded_output);
|
|
||||||
coded_output.WriteVarint32(message.ByteSizeLong());
|
|
||||||
message.SerializeWithCachedSizes(&coded_output);
|
|
||||||
- // Write the type id.
|
|
||||||
- uint32 type_id = message.GetDescriptor()->extension(0)->number();
|
|
||||||
+ }
|
|
||||||
+ return data;
|
|
||||||
+}
|
|
||||||
+std::string BuildMessageSetItemTypeId(int extension_number) {
|
|
||||||
+ std::string data;
|
|
||||||
+ {
|
|
||||||
+ io::StringOutputStream output_stream(&data);
|
|
||||||
+ io::CodedOutputStream coded_output(&output_stream);
|
|
||||||
WireFormatLite::WriteUInt32(WireFormatLite::kMessageSetTypeIdNumber,
|
|
||||||
- type_id, &coded_output);
|
|
||||||
- coded_output.WriteTag(WireFormatLite::kMessageSetItemEndTag);
|
|
||||||
+ extension_number, &coded_output);
|
|
||||||
}
|
|
||||||
+ return data;
|
|
||||||
+}
|
|
||||||
+void ValidateTestMessageSet(const std::string& test_case,
|
|
||||||
+ const std::string& data) {
|
|
||||||
+ SCOPED_TRACE(test_case);
|
|
||||||
{
|
|
||||||
- proto2_wireformat_unittest::TestMessageSet message_set;
|
|
||||||
+ ::proto2_wireformat_unittest::TestMessageSet message_set;
|
|
||||||
ASSERT_TRUE(message_set.ParseFromString(data));
|
|
||||||
|
|
||||||
EXPECT_EQ(123,
|
|
||||||
@@ -616,10 +643,15 @@ TEST(WireFormatTest, ParseMessageSetWithReverseTagOrder) {
|
|
||||||
.GetExtension(
|
|
||||||
unittest::TestMessageSetExtension1::message_set_extension)
|
|
||||||
.i());
|
|
||||||
+
|
|
||||||
+ // Make sure it does not contain anything else.
|
|
||||||
+ message_set.ClearExtension(
|
|
||||||
+ unittest::TestMessageSetExtension1::message_set_extension);
|
|
||||||
+ EXPECT_EQ(message_set.SerializeAsString(), "");
|
|
||||||
}
|
|
||||||
{
|
|
||||||
// Test parse the message via Reflection.
|
|
||||||
- proto2_wireformat_unittest::TestMessageSet message_set;
|
|
||||||
+ ::proto2_wireformat_unittest::TestMessageSet message_set;
|
|
||||||
io::CodedInputStream input(reinterpret_cast<const uint8*>(data.data()),
|
|
||||||
data.size());
|
|
||||||
EXPECT_TRUE(WireFormat::ParseAndMergePartial(&input, &message_set));
|
|
||||||
@@ -631,6 +663,61 @@ TEST(WireFormatTest, ParseMessageSetWithReverseTagOrder) {
|
|
||||||
unittest::TestMessageSetExtension1::message_set_extension)
|
|
||||||
.i());
|
|
||||||
}
|
|
||||||
+ {
|
|
||||||
+ // Test parse the message via DynamicMessage.
|
|
||||||
+ DynamicMessageFactory factory;
|
|
||||||
+ std::unique_ptr<Message> msg(
|
|
||||||
+ factory
|
|
||||||
+ .GetPrototype(
|
|
||||||
+ ::proto2_wireformat_unittest::TestMessageSet::descriptor())
|
|
||||||
+ ->New());
|
|
||||||
+ msg->ParseFromString(data);
|
|
||||||
+ auto* reflection = msg->GetReflection();
|
|
||||||
+ std::vector<const FieldDescriptor*> fields;
|
|
||||||
+ reflection->ListFields(*msg, &fields);
|
|
||||||
+ ASSERT_EQ(fields.size(), 1);
|
|
||||||
+ const auto& sub = reflection->GetMessage(*msg, fields[0]);
|
|
||||||
+ reflection = sub.GetReflection();
|
|
||||||
+ EXPECT_EQ(123, reflection->GetInt32(
|
|
||||||
+ sub, sub.GetDescriptor()->FindFieldByName("i")));
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+} // namespace
|
|
||||||
+
|
|
||||||
+TEST(WireFormatTest, ParseMessageSetWithAnyTagOrder) {
|
|
||||||
+ std::string start = BuildMessageSetItemStart();
|
|
||||||
+ std::string end = BuildMessageSetItemEnd();
|
|
||||||
+ std::string id = BuildMessageSetItemTypeId(
|
|
||||||
+ unittest::TestMessageSetExtension1::descriptor()->extension(0)->number());
|
|
||||||
+ std::string message = BuildMessageSetTestExtension1();
|
|
||||||
+
|
|
||||||
+ ValidateTestMessageSet("id + message", start + id + message + end);
|
|
||||||
+ ValidateTestMessageSet("message + id", start + message + id + end);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+TEST(WireFormatTest, ParseMessageSetWithDuplicateTags) {
|
|
||||||
+ std::string start = BuildMessageSetItemStart();
|
|
||||||
+ std::string end = BuildMessageSetItemEnd();
|
|
||||||
+ std::string id = BuildMessageSetItemTypeId(
|
|
||||||
+ unittest::TestMessageSetExtension1::descriptor()->extension(0)->number());
|
|
||||||
+ std::string other_id = BuildMessageSetItemTypeId(123456);
|
|
||||||
+ std::string message = BuildMessageSetTestExtension1();
|
|
||||||
+ std::string other_message = BuildMessageSetTestExtension1(321);
|
|
||||||
+
|
|
||||||
+ // Double id
|
|
||||||
+ ValidateTestMessageSet("id + other_id + message",
|
|
||||||
+ start + id + other_id + message + end);
|
|
||||||
+ ValidateTestMessageSet("id + message + other_id",
|
|
||||||
+ start + id + message + other_id + end);
|
|
||||||
+ ValidateTestMessageSet("message + id + other_id",
|
|
||||||
+ start + message + id + other_id + end);
|
|
||||||
+ // Double message
|
|
||||||
+ ValidateTestMessageSet("id + message + other_message",
|
|
||||||
+ start + id + message + other_message + end);
|
|
||||||
+ ValidateTestMessageSet("message + id + other_message",
|
|
||||||
+ start + message + id + other_message + end);
|
|
||||||
+ ValidateTestMessageSet("message + other_message + id",
|
|
||||||
+ start + message + other_message + id + end);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SerializeReverseOrder(
|
|
||||||
--
|
|
||||||
2.25.1
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
BIN
protobuf-all-3.19.6.tar.gz
Normal file
BIN
protobuf-all-3.19.6.tar.gz
Normal file
Binary file not shown.
@ -7,19 +7,16 @@
|
|||||||
|
|
||||||
Summary: Protocol Buffers - Google's data interchange format
|
Summary: Protocol Buffers - Google's data interchange format
|
||||||
Name: protobuf
|
Name: protobuf
|
||||||
Version: 3.14.0
|
Version: 3.19.6
|
||||||
Release: 6
|
Release: 1
|
||||||
License: BSD
|
License: BSD
|
||||||
URL: https://github.com/protocolbuffers/protobuf
|
URL: https://github.com/protocolbuffers/protobuf
|
||||||
Source: https://github.com/protocolbuffers/protobuf/releases/download/v%{version}%{?rcver}/%{name}-all-%{version}%{?rcver}.tar.gz
|
Source: https://github.com/protocolbuffers/protobuf/releases/download/v%{version}%{?rcver}/%{name}-all-%{version}%{?rcver}.tar.gz
|
||||||
Source1: protobuf-init.el
|
Source1: protobuf-init.el
|
||||||
|
%global so_version 30
|
||||||
|
|
||||||
Patch9000: 0001-add-secure-compile-option-in-Makefile.patch
|
Patch9000: 0001-add-secure-compile-option-in-Makefile.patch
|
||||||
Patch9001: 0002-add-secure-compile-fs-check-in-Makefile.patch
|
Patch9001: 0002-add-secure-compile-fs-check-in-Makefile.patch
|
||||||
Patch9002: 0003-fix-CVE-2021-22570.patch
|
|
||||||
Patch9003: 0004-Improve-performance-of-parsing-unknown-fields-in-Jav.patch
|
|
||||||
Patch9004: 0005-fix-CVE-2022-1941.patch
|
|
||||||
Patch9005: 0006-fix-CVE-2022-3171.patch
|
|
||||||
|
|
||||||
BuildRequires: make autoconf automake emacs gcc-c++ libtool pkgconfig zlib-devel
|
BuildRequires: make autoconf automake emacs gcc-c++ libtool pkgconfig zlib-devel
|
||||||
|
|
||||||
@ -162,10 +159,11 @@ chmod 644 examples/*
|
|||||||
%if %{with java}
|
%if %{with java}
|
||||||
#%pom_remove_dep com.google.truth:truth java/pom.xml
|
#%pom_remove_dep com.google.truth:truth java/pom.xml
|
||||||
#%pom_remove_dep org.easymock:easymockclassextension java/pom.xml java/*/pom.xml
|
#%pom_remove_dep org.easymock:easymockclassextension java/pom.xml java/*/pom.xml
|
||||||
%pom_remove_dep org.easymock:easymockclassextension java/pom.xml java/core/pom.xml java/lite/pom.xml java/util/pom.xml
|
#%pom_remove_dep org.easymock:easymockclassextension java/pom.xml java/core/pom.xml java/lite/pom.xml java/util/pom.xml
|
||||||
%pom_remove_dep com.google.truth:truth java/pom.xml java/util/pom.xml java/lite/pom.xml java/core/pom.xml
|
%pom_remove_dep com.google.truth:truth java/pom.xml java/util/pom.xml java/lite/pom.xml java/core/pom.xml
|
||||||
%pom_remove_dep com.google.errorprone:error_prone_annotations java/util/pom.xml
|
%pom_remove_dep com.google.errorprone:error_prone_annotations java/util/pom.xml
|
||||||
%pom_remove_dep com.google.guava:guava-testlib java/pom.xml java/util/pom.xml
|
%pom_remove_dep com.google.guava:guava-testlib java/pom.xml java/util/pom.xml
|
||||||
|
%pom_remove_dep com.google.j2objc:j2objc-annotations java/util/pom.xml
|
||||||
|
|
||||||
# These use easymockclassextension
|
# These use easymockclassextension
|
||||||
rm java/core/src/test/java/com/google/protobuf/ServiceTest.java
|
rm java/core/src/test/java/com/google/protobuf/ServiceTest.java
|
||||||
@ -216,7 +214,9 @@ popd
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%if %{with java}
|
%if %{with java}
|
||||||
%mvn_build -s -- -f java/pom.xml
|
%pom_disable_module kotlin java/pom.xml
|
||||||
|
%pom_disable_module kotlin-lite java/pom.xml
|
||||||
|
%mvn_build -s -- -Dmaven.test.skip=true -f java/pom.xml
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
%{_emacs_bytecompile} editors/protobuf-mode.el
|
%{_emacs_bytecompile} editors/protobuf-mode.el
|
||||||
@ -263,11 +263,11 @@ install -p -m 0644 %{SOURCE1} %{buildroot}%{_emacs_sitestartdir}
|
|||||||
%files
|
%files
|
||||||
%doc CHANGES.txt CONTRIBUTORS.txt README.md
|
%doc CHANGES.txt CONTRIBUTORS.txt README.md
|
||||||
%license LICENSE
|
%license LICENSE
|
||||||
%{_libdir}/libprotobuf.so.25*
|
%{_libdir}/libprotobuf.so.%{so_version}{,.*}
|
||||||
|
|
||||||
%files compiler
|
%files compiler
|
||||||
%{_bindir}/protoc
|
%{_bindir}/protoc
|
||||||
%{_libdir}/libprotoc.so.25*
|
%{_libdir}/libprotoc.so.%{so_version}{,.*}
|
||||||
%{_emacs_sitelispdir}/%{name}/
|
%{_emacs_sitelispdir}/%{name}/
|
||||||
%{_emacs_sitestartdir}/protobuf-init.el
|
%{_emacs_sitestartdir}/protobuf-init.el
|
||||||
%license LICENSE
|
%license LICENSE
|
||||||
@ -286,7 +286,7 @@ install -p -m 0644 %{SOURCE1} %{buildroot}%{_emacs_sitestartdir}
|
|||||||
%{_datadir}/vim/vimfiles/syntax/proto.vim
|
%{_datadir}/vim/vimfiles/syntax/proto.vim
|
||||||
|
|
||||||
%files lite
|
%files lite
|
||||||
%{_libdir}/libprotobuf-lite.so.25*
|
%{_libdir}/libprotobuf-lite.so.%{so_version}{,.*}
|
||||||
|
|
||||||
%files lite-devel
|
%files lite-devel
|
||||||
%{_libdir}/libprotobuf-lite.so
|
%{_libdir}/libprotobuf-lite.so
|
||||||
@ -325,6 +325,9 @@ install -p -m 0644 %{SOURCE1} %{buildroot}%{_emacs_sitestartdir}
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Jul 17 2023 zhongtao <zhongtao17@huawei.com> - 3.19.6-1
|
||||||
|
- update to 3.19.6
|
||||||
|
|
||||||
* Tue Oct 18 2022 chengzeruizhi <chengzeruizhi@huawei.com> - 3.14.0-6
|
* Tue Oct 18 2022 chengzeruizhi <chengzeruizhi@huawei.com> - 3.14.0-6
|
||||||
- Type:bugfix
|
- Type:bugfix
|
||||||
- ID:NA
|
- ID:NA
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user