[libvirt] [PATCH v2] util: Forbid calling hash APIs from iterator callback
Eric Blake
eblake at redhat.com
Thu Mar 17 19:30:33 UTC 2011
On 03/17/2011 09:22 AM, Jiri Denemark wrote:
> Calling most hash APIs is not safe from inside of an iterator callback.
> Exceptions are APIs that do not modify the hash table and removing
> current hash entry from virHashFroEach callback.
>
> This patch make all APIs which are not safe fail instead of just relying
> on the callback being nice not calling any unsafe APIs.
> ---
> src/util/hash.c | 49 +++++++++++++++++++++++++++++++++++++++++++++----
> 1 files changed, 45 insertions(+), 4 deletions(-)
>
> diff --git a/src/util/hash.c b/src/util/hash.c
> index 2a9a9cf..48a94ad 100644
> --- a/src/util/hash.c
> +++ b/src/util/hash.c
> @@ -35,6 +35,12 @@
>
> /* #define DEBUG_GROW */
>
> +#define virHashIterationError(ret) \
> + do { \
> + VIR_ERROR0(_("Hash operation not allowed during iteration")); \
> + return ret; \
> + } while (0)
ACK; nice helper macro.
--
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/20110317/c9ca38e1/attachment-0001.sig>
More information about the libvir-list
mailing list