[libvirt PATCH 10/11] remote: allocate def in remoteRelayDomainEventCheckACL

Peter Krempa pkrempa at redhat.com
Fri Aug 28 06:58:43 UTC 2020


On Thu, Aug 27, 2020 at 22:19:52 +0200, Ján Tomko wrote:
> Signed-off-by: Ján Tomko <jtomko at redhat.com>
> ---
>  src/remote/remote_daemon_dispatch.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
> index 53d17a8f4a..84cc45e1ac 100644
> --- a/src/remote/remote_daemon_dispatch.c
> +++ b/src/remote/remote_daemon_dispatch.c
> @@ -159,22 +159,21 @@ static bool
>  remoteRelayDomainEventCheckACL(virNetServerClientPtr client,
>                                 virConnectPtr conn, virDomainPtr dom)
>  {
> -    virDomainDef def;
> +    g_autoptr(virDomainDef) def = g_new0(virDomainDef, 1);

Registering this for a cleanup by 'virDomainDefFree' ...

>      g_autoptr(virIdentity) identity = NULL;
>      bool ret = false;
>  
>      /* For now, we just create a virDomainDef with enough contents to
>       * satisfy what viraccessdriverpolkit.c references.  This is a bit
>       * fragile, but I don't know of anything better.  */
> -    memset(&def, 0, sizeof(def));
> -    def.name = dom->name;
> -    memcpy(def.uuid, dom->uuid, VIR_UUID_BUFLEN);
> +    def->name = dom->name;

... will free the 'dom->name' pointer borrowed incorrectly here.

> +    memcpy(def->uuid, dom->uuid, VIR_UUID_BUFLEN);
>  
>      if (!(identity = virNetServerClientGetIdentity(client)))
>          goto cleanup;
>      if (virIdentitySetCurrent(identity) < 0)
>          goto cleanup;
> -    ret = virConnectDomainEventRegisterAnyCheckACL(conn, &def);
> +    ret = virConnectDomainEventRegisterAnyCheckACL(conn, def);
>  
>   cleanup:
>      ignore_value(virIdentitySetCurrent(NULL));
> -- 
> 2.26.2
> 




More information about the libvir-list mailing list