From: Maxim Nestratov Date: Mon, 6 Jun 2016 15:54:23 +0000 (+0300) Subject: vz: fix crash when parsing unexpected disk configuration X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=85d54f133c3b811d06fd8d55702ead03385a8a56;p=libvirt.git vz: fix crash when parsing unexpected disk configuration As it turned out PrlVmDev_GetStackIndex can return negative values without reporting an error, which is incorrect but nevertheless. After that we feed this negative index to virIndexToDiskName, which in turn returns NULL and we set it to virDomainDiskDef.dst. Using virDiskNameToBusDeviceIndex with a virDomainDiskDef structure which has NULL dst field crashes. Fix this by returning an error in prlsdkGetDiskId in such cases. Signed-off-by: Maxim Nestratov --- diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 0e989e6598..99c5d4a4a2 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -539,6 +539,9 @@ prlsdkGetDiskId(PRL_HANDLE disk, bool isCt, int *bus, char **dst) return -1; } + if (NULL == *dst) + return -1; + return 0; }