Changeset 39629 in vbox for trunk/src/VBox/HostServices/SharedFolders
- Timestamp:
- Dec 15, 2011 3:38:42 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 75424
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedFolders/vbsf.cpp
r39628 r39629 182 182 } 183 183 184 /** 185 * Do a simple path check given by pUtf8Path. Verify that the path is within 186 * the root directory of the mapping. Count '..' and other path components 187 * and check that we do not go over the root. 188 * 189 * @remarks This function assumes that the path will be appended to the root 190 * directory of the shared folder mapping. Keep that in mind when checking 191 * absolute pathes! 192 */ 184 193 static int vbsfPathCheck(const char *pUtf8Path, size_t cbPath) 185 194 { 186 195 int rc = VINF_SUCCESS; 187 188 /* The pUtf8Path is what the guest sent. Verify that the path is within the root.189 * Count '..' and other path components and check that we do not go over the root.190 */191 196 192 197 size_t i = 0; … … 265 270 /* Verify that the path is under the root directory. */ 266 271 rc = vbsfPathCheck((const char *)&pPath->String.utf8[0], pPath->u16Length); 267 268 272 if (RT_SUCCESS(rc)) 269 273 { … … 485 489 rc = RTPathQueryInfoEx(pszFullPath, &info, RTFSOBJATTRADD_NOTHING, RTPATH_F_ON_LINK); 486 490 *pszSrc = RTPATH_DELIMITER; 487 if ( rc == VINF_SUCCESS)491 if (RT_SUCCESS(rc)) 488 492 { 489 493 #ifdef DEBUG … … 1222 1226 1223 1227 rc = vbsfBuildFullPath(pClient, root, pPath, cbPath, &pszFullPath, &cbFullPathRoot); 1224 1225 1228 if (RT_SUCCESS(rc)) 1226 1229 { … … 2279 2282 2280 2283 char *pszFullNewPath = NULL; 2281 c har *pszOldPath = NULL;2284 const char *pszOldPath = (const char *)pOldPath->String.utf8; 2282 2285 2283 2286 /* XXX: no support for UCS2 at the moment. */ … … 2285 2288 return VERR_NOT_IMPLEMENTED; 2286 2289 2290 /* don't allow absolute targets */ 2291 if (RTPathStartsWithRoot(pszOldPath)) 2292 return VERR_INVALID_NAME; 2293 2294 /* Force relative pathes to be inside the shared folder. Don't allow the target to go up */ 2295 rc = vbsfPathCheck(pszOldPath, pOldPath->u16Length); 2296 AssertRCReturn(rc, rc); 2297 2287 2298 rc = vbsfBuildFullPath(pClient, root, pNewPath, pNewPath->u16Size, &pszFullNewPath, NULL); 2288 if (rc != VINF_SUCCESS) 2289 return rc; 2299 AssertRCReturn(rc, rc); 2290 2300 2291 2301 rc = RTSymlinkCreate(pszFullNewPath, (const char *)pOldPath->String.utf8,
Note:
See TracChangeset
for help on using the changeset viewer.