core: fix free undefined pointer when strdup failed in the first loop

Signed-off-by: ExtinctFire <shenyining_00@126.com>
This commit is contained in:
ExtinctFire 2021-09-16 17:14:48 +08:00
parent c1ca35c2e1
commit f17dfea337
2 changed files with 38 additions and 1 deletions

View File

@ -0,0 +1,33 @@
From 1509274359979079e3e61899ce12fc8b0f0958d9 Mon Sep 17 00:00:00 2001
From: xujing <17826839720@163.com>
Date: Wed, 8 Sep 2021 14:26:20 +0800
Subject: [PATCH] core: fix free undefined pointer when strdup failed in the
first loop
---
src/core/load-fragment.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 92815b1dbaea..1c8159a23550 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -800,7 +800,7 @@ int config_parse_exec(
if (!separate_argv0) {
char *w = NULL;
- if (!GREEDY_REALLOC(n, nbufsize, nlen + 2))
+ if (!GREEDY_REALLOC0(n, nbufsize, nlen + 2))
return log_oom();
w = strdup(path);
@@ -832,7 +832,7 @@ int config_parse_exec(
p += 2;
p += strspn(p, WHITESPACE);
- if (!GREEDY_REALLOC(n, nbufsize, nlen + 2))
+ if (!GREEDY_REALLOC0(n, nbufsize, nlen + 2))
return log_oom();
w = strdup(";");

View File

@ -16,7 +16,7 @@
Name: systemd
Url: https://www.freedesktop.org/wiki/Software/systemd
Version: 243
Release: 46
Release: 47
License: MIT and LGPLv2+ and GPLv2+
Summary: System and Service Manager
@ -138,6 +138,7 @@ Patch0090: backport-basic-stat-util-make-mtime-check-stricter-and-use-en.pa
Patch0091: backport-udev-make-algorithm-that-selects-highest-priority-de.patch
Patch0092: backport-tentatively-ignore-FORCERENEW-command.patch
Patch0093: backport-network-add-missing-link-network-checks.patch
Patch0094: backport-core-fix-free-undefined-pointer-when-strdup-failed-i.patch
#openEuler
Patch9002: 1509-fix-journal-file-descriptors-leak-problems.patch
@ -1525,6 +1526,9 @@ fi
%exclude /usr/share/man/man3/*
%changelog
* Thu Sep 16 2021 ExtinctFire <shenyining_00@126.com> - 243-47
- core: fix free undefined pointer when strdup failed in the first loop
* Thu Sep 9 2021 yangmingtai <yangmingtai@huawei.com> - 243-46
- fix network coredump after install cloud-init