- Timestamp:
- Apr 12, 2024 8:51:39 AM (10 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-transfers-http.cpp
r104305 r104306 465 465 if (RT_SUCCESS(rc)) 466 466 { 467 char *pszPa th = RTUriParsedPath(pszUrl, &Parsed);468 AssertPtrReturn(pszPa th, VERR_NO_MEMORY); /* Should be okay, as we succeeded RTUriParse() above. */469 size_t const cchPa th = strlen(pszPath);467 char *pszParsedPath = RTUriParsedPath(pszUrl, &Parsed); 468 AssertPtrReturn(pszParsedPath, VERR_NO_MEMORY); /* Should be okay, as we succeeded RTUriParse() above. */ 469 size_t const cchParsedPath = strlen(pszParsedPath); 470 470 471 471 /* For now we only know the transfer -- now we need to figure out the entry we want to serve. */ … … 473 473 if (pSrvTx) 474 474 { 475 size_t const cchBase = strlen(pSrvTx->szPathVirtual) + 1 /* Skip slash separating the base from the rest */; 476 AssertReturn(cchPath >= cchBase, VERR_INVALID_PARAMETER); 477 478 SHCLOBJOPENCREATEPARMS openParms; 479 rc = ShClTransferObjOpenParmsInit(&openParms); 475 size_t const cchRoot = strlen(pSrvTx->szPathVirtual) + 1 /* Skip slash separating the base from the rest */; 476 AssertStmt(cchParsedPath >= cchRoot, rc = VERR_INVALID_PARAMETER); 477 const char *pszRoot = pszParsedPath + cchRoot; /* Marks the actual root path. */ 478 AssertStmt(RT_VALID_PTR(pszRoot), rc = VERR_INVALID_POINTER); 479 AssertStmt(*pszRoot != '\0', rc = VERR_INVALID_PARAMETER); 480 480 481 if (RT_SUCCESS(rc)) 481 482 { 482 openParms.fCreate = SHCL_OBJ_CF_ACCESS_READ 483 | SHCL_OBJ_CF_ACCESS_DENYWRITE; 484 485 PSHCLTRANSFER pTx = pSrvTx->pTransfer; 486 AssertPtr(pTx); 487 488 rc = VERR_NOT_FOUND; /* Must find the matching root entry first. */ 489 490 uint64_t const cRoots = ShClTransferRootsCount(pTx); 491 for (uint32_t i = 0; i < cRoots; i++) 483 SHCLOBJOPENCREATEPARMS openParms; 484 rc = ShClTransferObjOpenParmsInit(&openParms); 485 if (RT_SUCCESS(rc)) 492 486 { 493 PCSHCLLISTENTRY pEntry = ShClTransferRootsEntryGet(pTx, i); 494 AssertPtrBreakStmt(pEntry, rc = VERR_NOT_FOUND); 495 496 Log3Func(("pszPath=%s vs. pEntry=%s\n", pszPath, pEntry->pszName)); 497 498 if (RTStrCmp(pEntry->pszName, pszPath + cchBase)) /* Case-sensitive! */ 499 continue; 500 501 rc = RTStrCopy(openParms.pszPath, openParms.cbPath, pEntry->pszName); 502 if (RT_SUCCESS(rc)) 487 openParms.fCreate = SHCL_OBJ_CF_ACCESS_READ 488 | SHCL_OBJ_CF_ACCESS_DENYWRITE; 489 490 PSHCLTRANSFER pTx = pSrvTx->pTransfer; 491 AssertPtr(pTx); 492 493 rc = VERR_NOT_FOUND; /* Must find the matching root entry first. */ 494 495 Log3Func(("pszParsedPath=%s\n", pszParsedPath)); 496 497 uint64_t const cRoots = ShClTransferRootsCount(pTx); 498 for (uint32_t i = 0; i < cRoots; i++) 503 499 { 504 rc = ShClTransferObjOpen(pTx, &openParms, &pSrvTx->hObj); 500 PCSHCLLISTENTRY pEntry = ShClTransferRootsEntryGet(pTx, i); 501 AssertPtrBreakStmt(pEntry, rc = VERR_NOT_FOUND); 502 503 Log3Func(("pszRoot=%s vs. pEntry=%s\n", pszRoot, pEntry->pszName)); 504 505 if (RTStrCmp(pszRoot, pEntry->pszName)) /* Case-sensitive! */ 506 continue; 507 508 rc = RTStrCopy(openParms.pszPath, openParms.cbPath, pEntry->pszName); 505 509 if (RT_SUCCESS(rc)) 506 510 { 507 rc = VERR_NOT_SUPPORTED; /* Play safe by default. */ 508 509 if ( pEntry->fInfo & VBOX_SHCL_INFO_F_FSOBJINFO 510 && pEntry->cbInfo == sizeof(SHCLFSOBJINFO)) 511 rc = ShClTransferObjOpen(pTx, &openParms, &pSrvTx->hObj); 512 if (RT_SUCCESS(rc)) 511 513 { 512 PCSHCLFSOBJINFO pSrcObjInfo = (PSHCLFSOBJINFO)pEntry->pvInfo; 513 514 LogFlowFunc(("pszName=%s, cbInfo=%RU32, fMode=%#x (type %#x)\n", 515 pEntry->pszName, pEntry->cbInfo, pSrcObjInfo->Attr.fMode, (pSrcObjInfo->Attr.fMode & RTFS_TYPE_MASK))); 516 517 LogRel2(("Shared Clipboard: HTTP object info: fMode=%#x, cbObject=%zu\n", pSrcObjInfo->Attr.fMode, pSrcObjInfo->cbObject)); 518 519 if (RTFS_IS_FILE(pSrcObjInfo->Attr.fMode)) 514 rc = VERR_NOT_SUPPORTED; /* Play safe by default. */ 515 516 if ( pEntry->fInfo & VBOX_SHCL_INFO_F_FSOBJINFO 517 && pEntry->cbInfo == sizeof(SHCLFSOBJINFO)) 520 518 { 521 memcpy(pObjInfo, pSrcObjInfo, sizeof(SHCLFSOBJINFO)); 522 rc = VINF_SUCCESS; 519 PCSHCLFSOBJINFO pSrcObjInfo = (PSHCLFSOBJINFO)pEntry->pvInfo; 520 521 LogFlowFunc(("pszName=%s, cbInfo=%RU32, fMode=%#x (type %#x)\n", 522 pEntry->pszName, pEntry->cbInfo, pSrcObjInfo->Attr.fMode, (pSrcObjInfo->Attr.fMode & RTFS_TYPE_MASK))); 523 524 LogRel2(("Shared Clipboard: HTTP object info: fMode=%#x, cbObject=%zu\n", pSrcObjInfo->Attr.fMode, pSrcObjInfo->cbObject)); 525 526 if (RTFS_IS_FILE(pSrcObjInfo->Attr.fMode)) 527 { 528 memcpy(pObjInfo, pSrcObjInfo, sizeof(SHCLFSOBJINFO)); 529 rc = VINF_SUCCESS; 530 } 523 531 } 532 else 533 LogRel2(("Shared Clipboard: Supplied entry information for '%s' not supported (fInfo=%#x, cbInfo=%RU32\n", 534 pEntry->pszName, pEntry->fInfo, pEntry->cbInfo)); 535 /* Note: Directories / symlinks or other fancy stuff is not supported here (yet) -- would require using WebDAV. */ 524 536 } 525 else526 LogRel2(("Shared Clipboard: Supplied entry information for '%s' not supported (fInfo=%#x, cbInfo=%RU32\n",527 pEntry->pszName, pEntry->fInfo, pEntry->cbInfo));528 537 } 529 /* Note: Directories are not supported here (yet) -- would require using WebDAV. */ 538 539 break; 530 540 } 531 541 532 break;542 ShClTransferObjOpenParmsDestroy(&openParms); 533 543 } 534 535 ShClTransferObjOpenParmsDestroy(&openParms);536 544 } 537 545 538 RTStrFree(pszPa th);539 pszPa th = NULL;546 RTStrFree(pszParsedPath); 547 pszParsedPath = NULL; 540 548 } 541 549 else
Note:
See TracChangeset
for help on using the changeset viewer.