]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virdomainjob: virDomainObjInitJob: Avoid borrowing memory from 'virDomainXMLOption'
authorPeter Krempa <pkrempa@redhat.com>
Mon, 19 Sep 2022 08:18:14 +0000 (10:18 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 20 Sep 2022 11:56:57 +0000 (13:56 +0200)
commitb34c7c91040bf61703407bd24056866d2441bc10
treed9d5161a2468359c674f631177391ab578d8370d
parent7c35778126104308480c2ad08c4cb390d0cd1032
virdomainjob: virDomainObjInitJob: Avoid borrowing memory from 'virDomainXMLOption'

The 'cb' and 'jobDataPrivateCb' pointers are stored in the job object
but made point to the memory owned by the virDomainXMLOption struct in
the callers.

Since the 'virdomainjob' module isn't in control the lifetime of the
virDomainXMLOption, which in some cases is freed before the domain job
data, freed memory would be dereferenced in some cases.

Copy the structs from virDomainXMLOption to ensure the lifetime. This is
possible since the callback functions are immutable.

Fixes: 84e9fd068ccad6e19e037cd6680df437617e2de5
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/conf/virdomainjob.c