]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
More Coverity annotations for open-vm-tools issues.
authorOliver Kurth <okurth@vmware.com>
Mon, 9 Sep 2019 18:23:48 +0000 (11:23 -0700)
committerOliver Kurth <okurth@vmware.com>
Mon, 9 Sep 2019 18:23:48 +0000 (11:23 -0700)
Add annotations for additional Coverity-reported issues so that
Coverity scans of ovt will automatically classify these issues
as "intentional."  Such annotations are useful both for internal
use as well as for partners who run Coverity scans of open-vm-tools.

open-vm-tools/lib/hgfsServer/hgfsServer.c
open-vm-tools/lib/procMgr/procMgrPosix.c
open-vm-tools/lib/rpcChannel/rpcChannel.c
open-vm-tools/libguestlib/vmGuestLib.c
open-vm-tools/services/plugins/guestInfo/guestInfoServer.c
open-vm-tools/toolbox/toolboxcmd-info.c
open-vm-tools/vgauth/serviceImpl/alias.c

index c404047f2a47819eeca793461a7a89c168843aa6..e140e420a311c506d29ab587ae18cfb75db3f48b 100644 (file)
@@ -3399,6 +3399,13 @@ HgfsServerSessionReceive(HgfsPacket *packet,      // IN: Hgfs Packet
       LOG(4, ("Error %d occurred parsing the packet\n", (uint32)status));
       HgfsServerCompleteRequest(status, 0, input);
    }
+
+   /*
+    * Storage pointed at by the variable input was freed either by
+    * HgfsServerProcessRequest at the end of request processing
+    * or by HgfsServerCompleteRequest if there was a protocol error.
+    */
+   /* coverity[leaked_storage] */
 }
 
 
index 980583303d8291a93847b4a8a8643ac927685022..f3e176a15e8f6105f24e22f902ae7fa05a6b6331 100644 (file)
@@ -393,6 +393,13 @@ ProcMgr_ListProcesses(void)
          int exeLen;
          char exeRealPath[1024];
 
+         /*
+          * This readlink() call on the "exe" file of the current /proc
+          * entry is not intended as a check on the subsequent open() of
+          * the "status" file of that entry, hence no time-of-check to
+          * time-of-use issue.
+          */
+         /* coverity[fs_check_call] */
          exeLen = readlink(cmdFilePath, exeRealPath, sizeof exeRealPath -1);
          if (exeLen != -1) {
             exeRealPath[exeLen] = '\0';
@@ -521,7 +528,13 @@ ProcMgr_ListProcesses(void)
        * stat() /proc/<pid> to get the owner.  We use fileStat.st_uid
        * later in this code.  If we can't stat(), ignore and continue.
        * Maybe we don't have enough permission.
+       *
+       * This stat() call on the current /proc entry is not intended
+       * as a check on the open() near the top of the while loop which
+       * is on the cmdline file of the next entry in /proc, hence no
+       * time-of-check to time-of-use issue.
        */
+      /* coverity[fs_check_call] */
       statResult = stat(cmdFilePath, &fileStat);
       if (0 != statResult) {
          goto next_entry;
index 98b46d19633568198e025e5652006c309b0912eb..7d1edbde404b6a823f6f937405142a8cd0ee807b 100644 (file)
@@ -296,6 +296,12 @@ RpcChannelXdrWrapper(RpcInData *data,
 
       if (!xdrProc(&xdrs, copy.result, 0)) {
          ret = RPCIN_SETRETVALS(data, "XDR serialization failed.", FALSE);
+
+         /*
+          * DynXdr_Destroy only tries to free storage returned by a call to
+          * DynXdr_Create(NULL).
+          */
+         /* coverity[address_free] */
          DynXdr_Destroy(&xdrs, TRUE);
          goto exit;
       }
@@ -306,6 +312,12 @@ RpcChannelXdrWrapper(RpcInData *data,
       data->result = DynXdr_Get(&xdrs);
       data->resultLen = XDR_GETPOS(&xdrs);
       data->freeResult = TRUE;
+
+      /*
+       * DynXdr_Destroy only tries to free storage returned by a call to
+       * DynXdr_Create(NULL).
+       */
+      /* coverity[address_free] */
       DynXdr_Destroy(&xdrs, FALSE);
    }
 
@@ -362,6 +374,12 @@ RpcChannel_BuildXdrCommand(const char *cmd,
    ret = TRUE;
 
 exit:
+
+   /*
+    * DynXdr_Destroy only tries to free storage returned by a call to
+    * DynXdr_Create(NULL).
+    */
+   /* coverity[address_free] */
    DynXdr_Destroy(&xdrs, !ret);
    return ret;
 }
index f3d48521668b07203282b3594f0f03bc34748d37..e7f7795319f857d1d3552e2569438c771ec9a516 100644 (file)
@@ -1842,6 +1842,12 @@ VMGuestLibIoctl(const GuestLibIoctlParam *param,
    }
    ret = RpcChannel_SendOneRaw(DynXdr_Get(&xdrs), xdr_getpos(&xdrs),
                                reply, replySize);
+
+   /*
+    * DynXdr_Destroy only tries to free storage returned by a call to
+    * DynXdr_Create(NULL).
+    */
+   /* coverity[address_free] */
    DynXdr_Destroy(&xdrs, TRUE);
    return ret;
 }
index f0df0e2e55656f798092da088f3fe3c490834198..b283250483c4ce5ee594d5036e684f79378376a7 100644 (file)
@@ -994,6 +994,12 @@ GuestInfoSendNicInfoXdr(ToolsAppCtx *ctx,          // IN
       }
       vm_free(reply);
    }
+
+   /*
+    * DynXdr_Destroy only tries to free storage returned by a call to
+    * DynXdr_Create(NULL).
+    */
+   /* coverity[address_free] */
    DynXdr_Destroy(&xdrs, TRUE);
 
 exit:
index 910f208818be725ba000dfe63c208d213e492284..c7408d1fe71bb4c8a7863a0f3a23d8c3cd841b98 100644 (file)
@@ -81,6 +81,12 @@ InfoSendNetworkXdr(GuestNicProto *message,
       }
       ToolsCmd_FreeRPC(reply);
    }
+
+   /*
+    * DynXdr_Destroy only tries to free storage returned by a call to
+    * DynXdr_Create(NULL).
+    */
+   /* coverity[address_free] */
    DynXdr_Destroy(&xdrs, TRUE);
 
 exit:
index e719deff845ed4e7052e698743a490d198f6279c..83694e87674e474496e90752087e8dbd3b9c9ccf 100644 (file)
@@ -675,6 +675,14 @@ ServiceLoadFileContentsPosix(const gchar *fileName,
 
    *fileSize = 0;
    *contents = NULL;
+
+   /*
+    * No time-of-check to time-of-use issue between this lstat() call and the
+    * subsequent open() since the open() is followed by fstat() and a series
+    * of checks of the fstat results against the lstat results to ensure that
+    * key file attributes did not change between the lstat() and the open().
+    */
+   /* coverity[fs_check_call] */
    ret = g_lstat(fileName, &lstatBuf);
    if (ret != 0) {
       Warning("%s: lstat(%s) failed (%d %d)\n",