Free constraint in error branch

(cherry picked from commit e66264aacb7c41ec4df121a236372edd9a796bd3)
This commit is contained in:
yixiangzhike 2024-10-23 15:24:31 +08:00 committed by openeuler-sync-bot
parent d033c3d8c9
commit c015766e91
2 changed files with 38 additions and 1 deletions

View File

@ -0,0 +1,32 @@
From 55b474ee41034e7cec38cf7b739c2a5c5a7886c4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgzones@googlemail.com>
Date: Mon, 29 Apr 2024 18:39:01 +0200
Subject: [PATCH] mcstrans: free constraint in error branch
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Free constraint, like in all other error branches.
Reported-by: Cppcheck
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
---
mcstrans/src/mcstrans.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mcstrans/src/mcstrans.c b/mcstrans/src/mcstrans.c
index fded3235..7667e131 100644
--- a/mcstrans/src/mcstrans.c
+++ b/mcstrans/src/mcstrans.c
@@ -477,6 +477,7 @@ add_constraint(char op, char *raw, char *tok) {
}
if (asprintf(&constraint->text, "%s%c%s", raw, op, tok) < 0) {
log_error("asprintf failed %s", strerror(errno));
+ free(constraint);
return -1;
}
constraint->op = op;
--
2.33.0

View File

@ -1,12 +1,13 @@
Name: mcstrans Name: mcstrans
Version: 3.5 Version: 3.5
Release: 2 Release: 3
Summary: SELinux Translation Daemon Summary: SELinux Translation Daemon
License: GPL2 License: GPL2
URL: https://github.com/SELinuxProject/selinux/wiki URL: https://github.com/SELinuxProject/selinux/wiki
Source: https://github.com/SELinuxProject/selinux/releases/download/%{version}/%{name}-%{version}.tar.gz Source: https://github.com/SELinuxProject/selinux/releases/download/%{version}/%{name}-%{version}.tar.gz
Patch1: backport-mcstrans-check-memory-allocations.patch Patch1: backport-mcstrans-check-memory-allocations.patch
Patch2: backport-mcstrans-free-constraint-in-error-branch.patch
BuildRequires: gcc systemd-units make BuildRequires: gcc systemd-units make
BuildRequires: libselinux-devel >= %{version} BuildRequires: libselinux-devel >= %{version}
@ -41,6 +42,7 @@ mcstrans-help include help files for man page
%prep %prep
%setup -q %setup -q
%patch1 -p2 %patch1 -p2
%patch2 -p2
%build %build
%set_build_flags %set_build_flags
@ -90,6 +92,9 @@ rm -rf %{buildroot}/%{_sysconfdir}/rc.d/init.d/mcstrans
%{_mandir}/ru/man8/*.8.gz %{_mandir}/ru/man8/*.8.gz
%changelog %changelog
* Wed Oct 23 2024 yixiangzhike <yixiangzhike007@163.com> - 3.5-3
- backport upstream patch to free constraint in error branch
* Mon Jul 8 2024 yixiangzhike <yixiangzhike007@163.com> - 3.5-2 * Mon Jul 8 2024 yixiangzhike <yixiangzhike007@163.com> - 3.5-2
- backport upstream patch to avoid NULL dereferences - backport upstream patch to avoid NULL dereferences