--- open-vm-tools-10.3.0-8931395-orig/vmhgfs-fuse/filesystem.c 2018-06-23 03:03:28.000000000 -0700 +++ open-vm-tools-10.3.0-8931395/vmhgfs-fuse/filesystem.c 2019-02-11 18:47:36.188968780 -0800 @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2013 VMware, Inc. All rights reserved. + * Copyright (C) 2013,2019 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 @@ -123,36 +123,50 @@ HgfsOp opUsed, // IN: Op to be used. HgfsReq *req) // IN/OUT: Packet to write into { - char *name; - uint32 *nameLength; size_t requestSize; - int result; + ASSERT(req); switch (opUsed) { case HGFS_OP_QUERY_VOLUME_INFO_V3: { + int result; HgfsRequestQueryVolumeV3 *requestV3 = HgfsGetRequestPayload(req); - /* We'll use these later. */ - name = requestV3->fileName.name; - nameLength = &requestV3->fileName.length; requestV3->fileName.flags = 0; requestV3->fileName.fid = HGFS_INVALID_HANDLE; requestV3->fileName.caseType = HGFS_FILE_NAME_CASE_SENSITIVE; requestV3->reserved = 0; requestSize = sizeof(*requestV3) + HgfsGetRequestHeaderSize(); + /* Convert to CP name. */ + result = CPName_ConvertTo(path, + HGFS_LARGE_PACKET_MAX - (requestSize - 1), + requestV3->fileName.name); + if (result < 0) { + LOG(4, ("CP conversion failed.\n")); + return -EINVAL; + } + requestV3->fileName.length = result; + requestSize += result; break; } case HGFS_OP_QUERY_VOLUME_INFO: { + int result; HgfsRequestQueryVolume *request; request = (HgfsRequestQueryVolume *)(HGFS_REQ_PAYLOAD(req)); - /* We'll use these later. */ - name = request->fileName.name; - nameLength = &request->fileName.length; requestSize = sizeof *request; + /* Convert to CP name. */ + result = CPName_ConvertTo(path, + HGFS_LARGE_PACKET_MAX - (requestSize - 1), + request->fileName.name); + if (result < 0) { + LOG(4, ("CP conversion failed.\n")); + return -EINVAL; + } + request->fileName.length = result; + requestSize += result; break; } default: @@ -160,17 +174,7 @@ return -EPROTO; } - /* Convert to CP name. */ - result = CPName_ConvertTo(path, - HGFS_LARGE_PACKET_MAX - (requestSize - 1), - name); - if (result < 0) { - LOG(4, ("CP conversion failed.\n")); - return -EINVAL; - } - - *nameLength = (uint32) result; - req->payloadSize = requestSize + result; + req->payloadSize = requestSize; /* Fill in header here as payloadSize needs to be there. */ HgfsPackHeader(req, opUsed);