VirtualBox

Ignore:
Timestamp:
Dec 15, 2011 3:38:42 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
75424
Message:

more symlinks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedFolders/vbsf.cpp

    r39628 r39629  
    182182}
    183183
     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 */
    184193static int vbsfPathCheck(const char *pUtf8Path, size_t cbPath)
    185194{
    186195    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      */
    191196
    192197    size_t i = 0;
     
    265270        /* Verify that the path is under the root directory. */
    266271        rc = vbsfPathCheck((const char *)&pPath->String.utf8[0], pPath->u16Length);
    267 
    268272        if (RT_SUCCESS(rc))
    269273        {
     
    485489                        rc = RTPathQueryInfoEx(pszFullPath, &info, RTFSOBJATTRADD_NOTHING, RTPATH_F_ON_LINK);
    486490                        *pszSrc = RTPATH_DELIMITER;
    487                         if (rc == VINF_SUCCESS)
     491                        if (RT_SUCCESS(rc))
    488492                        {
    489493#ifdef DEBUG
     
    12221226
    12231227    rc = vbsfBuildFullPath(pClient, root, pPath, cbPath, &pszFullPath, &cbFullPathRoot);
    1224 
    12251228    if (RT_SUCCESS(rc))
    12261229    {
     
    22792282
    22802283    char *pszFullNewPath = NULL;
    2281     char *pszOldPath = NULL;
     2284    const char *pszOldPath = (const char *)pOldPath->String.utf8;
    22822285
    22832286    /* XXX: no support for UCS2 at the moment. */
     
    22852288        return VERR_NOT_IMPLEMENTED;
    22862289
     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
    22872298    rc = vbsfBuildFullPath(pClient, root, pNewPath, pNewPath->u16Size, &pszFullNewPath, NULL);
    2288     if (rc != VINF_SUCCESS)
    2289         return rc;
     2299    AssertRCReturn(rc, rc);
    22902300
    22912301    rc = RTSymlinkCreate(pszFullNewPath, (const char *)pOldPath->String.utf8,
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette