VirtualBox

Changeset 67226 in vbox


Ignore:
Timestamp:
Jun 2, 2017 9:27:26 AM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
115915
Message:

Main/MediumImpl: bugref:8344: enforce an absolute path when changing the medium location

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/MediumImpl.cpp

    r67205 r67226  
    30673067        /* play with locations */
    30683068        {
    3069             /*get source path and filename */
     3069            /* get source path and filename */
    30703070            Utf8Str sourceMediumPath = i_getLocationFull();
    30713071            Utf8Str sourceMediumFileName = i_getName();
     
    30793079            }
    30803080
    3081             /*extract destination path and filename */
     3081            /* extract destination path and filename */
    30823082            Utf8Str destMediumPath(aLocation);
    30833083            Utf8Str destMediumFileName(destMediumPath);
     
    30853085
    30863086            Utf8Str suffix(destMediumFileName);
    3087             suffix.stripSuffix();//for small trick, see next condition
    3088 
    3089             if(suffix.equals(destMediumFileName) && !destMediumFileName.isEmpty())
     3087            suffix.stripSuffix();
     3088
     3089            if (suffix.equals(destMediumFileName) && !destMediumFileName.isEmpty())
    30903090            {
    30913091                /*
     
    31033103                    destMediumPath = destMediumFileName;
    31043104                }
    3105                 /* case when new path looks like "/path/to/new/location"
    3106                  * In this case just set destMediumFileName to NULL and
    3107                  * and add '/' in the end of path.destMediumPath
    3108                  */
    31093105                else
    31103106                {
     3107                    /* new path looks like "/path/to/new/location" */
    31113108                    destMediumFileName.setNull();
    31123109                    destMediumPath.append(RTPATH_SLASH);
     
    31163113            if (destMediumFileName.isEmpty())
    31173114            {
    3118                 /* case when a target name is absent */
     3115                /* No target name */
    31193116                destMediumPath.append(sourceMediumFileName);
    31203117            }
     
    31233120                if (destMediumPath.equals(destMediumFileName))
    31243121                {
    3125                     /* the passed target path consist of only a filename without directory
     3122                    /*
     3123                     * the passed target path consist of only a filename without directory
    31263124                     * next move medium within the source directory with the passed new name
    31273125                     */
     
    31323130                if (suffix.compare("RAW", Utf8Str::CaseInsensitive) == 0)
    31333131                {
    3134                     if(i_getDeviceType() == DeviceType_DVD)
    3135                     {
     3132                    if (i_getDeviceType() == DeviceType_DVD)
    31363133                        suffix = "iso";
    3137                     }
    31383134                    else
    31393135                    {
     
    31513147            if (i_isMediumFormatFile())
    31523148            {
     3149                /* Path must be absolute */
     3150                char *pszAbs = RTPathAbsDup(destMediumPath.c_str());
     3151                int iCmp = destMediumPath.compare(pszAbs, Utf8Str::CaseInsensitive);
     3152                RTStrFree(pszAbs);
     3153                if (iCmp)
     3154                {
     3155                    rc = setError(VBOX_E_FILE_ERROR,
     3156                                  tr("The given target path '%s' is not absolute"),
     3157                                  destMediumPath.c_str());
     3158                    throw rc;
     3159                }
    31533160                /* Check path for a new file object */
    31543161                rc = VirtualBox::i_ensureFilePathExists(destMediumPath, true);
     
    66946701Utf8Str Medium::i_getNewLocationForMoving() const
    66956702{
    6696     if(m->fMoveThisMedium == true)
     6703    if (m->fMoveThisMedium == true)
    66976704        return m->strNewLocationFull;
    66986705    else
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