File c321bfc-CVE-2013-6456.patch of Package libvirt.openSUSE_13.1_Update
From 4f2282e9e1bb55b56b929a38512a6ef3e4319c44 Mon Sep 17 00:00:00 2001
From: "Daniel P. Berrange" <berrange@redhat.com>
Date: Thu, 30 Jan 2014 17:06:39 +0000
Subject: [PATCH 07/14] Add virFileMakeParentPath helper function
Add a helper function which takes a file path and ensures
that all directory components leading up to the file exist.
IOW, it strips the filename part of the path and passes
the result to virFileMakePath.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit c321bfc5c37c603af349dacf531bb03c91b0755e)
---
src/libvirt_private.syms | 1 +
src/util/virfile.c | 29 +++++++++++++++++++++++++++++
src/util/virfile.h | 1 +
3 files changed, 31 insertions(+)
Index: libvirt-1.1.2/src/libvirt_private.syms
===================================================================
--- libvirt-1.1.2.orig/src/libvirt_private.syms
+++ libvirt-1.1.2/src/libvirt_private.syms
@@ -1378,6 +1378,7 @@ virFileIsLink;
virFileLinkPointsTo;
virFileLock;
virFileLoopDeviceAssociate;
+virFileMakeParentPath;
virFileMakePath;
virFileMakePathWithMode;
virFileMatchesNameSuffix;
Index: libvirt-1.1.2/src/util/virfile.c
===================================================================
--- libvirt-1.1.2.orig/src/util/virfile.c
+++ libvirt-1.1.2/src/util/virfile.c
@@ -2093,6 +2093,35 @@ cleanup:
return ret;
}
+
+int
+virFileMakeParentPath(const char *path)
+{
+ char *p;
+ char *tmp;
+ int ret = -1;
+
+ VIR_DEBUG("path=%s", path);
+
+ if (VIR_STRDUP(tmp, path) < 0) {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ if ((p = strrchr(tmp, '/')) == NULL) {
+ errno = EINVAL;
+ goto cleanup;
+ }
+ *p = '\0';
+
+ ret = virFileMakePathHelper(tmp, 0777);
+
+ cleanup:
+ VIR_FREE(tmp);
+ return ret;
+}
+
+
/* Build up a fully qualified path for a config file to be
* associated with a persistent guest or network */
char *
Index: libvirt-1.1.2/src/util/virfile.h
===================================================================
--- libvirt-1.1.2.orig/src/util/virfile.h
+++ libvirt-1.1.2/src/util/virfile.h
@@ -187,6 +187,7 @@ int virDirCreate(const char *path, mode_
int virFileMakePath(const char *path) ATTRIBUTE_RETURN_CHECK;
int virFileMakePathWithMode(const char *path,
mode_t mode) ATTRIBUTE_RETURN_CHECK;
+int virFileMakeParentPath(const char *path) ATTRIBUTE_RETURN_CHECK;
char *virFileBuildPath(const char *dir,
const char *name,