Fix a largish directory walk related memory leak in transactions
This commit is contained in:
parent
56a300ba62
commit
293b446a51
@ -0,0 +1,38 @@
|
|||||||
|
From f78be76a00878183da86d5e37ddbe421c5fe028c Mon Sep 17 00:00:00 2001
|
||||||
|
Message-Id: <f78be76a00878183da86d5e37ddbe421c5fe028c.1663150557.git.pmatilai@redhat.com>
|
||||||
|
From: Panu Matilainen <pmatilai@redhat.com>
|
||||||
|
Date: Wed, 14 Sep 2022 13:13:24 +0300
|
||||||
|
Subject: [PATCH] Fix a memory leak in the new directory dance in ensureDir()
|
||||||
|
|
||||||
|
This would leak the path whenever we already had the directory open.
|
||||||
|
Which happens a lot. Oops.
|
||||||
|
---
|
||||||
|
lib/fsm.c | 5 +++--
|
||||||
|
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lib/fsm.c b/lib/fsm.c
|
||||||
|
index 129054067..7987abbc9 100644
|
||||||
|
--- a/lib/fsm.c
|
||||||
|
+++ b/lib/fsm.c
|
||||||
|
@@ -374,8 +374,6 @@ static int fsmDoMkDir(rpmPlugins plugins, int dirfd, const char *dn,
|
||||||
|
static int ensureDir(rpmPlugins plugins, const char *p, int owned, int create,
|
||||||
|
int quiet, int *dirfdp)
|
||||||
|
{
|
||||||
|
- char *path = xstrdup(p);
|
||||||
|
- char *dp = path;
|
||||||
|
char *sp = NULL, *bn;
|
||||||
|
char *apath = NULL;
|
||||||
|
int oflags = O_RDONLY;
|
||||||
|
@@ -387,6 +385,9 @@ static int ensureDir(rpmPlugins plugins, const char *p, int owned, int create,
|
||||||
|
int dirfd = fsmOpenat(-1, "/", oflags, 1);
|
||||||
|
int fd = dirfd; /* special case of "/" */
|
||||||
|
|
||||||
|
+ char *path = xstrdup(p);
|
||||||
|
+ char *dp = path;
|
||||||
|
+
|
||||||
|
while ((bn = strtok_r(dp, "/", &sp)) != NULL) {
|
||||||
|
fd = fsmOpenat(dirfd, bn, oflags, 1);
|
||||||
|
/* assemble absolute path for plugins benefit, sigh */
|
||||||
|
--
|
||||||
|
2.37.3
|
||||||
|
|
6
rpm.spec
6
rpm.spec
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
%global rpmver 4.18.0
|
%global rpmver 4.18.0
|
||||||
%global snapver rc1
|
%global snapver rc1
|
||||||
%global baserelease 3
|
%global baserelease 4
|
||||||
%global sover 9
|
%global sover 9
|
||||||
|
|
||||||
%global srcver %{rpmver}%{?snapver:-%{snapver}}
|
%global srcver %{rpmver}%{?snapver:-%{snapver}}
|
||||||
@ -57,6 +57,7 @@ Patch3: rpm-4.9.90-no-man-dirs.patch
|
|||||||
|
|
||||||
# Patches already upstream:
|
# Patches already upstream:
|
||||||
Patch100: 0001-Fix-buffer-overrun-from-commit-4420c78beb86cc6739227.patch
|
Patch100: 0001-Fix-buffer-overrun-from-commit-4420c78beb86cc6739227.patch
|
||||||
|
Patch101: 0001-Fix-a-memory-leak-in-the-new-directory-dance-in-ensu.patch
|
||||||
|
|
||||||
# These are not yet upstream
|
# These are not yet upstream
|
||||||
Patch906: rpm-4.7.1-geode-i686.patch
|
Patch906: rpm-4.7.1-geode-i686.patch
|
||||||
@ -611,6 +612,9 @@ fi
|
|||||||
%doc docs/librpm/html/*
|
%doc docs/librpm/html/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Sep 14 2022 Panu Matilainen <pmatilai@redhat.com> - 4.18.0-0.rc1.4
|
||||||
|
- Fix a largish directory walk related memory leak in transactions
|
||||||
|
|
||||||
* Wed Sep 07 2022 Panu Matilainen <pmatilai@redhat.com> - 4.18.0-0.rc1.3
|
* Wed Sep 07 2022 Panu Matilainen <pmatilai@redhat.com> - 4.18.0-0.rc1.3
|
||||||
- Fix buffer overrun on rpmdb queries involving ^ in version
|
- Fix buffer overrun on rpmdb queries involving ^ in version
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user