]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Add 4 new guestRPC commands for namespace manager.
authorVMware, Inc <>
Wed, 18 Sep 2013 03:32:13 +0000 (20:32 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 23 Sep 2013 05:19:59 +0000 (22:19 -0700)
Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
open-vm-tools/lib/rpcChannel/vsockChannel.c

index f12a81debd36f37fb26dbb53b78fb043376a9cbb..0c5cf37d210bdf82ba428c35feaeac61710de954 100644 (file)
@@ -415,6 +415,9 @@ VSockChannelShutdown(RpcChannel *chan)    // IN
  * VSockChannelSend --
  *
  *      Sends the data using the vsocket channel.
+ *      If the caller is not interested in the reply, result and resultLen
+ *      can be set to NULL, otherwise, the caller *must* free the result
+ *      whether the call is successful or not to avoid memory leak.
  *
  * Result:
  *      TRUE on success
@@ -430,24 +433,24 @@ static gboolean
 VSockChannelSend(RpcChannel *chan,      // IN
                  char const *data,      // IN
                  size_t dataLen,        // IN
-                 char **result,         // OUT
-                 size_t *resultLen)     // OUT
+                 char **result,         // OUT optional
+                 size_t *resultLen)     // OUT optional
 {
    gboolean ret = FALSE;
    VSockChannel *vsock = chan->_private;
-   const char *reply;
-   size_t replyLen;
+   const char *reply = NULL;
+   size_t replyLen = 0;
 
    if (!chan->outStarted) {
       goto exit;
    }
 
+   /*
+    * We propagate all replies from VSockOutSend: either a reply of the RPC
+    * result or a description of the error on failure.
+    */
    ret = VSockOutSend(vsock->out, data, dataLen, &reply, &replyLen);
 
-   if (!ret) {
-      goto exit;
-   }
-
    if (result != NULL) {
       if (reply != NULL) {
          *result = Util_SafeMalloc(replyLen + 1);