From: Oliver Kurth Date: Fri, 22 Nov 2019 22:52:35 +0000 (-0800) Subject: Address two Coverity-reported issues in hostinfoPosix.c. X-Git-Tag: stable-11.1.0~133 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8a01c912927b5bb8cdbfa57f5e8c92e8cf792bef;p=thirdparty%2Fopen-vm-tools.git Address two Coverity-reported issues in hostinfoPosix.c. Rework some code with the intent of making it more straightfoward, which also eliminates a false positive. Check the return value from PosixUnlink and log a warning on error. --- diff --git a/open-vm-tools/lib/misc/hostinfoPosix.c b/open-vm-tools/lib/misc/hostinfoPosix.c index 3baee94f4..941bc053a 100644 --- a/open-vm-tools/lib/misc/hostinfoPosix.c +++ b/open-vm-tools/lib/misc/hostinfoPosix.c @@ -1153,10 +1153,7 @@ out: if (success) { result[nArgs - 1] = DynBuf_Detach(&b); } else { - if (nArgs != 0) { - Util_FreeStringList(result, nArgs); - } - + Util_FreeStringList(result, nArgs); result = NULL; } @@ -2910,7 +2907,10 @@ Hostinfo_Daemonize(const char *path, // IN: NUL-terminated UTF-8 * with another process attempting to daemonize and unlinking the * file it created instead. */ - Posix_Unlink(pidPath); + if (Posix_Unlink(pidPath) != 0) { + Warning("%s: Unable to unlink %s: %u\n", + __FUNCTION__, pidPath, errno); + } } errno = err;