Blob Blame History Raw
From 1128cfce9031891ff0da50131b75771582756ca1 Mon Sep 17 00:00:00 2001
From: Oliver Kurth <okurth@vmware.com>
Date: Wed, 2 Oct 2019 17:48:35 -0700
Subject: Fix leaks in ListAliases and ListMappedAliases.

The 'record' for each alias was being leaked.
---
 open-vm-tools/services/plugins/vix/vixTools.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/open-vm-tools/services/plugins/vix/vixTools.c b/open-vm-tools/services/plugins/vix/vixTools.c
index 44bca5c..c40ad15 100644
--- a/open-vm-tools/services/plugins/vix/vixTools.c
+++ b/open-vm-tools/services/plugins/vix/vixTools.c
@@ -9762,7 +9762,6 @@ VixToolsListAuthAliases(VixCommandRequestHeader *requestMsg, // IN
    char *destPtr;
    char *endDestPtr;
    char *tmpBuf = NULL;
-   char *recordBuf;
    size_t recordSize;
    char *escapedStr = NULL;
    char *escapedStr2 = NULL;
@@ -9822,6 +9821,8 @@ VixToolsListAuthAliases(VixCommandRequestHeader *requestMsg, // IN
    destPtr += Str_Sprintf(destPtr, endDestPtr - destPtr, "%s",
                           VIX_XML_ESCAPED_TAG);
    for (i = 0; i < num; i++) {
+      char *recordBuf = NULL;
+
       escapedStr = VixToolsEscapeXMLString(uaList[i].pemCert);
       if (escapedStr == NULL) {
          err = VIX_E_OUT_OF_MEMORY;
@@ -9895,6 +9896,8 @@ VixToolsListAuthAliases(VixCommandRequestHeader *requestMsg, // IN
          Log("%s: ListAuth list results too large, truncating", __FUNCTION__);
          goto abort;
       }
+      free(recordBuf);
+      recordBuf = NULL;
    }
 
    *result = resultBuffer;
@@ -9960,7 +9963,6 @@ VixToolsListMappedAliases(VixCommandRequestHeader *requestMsg, // IN
    char *destPtr;
    char *endDestPtr;
    char *tmpBuf = NULL;
-   char *recordBuf;
    char *escapedStr = NULL;
    char *escapedStr2 = NULL;
    size_t recordSize;
@@ -10014,6 +10016,8 @@ VixToolsListMappedAliases(VixCommandRequestHeader *requestMsg, // IN
    destPtr += Str_Sprintf(destPtr, endDestPtr - destPtr, "%s",
                           VIX_XML_ESCAPED_TAG);
    for (i = 0; i < num; i++) {
+      char *recordBuf = NULL;
+
       escapedStr = VixToolsEscapeXMLString(maList[i].pemCert);
       if (escapedStr == NULL) {
          err = VIX_E_OUT_OF_MEMORY;
@@ -10085,6 +10089,8 @@ VixToolsListMappedAliases(VixCommandRequestHeader *requestMsg, // IN
          Log("%s: ListMapped results too large, truncating", __FUNCTION__);
          goto abort;
       }
+      free(recordBuf);
+      recordBuf = NULL;
    }
 
    *result = resultBuffer;
-- 
1.8.3.1