From: Oliver Kurth Date: Sun, 21 Jul 2019 00:15:20 +0000 (-0700) Subject: No JSON disk array termination needed, if partition count is zero. X-Git-Tag: stable-11.1.0~305 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2ebde975c41594a36355c5238098d84a15555ea;p=thirdparty%2Fopen-vm-tools.git No JSON disk array termination needed, if partition count is zero. In the unlikely case of a VM with zero disks, a jsonPerDiskFmtFooterLast should not be emitted. --- diff --git a/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c b/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c index 7c6fe1437..f0df0e2e5 100644 --- a/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c +++ b/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c @@ -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);