[PATCH 2/2] esx: Fix SetAutoStart invalid pointer free

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



esxVI_AutoStartPowerInfo_Free, which is called from
esxVI_HostAutoStartManagerConfig_Free, will always call VIR_FREE to free
memory from {start,stop}Action, leading to a invalid pointer.

With this patch applied, ESX can set autostart successfully to all it's
domains.

Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@xxxxxxxxx>
---
 src/esx/esx_driver.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 3835e4cb3c..a49862a1de 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -3386,7 +3386,9 @@ esxDomainSetAutostart(virDomainPtr domain, int autostart)
     if (esxVI_AutoStartPowerInfo_Alloc(&newPowerInfo) < 0 ||
         esxVI_Int_Alloc(&newPowerInfo->startOrder) < 0 ||
         esxVI_Int_Alloc(&newPowerInfo->startDelay) < 0 ||
-        esxVI_Int_Alloc(&newPowerInfo->stopDelay) < 0) {
+        esxVI_Int_Alloc(&newPowerInfo->stopDelay) < 0 ||
+        VIR_ALLOC_N(newPowerInfo->startAction, 8) < 0 ||
+        VIR_ALLOC_N(newPowerInfo->stopAction, 5) < 0) {
         goto cleanup;
     }
 
@@ -3394,9 +3396,9 @@ esxDomainSetAutostart(virDomainPtr domain, int autostart)
     newPowerInfo->startOrder->value = -1; /* no specific start order */
     newPowerInfo->startDelay->value = -1; /* use system default */
     newPowerInfo->waitForHeartbeat = esxVI_AutoStartWaitHeartbeatSetting_SystemDefault;
-    newPowerInfo->startAction = autostart ? (char *)"powerOn" : (char *)"none";
+    strcpy(newPowerInfo->startAction, autostart ? (char *)"powerOn" : (char *)"none");
     newPowerInfo->stopDelay->value = -1; /* use system default */
-    newPowerInfo->stopAction = (char *)"none";
+    strcpy(newPowerInfo->stopAction, (char *)"none");
 
     if (esxVI_AutoStartPowerInfo_AppendToList(&spec->powerInfo,
                                               newPowerInfo) < 0) {
-- 
2.17.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux