]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
No JSON disk array termination needed, if partition count is zero.
authorOliver Kurth <okurth@vmware.com>
Sun, 21 Jul 2019 00:15:20 +0000 (17:15 -0700)
committerOliver Kurth <okurth@vmware.com>
Sun, 21 Jul 2019 00:15:20 +0000 (17:15 -0700)
In the unlikely case of a VM with zero disks, a jsonPerDiskFmtFooterLast
should not be emitted.

open-vm-tools/services/plugins/guestInfo/guestInfoServer.c

index 7c6fe143741d965f55183f9354cb44d6337a26ac..f0df0e2e55656f798092da088f3fe3c490834198 100644 (file)
@@ -1322,9 +1322,11 @@ GuestInfoSendDiskInfoV1(ToolsAppCtx *ctx,             // IN
       }
 #endif
    }
-   /* Terminate the last element of the disk partition JSON array. */
-   DynBuf_Append(&dynBuffer, jsonPerDiskFmtFooterLast,
-                 sizeof jsonPerDiskFmtFooterLast - 1);
+   if (pdi->numEntries > 0) {
+      /* Terminate the last element of the disk partition JSON array. */
+      DynBuf_Append(&dynBuffer, jsonPerDiskFmtFooterLast,
+                    sizeof jsonPerDiskFmtFooterLast - 1);
+   }
 
    DynBuf_Append(&dynBuffer, jsonSuffix, sizeof jsonSuffix - 1);