Changeset 39626 in vbox for trunk/src/VBox/HostServices
- Timestamp:
- Dec 15, 2011 11:33:47 AM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 75420
- Location:
- trunk/src/VBox/HostServices/SharedFolders
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedFolders/service.cpp
r39607 r39626 244 244 else 245 245 { 246 pszFolderName = (char*)RTStrAlloc(cbFolderName );246 pszFolderName = (char*)RTStrAlloc(cbFolderName + 1); 247 247 AssertReturn(pszFolderName, VERR_NO_MEMORY); 248 248 249 rc = SSMR3GetStrZ(pSSM, mapping.pszFolderName, cbFolderName);249 rc = SSMR3GetStrZ(pSSM, pszFolderName, cbFolderName + 1); 250 250 AssertRCReturn(rc, rc); 251 251 mapping.pszFolderName = pszFolderName; -
trunk/src/VBox/HostServices/SharedFolders/vbsf.cpp
r39612 r39626 42 42 #endif 43 43 44 // never follow symbolic links */45 //#define SHFL_RT_LINK(pClient) ((pClient)->fu32Flags & SHFL_CF_SYMLINKS ? RTPATH_F_ON_LINK : RTPATH_F_FOLLOW_LINK)46 #define SHFL_RT_LINK(pClient) (RTPATH_F_ON_LINK)47 48 44 /** 49 45 * @todo find a better solution for supporting the execute bit for non-windows … … 139 135 strcat(pDirEntry->szName, szWildCard); 140 136 141 rc = RTDirOpenFiltered(&hSearch, pDirEntry->szName, RTDIRFILTER_WINNT, RTDIROPEN FILTERED_FLAGS_NO_SYMLINKS);137 rc = RTDirOpenFiltered(&hSearch, pDirEntry->szName, RTDIRFILTER_WINNT, RTDIROPEN_FLAGS_NO_SYMLINKS); 142 138 *(pszStartComponent-1) = RTPATH_DELIMITER; 143 139 if (RT_FAILURE(rc)) … … 148 144 size_t cbDirEntrySize = cbDirEntry; 149 145 150 rc = RTDirReadEx(hSearch, pDirEntry, &cbDirEntrySize, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 146 rc = RTDirReadEx(hSearch, pDirEntry, &cbDirEntrySize, RTFSOBJATTRADD_NOTHING, 147 RTPATH_F_ON_LINK | RTPATH_F_NO_SYMLINKS); 151 148 if (rc == VERR_NO_MORE_FILES) 152 149 break; … … 426 423 if (RT_SUCCESS(rc)) 427 424 { 428 /* When the host file system is case sensitive and the guest expects a case insensitive fs, then problems can occur */ 425 /* When the host file system is case sensitive and the guest expects 426 * a case insensitive fs, then problems can occur */ 429 427 if ( vbsfIsHostMappingCaseSensitive(root) 430 428 && !vbsfIsGuestMappingCaseSensitive(root)) … … 435 433 if (fWildCard || fPreserveLastComponent) 436 434 { 437 /* strip off the last path component, that has to be preserved: contains the wildcard(s) or a 'rename' target. */ 435 /* strip off the last path component, that has to be preserved: 436 * contains the wildcard(s) or a 'rename' target. */ 438 437 size_t cb = strlen(pszFullPath); 439 438 char *pszSrc = pszFullPath + cb - 1; … … 470 469 471 470 /** @todo don't check when creating files or directories; waste of time */ 472 rc = RTPathQueryInfoEx(pszFullPath, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 471 rc = RTPathQueryInfoEx(pszFullPath, &info, RTFSOBJATTRADD_NOTHING, 472 RTPATH_F_ON_LINK | RTPATH_F_NO_SYMLINKS); 473 473 if (rc == VERR_FILE_NOT_FOUND || rc == VERR_PATH_NOT_FOUND) 474 474 { … … 484 484 { 485 485 *pszSrc = 0; 486 rc = RTPathQueryInfoEx(pszFullPath, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 486 rc = RTPathQueryInfoEx(pszFullPath, &info, RTFSOBJATTRADD_NOTHING, 487 RTPATH_F_ON_LINK | RTPATH_F_NO_SYMLINKS); 487 488 *pszSrc = RTPATH_DELIMITER; 488 489 if (rc == VINF_SUCCESS) … … 520 521 fEndOfString = false; 521 522 *pszEnd = 0; 522 rc = RTPathQueryInfoEx(pszSrc, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 523 rc = RTPathQueryInfoEx(pszSrc, &info, RTFSOBJATTRADD_NOTHING, 524 RTPATH_F_ON_LINK | RTPATH_F_NO_SYMLINKS); 523 525 Assert(rc == VINF_SUCCESS || rc == VERR_FILE_NOT_FOUND || rc == VERR_PATH_NOT_FOUND); 524 526 } … … 860 862 861 863 /** @todo Possible race left here. */ 862 if (RT_SUCCESS(RTPathQueryInfoEx(pszPath, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)))) 864 if (RT_SUCCESS(RTPathQueryInfoEx(pszPath, &info, RTFSOBJATTRADD_NOTHING, 865 RTPATH_F_ON_LINK | RTPATH_F_NO_SYMLINKS))) 863 866 { 864 867 #ifdef RT_OS_WINDOWS … … 1032 1035 /* Open the directory now */ 1033 1036 rc = RTDirOpenFiltered(&pHandle->dir.Handle, pszPath, 1034 RTDIRFILTER_NONE, RTDIROPEN FILTERED_FLAGS_NO_SYMLINKS);1037 RTDIRFILTER_NONE, RTDIROPEN_FLAGS_NO_SYMLINKS); 1035 1038 if (RT_SUCCESS(rc)) 1036 1039 { … … 1130 1133 * @retval pParms->Info On success, information returned about the file 1131 1134 */ 1132 static int vbsfLookupFile(SHFLCLIENTDATA *pClient, char *pszPath, SHFLCREATEPARMS *pParms)1135 static int vbsfLookupFile(SHFLCLIENTDATA *pClient, SHFLROOT root, char *pszPath, SHFLCREATEPARMS *pParms) 1133 1136 { 1134 1137 RTFSOBJINFO info; 1135 1138 int rc; 1136 1139 1137 rc = RTPathQueryInfoEx(pszPath, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 1140 char szRealPath[RTPATH_MAX + 1]; 1141 const char *pszRoot = vbsfMappingsQueryHostRoot(root); 1142 AssertReturn(pszRoot, VERR_INVALID_PARAMETER); 1143 rc = RTPathReal(pszPath, szRealPath, sizeof(szRealPath)); 1144 AssertRCReturn(rc, rc); 1145 if (!RTPathStartsWith(szRealPath, pszRoot)) 1146 return VERR_TOO_MANY_SYMLINKS; 1147 1148 rc = RTPathQueryInfoEx(pszPath, &info, RTFSOBJATTRADD_NOTHING, 1149 RTPATH_F_ON_LINK | RTPATH_F_NO_SYMLINKS); 1138 1150 LogFlow(("SHFL_CF_LOOKUP\n")); 1139 1151 /* Client just wants to know if the object exists. */ … … 1234 1246 if (BIT_FLAG(pParms->CreateFlags, SHFL_CF_LOOKUP)) 1235 1247 { 1236 rc = vbsfLookupFile(pClient, pszFullPath, pParms);1248 rc = vbsfLookupFile(pClient, root, pszFullPath, pParms); 1237 1249 } 1238 1250 else … … 1241 1253 RTFSOBJINFO info; 1242 1254 1243 rc = RTPathQueryInfoEx(pszFullPath, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 1255 rc = RTPathQueryInfoEx(pszFullPath, &info, RTFSOBJATTRADD_NOTHING, 1256 RTPATH_F_ON_LINK | RTPATH_F_NO_SYMLINKS); 1244 1257 LogFlow(("RTPathQueryInfoEx returned %Rrc\n", rc)); 1245 1258 … … 1295 1308 { 1296 1309 if (BIT_FLAG(pParms->CreateFlags, SHFL_CF_DIRECTORY)) 1297 {1298 1310 rc = vbsfOpenDir(pClient, pszFullPath, pParms); 1299 }1300 1311 else 1301 {1302 1312 rc = vbsfOpenFile(pClient, pszFullPath, pParms); 1303 }1304 1313 } 1305 1314 else … … 1505 1514 PRTDIR DirHandle; 1506 1515 bool fUtf8; 1507 1516 1508 1517 fUtf8 = BIT_FLAG(pClient->fu32Flags, SHFL_CF_UTF8) != 0; 1509 1518 … … 1546 1555 if (RT_SUCCESS(rc)) 1547 1556 { 1557 #if 0 1558 const char *pszRoot = vbsfMappingsQueryHostRoot(root); 1559 if (!pszRoot) 1560 { 1561 rc = VERR_INVALID_PARAMETER; 1562 goto end; 1563 } 1564 char szRealPath[RTPATH_MAX + 1]; 1565 rc = RTPathReal(pszFullPath, szRealPath, sizeof(szRealPath)); 1566 if (RT_FAILURE(rc)) 1567 goto end; 1568 if (!RTPathStartsWith(szRealPath, pszRoot)) 1569 { 1570 rc = VERR_TOO_MANY_SYMLINKS; 1571 goto end; 1572 } 1573 #endif 1548 1574 rc = RTDirOpenFiltered(&pHandle->dir.SearchHandle, pszFullPath, 1549 RTDIRFILTER_WINNT, RTDIROPEN FILTERED_FLAGS_NO_SYMLINKS);1575 RTDIRFILTER_WINNT, RTDIROPEN_FLAGS_NO_SYMLINKS); 1550 1576 1551 1577 /* free the path string */ … … 1576 1602 pDirEntry = pDirEntryOrg; 1577 1603 1578 rc = RTDirReadEx(DirHandle, pDirEntry, &cbDirEntrySize, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 1604 rc = RTDirReadEx(DirHandle, pDirEntry, &cbDirEntrySize, RTFSOBJATTRADD_NOTHING, 1605 RTPATH_F_ON_LINK | RTPATH_F_NO_SYMLINKS); 1579 1606 if (rc == VERR_NO_MORE_FILES) 1580 1607 { … … 2295 2322 { 2296 2323 RTFSOBJINFO info; 2297 rc = RTPathQueryInfoEx(pszFullNewPath, &info, RTFSOBJATTRADD_NOTHING, SHFL_RT_LINK(pClient)); 2324 rc = RTPathQueryInfoEx(pszFullNewPath, &info, RTFSOBJATTRADD_NOTHING, 2325 RTPATH_F_ON_LINK | RTPATH_F_NO_SYMLINKS); 2298 2326 if (RT_SUCCESS(rc)) 2299 2327 vbfsCopyFsObjInfoFromIprt(pInfo, &info);
Note:
See TracChangeset
for help on using the changeset viewer.