!266 [sync] PR-262: check whether command_prev is null before assigning value

From: @openeuler-sync-bot 
Reviewed-by: @overweight 
Signed-off-by: @overweight
This commit is contained in:
openeuler-ci-bot 2022-04-12 08:45:15 +00:00 committed by Gitee
commit d3a4d14c77
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 40 additions and 1 deletions

View File

@ -0,0 +1,35 @@
From 5fe226b4378a2466d906ae45b8544f1003e9885a Mon Sep 17 00:00:00 2001
From: yefei25 <yefei25@huawei.com>
Date: Wed, 8 Apr 2020 23:10:58 -0400
Subject: [PATCH 1/2] check whether command_prev is null before assigning value
---
src/core/service.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/core/service.c b/src/core/service.c
index 9a26271f72..3c255b3bcc 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -2569,12 +2569,16 @@ static unsigned service_exec_command_index(Unit *u, ServiceExecCommand id, ExecC
assert(s);
assert(id >= 0);
assert(id < _SERVICE_EXEC_COMMAND_MAX);
-
+ if (!current)
+ return 0;
first = s->exec_command[id];
/* Figure out where we are in the list by walking back to the beginning */
- for (c = current; c != first; c = c->command_prev)
+ for (c = current; c != first; c = c->command_prev) {
idx++;
+ if (!c->command_prev)
+ return idx;
+ }
return idx;
}
--
2.19.1

View File

@ -20,7 +20,7 @@
Name: systemd
Url: https://www.freedesktop.org/wiki/Software/systemd
Version: 249
Release: 22
Release: 23
License: MIT and LGPLv2+ and GPLv2+
Summary: System and Service Manager
@ -71,6 +71,7 @@ Patch0022: 0022-systemd-core-fix-problem-of-dbus-service-can-not-be-started
Patch0023: 0023-delay-to-restart-when-a-service-can-not-be-auto-restarted.patch
Patch0024: 0024-disable-initialize_clock.patch
Patch0025: 0025-systemd-solve-that-rsyslog-reads-journal-s-object-of.patch
Patch0026: 0026-check-whether-command_prev-is-null-before-assigning-.patch
#backport
Patch6000: backport-core-fix-free-undefined-pointer-when-strdup-failed-i.patch
@ -1502,6 +1503,9 @@ fi
%{_libdir}/security/pam_systemd.so
%changelog
* Tue Apr 12 2022 xujing <xujing99@huawei.com> - 249-23
- check whether command_prev is null before assigning value
* Mon Apr 11 2022 xujing <xujing99@huawei.com> - 249-22
- solve that rsyslog reads journal's object of size 0