]> xenbits.xensource.com Git - libvirt.git/commitdiff
vz: fix crash when parsing unexpected disk configuration
authorMaxim Nestratov <mnestratov@virtuozzo.com>
Mon, 6 Jun 2016 15:54:23 +0000 (18:54 +0300)
committerMaxim Nestratov <mnestratov@virtuozzo.com>
Sat, 11 Jun 2016 15:21:15 +0000 (18:21 +0300)
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 <mnestratov@virtuozzo.com>
src/vz/vz_sdk.c

index 0e989e65986abb3bb68eac0367cd0bd8f7c4e1dd..99c5d4a4a209b0a92b2feb6e57db0536eca1d75d 100644 (file)
@@ -539,6 +539,9 @@ prlsdkGetDiskId(PRL_HANDLE disk, bool isCt, int *bus, char **dst)
         return -1;
     }
 
+    if (NULL == *dst)
+        return -1;
+
     return 0;
 }