From ea9f0fa8b81ba72f139577d9f2fe620348c53a50 Mon Sep 17 00:00:00 2001 From: Vitezslav Crhonek Date: Mon, 29 Jul 2024 12:39:38 +0200 Subject: [PATCH] Fix memory leaks, initialize memory Also fix mixed use of spaces and tabs in spec. Resolves: RHEL-42560 --- ...6.9.9-fix-memleaks-initialize-memory.patch | 38 +++++++++++++++++++ oniguruma.spec | 20 ++++++---- 2 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 onig-6.9.9-fix-memleaks-initialize-memory.patch diff --git a/onig-6.9.9-fix-memleaks-initialize-memory.patch b/onig-6.9.9-fix-memleaks-initialize-memory.patch new file mode 100644 index 0000000..7c7fb16 --- /dev/null +++ b/onig-6.9.9-fix-memleaks-initialize-memory.patch @@ -0,0 +1,38 @@ +diff -up onig-6.9.9/src/regexec.c.orig onig-6.9.9/src/regexec.c +--- onig-6.9.9/src/regexec.c.orig 2022-12-12 14:27:04.000000000 +0100 ++++ onig-6.9.9/src/regexec.c 2024-07-29 12:30:55.752328341 +0200 +@@ -4517,6 +4517,7 @@ regset_search_body_position_lead(OnigReg + + sr = (SearchRange* )xmalloc(sizeof(*sr) * n); + CHECK_NULL_RETURN_MEMERR(sr); ++ xmemset(sr, 0, sizeof(*sr) * n); + + for (i = 0; i < n; i++) { + reg = set->rs[i].reg; +diff -up onig-6.9.9/src/regparse.c.orig onig-6.9.9/src/regparse.c +--- onig-6.9.9/src/regparse.c.orig 2024-07-29 12:31:07.838347726 +0200 ++++ onig-6.9.9/src/regparse.c 2024-07-29 12:33:48.509582274 +0200 +@@ -4190,7 +4190,10 @@ and_cclass(CClassNode* dest, CClassNode* + pbuf = tbuf; + } + } +- if (r != 0) return r; ++ if (r != 0) { ++ bbuf_free(pbuf); ++ return r; ++ } + + dest->mbuf = pbuf; + bbuf_free(buf1); +@@ -4247,7 +4250,10 @@ or_cclass(CClassNode* dest, CClassNode* + pbuf = tbuf; + } + } +- if (r != 0) return r; ++ if (r != 0) { ++ bbuf_free(pbuf); ++ return r; ++ } + + dest->mbuf = pbuf; + bbuf_free(buf1); diff --git a/oniguruma.spec b/oniguruma.spec index 685f64b..38068a6 100644 --- a/oniguruma.spec +++ b/oniguruma.spec @@ -9,11 +9,11 @@ %endif %if 0%{?git_snapshot} -%global gitdate 20230501 -%global gitcommit 41a3b802af2155eef6d648aa3608e39605110642 -%global shortcommit %(c=%{gitcommit}; echo ${c:0:7}) +%global gitdate 20230501 +%global gitcommit 41a3b802af2155eef6d648aa3608e39605110642 +%global shortcommit %(c=%{gitcommit}; echo ${c:0:7}) -%global gitversion %{gitdate}git%{shortcommit} +%global gitversion %{gitdate}git%{shortcommit} %endif %global mainver 6.9.9 @@ -21,7 +21,7 @@ #%%global betaver rc4 #%%define prerelease 1 -%global baserelease 5 +%global baserelease 6 Name: oniguruma Version: %{mainver}%{?postver:.%postver}%{?gitversion:^%{?gitversion}} @@ -33,12 +33,13 @@ License: BSD-2-Clause URL: https://github.com/kkos/oniguruma/ Source0: https://github.com/kkos/oniguruma/releases/download/v%{mainver}%{?betaver:_%betaver}/onig-%{mainver}%{?postver:.%postver}%{?betaver:-%betaver}%{?gitversion:-%{?gitversion}}.tar.gz Source1: create-tarball-from-git.sh +Patch0: onig-6.9.9-fix-memleaks-initialize-memory.patch BuildRequires: make BuildRequires: gcc %if 0%{?git_snapshot} -BuildRequires: automake -BuildRequires: libtool +BuildRequires: automake +BuildRequires: libtool %endif %description @@ -59,6 +60,7 @@ developing applications that use %{name}. %prep %setup -q -n onig-%{mainver}%{?gitversion:-%{?gitversion}} +%autopatch -p1 %{__sed} -i.multilib -e 's|-L@libdir@||' onig-config.in @@ -124,6 +126,10 @@ autoreconf -fi %{_libdir}/pkgconfig/%{name}.pc %changelog +* Mon Jul 29 2024 Vitezslav Crhonek - 6.9.9-6 +- Fix memory leaks, initialize memory + Resolves: RHEL-42560 + * Wed Jul 10 2024 Vitezslav Crhonek - 6.9.9-5 - Enable LTO