|
|
99cbc7 |
From 46fe53ae905497a84d33065a9d8c31c9cd0c44bf Mon Sep 17 00:00:00 2001
|
|
|
99cbc7 |
Message-Id: <46fe53ae905497a84d33065a9d8c31c9cd0c44bf@dist-git>
|
|
|
99cbc7 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
99cbc7 |
Date: Fri, 19 Jul 2019 15:34:53 +0200
|
|
|
99cbc7 |
Subject: [PATCH] util: storage: Don't leak metadata on repeated calls of
|
|
|
99cbc7 |
virStorageFileGetMetadata
|
|
|
99cbc7 |
MIME-Version: 1.0
|
|
|
99cbc7 |
Content-Type: text/plain; charset=UTF-8
|
|
|
99cbc7 |
Content-Transfer-Encoding: 8bit
|
|
|
99cbc7 |
|
|
|
99cbc7 |
When querying storage metadata after a block job we re-run
|
|
|
99cbc7 |
virStorageFileGetMetadata on the top level storage file. This means that
|
|
|
99cbc7 |
the workers (virStorageFileGetMetadataInternal) must not overwrite any
|
|
|
99cbc7 |
pointers without freeing them.
|
|
|
99cbc7 |
|
|
|
99cbc7 |
This was not considered for src->compat and src->features. Fix it and
|
|
|
99cbc7 |
add a comment mentioning that.
|
|
|
99cbc7 |
|
|
|
99cbc7 |
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
99cbc7 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
99cbc7 |
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
99cbc7 |
(cherry picked from commit f0430d069af991475de6fa83ed62a45f8669c645)
|
|
|
99cbc7 |
https: //bugzilla.redhat.com/show_bug.cgi?id=1731329
|
|
|
99cbc7 |
Message-Id: <80801e221bea1a4e33fbdd62845d790e390a1632.1563542241.git.pkrempa@redhat.com>
|
|
|
99cbc7 |
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
99cbc7 |
---
|
|
|
99cbc7 |
src/util/virstoragefile.c | 9 ++++++++-
|
|
|
99cbc7 |
1 file changed, 8 insertions(+), 1 deletion(-)
|
|
|
99cbc7 |
|
|
|
99cbc7 |
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
|
|
|
99cbc7 |
index f516a7c7f3..0187c8d2c9 100644
|
|
|
99cbc7 |
--- a/src/util/virstoragefile.c
|
|
|
99cbc7 |
+++ b/src/util/virstoragefile.c
|
|
|
99cbc7 |
@@ -961,7 +961,11 @@ virStorageFileGetEncryptionPayloadOffset(const struct FileEncryptionInfo *info,
|
|
|
99cbc7 |
* assuming it has the given FORMAT, populate information into META
|
|
|
99cbc7 |
* with information about the file and its backing store. Return format
|
|
|
99cbc7 |
* of the backing store as BACKING_FORMAT. PATH and FORMAT have to be
|
|
|
99cbc7 |
- * pre-populated in META */
|
|
|
99cbc7 |
+ * pre-populated in META.
|
|
|
99cbc7 |
+ *
|
|
|
99cbc7 |
+ * Note that this function may be called repeatedly on @meta, so it must
|
|
|
99cbc7 |
+ * clean up any existing allocated memory which would be overwritten.
|
|
|
99cbc7 |
+ */
|
|
|
99cbc7 |
int
|
|
|
99cbc7 |
virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
|
|
|
99cbc7 |
char *buf,
|
|
|
99cbc7 |
@@ -1048,10 +1052,13 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
|
|
|
99cbc7 |
return -1;
|
|
|
99cbc7 |
}
|
|
|
99cbc7 |
|
|
|
99cbc7 |
+ virBitmapFree(meta->features);
|
|
|
99cbc7 |
+ meta->features = NULL;
|
|
|
99cbc7 |
if (fileTypeInfo[meta->format].getFeatures != NULL &&
|
|
|
99cbc7 |
fileTypeInfo[meta->format].getFeatures(&meta->features, meta->format, buf, len) < 0)
|
|
|
99cbc7 |
return -1;
|
|
|
99cbc7 |
|
|
|
99cbc7 |
+ VIR_FREE(meta->compat);
|
|
|
99cbc7 |
if (meta->format == VIR_STORAGE_FILE_QCOW2 && meta->features &&
|
|
|
99cbc7 |
VIR_STRDUP(meta->compat, "1.1") < 0)
|
|
|
99cbc7 |
return -1;
|
|
|
99cbc7 |
--
|
|
|
99cbc7 |
2.22.1
|
|
|
99cbc7 |
|