|
|
c480ed |
From d0add5355b434df64c5f9fb28b9ab4bdd86f93f2 Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <d0add5355b434df64c5f9fb28b9ab4bdd86f93f2@dist-git>
|
|
|
c480ed |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Date: Mon, 1 Jul 2019 17:06:04 +0200
|
|
|
c480ed |
Subject: [PATCH] vircgroup: Duplicate string before modifying
|
|
|
c480ed |
MIME-Version: 1.0
|
|
|
c480ed |
Content-Type: text/plain; charset=UTF-8
|
|
|
c480ed |
Content-Transfer-Encoding: 8bit
|
|
|
c480ed |
|
|
|
c480ed |
The 'mntDir' is part of 'struct mntent' as a result of getmntent_r
|
|
|
c480ed |
therefore we should not mangle with it.
|
|
|
c480ed |
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
(cherry picked from commit 4b2fb60777bdad70df2871dad1d0e604cda078c6)
|
|
|
c480ed |
|
|
|
c480ed |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Message-Id: <b57526226460be172899f5a6e14f185eabb18cea.1561993099.git.phrdina@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
---
|
|
|
c480ed |
src/util/vircgroup.c | 14 +++++++++-----
|
|
|
c480ed |
1 file changed, 9 insertions(+), 5 deletions(-)
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
|
|
|
c480ed |
index df38bb77e0..45b854e864 100644
|
|
|
c480ed |
--- a/src/util/vircgroup.c
|
|
|
c480ed |
+++ b/src/util/vircgroup.c
|
|
|
c480ed |
@@ -350,18 +350,22 @@ virCgroupCopyMounts(virCgroupPtr group,
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
static int
|
|
|
c480ed |
-virCgroupResolveMountLink(char *mntDir,
|
|
|
c480ed |
+virCgroupResolveMountLink(const char *mntDir,
|
|
|
c480ed |
const char *typeStr,
|
|
|
c480ed |
virCgroupControllerPtr controller)
|
|
|
c480ed |
{
|
|
|
c480ed |
VIR_AUTOFREE(char *) linkSrc = NULL;
|
|
|
c480ed |
+ VIR_AUTOFREE(char *) tmp = NULL;
|
|
|
c480ed |
char *dirName;
|
|
|
c480ed |
struct stat sb;
|
|
|
c480ed |
|
|
|
c480ed |
- dirName = strrchr(mntDir, '/');
|
|
|
c480ed |
+ if (VIR_STRDUP(tmp, mntDir) < 0)
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ dirName = strrchr(tmp, '/');
|
|
|
c480ed |
if (!dirName) {
|
|
|
c480ed |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c480ed |
- _("Missing '/' separator in cgroup mount '%s'"), mntDir);
|
|
|
c480ed |
+ _("Missing '/' separator in cgroup mount '%s'"), tmp);
|
|
|
c480ed |
return -1;
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
@@ -369,14 +373,14 @@ virCgroupResolveMountLink(char *mntDir,
|
|
|
c480ed |
return 0;
|
|
|
c480ed |
|
|
|
c480ed |
*dirName = '\0';
|
|
|
c480ed |
- if (virAsprintf(&linkSrc, "%s/%s", mntDir, typeStr) < 0)
|
|
|
c480ed |
+ if (virAsprintf(&linkSrc, "%s/%s", tmp, typeStr) < 0)
|
|
|
c480ed |
return -1;
|
|
|
c480ed |
*dirName = '/';
|
|
|
c480ed |
|
|
|
c480ed |
if (lstat(linkSrc, &sb) < 0) {
|
|
|
c480ed |
if (errno == ENOENT) {
|
|
|
c480ed |
VIR_WARN("Controller %s co-mounted at %s is missing symlink at %s",
|
|
|
c480ed |
- typeStr, mntDir, linkSrc);
|
|
|
c480ed |
+ typeStr, tmp, linkSrc);
|
|
|
c480ed |
} else {
|
|
|
c480ed |
virReportSystemError(errno, _("Cannot stat %s"), linkSrc);
|
|
|
c480ed |
return -1;
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|