From 783781ba071c83200ac91f2174a667d35e278541 Mon Sep 17 00:00:00 2001 From: wangxiaochao Date: Mon, 21 Mar 2022 20:19:32 +0800 Subject: [PATCH] fix CVE-2021-22570 Signed-off-by: wangxiaochao --- 0003-fix-CVE-2021-22570.patch | 73 +++++++++++++++++++++++++++++++++++ protobuf.spec | 9 ++++- 2 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 0003-fix-CVE-2021-22570.patch diff --git a/0003-fix-CVE-2021-22570.patch b/0003-fix-CVE-2021-22570.patch new file mode 100644 index 0000000..ae6ac24 --- /dev/null +++ b/0003-fix-CVE-2021-22570.patch @@ -0,0 +1,73 @@ +From 830db8f0098afe307300ff9bc12268daf9df6ff1 Mon Sep 17 00:00:00 2001 +From: wangxiaochao +Date: Mon, 21 Mar 2022 20:29:25 +0800 +Subject: [PATCH] fix CVE-2021-22570 + +Signed-off-by: wangxiaochao +--- + src/google/protobuf/descriptor.cc | 21 +++++++++++++++++++++ + 1 file changed, 21 insertions(+) + +diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc +index ff8ba25..898d6b5 100644 +--- a/src/google/protobuf/descriptor.cc ++++ b/src/google/protobuf/descriptor.cc +@@ -2640,6 +2640,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); +@@ -2843,6 +2845,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); +@@ -4034,6 +4038,12 @@ 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 +@@ -4073,6 +4083,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('.'); +@@ -4386,6 +4401,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.30.0 + diff --git a/protobuf.spec b/protobuf.spec index 6212a88..f5c4a8c 100644 --- a/protobuf.spec +++ b/protobuf.spec @@ -8,7 +8,7 @@ Summary: Protocol Buffers - Google's data interchange format Name: protobuf Version: 3.12.3 -Release: 16 +Release: 17 License: BSD URL: https://github.com/protocolbuffers/protobuf Source: https://github.com/protocolbuffers/protobuf/releases/download/v%{version}%{?rcver}/%{name}-all-%{version}%{?rcver}.tar.gz @@ -16,6 +16,7 @@ Source1: protobuf-init.el Patch9000: 0001-add-secure-compile-option-in-Makefile.patch Patch9001: 0002-add-secure-compile-fs-check-in-Makefile.patch +Patch9002: 0003-fix-CVE-2021-22570.patch BuildRequires: autoconf automake emacs gcc-c++ libtool pkgconfig zlib-devel @@ -281,6 +282,12 @@ install -p -m 0644 %{SOURCE1} %{buildroot}%{_emacs_sitestartdir} %endif %changelog +* Mon Mar 21 2022 wangxiaochao - 3.12.3-17 +- Type:CVE +- ID:NA +- SUG:NA +- DESC: fix CVE-2021-22570 + * Mon Apr 26 2021 haozi007 - 3.12.3-16 - Type:enhancement - ID:NA -- Gitee