From b08cd0da457263f80e84ca95348c2a97cb7e22a5 Mon Sep 17 00:00:00 2001 From: Oliver Kurth Date: Mon, 17 Sep 2018 16:41:19 -0700 Subject: [PATCH] Hgfs Server Linux: fix the share permissions on a file rename or delete Coverity found that the argumeents to obtain the share permissions on a file rename were swapped. Even though they are tested together in an if statement which is not an issue, it could be in the future. Reverse arguments so the share read and write permissions are correct. --- open-vm-tools/lib/hgfsServer/hgfsServer.c | 4 ++-- open-vm-tools/lib/hgfsServer/hgfsServerLinux.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/open-vm-tools/lib/hgfsServer/hgfsServer.c b/open-vm-tools/lib/hgfsServer/hgfsServer.c index bcde63669..7ea3b7f48 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServer.c +++ b/open-vm-tools/lib/hgfsServer/hgfsServer.c @@ -7246,8 +7246,8 @@ HgfsValidateRenameFile(Bool useHandle, // IN: if (HGFS_ERROR_SUCCESS != status) { LOG(4, ("%s: could not map cached handle %d, error %u\n", __FUNCTION__, fileHandle, status)); - } else if (!HgfsHandle2FileNameMode(fileHandle, session, &shareInfo->writePermissions, - &shareInfo->readPermissions, localFileName, + } else if (!HgfsHandle2FileNameMode(fileHandle, session, &shareInfo->readPermissions, + &shareInfo->writePermissions, localFileName, localNameLength)) { /* * HgfsPlatformRename requires valid source file name even when file handle diff --git a/open-vm-tools/lib/hgfsServer/hgfsServerLinux.c b/open-vm-tools/lib/hgfsServer/hgfsServerLinux.c index c4f7c89e6..f2b7ce67e 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServerLinux.c +++ b/open-vm-tools/lib/hgfsServer/hgfsServerLinux.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2017 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2018 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -4583,8 +4583,8 @@ HgfsPlatformDeleteFileByHandle(HgfsHandle file, // IN: File being delet char *localName; size_t localNameSize; - if (HgfsHandle2FileNameMode(file, session, &writePermissions, - &readPermissions, &localName, &localNameSize)) { + if (HgfsHandle2FileNameMode(file, session, &readPermissions, &writePermissions, + &localName, &localNameSize)) { if (writePermissions && readPermissions) { status = HgfsPlatformDeleteFileByName(localName); } else { @@ -4665,8 +4665,8 @@ HgfsPlatformDeleteDirByHandle(HgfsHandle file, // IN: File being delete char *localName; size_t localNameSize; - if (HgfsHandle2FileNameMode(file, session, &writePermissions, - &readPermissions, &localName, &localNameSize)) { + if (HgfsHandle2FileNameMode(file, session, &readPermissions, &writePermissions, + &localName, &localNameSize)) { if (writePermissions && readPermissions) { status = HgfsPlatformDeleteDirByName(localName); } else { -- 2.47.3