Possible memory leak of cgroup in Domain.SetThrottleGroup
Same problem as DelThrottleGroup: cgroup is allocated with C.CString and never
freed. Every call leaks len(group)+1 bytes.
domain.go:6093
func (d *Domain) SetThrottleGroup(group string, params *DomainBlockIoTuneParameters, flags DomainModificationImpact) error {
info := getBlockIoTuneParametersFieldInfo(params)
cparams, cnparams, gerr := typedParamsPackNew(info)
if gerr != nil {
return gerr
}
defer C.virTypedParamsFreeWrapper(cparams, cnparams)
var err C.virError
cgroup := C.CString(group)
ret := C.virDomainSetThrottleGroupWrapper(d.ptr, cgroup, cparams, cnparams, C.uint(flags), &err)
if ret == -1 {
return makeError(&err)
}
return nil
}
Note the cparams on the line above is released with a defer, but cgroup is not.
libvirt takes the group name as const char * and copies it, so the caller owns the
buffer. cgroup is a local, so no other function can reach it after the return.
Fix:
cgroup := C.CString(group)
defer C.free(unsafe.Pointer(cgroup))
If you could credit me as a reporter for my contributions to security advisory I will be thankful.
Possible memory leak of
cgroupinDomain.SetThrottleGroupSame problem as
DelThrottleGroup:cgroupis allocated withC.CStringand neverfreed. Every call leaks
len(group)+1bytes.domain.go:6093
Note the
cparamson the line above is released with adefer, butcgroupis not.libvirt takes the group name as
const char *and copies it, so the caller owns thebuffer.
cgroupis a local, so no other function can reach it after the return.Fix:
If you could credit me as a reporter for my contributions to security advisory I will be thankful.