39 lines
1.3 KiB
Diff
39 lines
1.3 KiB
Diff
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
|
|
|