From 805d013a5604b124177149be4d10384f58eff74b Mon Sep 17 00:00:00 2001 From: Cathy Avery Date: Tue, 3 Dec 2019 14:30:49 +0100 Subject: [PATCH 3/4] Address two Coverity-reported issues in hostinfoPosix.c. RH-Author: Cathy Avery Message-id: <20191203143050.23065-4-cavery@redhat.com> Patchwork-id: 92834 O-Subject: [RHEL8.2 open-vm-tools PATCH 3/4] Address two Coverity-reported issues in hostinfoPosix.c. Bugzilla: 1769881 RH-Acked-by: Vitaly Kuznetsov RH-Acked-by: Miroslav Rezanina commit 8a01c912927b5bb8cdbfa57f5e8c92e8cf792bef Author: Oliver Kurth Date: Fri Nov 22 14:52:35 2019 -0800 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. Signed-off-by: Cathy Avery Signed-off-by: Miroslav Rezanina --- open-vm-tools/lib/misc/hostinfoPosix.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/open-vm-tools/lib/misc/hostinfoPosix.c b/open-vm-tools/lib/misc/hostinfoPosix.c index 348a67e..302452e 100644 --- a/open-vm-tools/lib/misc/hostinfoPosix.c +++ b/open-vm-tools/lib/misc/hostinfoPosix.c @@ -1127,10 +1127,7 @@ out: if (success) { result[nArgs - 1] = DynBuf_Detach(&b); } else { - if (nArgs != 0) { - Util_FreeStringList(result, nArgs); - } - + Util_FreeStringList(result, nArgs); result = NULL; } @@ -2884,7 +2881,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; -- 1.8.3.1