[libvirt] [PATCH] initialize "meta" in virStorageFileGetMetadata, not in each caller

Eric Blake eblake at redhat.com
Tue May 18 14:21:06 UTC 2010


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 at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100518/e20e1db3/attachment-0001.sig>


More information about the libvir-list mailing list