[Libvirt-cim] [PATCH 1 of 4] VSSD: validate client given object path

Dan Smith danms at us.ibm.com
Fri Feb 22 19:38:42 UTC 2008


HE>          dom = virDomainLookupByName(conn, name);
HE> -        if (dom == NULL)
HE> -                goto out;
HE> -
HE> -        inst = get_vssd_instance(dom, _BROKER, reference);
HE> -
HE> +        if (dom == NULL) {
HE> +                cu_statusf(broker, &s,
HE> +                           CMPI_RC_ERR_NOT_FOUND,
HE> +                           "No such instance (%s)",
HE> +                           name);
HE> +                goto out;

I think you leak dom here, since you moved the virDomainFree before
the out target:

HE> +        }
HE> +        
HE> +        *_inst = _get_vssd(broker, reference, conn, dom, &s);
HE> +        
HE> +        virDomainFree(dom);
HE> +        
HE>   out:
HE>          virConnectClose(conn);
HE> -        virDomainFree(dom);
HE> -
HE> -        return inst;
HE> +
HE> +        return s;
HE> +}

...

HE> +CMPIStatus get_vssd_by_ref(const CMPIBroker *broker,
HE> +                           const CMPIObjectPath *reference,
HE> +                           CMPIInstance **_inst)
HE> +{
HE> +        CMPIStatus s = {CMPI_RC_OK, NULL};
HE> +        char *name = NULL;
HE> +        
HE> +        if (!parse_instanceid(reference, NULL, &name)) {
HE> +                cu_statusf(broker, &s,
HE> +                           CMPI_RC_ERR_NOT_FOUND,
HE> +                           "No such instance (InstanceID)");
HE> +                goto out;
HE> +        }
HE> +        
HE> +        s = get_vssd_by_name(broker, reference, name, _inst);
HE> +        if (s.rc != CMPI_RC_OK)
HE> +                goto out;

You leak name here because the free is before the out:

HE> +        
HE> +        s = cu_validate_ref(broker, reference, *_inst);
HE> +        
HE> +        free(name);
HE> +        
HE> + out:
HE> +        return s;
HE>  }

-- 
Dan Smith
IBM Linux Technology Center
Open Hypervisor Team
email: danms at us.ibm.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvirt-cim/attachments/20080222/6c018732/attachment.sig>


More information about the Libvirt-cim mailing list