269 lines
8.6 KiB
Diff
269 lines
8.6 KiB
Diff
diff -ru open-vm-tools-10.3.0-8931395-orig/vmhgfs-fuse/dir.c open-vm-tools-10.3.0-8931395/vmhgfs-fuse/dir.c
|
|
--- open-vm-tools-10.3.0-8931395-orig/vmhgfs-fuse/dir.c 2018-06-23 03:03:28.000000000 -0700
|
|
+++ open-vm-tools-10.3.0-8931395/vmhgfs-fuse/dir.c 2019-02-02 23:40:26.945508336 -0800
|
|
@@ -54,8 +54,6 @@
|
|
HgfsOp opUsed, // IN: Op to be used
|
|
HgfsReq *req) // IN/OUT: Packet to write into
|
|
{
|
|
- char *name;
|
|
- unsigned int *nameLength = NULL;
|
|
size_t reqSize;
|
|
int result;
|
|
|
|
@@ -66,14 +64,21 @@
|
|
case HGFS_OP_SEARCH_OPEN_V3: {
|
|
HgfsRequestSearchOpenV3 *requestV3 = HgfsGetRequestPayload(req);
|
|
|
|
- /* We'll use these later. */
|
|
- name = requestV3->dirName.name;
|
|
- nameLength = &requestV3->dirName.length;
|
|
requestV3->dirName.flags = 0;
|
|
requestV3->dirName.caseType = HGFS_FILE_NAME_CASE_SENSITIVE;
|
|
requestV3->dirName.fid = HGFS_INVALID_HANDLE;
|
|
requestV3->reserved = 0;
|
|
reqSize = sizeof(*requestV3) + HgfsGetRequestHeaderSize();
|
|
+ /* Convert to CP name. */
|
|
+ result = CPName_ConvertTo(path,
|
|
+ HGFS_LARGE_PACKET_MAX - (reqSize - 1),
|
|
+ requestV3->dirName.name);
|
|
+ if (result < 0) {
|
|
+ LOG(4, ("CP conversion failed\n"));
|
|
+ return -EINVAL;
|
|
+ }
|
|
+ LOG(4, ("After conversion = %s\n", requestV3->dirName.name));
|
|
+ requestV3->dirName.length = (uint32) result;
|
|
break;
|
|
}
|
|
|
|
@@ -82,10 +87,17 @@
|
|
|
|
request = (HgfsRequestSearchOpen *)(HGFS_REQ_PAYLOAD(req));
|
|
|
|
- /* We'll use these later. */
|
|
- name = request->dirName.name;
|
|
- nameLength = &request->dirName.length;
|
|
reqSize = sizeof *request;
|
|
+ /* Convert to CP name. */
|
|
+ result = CPName_ConvertTo(path,
|
|
+ HGFS_LARGE_PACKET_MAX - (reqSize - 1),
|
|
+ request->dirName.name);
|
|
+ if (result < 0) {
|
|
+ LOG(4, ("CP conversion failed\n"));
|
|
+ return -EINVAL;
|
|
+ }
|
|
+ LOG(4, ("After conversion = %s\n", request->dirName.name));
|
|
+ request->dirName.length = (uint32) result;
|
|
break;
|
|
}
|
|
|
|
@@ -94,20 +106,6 @@
|
|
return -EPROTO;
|
|
}
|
|
|
|
- /* Convert to CP name. */
|
|
-
|
|
- LOG(4, ("After buildPath = %s\n", path));
|
|
- result = CPName_ConvertTo(path,
|
|
- HGFS_LARGE_PACKET_MAX - (reqSize - 1),
|
|
- name);
|
|
- if (result < 0) {
|
|
- LOG(4, ("CP conversion failed\n"));
|
|
- return -EINVAL;
|
|
- }
|
|
-
|
|
- LOG(4, ("After conversion = %s\n", name));
|
|
-
|
|
- *nameLength = (uint32) result;
|
|
req->payloadSize = reqSize + result;
|
|
|
|
/* Fill in header here as payloadSize needs to be there. */
|
|
@@ -149,7 +147,7 @@
|
|
int result;
|
|
HgfsOp opUsed;
|
|
HgfsStatus replyStatus;
|
|
- HgfsHandle *replySearch;
|
|
+ HgfsHandle replySearch;
|
|
|
|
ASSERT(path);
|
|
req = HgfsGetNewRequest();
|
|
@@ -164,12 +162,12 @@
|
|
if (opUsed == HGFS_OP_SEARCH_OPEN_V3) {
|
|
HgfsReplySearchOpenV3 *requestV3 = HgfsGetReplyPayload(req);
|
|
|
|
- replySearch = &requestV3->search;
|
|
+ replySearch = requestV3->search;
|
|
|
|
} else {
|
|
HgfsReplySearchOpen *request = (HgfsReplySearchOpen *)HGFS_REQ_PAYLOAD(req);
|
|
|
|
- replySearch = &request->search;
|
|
+ replySearch = request->search;
|
|
}
|
|
|
|
result = HgfsPackDirOpenRequest(path, opUsed, req);
|
|
@@ -187,8 +185,8 @@
|
|
|
|
switch (result) {
|
|
case 0:
|
|
- *handle = *replySearch;
|
|
- LOG(6, ("Set handle to %u\n", *replySearch));
|
|
+ *handle = replySearch;
|
|
+ LOG(6, ("Set handle to %u\n", replySearch));
|
|
break;
|
|
case -EPROTO:
|
|
/* Retry with older version(s). Set globally. */
|
|
@@ -626,8 +624,6 @@
|
|
HgfsOp opUsed, // IN: Op to be used.
|
|
HgfsReq *req) // IN/OUT: Packet to write into
|
|
{
|
|
- char *fileName = NULL;
|
|
- uint32 *fileNameLength;
|
|
size_t reqSize;
|
|
int result;
|
|
|
|
@@ -638,13 +634,18 @@
|
|
HgfsRequestCreateDirV3 *requestV3 = HgfsGetRequestPayload(req);
|
|
|
|
reqSize = sizeof(*requestV3) + HgfsGetRequestHeaderSize();
|
|
- /* We'll use these later. */
|
|
- fileName = requestV3->fileName.name;
|
|
- fileNameLength = &requestV3->fileName.length;
|
|
requestV3->fileName.flags = 0;
|
|
requestV3->fileName.fid = HGFS_INVALID_HANDLE;
|
|
requestV3->fileName.caseType = HGFS_FILE_NAME_CASE_SENSITIVE;
|
|
-
|
|
+ /* Convert to CP name. */
|
|
+ result = CPName_ConvertTo(path,
|
|
+ HGFS_LARGE_PACKET_MAX - (reqSize - 1),
|
|
+ requestV3->fileName.name);
|
|
+ if (result < 0) {
|
|
+ LOG(4, ("CP conversion failed.\n"));
|
|
+ return -EINVAL;
|
|
+ }
|
|
+ requestV3->fileName.length = result;
|
|
requestV3->mask = HGFS_CREATE_DIR_MASK;
|
|
|
|
/* Set permissions. */
|
|
@@ -660,11 +661,17 @@
|
|
|
|
requestV2 = (HgfsRequestCreateDirV2 *)(HGFS_REQ_PAYLOAD(req));
|
|
|
|
- /* We'll use these later. */
|
|
- fileName = requestV2->fileName.name;
|
|
- fileNameLength = &requestV2->fileName.length;
|
|
reqSize = sizeof *requestV2;
|
|
|
|
+ /* Convert to CP name. */
|
|
+ result = CPName_ConvertTo(path,
|
|
+ HGFS_LARGE_PACKET_MAX - (reqSize - 1),
|
|
+ requestV2->fileName.name);
|
|
+ if (result < 0) {
|
|
+ LOG(4, ("CP conversion failed.\n"));
|
|
+ return -EINVAL;
|
|
+ }
|
|
+ requestV2->fileName.length = result;
|
|
requestV2->mask = HGFS_CREATE_DIR_MASK;
|
|
|
|
/* Set permissions. */
|
|
@@ -679,11 +686,16 @@
|
|
|
|
request = (HgfsRequestCreateDir *)(HGFS_REQ_PAYLOAD(req));
|
|
|
|
- /* We'll use these later. */
|
|
- fileName = request->fileName.name;
|
|
- fileNameLength = &request->fileName.length;
|
|
reqSize = sizeof *request;
|
|
-
|
|
+ /* Convert to CP name. */
|
|
+ result = CPName_ConvertTo(path,
|
|
+ HGFS_LARGE_PACKET_MAX - (reqSize - 1),
|
|
+ request->fileName.name);
|
|
+ if (result < 0) {
|
|
+ LOG(4, ("CP conversion failed.\n"));
|
|
+ return -EINVAL;
|
|
+ }
|
|
+ request->fileName.length = result;
|
|
/* Set permissions. */
|
|
request->permissions = (permsMode & S_IRWXU) >> 6;
|
|
break;
|
|
@@ -693,17 +705,6 @@
|
|
return -EPROTO;
|
|
}
|
|
|
|
-
|
|
- /* Convert to CP name. */
|
|
- result = CPName_ConvertTo(path,
|
|
- HGFS_LARGE_PACKET_MAX - (reqSize - 1),
|
|
- fileName);
|
|
- if (result < 0) {
|
|
- LOG(4, ("CP conversion failed.\n"));
|
|
- return -EINVAL;
|
|
- }
|
|
-
|
|
- *fileNameLength = result;
|
|
req->payloadSize = reqSize + result;
|
|
|
|
/* Fill in header here as payloadSize needs to be there. */
|
|
@@ -827,8 +828,6 @@
|
|
HgfsReq *req = NULL;
|
|
int result = 0;
|
|
HgfsStatus replyStatus;
|
|
- char *fileName = NULL;
|
|
- uint32 *fileNameLength;
|
|
uint32 reqSize;
|
|
HgfsOp opUsed;
|
|
HgfsAttrInfo newAttr = {0};
|
|
@@ -862,8 +861,16 @@
|
|
|
|
reqSize = sizeof(*request) + HgfsGetRequestHeaderSize();
|
|
request->hints = 0;
|
|
- fileName = request->fileName.name;
|
|
- fileNameLength = &request->fileName.length;
|
|
+ /* Convert to CP name. */
|
|
+ result = CPName_ConvertTo(path,
|
|
+ HGFS_NAME_BUFFER_SIZET(HGFS_LARGE_PACKET_MAX, reqSize),
|
|
+ request->fileName.name);
|
|
+ if (result < 0) {
|
|
+ LOG(4, ("CP conversion failed.\n"));
|
|
+ result = -EINVAL;
|
|
+ goto out;
|
|
+ }
|
|
+ request->fileName.length = result;
|
|
request->fileName.fid = HGFS_INVALID_HANDLE;
|
|
request->fileName.flags = 0;
|
|
request->fileName.caseType = HGFS_FILE_NAME_DEFAULT_CASE;
|
|
@@ -874,23 +881,19 @@
|
|
|
|
request = (HgfsRequestDelete *)(HGFS_REQ_PAYLOAD(req));
|
|
/* Fill out the request packet. */
|
|
- fileName = request->fileName.name;
|
|
- fileNameLength = &request->fileName.length;
|
|
reqSize = sizeof *request;
|
|
+ /* Convert to CP name. */
|
|
+ result = CPName_ConvertTo(path,
|
|
+ HGFS_NAME_BUFFER_SIZET(HGFS_LARGE_PACKET_MAX, reqSize),
|
|
+ request->fileName.name);
|
|
+ if (result < 0) {
|
|
+ LOG(4, ("CP conversion failed.\n"));
|
|
+ result = -EINVAL;
|
|
+ goto out;
|
|
+ }
|
|
+ request->fileName.length = result;
|
|
}
|
|
|
|
-
|
|
- /* Convert to CP name. */
|
|
- result = CPName_ConvertTo(path,
|
|
- HGFS_NAME_BUFFER_SIZET(HGFS_LARGE_PACKET_MAX, reqSize),
|
|
- fileName);
|
|
- if (result < 0) {
|
|
- LOG(4, ("CP conversion failed.\n"));
|
|
- result = -EINVAL;
|
|
- goto out;
|
|
- }
|
|
-
|
|
- *fileNameLength = result;
|
|
req->payloadSize = reqSize + result;
|
|
|
|
/* Fill in header here as payloadSize needs to be there. */
|