!25 Fix a clang analyzer 14 warning about a possible NULL deref.

From: @meng-wenhua 
Reviewed-by: @Charlie_li 
Signed-off-by: @Charlie_li
This commit is contained in:
openeuler-ci-bot 2023-01-07 09:22:38 +00:00 committed by Gitee
commit b5e5cbed26
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 33 additions and 1 deletions

View File

@ -0,0 +1,28 @@
From ab5f76a52bade28a2c025bd52c7847f033ca82f3 Mon Sep 17 00:00:00 2001
From: "Todd C. Miller" <Todd.Miller@sudo.ws>
Date: Wed, 29 Jun 2022 11:18:16 -0600
Subject: [PATCH] Fix a clang analyzer 14 warning about a possible NULL deref.
[edmonds: Import commit from
https://github.com/sudo-project/sudo/commit/bfc6249902d842626058e74074832930feaf2f80.patch.]
---
protobuf-c/protobuf-c.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/protobuf-c/protobuf-c.c b/protobuf-c/protobuf-c.c
index 448f3e8..ad3ab12 100644
--- a/protobuf-c/protobuf-c.c
+++ b/protobuf-c/protobuf-c.c
@@ -3231,6 +3231,9 @@ protobuf_c_message_unpack(const ProtobufCMessageDescriptor *desc,
/* allocate space for repeated fields, also check that all required fields have been set */
for (f = 0; f < desc->n_fields; f++) {
const ProtobufCFieldDescriptor *field = desc->fields + f;
+ if (field == NULL) {
+ continue;
+ }
if (field->label == PROTOBUF_C_LABEL_REPEATED) {
size_t siz =
sizeof_elt_in_repeated_array(field->type);
--
2.37.3.windows.1

View File

@ -1,6 +1,6 @@
Name: protobuf-c
Version: 1.4.0
Release: 3
Release: 4
Summary: This is protobuf-c, a C implementation of the Google Protocol Buffers data serialization format
License: BSD
URL: https://github.com/protobuf-c/protobuf-c
@ -13,6 +13,7 @@ Obsoletes: %{name}-compiler < %{version}-%{release}
Patch6000: backport-0001-Fix-issue-499-unsigned-integer-overflow.patch
Patch6001: backport-0002-Fix-regression-with-zero-length-messages-introduced-.patch
Patch6002: backport-0001-Fix-a-clang-analyzer-14-warning-about-a-possible-NUL.patch
%description
This is protobuf-c, a C implementation of the Google Protocol Buffers data serialization format.
@ -53,6 +54,9 @@ make check
%{_libdir}/{libprotobuf-c.so,pkgconfig/libprotobuf-c.pc}
%changelog
* Sat Jan 7 2023 mengwenhua <mengwenhua@xfusion.com> - 1.4.0-4
- Fix a clang analyzer 14 warning about a possible NULL deref.
* Sat Jan 7 2023 mengwenhua<mengwenhua@xfusion.com> - 1.4.0-3
- Type:bugfix
- CVE:NA