From 86ec5be96b61f3b391711aab3aee0c4d85101b2f Mon Sep 17 00:00:00 2001 From: Cathy Avery Date: Thu, 25 Jul 2019 12:32:39 +0200 Subject: [PATCH 16/16] Fix two coverity issues reported by a customer. RH-Author: Cathy Avery Message-id: <20190725123239.18274-17-cavery@redhat.com> Patchwork-id: 89719 O-Subject: [RHEL8.1 open-vm-tools PATCH 16/16] [Tools/dndcp] Fix two coverity issues reported by a customer. Bugzilla: 1602648 RH-Acked-by: Vitaly Kuznetsov RH-Acked-by: Miroslav Rezanina commit 04813113e28f6cfecf956166136bbad2a6c2a386 Author: Oliver Kurth Date: Sat Jul 20 17:15:19 2019 -0700 [Tools/dndcp] Fix two coverity issues reported by a customer. Signed-off-by: Cathy Avery Signed-off-by: Miroslav Rezanina --- open-vm-tools/services/plugins/dndcp/copyPasteUIX11.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/services/plugins/dndcp/copyPasteUIX11.cpp b/services/plugins/dndcp/copyPasteUIX11.cpp index 6c40b84..e9b9e26 100644 --- a/services/plugins/dndcp/copyPasteUIX11.cpp +++ b/services/plugins/dndcp/copyPasteUIX11.cpp @@ -1664,10 +1664,11 @@ CopyPasteUIX11::FileBlockMonitorThread(void *arg) // IN } int fd = open(params->fileBlockName.c_str(), O_RDONLY); - if (fd <= 0) { - g_debug("%s: Failed to open %s\n", + if (fd < 0) { + g_debug("%s: Failed to open %s, errno is %d\n", __FUNCTION__, - params->fileBlockName.c_str()); + params->fileBlockName.c_str(), + errno); continue; } @@ -1688,6 +1689,13 @@ CopyPasteUIX11::FileBlockMonitorThread(void *arg) // IN } else { g_debug("%s: Block is not added\n", __FUNCTION__); } + + if (close(fd) < 0) { + g_debug("%s: Failed to close %s, errno is %d\n", + __FUNCTION__, + params->fileBlockName.c_str(), + errno); + } } pthread_mutex_unlock(¶ms->fileBlockMutex); return NULL; -- 1.8.3.1