VirtualBox

Ignore:
Timestamp:
Jun 25, 2019 12:00:40 PM (6 years ago)
Author:
vboxsync
Message:

VBoxService: Bugfixes. bugref:9320

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp

    r79296 r79321  
    133133 * @param   pObjInfo            The object info buffer.  (ditto)
    134134 */
    135 static int vgsvcGstCtrlSessionHandleDirRemoveSub(char *pszDir, size_t cchDir, PRTDIRENTRY pDirEntry, PRTFSOBJINFO pObjInfo)
     135static int vgsvcGstCtrlSessionHandleDirRemoveSub(char *pszDir, size_t cchDir, PRTDIRENTRY pDirEntry)
    136136{
    137137    RTDIR hDir;
     
    145145        {
    146146            /* Construct the full name of the entry. */
    147             if (cchDir + pDirEntry->cbName + 1 /* dir slash */ >= RTPATH_MAX)
     147            if (cchDir + pDirEntry->cbName + 1 /* dir slash */ < RTPATH_MAX)
     148                memcpy(&pszDir[cchDir], pDirEntry->szName, pDirEntry->cbName + 1);
     149            else
    148150            {
    149151                rc = VERR_FILENAME_TOO_LONG;
    150152                break;
    151153            }
    152             memcpy(&pszDir[cchDir], pDirEntry->szName, pDirEntry->cbName + 1);
    153 
    154             /* Deal with the unknown type. */
     154
     155            /* Switch on type. */
    155156            if (pDirEntry->enmType == RTDIRENTRYTYPE_UNKNOWN)
    156             {
    157                 rc = RTPathQueryInfoEx(pszDir, pObjInfo, RTFSOBJATTRADD_NOTHING, RTPATH_F_ON_LINK);
    158                 if (RT_SUCCESS(rc) && RTFS_IS_DIRECTORY(pObjInfo->Attr.fMode))
    159                     pDirEntry->enmType = RTDIRENTRYTYPE_DIRECTORY;
    160                 else if (RT_SUCCESS(rc) && RTFS_IS_FILE(pObjInfo->Attr.fMode))
    161                     pDirEntry->enmType = RTDIRENTRYTYPE_FILE;
    162                 else if (RT_SUCCESS(rc) && RTFS_IS_SYMLINK(pObjInfo->Attr.fMode))
    163                     pDirEntry->enmType = RTDIRENTRYTYPE_SYMLINK;
    164             }
    165 
    166             /* Try the delete the fs object. */
     157                RTDirQueryUnknownType(pszDir, false /*fFollowSymlinks*/, &pDirEntry->enmType);
    167158            switch (pDirEntry->enmType)
    168159            {
    169160                case RTDIRENTRYTYPE_DIRECTORY:
    170161                {
    171                     size_t cchSubDir = cchDir + pDirEntry->cbName;
    172                     pszDir[cchSubDir++] = '/';
     162                    size_t cchSubDir    = cchDir + pDirEntry->cbName;
     163                    pszDir[cchSubDir++] = RTPATH_SLASH;
    173164                    pszDir[cchSubDir]   = '\0';
    174                     rc = vgsvcGstCtrlSessionHandleDirRemoveSub(pszDir, cchSubDir, pDirEntry, pObjInfo);
     165                    rc = vgsvcGstCtrlSessionHandleDirRemoveSub(pszDir, cchSubDir, pDirEntry);
    175166                    if (RT_SUCCESS(rc))
    176167                    {
     
    180171                    break;
    181172                }
    182 
    183                 /** @todo Implement deleting symlinks? Play safe for now. */
    184173
    185174                default:
     
    230219                else /* Only remove empty directory structures. Will fail if non-empty. */
    231220                {
    232                     RTDIRENTRY  dirEntry;
    233                     RTFSOBJINFO objInfo;
    234                     rc = vgsvcGstCtrlSessionHandleDirRemoveSub(szDir, strlen(szDir), &dirEntry, &objInfo);
     221                    RTDIRENTRY DirEntry;
     222                    RTPathEnsureTrailingSeparator(szDir, sizeof(szDir));
     223                    rc = vgsvcGstCtrlSessionHandleDirRemoveSub(szDir, strlen(szDir), &DirEntry);
    235224                }
    236225                VGSvcVerbose(4, "[Dir %s]: rmdir /s (%#x) -> rc=%Rrc\n", szDir, fFlags, rc);
Note: See TracChangeset for help on using the changeset viewer.

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