On 05/18/2010 01:09 AM, Jim Meyering wrote:
Here's proactive clean-up that is IMHO required.
Otherwise, it's just too easy not to realize that "meta" must
be cleared before each and every call to virStorageFileGetMetadata and
virStorageFileGetMetadataFromFD.
Besides, any change that adds just 2 lines and removes 11,
in addition to making the code harder to abuse must be an improvement.
Hard to fault that line of reasoning!
+++ b/src/security/virt-aa-helper.c
@@ -830,8 +830,6 @@ get_files(vahControl * ctl)
do {
virStorageFileMetadata meta;
- memset(&meta, 0, sizeof(meta));
-
ret = virStorageFileGetMetadata(path, &meta);
if (path != ctl->def->disks[i]->src)
diff --git a/src/util/storage_file.c b/src/util/storage_file.c
index a07bedc..b3ae905 100644
--- a/src/util/storage_file.c
+++ b/src/util/storage_file.c
@@ -275,6 +275,8 @@ virStorageFileGetMetadataFromFD(const char *path,
unsigned char head[20*512]; /* vmdk4GetBackingStore needs this much. */
int len, i;
+ memset(meta, 0, sizeof (*meta));
+
ACK.
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library
http://libvirt.org