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 16:12:40 +08:00
parent 6ea3c2cb9d
commit 2c3578ff30
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

@ -20,7 +20,7 @@
Name: systemd
Url: https://www.freedesktop.org/wiki/Software/systemd
Version: 248
Release: 12
Release: 13
License: MIT and LGPLv2+ and GPLv2+
Summary: System and Service Manager
@ -66,6 +66,7 @@ Patch0017: 0017-fix-capsh-drop-but-ping-success.patch
Patch0018: 0018-resolved-create-etc-resolv.conf-symlink-at-runtime.patch
Patch0019: 0019-journald-enforce-longer-line-length-limit-during-set.patch
Patch0020: 0020-fix-CVE-2021-33910.patch
Patch0021: backport-core-fix-free-undefined-pointer-when-strdup-failed-i.patch
BuildRequires: gcc, gcc-c++
@ -1551,6 +1552,9 @@ fi
%exclude /usr/share/man/man3/*
%changelog
* Thu Sep 16 2021 ExtinctFire <shenyining_00@126.com> - 248-13
- core: fix free undefined pointer when strdup failed in the first loop
* Mon Sep 6 2021 yangmingtai <yangmingtai@huawei.com> - 248-12
- move postun to correct position